1/*! fluidvids.js v2.4.1 | (c) 2014 @toddmotto | https://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 fluidvids = { 15 selector: ['iframe', 'object'], 16 players: ['www.youtube.com', 'player.vimeo.com'] 17 }; 18 19 var css = [ 20 '.fluidvids {', 21 'width: 100%; max-width: 100%; position: relative;', 22 '}', 23 '.fluidvids-item {', 24 'position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;', 25 '}' 26 ].join(''); 27 28 var head = document.head || document.getElementsByTagName('head')[0]; 29 30 function matches (src) { 31 return new RegExp('^(https?:)?\/\/(?:' + fluidvids.players.join('|') + ').*$', 'i').test(src); 32 } 33 34 function getRatio (height, width) { 35 return ((parseInt(height, 10) / parseInt(width, 10)) * 100) + '%'; 36 } 37 38 function fluid (elem) { 39 if (!matches(elem.src) && !matches(elem.data) || !!elem.getAttribute('data-fluidvids')) return; 40 var wrap = document.createElement('div'); 41 elem.parentNode.insertBefore(wrap, elem); 42 elem.className += (elem.className ? ' ' : '') + 'fluidvids-item'; 43 elem.setAttribute('data-fluidvids', 'loaded'); 44 wrap.className += 'fluidvids'; 45 wrap.style.paddingTop = getRatio(elem.height, elem.width); 46 wrap.appendChild(elem); 47 } 48 49 function addStyles () { 50 var div = document.createElement('div'); 51 div.innerHTML = '<p>x</p><style>' + css + '</style>'; 52 head.appendChild(div.childNodes[1]); 53 } 54 55 fluidvids.render = function () { 56 var nodes = document.querySelectorAll(fluidvids.selector.join()); 57 var i = nodes.length; 58 while (i--) { 59 fluid(nodes[i]); 60 } 61 }; 62 63 fluidvids.init = function (obj) { 64 for (var key in obj) { 65 fluidvids[key] = obj[key]; 66 } 67 fluidvids.render(); 68 addStyles(); 69 }; 70 71 return fluidvids; 72 73});
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.