PageSourceSearch

https://shinhanlife.co.kr/webponent-press/external/videolightning/videoLightning.js

js shinhanlife.co.kr collected 2026-10-01 15:36:00 UTC 27,823 bytes, 795 lines download raw bytes

1(function() {
2  var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
3
4  (function(document, $) {
5    var VideoLightning, _bitify, _boolify, _cc, _coverEl, _domStr, _extObj, _fadeCss, _fadeIn, _fadeOut, _frameCss, _fullHex, _getEl, _gravity, _initYTAPI, _isAry, _isElAry, _isObj, _isStr, _postToVM, _prepHex, _randar, _setSrc, _testEl, _topKeyOfObj, _val, _wrapCss, _wrapCssP, _ytReset, dom, videoLightning;
6    dom = document;
7    videoLightning = (function(_this) {
8      return function(obj) {
9        var de, domEls, e, el, els, i, j, l, len, len1, len2, len3, m, noElErr, optEls, pushRawEls, rawEls, settings;
10        noElErr = function() {
11          console.error('VideoLightning was initialized without elements.');
12        };
13        optEls = obj.elements || obj.element;
14        if (!optEls) {
15          return noElErr();
16        }
17        rawEls = [];
18        els = [];
19        pushRawEls = function(e) {
20          var el;
21          if (_isStr(e)) {
22            return rawEls.push({
23              el: e,
24              opts: null
25            });
26          } else {
27            el = _topKeyOfObj(e);
28            return rawEls.push({
29              el: el,
30              opts: e[el] || null
31            });
32          }
33        };
34        if (_isAry(optEls)) {
35          for (i = 0, len = optEls.length; i < len; i++) {
36            e = optEls[i];
37            pushRawEls(e);
38          }
39        } else {
40          pushRawEls(optEls);
41        }
42        for (j = 0, len1 = rawEls.length; j < len1; j++) {
43          el = rawEls[j];
44          if ((domEls = _getEl(el.el))) {
45            if (_isElAry(domEls)) {
46              for (l = 0, len2 = domEls.length; l < len2; l++) {
47                de = domEls[l];
48                els.push({
49                  el: de,
50                  opts: el.opts
51                });
52              }
53            } else {
54              els.push({
55                el: domEls,
56                opts: el.opts
57              });
58            }
59          }
60        }
61        if (els.length === 0) {
62          return noElErr();
63        }
64        settings = obj.settings || {};
65        for (m = 0, len3 = els.length; m < len3; m++) {
66          el = els[m];
67          if (el) {
68            _this.vlData.instances.push(new VideoLightning(el, settings));
69          }
70        }
71        _initYTAPI();
72      };
73    })(this);
74    VideoLightning = (function() {
75      function VideoLightning(elObj, opts) {
76        this.elObj = elObj;
77        this.vmStop = bind(this.vmStop, this);
78        this.vmPlay = bind(this.vmPlay, this);
79        this.vmListen = bind(this.vmListen, this);
80        this.initPlayerVM = bind(this.initPlayerVM, this);
81        this.coverYT = bind(this.coverYT, this);
82        this.ytState = bind(this.ytState, this);
83        this.ytStop = bind(this.ytStop, this);
84        this.ytPlay = bind(this.ytPlay, this);
85        this.setYTPlayer = bind(this.setYTPlayer, this);
86        this.initPlayerYT = bind(this.initPlayerYT, this);
87        this.cover = bind(this.cover, this);
88        this.hide = bind(this.hide, this);
89        this.show = bind(this.show, this);
90        this.clear = bind(this.clear, this);
91        this.stop = bind(this.stop, this);
92        this.play = bind(this.play, this);
93        this.peek = bind(this.peek, this);
94        this.hovered = bind(this.hovered, this);
95        this.clicked = bind(this.clicked, this);
96        this.regEvents = bind(this.regEvents, this);
97        this.resize = bind(this.resize, this);
98        this.popoverPos = bind(this.popoverPos, this);
99        this.buildEls = bind(this.buildEls, this);
100        this.buildOpts = bind(this.buildOpts, this);
101        this.opts = _extObj({}, opts);
102        this.inst = _randar();
103        this.el = this.elObj.el;
104        this.buildOpts();
105        this.buildEls();
106        if (_boolify(this.opts.cover, false)) {
107          this.cover();
108        }
109        this.regEvents();
110      }
111
112      VideoLightning.prototype.buildOpts = function() {
113        var base, base1, elDataSet, i, j, k, key, len, len1, name, normalize, ref, remap, results, v;
114        remap = [['backdrop_color', 'bdColor'], ['backdrop_opacity', 'bdOpacity'], ['ease_in', 'fadeIn'], ['ease_out', 'fadeOut'], ['glow_color', 'glowColor'], ['start_time', 'startTime'], ['z_index', 'zIndex'], ['rick_roll', 'rickRoll'], ['iv_load_policy', 'ivLoadPolicy']];
115        _extObj(this.opts, this.elObj.opts);
116        elDataSet = this.el.dataset || [];
117        if (elDataSet.length === 0) {
118          ref = ['id', 'width', 'height'];
119          for (i = 0, len = ref.length; i < len; i++) {
120            k = ref[i];
121            v = this.el.getAttribute("data-video-" + k);
122            if (v) {
123              elDataSet[k] = v;
124            }
125          }
126        }
127        normalize = (function(_this) {
128          return function(k, v) {
129            return _this.opts[k.replace(/^video(.)(.*)/, function(a, b, c) {
130              return b.toLowerCase() + c;
131            })] = v;
132          };
133        })(this);
134        for (k in elDataSet) {
135          v = elDataSet[k];
136          normalize(k, v);
137        }
138        this.opts.width = this.opts.width ? parseInt(this.opts.width, 10) : 640;
139        this.opts.height = this.opts.height ? parseInt(this.opts.height, 10) : 390;
140        if ((base = this.opts).id == null) {
141          base.id = 'y-dQw4w9WgXcQ';
142        }
143        if (this.opts.id.match(/^v/)) {
144          this.vendor = 'vimeo';
145          this.vm = true;
146        } else if (this.opts.id.match(/^f/)) {
147          this.vendor = 'iframe';
148          this.ifr = true;
149        } else {
150          this.vendor = 'youtube';
151          this.yt = true;
152        }
153        window.vlData[this.vendor] = true;
154        this.id = this.opts.id.replace(/([vyf]-)/i, '');
155        results = [];
156        for (j = 0, len1 = remap.length; j < len1; j++) {
157          key = remap[j];
158          results.push((base1 = this.opts)[name = key[1]] != null ? base1[name] : base1[name] = this.opts[key[0]]);
159        }
160        return results;
161      };
162
163      VideoLightning.prototype.buildEls = function() {
164        var bdbg, bdc, bdo, fdim, fglo, fmar, frameCss, g, wrapCss, xCss;
165        (this.target = dom.createElement('span')).className = 'video-target';
166        this.el.parentNode.insertBefore(this.target, this.el);
167        this.target.appendChild(this.el);
168        bdc = _cc(_val(this.opts.bdColor, '#ddd'));
169        bdo = _val(this.opts.bdOpacity, 0.6);
170        bdbg = "background: rgba(" + bdc.r + ", " + bdc.g + ", " + bdc.b + ", " + bdo + ");";
171        fdim = "width: " + this.opts.width + "px; height: " + this.opts.height + "px;";
172        fmar = "margin-top: -" + (this.opts.height / 2) + "px; margin-left: -" + (this.opts.width / 2) + "px;";
173        fglo = "box-shadow: 0px 0px " + (g = _val(this.opts.glow, 20)) + "px " + (g / 5) + "px " + (_fullHex(_val(this.opts.glowColor, '#000'))) + ";";
174        wrapCss = _boolify(this.opts.popover, false) ? _wrapCssP(this.opts.width, this.opts.height) : _wrapCss;
175        xCss = "background: " + (_fullHex(_val(this.opts.xBgColor, '#000'))) + "; color: " + (_fullHex(_val(this.opts.xColor, '#fff'))) + "; border: " + (_val(this.opts.xBorder, 'none')) + "; box-sizing: border-box;";
176        frameCss = "background: " + (_fullHex(_val(this.opts.frameColor, '#000'))) + "; border: " + (_val(this.opts.frameBorder, 'none')) + "; box-sizing: border-box;";
177        this.target.insertAdjacentHTML('beforeend', _domStr({
178          tag: 'div',
179          attrs: {
180            id: "wrap_" + this.inst,
181            "class": 'video-wrapper',
182            style: wrapCss + " " + bdbg + " z-index: " + (_val(this.opts.zIndex, 2100)) + "; opacity: 0;"
183          },
184          children: [
185            {
186              tag: 'div',
187              attrs: {
188                "class": 'video-frame',
189                style: _frameCss + " " + fdim + " " + fmar + " " + fglo
190              },
191              children: [
192                {
193                  tag: 'div',
194                  attrs: {
195                    "class": 'video'
196                  },
197                  children: [
198                    {
199                      tag: 'div',
200                      inner: '&times;',
201                      attrs: {
202                        id: "close_" + this.inst,
203                        "class": 'video-close',
204                        style: "float: right; margin-right: -34px; " + fglo + " " + xCss + " padding: 0 10px 0 12px; font-size: 25px;"
205                      }
206                    }, {
207                      tag: 'iframe',
208                      attrs: {
209                        type: 'text/html',
210                        id: "iframe_" + this.inst,
211                        "class": 'video-iframe',
212                        style: "position: absolute; top: 0; left: 0; " + frameCss
213                      }
214                    }
215                  ]
216                }
217              ]
218            }
219          ]
220        }));
221        this.wrapper = dom.getElementById("wrap_" + this.inst);
222        this.iframe = dom.getElementById("iframe_" + this.inst);
223        return this.close = dom.getElementById("close_" + this.inst);
224      };
225
226      VideoLightning.prototype.popoverPos = function() {
227        var pos;
228        pos = _gravity(this.target, this.opts.width, this.opts.height, this.opts.fluidity);
229        this.wrapper.style.left = pos.x + "px";
230        return this.wrapper.style.top = pos.y + "px";
231      };
232
233      VideoLightning.prototype.resize = function() {
234        var throttleOff;
235        if (!window.vlData.throttle) {
236          this.popoverPos();
237          if (this.opts.throttle) {
238            window.vlData.throttle = true;
239            throttleOff = function() {
240              return window.vlData.throttle = false;
241            };
242            return setTimeout(throttleOff, this.opts.throttle);
243          }
244        }
245      };
246
247      VideoLightning.prototype.regEvents = function() {
248        this.target.style.cursor = 'pointer';
249        this.target.addEventListener('mouseup', this.clicked, false);
250        if (_boolify(this.opts.popover, false)) {
251          window.addEventListener('resize', this.resize, false);
252          window.addEventListener('scroll', this.resize, false);
253          window.addEventListener('orientationchange', this.resize, false);
254          if (this.opts.peek) {
255            this.target.addEventListener('mouseenter', this.hovered, false);
256            return this.target.addEventListener('mouseleave', this.hovered, false);
257          }
258        }
259      };
260
261      VideoLightning.prototype.clicked = function(e) {
262        if (this.peeking) {
263          return this.peek(false, true);
264        }
265        if ((e.buttons && e.buttons !== 1) || (e.which && e.which !== 1) || (e.button && e.button !== 1)) {
266          return;
267        }
268        if (this.playing) {
269          return this.stop();
270        } else {
271          return this.play();
272        }
273      };
274
275      VideoLightning.prototype.hovered = function(e) {
276        if (e.type === 'mouseenter' && !this.playing) {
277          this.peek();
278        }
279        if (e.type === 'mouseleave' && this.playing) {
280          return this.peek(this.peeking);
281        }
282      };
283
284      VideoLightning.prototype.peek = function(close, pin) {
285        if (close == null) {
286          close = false;
287        }
288        if (pin == null) {
289          pin = false;
290        }
291        if (!this.peeking && this.playing) {
292          return;
293        }
294        this.close.innerHTML = close || pin ? '&times;' : '&#94;';
295        this.peeking = !!!(close || pin);
296        if (close) {
297          return this.stop();
298        } else if (pin) {
299          return null;
300        } else {
301          return this.play();
302        }
303      };
304
305      VideoLightning.prototype.play = function() {
306        if (_boolify(this.opts.popover, false)) {
307          this.popoverPos();
308        }
309        this.show();
310        if (this.ifr) {
311          _setSrc(this.iframe, {
312            url: encodeURI(this.id),
313            attrs: {
314              width: this.opts.width,
315              height: this.opts.height,
316              frameBorder: 0
317            }
318          });
319        } else if (this.ready && !this.playing && this.iframe.src !== 'about:blank') {
320          if (this.yt) {
321            this.ytPlay();
322          }
323          if (this.vm) {
324            this.vmPlay();
325          }
326        } else if (!this.playing) {
327          if (this.vm) {
328            this.initPlayerVM();
329          }
330          if (this.yt) {
331            this.initPlayerYT();
332          }
333        }
334        this.playing = true;
335        if (this.clearAfter) {
336          window.clearTimeout(this.clearAfter);
337        }
338      };
339
340      VideoLightning.prototype.stop = function(fade) {
341        if (fade == null) {
342          fade = 0;
343        }
344        if (_boolify(this.opts.rickRoll, false)) {
345          return;
346        }
347        this.hide(fade);
348        if (this.ready) {
349          if (this.yt) {
350            this.ytStop();
351          }
352          if (this.vm) {
353            this.vmStop();
354          }
355        } else {
356          this.clear();
357        }
358        this.playing = false;
359        if (_boolify(this.opts.unload, true)) {
360          this.clearAfter = window.setTimeout(this.clear, (_val(this.opts.unloadAfter) || 45) * 1000);
361        }
362      };
363
364      VideoLightning.prototype.clear = function() {
365        this.iframe.src = 'about:blank';
366      };
367
368      VideoLightning.prototype.show = function() {
369        _fadeIn(this.wrapper, _val(this.opts.fadeIn, 300));
370      };
371
372      VideoLightning.prototype.hide = function(fade) {
373        if (fade == null) {
374          fade = 0;
375        }
376        _fadeOut(this.wrapper, _val(this.opts.fadeOut, fade));
377      };
378
379      VideoLightning.prototype.cover = function() {
380        if (this.yt) {
381          this.coverYT();
382        }
383      };
384
385      VideoLightning.prototype.initPlayerYT = function() {
386        _setSrc(this.iframe, {
387          url: location.protocol + "//www.youtube.com/embed/" + this.id,
388          params: {
389            enablejsapi: 1,
390            autoplay: _bitify(this.opts.autoplay, 1),
391            autohide: _val(this.opts.autohide, 2),
392            cc_load_policy: _val(this.opts.ccLoadPolicy, 0),
393            color: _val(this.opts.color, null),
394            controls: _val(this.opts.controls, 2),
395            disablekb: _val(this.opts.disablekb, 0),
396            end: _val(this.opts.endTime, null),
397            fs: _val(this.opts.fs, 1),
398            hl: _val(this.opts.hl, 'en'),
399            iv_load_policy: _val(this.opts.ivLoadPolicy, 1),
400            list: _val(this.opts.list, null),
401            listType: _val(this.opts.listType, null),
402            loop: _val(this.opts.loop, 0),
403            modestbranding: _val(this.opts.modestbranding, 0),
404            origin: encodeURIComponent(_val(this.opts.origin, location.protocol + "//" + location.host)),
405            playerapiid: this.inst,
406            playlist: _val(this.opts.playlist, null),
407            playsinline: _val(this.opts.playsinline, 0),
408            rel: _val(this.opts.rel, 0),
409            showinfo: _val(this.opts.showinfo, 1),
410            start: _val(this.opts.startTime, 0),
411            theme: _val(this.opts.theme, null)
412          },
413          attrs: {
414            width: this.opts.width,
415            height: this.opts.height,
416            frameBorder: 0
417          }
418        });
419        this.iframe.setAttribute('allowFullScreen', '');
420        if (window.vlData.ytAPIReady) {
421          return this.setYTPlayer();
422        }
423      };
424
425      VideoLightning.prototype.setYTPlayer = function() {
426        var ready;
427        ready = (function(_this) {
428          return function() {
429            return _this.ready = true;
430          };
431        })(this);
432        return this.ytPlayer != null ? this.ytPlayer : this.ytPlayer = new YT.Player("iframe_" + this.inst, {
433          events: {
434            onReady: ready,
435            onStateChange: this.ytState
436          }
437        });
438      };
439
440      VideoLightning.prototype.ytPlay = function() {
441        return this.ytPlayer.playVideo();
442      };
443
444      VideoLightning.prototype.ytStop = function() {
445        _ytReset(this.ytPlayer, this.opts.startTime);
446        this.ytPlayer.stopVideo();
447        return this.ytPlayer.clearVideo();
448      };
449
450      VideoLightning.prototype.ytState = function(e) {
451        if (e.data === 0 && _boolify(this.opts.autoclose, true)) {
452          return this.stop(_val(this.opts.fadeOut, 1000));
453        }
454      };
455
456      VideoLightning.prototype.coverYT = function() {
457        this.ytCover = _coverEl(this.target, "//img.youtube.com/vi/" + this.id + "/hqdefault.jpg");
458      };
459
460      VideoLightning.prototype.initPlayerVM = function() {
461        _setSrc(this.iframe, {
462          url: location.protocol + "//player.vimeo.com/video/" + this.id,
463          params: {
464            autoplay: _bitify(this.opts.autoplay, 1),
465            loop: _val(this.opts.loop, 0),
466            title: _val(this.opts.showinfo, 1),
467            byline: _val(this.opts.byline, 1),
468            portrait: _val(this.opts.portrait, 1),
469            color: _prepHex(_val(this.opts.color, '#00adef')),
470            api: 1,
471            player_id: this.inst
472          },
473          attrs: {
474            width: this.opts.width,
475            height: this.opts.height,
476            frameBorder: 0
477          }
478        });
479        this.iframe.setAttribute('allowFullScreen', '');
480        window.addEventListener('message', this.vmListen, false);
481        return this.vmPlayer != null ? this.vmPlayer : this.vmPlayer = this.iframe;
482      };
483
484      VideoLightning.prototype.vmListen = function(msg) {
485        var data;
486        data = JSON.parse(msg.data);
487        if (data.player_id !== this.inst) {
488          return;
489        }
490        switch (data.event) {
491          case 'ready':
492            this.ready = true;
493            _postToVM(this.vmPlayer, this.id, 'addEventListener', 'f
493inish');
494            break;
495          case 'finish':
496            this.stop(1000);
497        }
498      };
499
500      VideoLightning.prototype.vmPlay = function() {
501        _postToVM(this.vmPlayer, this.id, 'play');
502      };
503
504      VideoLightning.prototype.vmStop = function() {
505        _postToVM(this.vmPlayer, this.id, 'pause');
506      };
507
508      return VideoLightning;
509
510    })();
511    _val = function(p, d) {
512      if (p === false || p === 'false' || p === 0 || p === '0') {
513        return p;
514      } else {
515        return p || d;
516      }
517    };
518    _bitify = function(p, d) {
519      if (p === false || p === 'false' || p === 0 || p === '0') {
520        return 0;
521      } else if (p === true || p === 'true' || p === '1' || p === 1) {
522        return 1;
523      } else {
524        return d;
525      }
526    };
527    _boolify = function(p, d) {
528      if (p === false || p === 'false' || p === 0 || p === '0') {
529        return false;
530      } else {
531        return !!p || d;
532      }
533    };
534    _domStr = function(o) {
535      var attrs, c, children, i, k, len, ref, ref1, v;
536      attrs = '';
537      children = '';
538      if (o.attrs) {
539        ref = o.attrs;
540        for (k in ref) {
541          v = ref[k];
542          attrs += ' ' + k + '="' + v + '"';
543        }
544      }
545      if (o.children) {
546        ref1 = o.children;
547        for (i = 0, len = ref1.length; i < len; i++) {
548          c = ref1[i];
549          children += _isObj(c) ? _domStr(c) : c;
550        }
551      }
552      return '<' + o.tag + attrs + '>' + (o.inner || children) + '</' + o.tag + '>';
553    };
554    _setSrc = function(el, o) {
555      var k, ref, ref1, results, src, v;
556      src = o.url + "?";
557      ref = o.params;
558      for (k in ref) {
559        v = ref[k];
560        if (v !== null) {
561          src += "&" + k + "=" + v;
562        }
563      }
564      el.src = src.replace(/&/, '');
565      ref1 = o.attrs;
566      results = [];
567      for (k in ref1) {
568        v = ref1[k];
569        results.push(el[k] = v);
570      }
571      return results;
572    };
573    _extObj = function(baseObj, extObj) {
574      var k, v;
575      for (k in extObj) {
576        v = extObj[k];
577        baseObj[k] = v;
578      }
579      return baseObj;
580    };
581    _isStr = function(obj) {
582      return typeof obj === 'string';
583    };
584    _isAry = function(obj) {
585      return obj instanceof Array;
586    };
587    _isElAry = function(obj) {
588      return obj instanceof HTMLCollection || obj instanceof NodeList;
589    };
590    _isObj = function(obj) {
591      return obj !== null && typeof obj === 'object';
592    };
593    _topKeyOfObj = function(obj) {
594      var k, v;
595      for (k in obj) {
596        v = obj[k];
597        return k;
598      }
599    };
600    _getEl = function(el) {
601      var els;
602      els = el.charAt(0) === '#' ? dom.getElementById(el.substr(1)) : dom.getElementsByClassName(el.substr(1));
603      if (_isAry(els) && els.length === 0) {
604        return null;
605      } else {
606        return els;
607      }
608    };
609    _randar = function() {
610      return (Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).substring(0, 16);
611    };
612    _prepHex = function(hex) {
613      hex = hex.replace(/^#/, '');
614      if (hex.length === 3) {
615        return "" + hex + hex;
616      } else {
617        return hex;
618      }
619    };
620    _fullHex = function(hex) {
621      if (hex === 'transparent') {
622        return hex;
623      } else {
624        return "#" + _prepHex(hex);
625      }
626    };
627    _cc = function(hex) {
628      return {
629        r: parseInt((_prepHex(hex)).substring(0, 2), 16),
630        g: parseInt((_prepHex(hex)).substring(2, 4), 16),
631        b: parseInt((_prepHex(hex)).substring(4, 6), 16)
632      };
633    };
634    _wrapCss = 'display: none; position: fixed; min-width: 100%; min-height: 100%; top: 0; right: 0; bottom: 0; left: 0;';
635    _wrapCssP = function(w, h) {
636      return "display: none; position: fixed; width: " + w + "px; height: " + h + "px;";
637    };
638    _frameCss = 'position: absolute; top: 50%; left: 50%; background: #000000;';
639    _fadeCss = function(el, t) {
640      return el.style.transition = el.style.mozTransition = el.style.webkitTransition = "opacity " + t + "ms ease";
641    };
642    _fadeIn = function(el, t) {
643      var applyFade;
644      _fadeCss(el, t);
645      el.style.display = 'block';
646      applyFade = function() {
647        return el.style.opacity = 1;
648      };
649      return setTimeout(applyFade, 20);
650    };
651    _fadeOut = function(el, t) {
652      var applyFade;
653      _fadeCss(el, t);
654      el.style.opacity = 0;
655      applyFade = function() {
656        return el.style.display = 'none';
657      };
658      return setTimeout(applyFade, t);
659    };
660    _initYTAPI = function() {
661      var scriptA, vFuncs, vScript;
662      if (dom.getElementById('ytScript')) {
663        return;
664      }
665      scriptA = dom.getElementsByTagName('script')[0];
666      vFuncs = document.createElement('script');
667      vFuncs.innerHTML = 'function onYouTubeIframeAPIReady() {vlData.ytReady()};';
668      scriptA.parentNode.insertBefore(vFuncs, scriptA);
669      vScript = document.createElement('script');
670      vScript.id = 'ytScript';
671      vScript.async = true;
672      vScript.src = location.protocol + "//www.youtube.com/iframe_api";
673      vFuncs.parentNode.insertBefore(vScript, vFuncs.nextSibling);
674    };
675    _ytReset = function(p, s) {
676      if (s == null) {
677        s = 0;
678      }
679      if ((p.getDuration() - 3) < p.getCurrentTime()) {
680        p.pauseVideo();
681        p.seekTo(s, false);
682      }
683    };
684    _postToVM = function(player, id, k, v) {
685      var data;
686      if (v == null) {
687        v = null;
688      }
689      data = v ? {
690        method: k,
691        value: v
692      } : {
693        method: k
694      };
695      return player.contentWindow.postMessage(JSON.stringify(data), location.protocol + "//player.vimeo.com/video/" + id);
696    };
697    _coverEl = function(target, src) {
698      var cover;
699      cover = dom.createElement('img');
700      cover.className = 'video-cover';
701      cover.src = src;
702      target.appendChild(cover);
703      return cover;
704    };
705    _testEl = function() {
706      var test;
707      if (!(test = document.getElementById('vl-size-test'))) {
708        test = document.createElement("div");
709        test.id = 'vl-size-test';
710        test.style.cssText = "position:fixed;top:0;left:0;bottom:0;right:0;visibility:hidden;";
711        document.body.appendChild(test);
712      }
713      return {
714        width: test.offsetWidth,
715        height: test.offsetHeight
716      };
717    };
718    _gravity = function(el, width, height, fluidity) {
719      var box_center, center, coords, i, j, page_height, page_width, points, ref, ref1, ref2, ref3, ref4, ref5, sort, x, y;
720      if (fluidity == null) {
721        fluidity = 30;
722      }
723      coords = el.getBoundingClientRect();
724      center = {
725        x: (page_width = _testEl().width) / 2,
726        y: (page_height = _testEl().height) / 2
727      };
728      box_center = {
729        x: width / 2,
730        y: height / 2
731      };
732      points = [];
733      for (x = i = ref = coords.left, ref1 = coords.right + width, ref2 = fluidity; ref2 > 0 ? i <= ref1 : i >= ref1; x = i += ref2) {
734        points.push([x - width, coords.top - height]);
735        points.push([x - width, coords.bottom]);
736      }
737      for (y = j = ref3 = coords.top, ref4 = coords.bottom + height, ref5 = fluidity; ref5 > 0 ? j <= ref4 : j >= ref4; y = j += ref5) {
738        points.push([coords.left - width, y - height]);
739        points.push([coords.right, y - height]);
740      }
741      sort = function(a, b) {
742        var ary, dax, day, l, len, obja, objb, ref6;
743        ref6 = [[a, obja = {}], [b, objb = {}]];
744        for (l = 0, len = ref6.length; l < len; l++) {
745          ary = ref6[l];
746          x = ary[0][0];
747          y = ary[0][1];
748          ary[1].diffx = (dax = x + box_center.x) > center.x ? dax - center.x : center.x - dax;
749          ary[1].diffy = (day = y + box_center.y) > center.y ? day - center.y : center.y - day;
750          ary[1].diff = ary[1].diffx + ary[1].diffy;
751          if (x < 0 || x + width > page_width) {
752            ary[1].diff += 10000;
753          }
754          if (y < 0 || y + height > page_height) {
755            ary[1].diff += 10000;
756          }
757        }
758        return obja.diff - objb.diff;
759      };
760      points.sort(sort);
761      return {
762        x: parseInt(((x = points[0][0]) < 0 || x + width > page_width ? center.x - box_center.x : x), 10),
763        y: parseInt(((y = points[0][1]) < 0 || y + height > page_height ? center.y - box_center.y : y), 10)
764      };
765    };
766    this.videoLightning = videoLightning;
767    this.vlData = {};
768    this.vlData.instances = [];
769    this.vlData.ytReady = (function(_this) {
770      return function() {
771        return _this.vlData.ytAPIReady = true;
772      };
773    })(this);
774    this.vlData.youtube = this.vlData.vimeo = false;
775    if (typeof $ !== 'undefined') {
776      return $.fn.jqueryVideoLightning = function(options) {
777        this.each(function() {
778          var inst;
779          if (!$.data(this, 'plugin_jqueryVideoLightning')) {
780            inst = new VideoLightning({
781              el: this,
782              opts: options
783            });
784            vlData.instances.push(inst);
785            $.data(this, 'plugin_jqueryVideoLightning', inst);
786          }
787        });
788        return _initYTAPI();
789      };
790    }
791  })(document, jQuery);
792
793}).call(this);
794
795//# sourceMappingURL=videoLightning.js.map

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.