jQuery(window).scroll(function() { sizeEmbed(); }); jQuery(window).resize(function() { setTimeout(function() { windowWidth = jQuery(window).width(); sizeEmbed(); }, 50); }); function sizeEmbed(){ if (typeof customSizeEmbed == 'function') { customSizeEmbed(); } else{ if (jQuery("#NeulionVidContainer").length > 0) { if(window.location.pathname ==="/ViewArticle.dbml"){ EmbedSizeStickyVideo(); } else{ EmbedSizeDefault(); } } } } function EmbedSizeDefault(){ if (typeof customEmbedSizeDefault == 'function') { customEmbedSizeDefault(); } else{ if (jQuery("body").hasClass('mobile')){ jQuery("#embedPlayer").css({'z-index':'10500','width':'100%','position':'fixed','left':'0px'}); jQuery("#embedPlayer").css('height', jQuery("#embedPlayer").width()*(9/16)); jQuery("#embedPlayer").css('top', ((jQuery(window).height()/2)-(parseInt(jQuery("#embedPlayer").css('height').replace('px', ''))/2)+'px')); jQuery("#NeulionVidContainer").css({'width':'100%','top':'0px','left':'0px'}); jQuery("#NeulionVidContainer").css('height', jQuery("#NeulionVidContainer").width()*(9/16)); jQuery("#embedPlayerFade").css({'width':jQuery(window).width()+'px','height':jQuery(window).height()+'px'}); jQuery(window).scroll(function() { var height = window.innerHeight ? window.innerHeight : jQuery(window).height(); jQuery("#embedPlayerFade").css('height', height+'px'); }); } else { jQuery("#embedPlayer").css({'z-index':'10500','width':'724px','height':'444px','position':'fixed','left':((jQuery(window).width()/2)-357)+'px','top':((jQuery(window).height()/2)-250)+'px'}); jQuery("#NeulionVidContainer").css({'width':'100%','top':'0px','left':'0px'}); jQuery("#NeulionVidContainer").css('height', jQuery("#NeulionVidContainer").width()*(9/16)); jQuery("#embedPlayerFade").css({'width':jQuery(window).width()+'px','height':jQuery(window).height()+'px'}); } } } function EmbedSizeStickyVideo(){ if (typeof customEmbedSizeStickyVideo == 'function') { customEmbedSizeStickyVideo(); } else{ if (jQuery("#NeulionVidContainer").length > 0) { jQuery("#embedPlayerFade").hide(); if(jQuery(window).scrollTop() > (jQuery("#GlobalArticleContainer").offset().top + 200)){ EmbedDraggableEnable(); if (jQuery("body").hasClass('desktop')) { EmbedSizeMiniVideo(); } else{ EmbedSizeTopVideo(); } } else{ EmbedDraggableDisable(); EmbedSizeTopVideo(); } } } } function EmbedSizeMiniVideo(){ if (typeof customEmbedSizeMiniVideo == 'function') { customEmbedSizeMiniVideo(); } else{ jQuery("#embedPlayer").css({'z-index':'500','width':'390px','height':'219.37px','position':'fixed','left':'auto','right':'1%','top':'auto','bottom':'1px'}); jQuery("#NeulionVidContainer").css({'width':'100%','max-width':'900px','top':'0px','left':'0px'}); jQuery("#NeulionVidContainer").css('height', jQuery("#NeulionVidContainer").width()*(9/16)); } } function EmbedSizeTopVideo() { if (typeof customEmbedSizeTopVideo == 'function') { customEmbedSizeTopVideo(); } else{ if (jQuery("#ArticleImageContainer").length > 0) { jQuery("#embedPlayer").css({'z-index':'500','width': jQuery("#ArticleImageContainer").width(),'position':'absolute','left': (jQuery("#ArticleImageContainer").offset().left+'px') ,'top': (jQuery("#ArticleImageContainer").offset().top+'px') }); } else{ jQuery("#embedPlayer").css({'z-index':'500','width': '100%','max-width' : '728px' ,'position':'absolute','left': (((jQuery(window).width()/2)-357)+'px') ,'top': (jQuery("#GlobalArticleContainer").offset().top+'px') }); } jQuery("#embedPlayer").css('height', jQuery("#embedPlayer").width()*(9/16)); jQuery("#NeulionVidContainer").css({'width': '100%' , 'max-width' : '900px'}); jQuery("#NeulionVidContainer").css('height', jQuery("#NeulionVidContainer").width()*(9/16)); if (jQuery("body").hasClass('mobile')){ jQuery("#NeulionVidContainer").css({'top' : '0px', 'left' : '0px'}); } else{ jQuery("#NeulionVidContainer").css({'top' : ((jQuery("#embedPlayer").height()-jQuery("#NeulionVidContainer").height()) /2 ) , 'left' : ((jQuery("#embedPlayer").width()-jQuery("#NeulionVidContainer").width()) /2 ) }); } } } function EmbedDraggableEnable(){ if (typeof customEmbedDraggableEnable == 'function') { customEmbedDraggableEnable(); } else{ jQuery("#embedPlayer").addClass("ui-widget-content"); jQuery("#embedPlayer").draggable(); jQuery("#embedPlayer").draggable("enable"); } } function EmbedDraggableDisable(){ if (typeof customEmbedDraggableDisable == 'function') { customEmbedDraggableDisable(); } else{ jQuery("#embedPlayer").draggable(); jQuery("#embedPlayer").draggable("disable"); } } function showNeuLionVid(vidid){ if (typeof customShowNeuLionVid == 'function') { customShowNeuLionVid(); } else{ jQuery("#embedPlayer").fadeIn(500); jQuery("#NeulionVidContainer").fadeIn(500); jQuery("#embedPlayerFade").fadeTo(0, .7); jQuery("#embedPlayerFade").fadeIn(500); jQuery(document).on('keydown', function() { if ( event.which == 27 ) { //Esc hideNeuLionVid(); } }); sizeEmbed(); neulionPlayer.play({id:vidid}); playerRunning = true; } } function hideNeuLionVid(){ if (typeof customHideNeuLionVid == 'function') { customHideNeuLionVid(); } else{ if (jQuery("#embedPlayer").css('display') != 'none'){ jQuery("#embedPlayer").fadeOut(500); jQuery("#NeulionVidContainer").fadeOut(500); jQuery("#embedPlayerFade").fadeOut(500); neulionPlayer.stop(); jQuery(document).off('keydown'); } } }