diff --git a/assets/gifplayer/jquery.gifplayer.js b/assets/gifplayer/jquery.gifplayer.js index 52da522..59b13ec 100644 --- a/assets/gifplayer/jquery.gifplayer.js +++ b/assets/gifplayer/jquery.gifplayer.js @@ -1,11 +1,17 @@ /* - * Gifplayer v0.3.2 + * Gifplayer v0.3.4 * Customizable jquery plugin to play and stop animated gifs. Similar to 9gag's * (c)2014 Rubén Torres - rubentdlh@gmail.com * Released under the MIT license */ -(function ($) { +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + module.exports = factory(require("jquery")); + } else { + factory(jQuery); + } +}(function ($) { function GifPlayer(preview, options) { this.previewElement = preview; @@ -13,7 +19,7 @@ this.animationLoaded = false; } - GifPlayer.scopes = []; + GifPlayer.scopes = new Array(); GifPlayer.prototype = { @@ -75,10 +81,14 @@ gp.previewElement.trigger('click'); }); gp.previewElement.on('click', function (e) { + // Fire event onClick + gp.getOption('onClick').call(gp.previewElement, e); + gp.loadAnimation(); e.preventDefault(); e.stopPropagation(); }); + break; case 'hover': gp.previewElement.on('click mouseover', function (e) { @@ -96,7 +106,7 @@ }, processScope: function () { - scope = this.getOption('scope'); + var scope = this.getOption('scope'); if (scope) { if (GifPlayer.scopes[scope]) { GifPlayer.scopes[scope].stopGif(); @@ -166,13 +176,15 @@ var wait = this.getOption('wait'); if (wait) { //Wait until gif loads - this.gifElement.on('load', function () { - gp.animationLoaded = true; - gp.resetEvents(); - gp.previewElement.hide(); - gp.wrapper.append(gp.gifElement); - gp.spinnerElement.hide(); - gp.getOption('onLoadComplete').call(gp.previewElement); + this.gifElement.on({ + load: function () { + gp.animationLoaded = true; + gp.resetEvents(); + gp.previewElement.hide(); + gp.wrapper.append(gp.gifElement); + gp.spinnerElement.hide(); + gp.getOption('onLoadComplete').call(gp.previewElement); + } }); } else { //Try to show gif instantly @@ -188,6 +200,9 @@ this.gifElement.css('left', '0'); this.gifElement.attr('src', gifSrc); this.gifElement.click(function (e) { + // Fire event onClick + gp.getOption('onClick').call(gp.previewElement, e); + $(this).remove(); gp.stopGif(); e.preventDefault(); @@ -358,10 +373,14 @@ }, onStop: function () { }, + onClick: function () { + }, onLoad: function () { }, onLoadComplete: function () { } }; -})(jQuery); + return GifPlayer; + +}));