Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fitvids

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fitvids - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

178

dist/fitvids.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fitvids = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var selectors = [
'iframe[src*="player.vimeo.com"]',
'iframe[src*="youtube.com"]',
'iframe[src*="youtube-nocookie.com"]',
'iframe[src*="kickstarter.com"][src*="video.html"]',
"object"
];
'use strict'
var css =
".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";
var selectors = [
'iframe[src*="player.vimeo.com"]',
'iframe[src*="youtube.com"]',
'iframe[src*="youtube-nocookie.com"]',
'iframe[src*="kickstarter.com"][src*="video.html"]',
'object'
]
module.exports = function(parentSelector, opts) {
parentSelector = parentSelector || "body";
opts = opts || {};
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}'
if (isObject(parentSelector)) {
opts = parentSelector;
parentSelector = "body";
}
module.exports = function (parentSelector, opts) {
parentSelector = parentSelector || 'body'
opts = opts || {}
opts.ignore = opts.ignore || "";
opts.players = opts.players || "";
if (isObject(parentSelector)) {
opts = parentSelector
parentSelector = 'body'
}
var containers = queryAll(parentSelector);
if (!hasLength(containers)) return;
opts.ignore = opts.ignore || ''
opts.players = opts.players || ''
if (!document.getElementById("fit-vids-style")) {
var head = document.head || document.getElementsByTagName("head")[0];
head.appendChild(styles());
}
var containers = queryAll(parentSelector)
if (!hasLength(containers)) return
var custom = toSelectorArray(opts.players);
var ignored = toSelectorArray(opts.ignore);
var ignoredSelector = ignored.length > 0 ? ignored.join() : null;
var selector = selectors.concat(custom).join();
if (!document.getElementById('fit-vids-style')) {
var head = document.head || document.getElementsByTagName('head')[0]
head.appendChild(styles())
}
if (!hasLength(selector)) {
return;
}
var custom = toSelectorArray(opts.players) || []
var ignored = toSelectorArray(opts.ignore) || []
var selector = selectors
.filter(notIgnored(ignored))
.concat(custom)
.join()
containers.forEach(function(container) {
var videos = queryAll(container, selector);
if (!hasLength(selector)) return
containers.forEach(function (container) {
var videos = queryAll(container, selector)
videos.forEach(function (video) {
wrap(video)
})
})
videos.forEach(function(video) {
if (ignoredSelector && video.matches(ignoredSelector)) {
return;
}
wrap(video);
});
});
}
function queryAll (el, selector) {
if (typeof el === 'string') {
selector = el
el = document
}
return Array.prototype.slice.call(el.querySelectorAll(selector))
function queryAll(el, selector) {
if (typeof el === "string") {
selector = el;
el = document;
}
return Array.prototype.slice.call(el.querySelectorAll(selector));
}
function toSelectorArray (input) {
if (typeof input === 'string') {
return input.split(',').map(trim).filter(hasLength)
} else if (isArray(input)) {
return flatten(input.map(toSelectorArray).filter(hasLength))
}
return input || []
function toSelectorArray(input) {
if (typeof input === "string") {
return input
.split(",")
.map(trim)
.filter(hasLength);
} else if (isArray(input)) {
return flatten(input.map(toSelectorArray).filter(hasLength));
}
return input || [];
}
function wrap (el) {
if (/fluid-width-video-wrapper/.test(el.parentNode.className)) return
function wrap(el) {
if (/fluid-width-video-wrapper/.test(el.parentNode.className)) {
return;
}
var widthAttr = parseInt(el.getAttribute('width'), 10)
var heightAttr = parseInt(el.getAttribute('height'), 10)
var widthAttr = parseInt(el.getAttribute("width"), 10);
var heightAttr = parseInt(el.getAttribute("height"), 10);
var width = !isNaN(widthAttr) ? widthAttr : el.clientWidth
var height = !isNaN(heightAttr) ? heightAttr : el.clientHeight
var aspect = height / width
var width = !isNaN(widthAttr) ? widthAttr : el.clientWidth;
var height = !isNaN(heightAttr) ? heightAttr : el.clientHeight;
var aspect = height / width;
el.removeAttribute('width')
el.removeAttribute('height')
el.removeAttribute("width");
el.removeAttribute("height");
var wrapper = document.createElement('div')
el.parentNode.insertBefore(wrapper, el)
wrapper.className = 'fluid-width-video-wrapper'
wrapper.style.paddingTop = (aspect * 100) + '%'
wrapper.appendChild(el)
var wrapper = document.createElement("div");
el.parentNode.insertBefore(wrapper, el);
wrapper.className = "fluid-width-video-wrapper";
wrapper.style.paddingTop = aspect * 100 + "%";
wrapper.appendChild(el);
}
function styles () {
var div = document.createElement('div')
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>'
return div.childNodes[1]
function styles() {
var div = document.createElement("div");
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + "</style>";
return div.childNodes[1];
}
function notIgnored (ignored) {
if (ignored.length < 1) {
return function () {
return true
}
}
return function (selector) {
return ignored.indexOf(selector) === -1
}
function hasLength(input) {
return input.length > 0;
}
function hasLength (input) {
return input.length > 0
function trim(str) {
return str.replace(/^\s+|\s+$/g, "");
}
function trim (str) {
return str.replace(/^\s+|\s+$/g, '')
function flatten(input) {
return [].concat.apply([], input);
}
function flatten (input) {
return [].concat.apply([], input)
function isObject(input) {
return Object.prototype.toString.call(input) === "[object Object]";
}
function isObject (input) {
return Object.prototype.toString.call(input) === '[object Object]'
function isArray(input) {
return Object.prototype.toString.call(input) === "[object Array]";
}
function isArray (input) {
return Object.prototype.toString.call(input) === '[object Array]'
}
},{}]},{},[1])(1)
});
});

@@ -1,1 +0,1 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fitvids=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var selectors=['iframe[src*="player.vimeo.com"]','iframe[src*="youtube.com"]','iframe[src*="youtube-nocookie.com"]','iframe[src*="kickstarter.com"][src*="video.html"]',"object"];var css=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";module.exports=function(parentSelector,opts){parentSelector=parentSelector||"body";opts=opts||{};if(isObject(parentSelector)){opts=parentSelector;parentSelector="body"}opts.ignore=opts.ignore||"";opts.players=opts.players||"";var containers=queryAll(parentSelector);if(!hasLength(containers))return;if(!document.getElementById("fit-vids-style")){var head=document.head||document.getElementsByTagName("head")[0];head.appendChild(styles())}var custom=toSelectorArray(opts.players)||[];var ignored=toSelectorArray(opts.ignore)||[];var selector=selectors.filter(notIgnored(ignored)).concat(custom).join();if(!hasLength(selector))return;containers.forEach(function(container){var videos=queryAll(container,selector);videos.forEach(function(video){wrap(video)})})};function queryAll(el,selector){if(typeof el==="string"){selector=el;el=document}return Array.prototype.slice.call(el.querySelectorAll(selector))}function toSelectorArray(input){if(typeof input==="string"){return input.split(",").map(trim).filter(hasLength)}else if(isArray(input)){return flatten(input.map(toSelectorArray).filter(hasLength))}return input||[]}function wrap(el){if(/fluid-width-video-wrapper/.test(el.parentNode.className))return;var widthAttr=parseInt(el.getAttribute("width"),10);var heightAttr=parseInt(el.getAttribute("height"),10);var width=!isNaN(widthAttr)?widthAttr:el.clientWidth;var height=!isNaN(heightAttr)?heightAttr:el.clientHeight;var aspect=height/width;el.removeAttribute("width");el.removeAttribute("height");var wrapper=document.createElement("div");el.parentNode.insertBefore(wrapper,el);wrapper.className="fluid-width-video-wrapper";wrapper.style.paddingTop=aspect*100+"%";wrapper.appendChild(el)}function styles(){var div=document.createElement("div");div.innerHTML='<p>x</p><style id="fit-vids-style">'+css+"</style>";return div.childNodes[1]}function notIgnored(ignored){if(ignored.length<1){return function(){return true}}return function(selector){return ignored.indexOf(selector)===-1}}function hasLength(input){return input.length>0}function trim(str){return str.replace(/^\s+|\s+$/g,"")}function flatten(input){return[].concat.apply([],input)}function isObject(input){return Object.prototype.toString.call(input)==="[object Object]"}function isArray(input){return Object.prototype.toString.call(input)==="[object Array]"}},{}]},{},[1])(1)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fitvids=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var selectors=['iframe[src*="player.vimeo.com"]','iframe[src*="youtube.com"]','iframe[src*="youtube-nocookie.com"]','iframe[src*="kickstarter.com"][src*="video.html"]',"object"];var css=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";module.exports=function(parentSelector,opts){parentSelector=parentSelector||"body";opts=opts||{};if(isObject(parentSelector)){opts=parentSelector;parentSelector="body"}opts.ignore=opts.ignore||"";opts.players=opts.players||"";var containers=queryAll(parentSelector);if(!hasLength(containers))return;if(!document.getElementById("fit-vids-style")){var head=document.head||document.getElementsByTagName("head")[0];head.appendChild(styles())}var custom=toSelectorArray(opts.players);var ignored=toSelectorArray(opts.ignore);var ignoredSelector=ignored.length>0?ignored.join():null;var selector=selectors.concat(custom).join();if(!hasLength(selector)){return}containers.forEach(function(container){var videos=queryAll(container,selector);videos.forEach(function(video){if(ignoredSelector&&video.matches(ignoredSelector)){return}wrap(video)})})};function queryAll(el,selector){if(typeof el==="string"){selector=el;el=document}return Array.prototype.slice.call(el.querySelectorAll(selector))}function toSelectorArray(input){if(typeof input==="string"){return input.split(",").map(trim).filter(hasLength)}else if(isArray(input)){return flatten(input.map(toSelectorArray).filter(hasLength))}return input||[]}function wrap(el){if(/fluid-width-video-wrapper/.test(el.parentNode.className)){return}var widthAttr=parseInt(el.getAttribute("width"),10);var heightAttr=parseInt(el.getAttribute("height"),10);var width=!isNaN(widthAttr)?widthAttr:el.clientWidth;var height=!isNaN(heightAttr)?heightAttr:el.clientHeight;var aspect=height/width;el.removeAttribute("width");el.removeAttribute("height");var wrapper=document.createElement("div");el.parentNode.insertBefore(wrapper,el);wrapper.className="fluid-width-video-wrapper";wrapper.style.paddingTop=aspect*100+"%";wrapper.appendChild(el)}function styles(){var div=document.createElement("div");div.innerHTML='<p>x</p><style id="fit-vids-style">'+css+"</style>";return div.childNodes[1]}function hasLength(input){return input.length>0}function trim(str){return str.replace(/^\s+|\s+$/g,"")}function flatten(input){return[].concat.apply([],input)}function isObject(input){return Object.prototype.toString.call(input)==="[object Object]"}function isArray(input){return Object.prototype.toString.call(input)==="[object Array]"}},{}]},{},[1])(1)});

@@ -12,3 +12,3 @@ var selectors = [

export default function(parentSelector, opts) {
module.exports = function(parentSelector, opts) {
parentSelector = parentSelector || "body";

@@ -15,0 +15,0 @@ opts = opts || {};

{
"name": "fitvids",
"version": "2.1.0",
"version": "2.1.1",
"description": "Makes your videos fluid-width.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -57,3 +57,3 @@ # fitvids

If you'd like to ignore one of the [default selectors](#usage), you can pass a selector via the `ignore` option:
If you'd like to ignore certain videos, you can pass a selector via the `ignore` option:

@@ -60,0 +60,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc