1jQuery(function(e) { 2 3 var videoType; 4 var pinWidth = PinnedVideoWidth; //Pinned video container width 5 var pinHeight = PinnedVideoHeight; //Pinned video container height 6 var pTop = PositionVerticalOffset; //Pinned video top offset 7 var pRight = PositionSideOffset; //Pinned video right offset 8 var verPos = VerPosition;//top,bottom 9 var horPos = HorPosition;//left,right 10 var YT_enabled = EnableOnYT;//EnableOnYT 11 var enable_on_mobile = EnableOnMobile;//EnableOnMobile; 12 var enable_BCiframe = enableBCiframe;//enableBCiframe; 13 var enable_BCHTML5 = enableBCHTML5;//enableBCHTML5; 14 var pip_enabled = true; 15 var jump = 500; 16 window.scrollHeight = 0; 17 var HideControls = '.vjs-share-control, .rdm-video-autoplay-switch-container, .vjs-thumbs-up-button, .vjs-thumbs-down-button, .vjs-captions-button, .vjs-subs-caps-button'; 18 19 jQuery("head").append('<style type="text/css">' + (!enable_on_mobile ? "@media (min-width: 768px) {":"") + '#featured-videoYT.is-sticky, #featured-video.is-sticky {position: fixed; ' + verPos + ': ' + pTop + 'px; ' + horPos + ': ' + pRight + 'px; max-width: ' + pinWidth + 'px; max-height: ' + pinHeight + 'px; width: ' + pinWidth + 'px; height: ' + pinHeight + 'px !important; z-index: 1001;' +(!enable_on_mobile ? "}":"")+ '}</style>'); 20 21 if (window.innerWidth < 767 && enable_on_mobile === false) { 22 pip_enabled = false; 23 } 24 25 jQuery(window).resize(function() { 26 if (window.innerWidth < 767 && enable_on_mobile === false) { 27 pip_enabled = false; 28 } 29 }); 30 31 jQuery(window).on("load resize scroll",function(e){//Check for new videos every 500px scroll 32 var diff = jQuery(this).scrollTop() - window.scrollHeight; 33 if (diff >= jump || window.scrollHeight == 0) { 34 window.scrollHeight = jQuery(this).scrollTop(); 35 //console.log('Checking for videos - '+ jQuery(this).scrollTop()); 36 37 if(jQuery('.bc-video').length && !jQuery(".bc-video-iframe").length && pip_enabled === true && enable_BCHTML5 === 'yes') { //BRIGHTCOVE STUFF 38 videoType = 'HTML5'; 39 40 var checkExist = setInterval(function(){ 41 if ( typeof(videojs) !== "undefined") { 42 //console.log("videojs loaded!........."); 43 clearInterval(checkExist); 44 45 if (jQuery('div[autoplay^="true"]').length && jQuery('div[autoplay^="true"]').parents().parents('.bc-video').length == 1){ 46 jQuery('div[autoplay^="true"]').parent().attr('id', 'featured-video'); 47 jQuery('div[autoplay^="true"]').parent().parent().attr('id', 'featured-media'); 48 pinnedVideo(jQuery('div[autoplay^="true"]').attr('id')); 49 } 50 51 var players = []; 52 for (x = 0; x < Object.keys(videojs.players).length; x++) { 53 var setPlayer = Object.keys(videojs.players)[x]; 54 videojs(setPlayer).ready(function () { 55 player = this; 56 player.on('play', onPlay); 57 player.on('pause', onPause); 58 players.push(player); 59 }); 60 } 61 62 function onPlay(e) { 63 var id = e.target.id; 64 //console.log('onPlay ' + id) 65 66 for (var i = 0; i < players.length; i++) { 67 if (players[i].id() != id) { 68 videojs(players[i].id()).pause(); 69 } 70 } 71 jQuery('#' + id).parent().attr('id', 'featured-video'); 72 jQuery('#' + id).parent().parent().attr('id', 'featured-media'); 73 pinnedVideo(id); 74 } 75 76 function onPause(e) { 77 var id = e.target.id; 78 //console.log('onPause ' + id); 79 if(!jQuery('#featured-video').hasClass('is-sticky')){ 80 jQuery('#' + id).parent().css("padding-top", '56.25%').removeAttr('id').removeClass('is-sticky'); 81 jQuery('#' + id).parent().parent().removeAttr('id'); 82 } 83 } 84 } 85 }, 400); // check for videojs every xxx ms 86 } else 87 if(jQuery('.bc-video').length && jQuery(".bc-video-iframe").length && pip_enabled === true && enableBCiframe === 'yes') {//brightcove iframe stuff 88 89 videoType = 'iframeBC'; 90 jQuery('iframe[class*=rdm-brightcove-videojs-iframe]').each( function (k, v) { 91 if(!this.id) { this.id = 'bc-iframe-id-' + k + Math.floor(Math.random()*100) + 1}
91//adding id to all iframes 92 }); 93 94 function PinControlVideo(evt){ 95 if(evt.data === "playVideo" || evt.data === "ads-ad-started" || evt.data === "ads-play") { 96 97 var frame_id = evt.source.frameElement.id; 98 jQuery('iframe[class*=rdm-brightcove-videojs-iframe]').each( function (k, v) { //pause all videos but one 99 if (this.id !== frame_id && this.id !== '' && frame_id !== '') { 100 var iframeEl = document.getElementById(this.id); 101 var sendMessage = function(msg) { 102 iframeEl.contentWindow.postMessage(msg, '*'); 103 }; 104 sendMessage('pauseVideo'); 105 if(!jQuery('#' + frame_id).parent().hasClass('is-sticky') || (evt.data === "ads-ad-started" && !jQuery('#' + frame_id).parent().hasClass('is-sticky'))){ 106 107 jQuery("#pipclose").remove(); 108 jQuery('div[id*=featured-video]').removeAttr('id').removeClass('is-sticky'); 109 jQuery('div[id*=featured-media]').removeAttr('id'); 110 } 111 } 112 }); 113 114 if(!jQuery('#' + frame_id).parent().hasClass('is-sticky')) { 115 jQuery('#' + frame_id).parent().attr('id', 'featured-video'); 116 jQuery('#' + frame_id).parent().parent().attr('id', 'featured-media'); 117 } 118 pinnedVideo(frame_id); 119 120 } else if (evt.data === 'pauseVideo' /*|| evt.data === "ads-pause"*/) { 121 122 var frame_id = evt.source.frameElement.id; 123 124 if(!jQuery('#featured-video').hasClass('is-sticky')){ 125 jQuery('#' + frame_id).parent().css("padding-top", '56.25%').removeAttr('id').removeClass('is-sticky'); 126 jQuery('#' + frame_id).parent().parent().removeAttr('id'); 127 } 128 } 129 }; 130 window.addEventListener("message",PinControlVideo); //listen to Brightcove videojs.eventracker.js plugin 131 } 132 } 133 }); 134 //YOUTUBE STUFF STARTS 135 if(jQuery('iframe[src*=youtube]').length && YT_enabled === 'yes' && pip_enabled === true) { 136 137 //API YOUTUBE get player state 138 var tag = document.createElement('script'); 139 tag.src = '//www.youtube.com/iframe_api'; 140 var firstScriptTag = document.getElementsByTagName('script')[0]; 141 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 142 143 var videoTypeYT = 'iframeYT'; 144 if(jQuery("iframe[src*=youtube]").parent(".content-media--video").length === 0){ 145 jQuery("iframe[src*=youtube]" ).wrap( "<div class='content-media--video' style='position: absolute;'><div></div></div>" ); 146 } 147 148 window.onYouTubeIframeAPIReady = function() { 149 150 var ytplayers = []; 151 jQuery('iframe[src*=youtube]').each( function (k, v) { 152 if(!this.id) { this.id = 'yt-id-' + k + Math.floor(Math.random()*100) + 1}//adding id if missing 153 154 if(this.src.indexOf("enablejsapi") == -1) { //adding enablejsapi if missing 155 if(this.src.indexOf("?") != -1) { 156 jQuery("#" + this.id).attr("src", jQuery("#" + this.id).attr('src') + '&enablejsapi=1'); 157 }else{ 158 jQuery("#" + this.id).attr("src", jQuery("#" + this.id).attr('src') + '?enablejsapi=1'); 159 } 160 } 161 ytplayers.push(new YT.Player(this.id, { 162 events: { 163 'onStateChange': function(event) { 164 var myid = '#' + event.target.getIframe().id; 165 166 if(event.data == YT.PlayerState.PLAYING) { 167 168 e.each(ytplayers, function(k, v) { //pause all videos but one 169 if (this.getIframe().id != event.target.getIframe().id) { 170 this.pauseVideo(); 171 jQuery('div[id*=featured-video]').removeAttr('id').removeClass('is-sticky'); 172 jQuery('div[id*=featured-media]').removeAttr('id'); 173 } 174 }); 175 176 jQuery(myid).parent().attr('id', 'featured-video'); 177 jQuery(myid).parent().parent().attr('id', 'featured-media'); 178 pinnedVideoYT(event.target.getIframe().id); 179 } 180 181 if(event.data == YT.PlayerState.PAUSED) { 182 if(!$('#featured-video').hasClass('is-sticky')){ 183 jQuery(myid).parent().removeAttr('id').removeClass('is-sticky'); 184 jQuery(myid).parent().parent().removeAttr('id'); 185 jQuery("#pipclose").remove(); 186 } 187 } 188 189 if(event.data == YT.PlayerState.ENDED) { 190 /*jQuery(myid).parent().removeAttr('id'); 191 jQuery(myid).parent().parent().removeAttr('id'); 192 jQuery("#pipclose").remove();*/ 193 } 194 } 195 } 196 })) 197 }); 198 }; 199 }//YOUTUBE ENDS 200 201 function pinnedVideo(player_id) { 202 var w = jQuery(window), 203 top = jQuery('#' + player_id).closest(".bc-video").offset().top, 204 offset = Math.floor(top + jQuery("#featured-media").outerHeight() / 2), 205 el_offset = Math.round(jQuery(window).height() - (jQuery("#featured-media").outerHeight() / 2)); 206 207 208 var bcWidth = jQuery("#featured-media").outerWidth(); //original iframe player width 209 var bcHeight = jQuery("#featured-media").outerHeight(); //original iframe player height 210 211 w.on("resize", function() { 212 213 bcWidth = jQuery("#featured-media").outerWidth(); //original iframe player width 214 bcHeight = jQuery("#featured-media").outerHeight(); //original iframe player height 215 top = jQuery('#' + player_id).closest(".bc-video").offset().top, 216 offset = Math.floor(top + jQuery("#featured-media").outerHeight() / 2), 217 el_offset = Math.round(jQuery(window).height() - (jQuery("#featured-media").outerHeight() / 2)) 218 }).on("scroll", debounce(function() { 219 //console.log("ID - " + player_id +" bcWidth - " + bcWidth +" bcHeight - " + bcHeight + " el_offset - " + el_offset); 220 221 jQuery('#' + player_id).closest("#featured-video").toggleClass("is-sticky", ((w.scrollTop() > offset) || ((w.scrollTop() + el_offset) < top))) 222 223 if(jQuery("#featured-video").hasClass("is-sticky")){ 224 if(jQuery("#pipclose").length == 0) { 225 jQuery("#featured-video").prepend('<div id="pipclose">Close</div>'); 226 } 227 //jQuery("#featured-media").css("width", Math.round(bcWidth)); 228 jQuery("#featured-media").css("height", Math.round(bcHeight)); 229 jQuery("#featured-video").css("padding-top", ""); 230 231 if(videoType == 'HTML5') { 232 jQuery(HideControls).hide(); 233 } 234 235 if(videoType == 'iframeBC' ) { 236 jQuery('#' + player_id).contents().find(HideControls).hide(); 237 } 238 239 jQuery('#pipclose').on('click', function() {//PIP close button 240 241 if(videoType == 'HTML5') {//pause BC HTML5 242 if(jQuery("#" + player_id).hasClass("vjs-ad-playing") && typeof(videojs(player_id).ima3.adsManager) !== "undefined" && videojs(player_id).ima3.adsManager !== null) { 243 videojs(player_id).ima3.adsManager.pause(); 244 }else { 245 videojs(player_id).pause(); 246 } 247 jQuery("#featured-video").css("padding-top", '56.25%'); 248 jQuery("#featured-media").css("height", ''); 249 jQuery(HideControls).show(); 250 jQuery('#' + player_id + ' > video').width('100%').height('100%').attr("width", bcWidth).attr("height", bcHeight); 251 } 252 253 if(videoType == 'iframeBC') {//pause bc iframe 254 255 var iframeEl = document.getElementById(player_id); 256 var sendMessage = function(msg) { 257 iframeEl.contentWindow.postMessage(msg, '*'); 258 }; 259 sendMessage('pauseVideo'); 260 jQuery('#' + player_id).css({"width": '100%', "height": '100%'}); 261 } 262 263 jQuery('#' + player_id).parent().removeClass('is-sticky').removeAttr('id'); 264 jQuery('#' + player_id).parent().parent().removeAttr('id'); 265 //jQuery("#featured-media").css("height", ''); 266 jQuery("#pipclose").remove(); 267 }); 268 269 }else{ 270 271 jQuery("#pipclose").remove(); 272 jQuery("#featured-video").css("padding-top", '56.25%'); 273 //jQuery("#" + player_id).attr("width", bcWidth).attr("height", bcHeight); 274 jQuery("#featured-media").css("height", ''); 275 if(videoType == 'HTML5') { 276 jQuery(HideControls).show(); 277 jQuery('#' + player_id + ' > video').width('100%').height('100%').attr("width", bcWidth).attr("height", bcHeight);; 278 } 279 280 if(videoType == 'iframeBC') { 281 jQuery('#' + player_id).css({"width": '100%', "height": '100%'}); 282 jQuery('#' + player_id).contents().find(HideControls).show(); 283 } 284 } 285 }, 10)); 286 } 287 288 function pinnedVideoYT(player_id) {//YOUTUBE STUFF STARTS 289 290 var w = jQuery(window), 291 top = jQuery("#" + player_id).last().offset().top, 292 offset = Math.floor(top + jQuery("#" + player_id).outerHeight() / 2), 293 el_offset = jQuery(window).height() - (jQuery("#" + player_id).outerHeight() / 2); 294 295 w.on("resize", function() { 296 top = jQuery("#" + player_id).last().offset().top, 297 offset = Math.floor(top + jQuery("#" + player_id).outerHeight() / 2), 298 el_offset = jQuery(window).height() - (jQuery("#" + player_id).outerHeight() / 2) 299 }).on("scroll", debounce(function() { 300 //console.log("top - " + top +" offset - " + offset + " el_offset - " + el_offset); 301 jQuery('#' + player_id).closest("#featured-video").toggleClass("is-sticky", ((w.scrollTop() > offset) || ((w.scrollTop() + el_offset) < top))) 302 if(jQuery("#featured-video").hasClass("is-sticky")){ 303 304 if(jQuery("#pipclose").length == 0) { 305 jQuery("#featured-video").prepend('<div id="pipclose">Close</div>'); 306 } 307 jQuery('#' + player_id).width('100%').height('100%'); 308 jQuery('#pipclose').on('click', function() {//PIP close button 309 //pause Youtube 310 jQuery('#'+ player_id)[0].contentWindow.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*'); 311 jQuery('#'+ player_id).parent().removeAttr('id').removeClass('is-sticky'); 312 jQuery('#'+ player_id).parent().parent().removeAttr('id'); 313 jQuery("#pipclose").remove(); 314 }); 315 }else{ 316 jQuery("#pipclose").remove(); 317 } 318 }, 10)); 319 }//YOUTUBE ENDS 320 321 var debounce = function(func, delay) { 322 var inDebounce = undefined; 323 return function() { 324 var context = this, 325 args = arguments; 326 clearTimeout(inDebounce); 327 return inDebounce = setTimeout(function() {
328 return func.apply(context, args); 329 }, delay); 330 } 331 } 332 333/* 334 //pause videos 335 function pauseVideos(player_id) { 336 //HTML5 pause 337 if(jQuery('.bc-video').length){ 338 jQuery('video').each(function(){ 339 console.log("id: " + jQuery(this).attr('id')); 340 if(jQuery(this).attr('id') !== player_id){ 341 jQuery(this)[0].pause(); 342 } 343 }) 344 } 345 //BC iframe pause 346 if(jQuery('.bc-video-iframe').length){ 347 jQuery('iframe[class*=rdm-brightcove-videojs-iframe]').each( function (k, v) { //pause all videos but one 348 if (this.id !== player_id && this.id !== '' && player_id !== '') { 349 var iframeEl = document.getElementById(this.id); 350 var sendMessage = function(msg) { 351 iframeEl.contentWindow.postMessage(msg, '*'); 352 }; 353 sendMessage('pauseVideo'); 354 } 355 }) 356 } 357 //Youtube pause 358 if(jQuery('iframe[src*=youtube]').length){ 359 jQuery('iframe[src*=youtube]').each( function (k, v) { 360 if (this.id !== player_id && this.id !== '' && player_id !== '') { 361 jQuery('#'+this.id)[0].contentWindow.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*'); 362 } 363 }) 364 } 365 };*/ 366});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.