%PDF- %PDF-
Direktori : /www/varak.net/paste.varak.net.old/libs/jscript/ |
Current File : /www/varak.net/paste.varak.net.old/libs/jscript/jquery.jcountdown1.4.min.js |
/* jCountdown 1.4 jQuery Plugin | Copyright 2011 Tom Ellis http://www.webmuse.co.uk | MIT Licensed (license.txt) */ (function(g){g.fn.countdown=function(m){var r={date:null,updateTime:1E3,htmlTemplate:"%d <span class='cd-time'>days</span> %h <span class='cd-time'>hours</span> %i <span class='cd-time'>mins</span> %s <span class='cd-time'>sec</span>",minus:false,onChange:null,onComplete:null,onResume:null,onPause:null,leadingZero:false,offset:null,servertime:null,hoursOnly:false,hours:false,yearsAndMonths:false,direction:"down"},s=[].slice,n=window.clearInterval,t=/(%y|%m|%d|%h|%i|%s)/g,u=/%y/,v=/%m/,w=/%d/,x=/%h/, y=/%i/,z=/%s/,q=function(c,a){var d,b=new Date;if(c===null)d=b.getTime()-a;else{d=c*36E5;curHrs=b.getTime()- -b.getTimezoneOffset()/60*36E5+d;d=b.setTime(curHrs)}return new Date(d)},o=function(){var c,a,d,b,f,i,k,l,j;c="";var h,e=this.data("jcdData");if(!e)return false;c=e.htmlTemplate;a=e.offset===null&&e.servertime===null?new Date:e.offset!==null?q(e.offset):q(null,e.difference);d=new Date(e.date);b=e.direction==="down"?d.getTime()-a.getTime():a.getTime()-d.getTime();h=Math.floor(b/1E3);j=h%60; h=Math.floor(h/60);l=h%60;h=Math.floor(h/60);k=h%24;b=h=Math.floor(h/24);if(e.yearsAndMonths){f=Math.floor(h/365);h=Math.floor(h%365);i=Math.floor(h/30);b=Math.ceil(h%30)}if(e.hoursOnly){k+=b*24;b=0}e.yearsLeft=f;e.monthsLeft=i;e.daysLeft=b;e.hrsLeft=k;e.minsLeft=l;e.secLeft=j;if(j==60)j=0;if(e.leadingZero){if(b<10&&!e.hoursOnly)b="0"+b;if(f<10)f="0"+f;if(i<10)i="0"+i;if(k<10)k="0"+k;if(l<10)l="0"+l;if(j<10)j="0"+j}if(e.direction==="down"&&(a<=d||e.minus)||e.direction==="up"&&(d<=a||e.minus)){c=c.replace(u, f).replace(v,i);c=c.replace(w,b).replace(x,k).replace(y,l).replace(z,j)}else{c=c.replace(t,"00");e.hasCompleted=true}this.html(c).trigger("change.jcdevt",[e]);if(e.hasCompleted){this.trigger("complete.jcdevt");n(e.timer)}},p={init:function(c){var a=g.extend({},r,c),d;return this.each(function(){var b=g(this),f={},i;if(b.data("jcdData")){b.countdown("changeSettings",c,true);a=b.data("jcdData")}if(a.date===null)return true;a.onChange&&b.on("change.jcdevt",a.onChange);a.onComplete&&b.on("complete.jcdevt", a.onComplete);a.onPause&&b.on("pause.jcdevt",a.onPause);a.onResume&&b.on("resume.jcdevt",a.onResume);f={originalHTML:b.html(),date:a.date,yearsAndMonths:a.yearsAndMonths,hoursOnly:a.hoursOnly,leadingZero:a.leadingZero,updateTime:a.updateTime,direction:a.direction,template:a.htmlTemplate,htmlTemplate:a.htmlTemplate,minus:a.minus,offset:a.offset,servertime:a.servertime,difference:null,onChange:a.onChange,onComplete:a.onComplete,onResume:a.onResume,onPause:a.onPause,hasCompleted:false,timer:0};if(a.servertime!== null){d=new Date;i=g.isFunction(f.servertime)?f.servertime():f.servertime;f.difference=d.getTime()-i}i=g.proxy(o,b);f.timer=setInterval(i,f.updateTime);b.data("jcdData",f);i()})},changeSettings:function(c,a){return this.each(function(){var d=g(this),b,f=g.proxy(o,d);if(!d.data("jcdData"))return true;b=g.extend({},d.data("jcdData"),c);b.completed=false;n(b.timer);d.off(".jcdevt").data("jcdData",b);if(!a){b.onChange&&d.on("change.jcdevt",b.onChange);b.onComplete&&d.on("complete.jcdevt",b.onComplete); b.onPause&&d.on("pause.jcdevt",b.onPause);b.onResume&&d.on("resume.jcdevt",b.onResume);b.timer=setInterval(f,b.updateTime);d.data("jcdData",b);f()}})},resume:function(){return this.each(function(){var c=g(this),a=c.data("jcdData"),d=g.proxy(o,c);if(!a)return true;c.data("jcdData",a).trigger("resume.jcdevt");if(!a.hasCompleted){a.timer=setInterval(d,a.updateTime);d()}})},pause:function(){return this.each(function(){var c=g(this),a=c.data("jcdData");if(!a)return true;n(a.timer);c.data("jcdData",a).trigger("pause.jcdevt")})}, complete:function(){return this.each(function(){var c=g(this),a=c.data("jcdData");if(!a)return true;n(a.timer);a.hasCompleted=true;c.data("jcdData",a).trigger("complete.jcdevt").off(".jcdevt")})},destroy:function(){return this.each(function(){var c=g(this),a=c.data("jcdData");if(!a)return true;n(a.timer);c.off(".jcdevt").removeData("jcdData").html(a.originalHTML)})},getSettings:function(c){var a=g(this).data("jcdData");if(c&&a){if(a.hasOwnProperty(c))return a[c]}else return a}};if(p[m])return p[m].apply(this, s.call(arguments,1));else if(typeof m==="object"||!m)return p.init.apply(this,arguments);else g.error("Method "+m+" does not exist in the jCountdown Plugin")}})(jQuery);