Countdown_wev8.js
1.21 KB
define("Countdown_html",function(){return'<div id="NMEC_${id}" class="wev-comp-${compType}" >\t<div id="timeContainer_${id}" data-date="${countdowndate}"></div></div>'}),define(["mUtil","Component"],function(t,i){return i.init(function(t){i.super(this,t),this.type="Countdown",this.tpl=this.type+"_html",this.css=this.type+"_css";var e=this.viewModel={countdowndate:(new Date).getFullYear()+1+"-01-01 00:00:01"};this.beforeMount=function(){e.validate=!0,e.countdowndate.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{1,2}:[0-9]{2}:[0-9]{2}$/)||(e.countdowndate="0",e.validate=!1)},this.mounted=function(){var n=$(".wev-comp-Countdown > div",this.$el),d=e.validate?new Date(e.countdowndate):new Date;require(["timeCircles"],function(){n.TimeCircles({time:{Days:{show:!1,text:"天",color:"#FC6"},Hours:{show:!1,text:"时",color:"#9CF"},Minutes:{show:!1,text:"分",color:"#BFB"},Seconds:{show:!1,text:"秒",color:"#F99"}},refresh_interval:.1,count_past_zero:!(e.validate&&0<=((new Date).getTime()-d.getTime())/1e3)&&e.validate,circle_bg_color:"#ddd",fg_width:.03,bg_width:.2}).addListener(function(t,e,i){var o=((new Date).getTime()-d.getTime())/1e3;(i<=1&&Math.abs(o)<=1||1<o)&&o<=1&&setTimeout(function(){n.TimeCircles().stop()},1e3)})})}})});