1/*! Fluidvids v2.2.0 | (c) 2014 @toddmotto | github.com/toddmotto/fluidvids */ 2(function (root, factory) { 3 if (typeof define === 'function' && define.amd) { 4 define(factory); 5 } else if (typeof exports === 'object') { 6 module.exports = factory; 7 } else { 8 root.fluidvids = factory(); 9 } 10})(this, function () { 11 12 'use strict'; 13 14 var exports = { 15 selector: 'iframe', 16 players: ['www.youtube.com', 'player.vimeo.com'] 17 }; 18 19 var head = document.head || document.getElementsByTagName('head')[0]; 20 var css = '.fluidvids{width:100%;position:relative;}' + 21 '.fluidvids iframe{position:absolute;top:0px;left:0px;width:100%;height:100%;}'; 22 23 var _matches = function (source) { 24 var regexp = new RegExp('^(https?:)?\/\/(?:' + exports.players.join('|') + ').*$', 'i'); 25 return regexp.test(source); 26 }; 27 28 var _render = function (elem) { 29 if (!!elem.getAttribute('data-fluidvids')) { 30 return; 31 } 32 var wrap = document.createElement('div'); 33 var ratio = (parseInt(elem.height ? elem.height : elem.offsetHeight, 10) / (parseInt(elem.width ? elem.width : elem.offsetWidth, 10)) * 100); 34 elem.parentNode.insertBefore(wrap, elem); 35 elem.setAttribute('data-fluidvids', 'loaded'); 36 wrap.className += 'fluidvids'; 37 wrap.style.paddingTop = ratio + '%'; 38 wrap.appendChild(elem); 39 }; 40 41 var _addStyles = function () { 42 var div = document.createElement('div'); 43 div.innerHTML = '<p>x</p><style>' + css + '</style>'; 44 head.appendChild(div.childNodes[1]); 45 }; 46 47 exports.apply = function () { 48 var nodes = document.querySelectorAll(exports.selector); 49 for (var i = 0; i < nodes.length; i++) { 50 var node = nodes[i]; 51 if (_matches(node.src)) { 52 _render(node); 53 } 54 } 55 }; 56 57 exports.init = function (obj) { 58 for (var key in obj) { 59 exports[key] = obj[key]; 60 } 61 exports.apply(); 62 _addStyles(); 63 }; 64 65 return exports; 66 67});
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.