From ddfc03d7cdec6819b34470e5dc0a608166866a8d Mon Sep 17 00:00:00 2001 From: savvasha Date: Thu, 11 Apr 2024 11:45:34 +0300 Subject: [PATCH] Upgrade to 1.2.0 --- assets/js/jquery.fitvids.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/assets/js/jquery.fitvids.js b/assets/js/jquery.fitvids.js index 2b184abec..bbfcdc0fe 100644 --- a/assets/js/jquery.fitvids.js +++ b/assets/js/jquery.fitvids.js @@ -1,4 +1,3 @@ -/*global jQuery */ /*jshint browser:true */ /*! * FitVids 1.1 @@ -9,7 +8,7 @@ * */ -(function( $ ){ +;(function( $ ){ 'use strict'; @@ -70,14 +69,19 @@ var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(), width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(), aspectRatio = height / width; - if(!$this.attr('id')){ - var videoID = 'fitvid' + Math.floor(Math.random()*999999); - $this.attr('id', videoID); + if(!$this.attr('name')){ + var videoName = 'fitvid' + $.fn.fitVids._count; + $this.attr('name', videoName); + $.fn.fitVids._count++; } $this.wrap('
').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%'); $this.removeAttr('height').removeAttr('width'); }); }); }; + + // Internal counter for unique video names. + $.fn.fitVids._count = 0; + // Works with either jQuery or Zepto -})( window.jQuery || window.Zepto ); \ No newline at end of file +})( window.jQuery || window.Zepto );