1(function($) { 2 "use strict"; 3 4 UNCODE.okvideo = function(ev) { 5 var BLANK_GIF = "data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D"; 6 $.okvideo = function(options) { 7 // if the option var was just a string, turn it into an object 8 if (typeof options !== 'object') options = { 9 'video': options 10 }; 11 var base = this; 12 // kick things off 13 base.init = function() { 14 base.options = $.extend({}, $.okvideo.options, options); 15 // support older versions of okvideo 16 if (base.options.video === null) base.options.video = base.options.source; 17 base.setOptions(); 18 var target = base.options.target || $('body'); 19 var position = target[0] == $('body')[0] ? 'fixed' : 'absolute'; 20 var zIndex = base.options.controls === 3 ? -999 : "auto"; 21 if ($('#okplayer-' + base.options.id).length == 0) { //base.options.id = String(Math.round(Math.random() * 100000)); 22 var mask = '<div id="okplayer-mask-' + base.options.id + '" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-998;height:100%;width:100%;"></div>'; 23 if (OKEvents.utils.isMobile()) { 24 target.append('<div id="okplayer-' + base.options.id + '" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:' + zIndex + ';height:100%;width:100%;"></div>'); 25 } else { 26 if (base.options.controls === 3) { 27 target.append(mask) 28 } 29 if (base.options.adproof === 1) { 30 target.append('<div id="okplayer-' + base.options.id + '" style="position:' + position + ';left:-10%;top:-10%;overflow:hidden;z-index:' + zIndex + ';height:120%;width:120%;"></div>'); 31 } else { 32 target.append('<div id="okplayer-' + base.options.id + '" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:' + zIndex + ';height:100%;width:100%;"></div>'); 33 } 34 } 35 $("#okplayer-mask-" + base.options.id).css("background-image", "url(" + BLANK_GIF + ")"); 36 if (base.options.playlist.list === null) { 37 if (base.options.video.provider === 'youtube') { 38 base.loadYouTubeAPI(); 39 } else if (base.options.video.provider === 'vimeo') { 40 base.options.volume /= 100; 41 base.loadVimeoAPI(); 42 } 43 } else { 44 base.loadYouTubeAPI(); 45 } 46 } 47 }; 48 // clean the options 49 base.setOptions = function() { 50 // exchange 'true' for '1' and 'false' for 3 51 for (var key in this.options) { 52 if (this.options[key] === true) this.options[key] = 1; 53 if (this.options[key] === false) this.options[key] = 3; 54 } 55 if (base.options.playlist.list === null) { 56 base.options.video = base.determineProvider(); 57 } 58 // pass options to the window 59 $(window).data('okoptions-' + base.options.id, base.options); 60 }; 61 // insert js into the head and exectue a callback function 62 base.insertJS = function(src, callback, provider){ 63 var tag; 64 if ( ev === 'uncode-more-items-loaded' && provider !== 'youtube' ) { 65 delete UNCODE.insertedSripts[src]; 66 var tags = document.getElementsByTagName('script'); 67 for (var i = tags.length; i >= 0; i--){ 68 if (tags[i] && tags[i].getAttribute('src') != null && tags[i].getAttribute('src').indexOf(src) != -1) { 69 tags[i].parentNode.removeChild(tags[i]); 70 } 71 } 72 } else { 73 if (UNCODE.insertedSripts && UNCODE.insertedSripts[src]) { 74 tag = UNCODE.insertedSripts[src]; 75 if (callback){ 76 if (tag.readyState){ //IE 77 tag.onreadystatechange = function(){ 78 if (tag.readyState === "loaded" || 79 tag.readyState === "complete"){ 80 tag.onreadystatechange = null; 81 callback(); 82 } 83 }; 84 } else { 85 $(tag).on('load', callback); 86 } 87 } 88 return; 89 } 90 } 91 tag = document.createElement('script'); 92 if (callback){ 93 if (tag.readyState){ //IE 94 tag.onreadystatechange = function(){ 95 if (tag.readyState === "loaded" || tag.readyState === "complete"){ 96 tag.onreadystatechange = null; 97 callback(); 98 } 99 }; 100 } else { 101 tag.onload = function() { 102 callback(); 103 }; 104 } 105 } 106 tag.src = src; 107 var firstScriptTag = document.getElementsByTagName('script')[0]; 108 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 109 if ( ! UNCODE.insertedSripts ) { 110 UNCODE.insertedSripts = []; 111 } 112 UNCODE.insertedSripts[src] = tag; 113 }; 114 // load the youtube api 115 base.loadYouTubeAPI = function(callback) { 116 if ( ev === 'uncode-more-items-loaded' ) { 117 onYouTubeIframeAPIReady(); 118 } else { 119 base.insertJS('https://www.youtube.com/player_api', false, 'youtube'); 120 } 121 }; 122 base.loadYouTubePlaylist = function() { 123 player.loadPlaylist(base.options.playlist.list, base.options.playlist.index, base.options.playlist.startSeconds, base.options.playlist.suggestedQuality); 124 }; 125 // load the vimeo api by replacing the div with an iframe and loading js 126 base.loadVimeoAPI = function() { 127 var source = '//player.vimeo.com/video/' + base.options.video.id + '?background=1&api=1&title=0&byline=0&portrait=0&playbar=0&loop=' + base.options.loop + '&autoplay=' + (base.options.autoplay === 1 ? 1 : 0) + '&player_id=okplayer-' + base.options.id + '&autopause=0', 128 jIframe = $('<iframe data-src="'+source+'" frameborder="0" id="okplayer-' + base.options.id +'" style="visibility: hidden;" class="vimeo-background" webkitallowfullscreen mozallowfullscreen allowfullscreen >'); 129 $(window).data('okoptions-' + base.options.id).jobject = jIframe; 130 $('#okplayer-' + base.options.id).replaceWith(jIframe[0]); 131 base.insertJS('//player.vimeo.com/api/player.js', function() { 132 vimeoPlayerReady(base.options.id); 133 }, 'vimeo'); 134 }; 135 // is it from youtube or vimeo? 136 base.determineProvider = function() { 137 var a = document.createElement('a'); 138 a.href = base.options.video; 139 if (/youtube.com/.test(base.options.video) || /youtu.be/.test(base.options.video)) { 140 var videoid = a.href.split('/')[3].toString(); 141 var query = videoid.substring(videoid.indexOf('?') + 1); 142 if (query != '') { 143 var vars = query.split('&'); 144 for (var i = 0; i < vars.length; i++) { 145 var pair = vars[i].split('='); 146 if (pair[0] == 'v') { 147 videoid = pair[1]; 148 } 149 } 150 } 151 return { 152 "provider": "youtube", 153 "id": videoid 154 }; 155 } else if (/vimeo.com/.test(base.options.video)) { 156 return { 157 "provider": "vimeo", 158 "id": (a.href.split('/')[3].toString()).split('#')[0], 159 }; 160 } else if (/[-A-Za-z0-9_]+/.test(base.options.video)) { 161 var id = new String(base.options.video.match(/[-A-Za-z0-9_]+/)); 162 if (id.length == 11) { 163 return { 164 "provider": "youtube", 165 "id": id.toString() 166 }; 167 } else { 168 for (var i = 0; i < base.options.video.length; i++) { 169 if (typeof parseInt(base.options.video[i]) !== "number") { 170 throw 'not vimeo but thought it was for a sec'; 171 } 172 } 173 return { 174 "provider": "vimeo", 175 "id": base.options.video 176 }; 177 } 178 } else { 179 throw "OKVideo: Invalid video source"; 180 } 181 }; 182 base.init(); 183 }; 184 185 var checkResize, 186 newW = UNCODE.wwidth; 187 188 $.okvideo.options = { 189 id: null, 190 source: null, // Deprecate dis l8r 191 video: null, 192 playlist: { // eat ur heart out @brokyo 193 list: null, 194 index: 0, 195 startSeconds: 0, 196 suggestedQuality: "default" // options: small, medium, large, hd720, hd1080, highres, default 197 }, 198 disableKeyControl: 1, 199 captions: 0, 200 loop: 1, 201 hd: 1, 202 volume: 0, 203 adproof: false, 204 unstarted: null, 205 onFinished: null, 206 onReady: null, 207 onPlay: null, 208 onPause: null, 209 buffering: null, 210 controls: false, 211 autoplay: true, 212 annotations: true, 213 cued: null 214 }; 215 $.fn.okvideo = function(options) { 216 options.target = this; 217 return this.each(function() { 218 (new $.okvideo(options)); 219 }); 220 }; 221 222 var checkForVideos = function(){ 223 $(".uncode-video-container.video").each(function(index, el) { 224 var $this = $(this), 225 mobile_ready = $this.hasClass('no-control-mobile-autoplay'), 226 url = $this.attr('data-video'), 227 id = $this.attr('data-id'), 228 cloned = $this.closest('.owl-item'); 229 230 if ( mobile_ready || newW >= UNCODE.mediaQuery ) { 231 if (!cloned.hasClass('cloned') || cloned.length == 0) { 232 $this.okvideo({ 233 id: id, 234 source: url.split('#')[0], 235 time: ((url).indexOf("#") > -1) ? (url).substring((url).indexOf('#') + 1) : null, 236 autoplay: 1, 237 controls: 0, 238 volume: 0, 239 adproof: 0, 240 caller: $this, 241 hd: 1, 242 onReady: function(player) { 243 var getPlayer = player.c || player.h || player, 244 $iframe, 245 getContainer = $(getPlayer).closest('.background-element'); 246 if (getContainer.length) { 247 UNCODE.initVideoComponent(getContainer[0], '.uncode-video-container.video:not(.drop-move)'); 248 } 249 250 if ( $this.hasClass('drop-move') ) { 251 252 var $iframe = $(getPlayer), 253 w = parseFloat($iframe.attr('width')), 254 h = parseFloat($iframe.attr('height')), 255 ratio = h / w, 256 setResizeiFto, 257 resizeiFrame = function(){ 258 var dataW = $this.attr('data-w'), 259 newW = UNCODE.wwidth / 12 * parseFloat( dataW ), 260 newH = newW * ratio; 261 $iframe.css({ 262 width: newW, 263 height: newH 264 }); 265 }; 266 resizeiFrame(); 267 $(window).on( 'load', resizeiFrame ); 268 $(window).on( 'resize', function(){ 269 clearRequestTimeout(setResizeiFto); 270 setResizeiFto = requestTimeout( function() { 271 resizeiFrame(); 272 }, 10 ); 273 }); 274 275 } 276 277 } 278 }); 279 } 280 } 281 }); 282 }; 283 284 checkForVideos(); 285 286 $(window).on('load', function(){ 287 $('.mejs-fullscreen-button button').on('click', function(){ 288 var $button = $(this), 289 $stuck = $button.closest('.is_stucked'); 290 291 if ( $stuck.length ) { 292 $stuck = $(this).trigger("sticky_kit:detach"); 293 window.scrollTo(0, 0); 294 } 295 }); 296 }); 297 298 var checkVideoResize = function(){ 299 clearRequestTimeout(checkResize); 300 checkResize = requestTimeout(function(){ 301 if ( newW !== UNCODE.wwidth ) { 302 newW = UNCODE.wwidth; 303 checkForVideos(); 304 } 305 }, 1000); 306 }; 307 308 $(window).off('resize', checkVideoResize) 309 .on( 'resize', checkVideoResize); 310 311}; 312 313$(document).on('uncode-ajax-filtered.videos', function(){ 314 UNCODE.okvideo("uncode-more-items-loaded"); 315}); 316 317})(jQuery);
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.