This repository has been archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.dynamicPreview.min.js
2 lines (2 loc) · 1.94 KB
/
jquery.dynamicPreview.min.js
1
2
!function(t){"use strict";var a="dynamicPreview",n=t("body"),r=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},e=function(n){var e,o,i={};for(e in t.fn.dynamicPreview.defaults)t.fn.dynamicPreview.defaults.hasOwnProperty(e)&&(o=a+r(e),void 0!==n.data(o)&&(i[e]=n.data(o)));return i},o=function(t){var a;return a="IMG"===t.prop("tagName")?t.attr("src"):t.css("background-image").match(/url\(["|']?([^"']*)["|']?\)/)[1]},i=function(a,r){var e=t("<img/>");e.on("load cached",function(){e.remove(),"IMG"===a.prop("tagName")?a.attr("src",r):a.css("background-image","url("+r+")")}).on("abort error",function(){e.remove()}).attr("src",r),n.append(e)},u=function(t,a){for(var n=t.toString(),r=a.toString().length;n.length<r;)n="0"+n;return n},d=function(t,a){return a.prefix+(a.zeroPad?u(t,a.count):t)+a.suffix},c={init:function(n){var r=t.extend({},t.fn.dynamicPreview.defaults,n);return this.each(function(){var n,i=t(this);void 0===i.data(a)&&(n=t.extend({},r,e(i)),""===n["default"]&&(n["default"]=o(i)),n.autoMode&&i.on("mouseover",c.start.bind(i)).on("mouseout",c.stop.bind(i)),i.data(a,n))})},start:function(n){return this.each(function(){var r,e=t(this),o=e.data(a);void 0===o&&(o=t.extend(n,{autoMode:!1}),e.dynamicPreview(o),o=e.data(a)),!e.data(a+"Rotation")&&o.count>0&&(r=o.startIndex,i(e,o.url+d(r,o)),e.data(a+"Rotation",setInterval(function(){r++,r===o.startIndex+o.count&&(r=o.startIndex),i(e,o.url+d(r,o))},o.delay)))})},stop:function(){return this.each(function(){var n=t(this),r=n.data(a);n.data(a+"Rotation")&&(clearInterval(n.data(a+"Rotation")),n.data(a+"Rotation",null),i(n,r["default"]))})}};t.fn.dynamicPreview=function(){var t;return t=arguments.length&&c[arguments[0]]?c[arguments[0]].apply(this,Array.prototype.slice.call(arguments,1)):c.init.apply(this,arguments)},t.fn.dynamicPreview.defaults={url:"",prefix:"",suffix:".jpg",count:0,startIndex:1,zeroPad:!1,autoMode:!0,"default":"",delay:750}}(jQuery);
//# sourceMappingURL=jquery.dynamicPreview.min.js.map