1var hsYTPlayers = {}, 2 hsVimeoPlayers = {}, 3 hsYTInit = (function () { 4 var onReady_funcs = [], 5 api_isReady = false; 6 7 return function (func, b_before) { 8 if (func === true) { 9 api_isReady = true; 10 for (var i = 0; i < onReady_funcs.length; i++) { 11 onReady_funcs.shift()(); 12 } 13 } 14 else if (typeof func == "function") { 15 if (api_isReady) func(); 16 else onReady_funcs[b_before ? "unshift" : "push"](func); 17 } 18 } 19 })(), 20 hsVimeoInit = (function () { 21 var onReady_funcs = [], 22 api_isReady = false; 23 24 return function (func, b_before) { 25 if (func === true) { 26 api_isReady = true; 27 for (var i = 0; i < onReady_funcs.length; i++) { 28 onReady_funcs.shift()(); 29 } 30 } 31 else if (typeof func == "function") { 32 if (api_isReady) func(); 33 else onReady_funcs[b_before ? "unshift" : "push"](func); 34 } 35 } 36 })(); 37 38$.fn.hsBgVideo = function (options) { 39 hsYTAPICreate(); 40 hsVimeoAPICreate(); 41 42 var YTVideo = $('[data-hs-bgv-type="youtube"]'), 43 VimeoVideo = $('[data-hs-bgv-type="vimeo"]'), 44 defaultVideo = $(this); 45 46 if (YTVideo.length) { 47 YTVideo.each(function (i) { 48 var $this = $(this), 49 ID = $this.data('hs-bgv-id'), 50 loop = $this.data('hs-bgv-loop') ? 1 : 0, 51 preview = $('<div class="hs-video-preview" style="background-image: url(//img.youtube.com/vi/' + ID + '/maxresdefault.jpg);"></div>'); 52 53 $this 54 .css('position', 'relative') 55 .prepend(preview) 56 .prepend('<div id="hsYTPlayer' + i + '" class="hs-youtube hs-bg-video" data-hs-bgv-id="' + ID + '" data-hs-bgv-loop="' + loop + '"></div>'); 57 }); 58 59 hsYTInit(function () { 60 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) return; 61 62 $('.hs-youtube').each(function (i) { 63 var ID = $(this).attr('id'), 64 videoID = $(this).data('hs-bgv-id'), 65 loop = $(this).data('hs-bgv-loop') ? 1 : 0; 66 67 return hsYTPlayers[i] = new YT.Player(ID, { 68 videoId: videoID, 69 playerVars: { 70 autoplay: 1, 71 controls: 0, 72 showinfo: 0, 73 enablejsapi: 1, 74 modestbranding: 1, 75 iv_load_policy: 3, 76 loop: loop, 77 playlist: videoID 78 }, 79 events: { 80 'onReady': hsYTReady, 81 'onStateChange': hsYTPlay 82 } 83 }); 84 }); 85 }); 86 } 87 88 if (VimeoVideo.length) { 89 VimeoVideo.each(function (i) { 90 var $this = $(this), 91 ID = $this.data('hs-bgv-id'), 92 loop = $this.data('hs-bgv-loop') ? 1 : 0; 93 94 function getComputerName() { 95 $.getJSON('//www.vimeo.com/api/v2/video/' + ID + '.json?callback=?', function (data) { 96 var preview = data[0].thumbnail_large; 97 98 $this.prepend('<div class="hs-video-preview" style="background-image: url(' + preview + ');"></div>'); 99 }); 100 } 101 102 getComputerName(); 103 104 $this 105 .css('position', 'relative') 106 .prepend('<div id="hsVimeoPlayer' + i + '" class="hs-vimeo hs-bg-video" data-hs-bgv-id="' + ID + '" data-hs-bgv-loop="' + loop + '"></div>'); 107 }); 108 109 hsVimeoInit(function () { 110 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) return; 111 112 $('.hs-vimeo').each(function (i) { 113 var ID = $(this).attr('id'), 114 videoID = $(this).data('hs-bgv-id'), 115 loop = $(this).data('hs-bgv-loop') ? 1 : 0; 116 117 hsVimeoPlayers[i] = new Vimeo.Player(ID, { 118 id: videoID, 119 loop: loop, 120 title: false, 121 portrait: false, 122 byline: false, 123 autoplay: true, 124 autopause: false 125 }); 126 127 hsVimeoPlayers[i].setVolume(0); 128 129 hsVimeoPlayers[i].play().then(function () { 130 var thisW = hsVimeoPlayers[i].element.width, 131 thisH = hsVimeoPlayers[i].element.height, 132 ratio = thisW / thisH; 133 134 ratioCalc(hsVimeoPlayers[i].element, ratio); 135 136 $(window).resize(function () { 137 ratioCalc(hsVimeoPlayers[i].element, ratio); 138 }); 139 140 $('*').on('blur change click dblclick error focus focusin focusout hover keydown keypress keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup resize scroll select submit', function () { 141 ratioCalc(hsVimeoPlayers[i].element, ratio); 142 }); 143 144 setTimeout(function () { 145 $('#' + ID).prev().fadeOut(400); 146 }, 3000); 147 }); 148 }); 149 }); 150 } 151 152 if (defaultVideo.length) { 153 defaultVideo.not('[data-hs-bgv-type]').each(function () { 154 var $this = $(this), 155 path = $this.data('hs-bgv-path'), 156 loop = $this.data('hs-bgv-loop') ? 'loop ' : '', 157 template = '<video ' + 158 'class="hs-html5 hs-bg-video"' + 159 ' poster="" autoplay muted ' + loop + '>' + 160 '<source src="' + path + '.mp4" type="video/mp4">' + 161 '<source src="' + path + '.webm" type="video/webm">' +
162 '<source src="' + path + '.ogv" type="video/ogg">' + 163 'Your browser doesn\'t support HTML5 video.' + 164 '</video>'; 165 166 $this 167 .css('position', 'relative') 168 .prepend(template); 169 }); 170 } 171}; 172 173//Ratio 174function ratioCalc(target, ratio) { 175 var windW = $(window).width(), 176 containerH = $(target).parents('[data-hs-bgv-id]').outerHeight(), 177 containerW = $(target).parent('[data-hs-bgv-id]').outerWidth(), 178 newW = ratio * containerH, 179 newH = ratio * containerW; 180 181 182 if (containerH > containerW) { 183 $(target).css({ 184 'width': newW, 185 'height': '130%' 186 }); 187 } else { 188 $(target).css({ 189 'width': newH, 190 'height': windW > 1600 ? newH * .4 : newW 191 }); 192 } 193} 194 195//YouTube 196function hsYTAPICreate() { 197 if ($('[data-hs-bgv-type="youtube"]').length) { 198 var script = document.createElement('script'); 199 script.src = '//www.youtube.com/player_api'; 200 201 var before = document.getElementsByTagName('script')[0]; 202 before.parentNode.insertBefore(script, before); 203 } 204} 205 206function hsYTReady(e) { 207 e.target.mute(); 208 209 var thisW = e.target.a.width, 210 thisH = e.target.a.height, 211 ratio = thisW / thisH; 212 213 ratioCalc(e.target.a, ratio); 214 215 $(window).resize(function () { 216 ratioCalc(e.target.a, ratio); 217 }); 218 219 $('*').on('blur change click dblclick error focus focusin focusout hover keydown keypress keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup resize scroll select submit', function () { 220 ratioCalc(e.target.a, ratio); 221 }); 222} 223 224function hsYTPlay(e) { 225 if (e.data == YT.PlayerState.PLAYING) { 226 setTimeout(function () { 227 $(e.target.a).next().fadeOut(400); 228 }, 3000); 229 } 230} 231 232function onYouTubePlayerAPIReady() { 233 hsYTInit(true); 234} 235 236//Vimeo 237function hsVimeoAPICreate() { 238 if ($('[data-hs-bgv-type="vimeo"]').length) { 239 var script = document.createElement('script'); 240 script.src = '//player.vimeo.com/api/player.js'; 241 242 var before = document.getElementsByTagName('script')[0]; 243 before.parentNode.insertBefore(script, before); 244 } 245} 246 247hsVimeoInit(true);
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.