From b3b059b89343208a76ecbe58a73da5025de443f0 Mon Sep 17 00:00:00 2001 From: I Wayan Wirka Date: Fri, 6 Dec 2013 16:23:14 +0800 Subject: [PATCH] Update dscountdown.min.js --- dscountdown.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dscountdown.min.js b/dscountdown.min.js index dc08eee..6e58035 100644 --- a/dscountdown.min.js +++ b/dscountdown.min.js @@ -1,7 +1,7 @@ /*! - dsCountDown v1.0 + dsCountDown v1.1 jQuery count down plugin (c) 2013 I Wayan Wirka - http://iwayanwirka.duststone.com/dscountdown/ license: http://www.opensource.org/licenses/mit-license.php */ -(function(e){e.fn.dsCountDown=function(t){var n=this;var r=1e3,i=null,s=false,o=0,u=1,a=0,f=0,l=0,c=0,h=0,p=null,d=null,v=null,m=null;var g={startDate:new Date,endDate:null,elemSelDays:"",elemSelHours:"",elemSelMinutes:"",elemSelSeconds:"",theme:"white",titleDays:"Days",titleHours:"Hours",titleMinutes:"Minutes",titleSeconds:"Seconds",onBevoreStart:null,onClocking:null,onFinish:null};var y=e.extend({},g,t);if(this.length>1){this.each(function(){e(this).dsCountDown(t)});return this}var b=function(){if(!y.elemSelSeconds){n.prepend('
'+y.titleSeconds+'
00
');m=n.find(".ds-seconds")}else{m=n.find(y.elemSelSeconds)}if(!y.elemSelMinutes){n.prepend('
'+y.titleMinutes+'
00
');v=n.find(".ds-minutes")}else{v=n.find(y.elemSelMinutes)}if(!y.elemSelHours){n.prepend('
'+y.titleHours+'
00
');d=n.find(".ds-hours")}else{d=n.find(y.elemSelHours)}if(!y.elemSelDays){n.prepend('
'+y.titleDays+'
00
');p=n.find(".ds-days")}else{p=n.find(y.elemSelDays)}n.addClass("dsCountDown");n.addClass("ds-"+y.theme);if(y.startDate&&y.endDate){a=y.endDate.getTime()-y.startDate.getTime();if(a>0){var e=a/1e3;var t=e%86400;var r=t%3600;o=e;h=Math.floor(e/86400);c=Math.floor(t/3600);l=Math.floor(r/60);f=Math.floor(r%60)}}E()};var w=function(e){if(s){clearInterval(i);s=false}if(e){e(n)}};var E=function(){if(!s){if(o>0){if(y.onBevoreStart){y.onBevoreStart(n)}i=setInterval(function(){if(o>0){o-=u;f-=u;if(f<=0&&(l>0||c>0||h>0)){l--;f=60}if(l<=0&&(c>0||h>0)){c--;l=60}if(c<=0&&h>0){h--;c=24}if(p)p.html(h<10?"0"+h:h);if(d)d.html(c<10?"0"+c:c);if(v)v.html(l<10?"0"+l:l);if(m)m.html(f<10?"0"+f:f);if(y.onClocking){y.onClocking(n)}}else{w(y.onFinish)}},r);s=true}else{if(y.onFinish){y.onFinish(n)}}}};b()}})(jQuery) +(function(e){e.fn.dsCountDown=function(t){var n=this;n.data={refreshed:1e3,thread:null,running:false,left:0,decreament:1,interval:0,seconds:0,minutes:0,hours:0,days:0,elemDays:null,elemHours:null,elemMinutes:null,elemSeconds:null};var r={startDate:new Date,endDate:null,elemSelDays:"",elemSelHours:"",elemSelMinutes:"",elemSelSeconds:"",theme:"white",titleDays:"Days",titleHours:"Hours",titleMinutes:"Minutes",titleSeconds:"Seconds",onBevoreStart:null,onClocking:null,onFinish:null};n.options=e.extend({},r,t);if(this.length>1){this.each(function(){e(this).dsCountDown(t)});return this}n.init=function(){if(!n.options.elemSelSeconds){n.prepend('
'+n.options.titleSeconds+'
00
');n.data.elemSeconds=n.find(".ds-seconds")}else{n.data.elemSeconds=n.find(n.options.elemSelSeconds)}if(!n.options.elemSelMinutes){n.prepend('
'+n.options.titleMinutes+'
00
');n.data.elemMinutes=n.find(".ds-minutes")}else{n.data.elemMinutes=n.find(n.options.elemSelMinutes)}if(!n.options.elemSelHours){n.prepend('
'+n.options.titleHours+'
00
');n.data.elemHours=n.find(".ds-hours")}else{n.data.elemHours=n.find(n.options.elemSelHours)}if(!n.options.elemSelDays){n.prepend('
'+n.options.titleDays+'
00
');n.data.elemDays=n.find(".ds-days")}else{n.data.elemDays=n.find(n.options.elemSelDays)}n.addClass("dsCountDown");n.addClass("ds-"+n.options.theme);if(n.options.startDate&&n.options.endDate){n.data.interval=n.options.endDate.getTime()-n.options.startDate.getTime();if(n.data.interval>0){var e=n.data.interval/1e3;var t=e%86400;var r=t%3600;n.data.left=e;n.data.days=Math.floor(e/86400);n.data.hours=Math.floor(t/3600);n.data.minutes=Math.floor(r/60);n.data.seconds=Math.floor(r%60)}}n.start()};n.stop=function(e){if(n.data.running){clearInterval(n.data.thread);n.data.running=false}if(e){e(n)}};n.start=function(){e("#logger").append("
Start");if(!n.data.running){e("#logger").append("
Clock");if(n.data.left>0){if(n.options.onBevoreStart){n.options.onBevoreStart(n)}n.data.thread=setInterval(function(){if(n.data.left>0){n.data.left-=n.data.decreament;n.data.seconds-=n.data.decreament;if(n.data.seconds<=0&&(n.data.minutes>0||n.data.hours>0||n.data.days>0)){n.data.minutes--;n.data.seconds=60}if(n.data.minutes<=0&&(n.data.hours>0||n.data.days>0)){n.data.hours--;n.data.minutes=60}if(n.data.hours<=0&&n.data.days>0){n.data.days--;n.data.hours=24}if(n.data.elemDays)n.data.elemDays.html(n.data.days<10?"0"+n.data.days:n.data.days);if(n.data.elemHours)n.data.elemHours.html(n.data.hours<10?"0"+n.data.hours:n.data.hours);if(n.data.elemMinutes)n.data.elemMinutes.html(n.data.minutes<10?"0"+n.data.minutes:n.data.minutes);if(n.data.elemSeconds)n.data.elemSeconds.html(n.data.seconds<10?"0"+n.data.seconds:n.data.seconds);if(n.options.onClocking){n.options.onClocking(n)}}else{n.stop(n.options.onFinish)}},n.data.refreshed);n.data.running=true}else{if(n.options.onFinish){n.options.onFinish(n)}}}};n.init()}})(jQuery)