UNPKG

vue2-countdown-component

Version:
1 lines 2.5 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vue2-countdown-timer"]=e():t["vue2-countdown-timer"]=e()})("undefined"!==typeof self?self:this,(function(){return function(){"use strict";var t={};!function(){t.d=function(e,n){for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})}}(),function(){t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}}(),function(){t.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}}(),function(){t.p=""}();var e={};if(t.r(e),t.d(e,{default:function(){return p}}),"undefined"!==typeof window){var n=window.document.currentScript,o=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(t.p=o[1])}var i=function(){var t=this,e=t._self._c;return e("span",{staticClass:"countdown-timer"},[t._t("header"),t._v(" "+t._s(t.time)+" "),t._t("footer")],2)},r=[],s={name:"CountdownTimer",props:{duration:{type:Number,required:!0,default:60}},data(){return{timer:null,time:this.duration}},mounted(){},methods:{start(){this.time&&(this.$emit("start"),this.stopCountdown(),this.startCountdown())},stop(){this.time&&this.timer&&(this.$emit("stop"),this.stopCountdown())},startCountdown(){this.timer=setInterval((()=>{if(this.time>0)return this.time--;this.$emit("end"),this.stopCountdown()}),1e3)},stopCountdown(){clearInterval(this.timer),this.timer=null}},beforeDestroy(){this.stopCountdown()}},u=s;function d(t,e,n,o,i,r,s,u){var d,a="function"===typeof t?t.options:t;if(e&&(a.render=e,a.staticRenderFns=n,a._compiled=!0),o&&(a.functional=!0),r&&(a._scopeId="data-v-"+r),s?(d=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},a._ssrRegister=d):i&&(d=u?function(){i.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:i),d)if(a.functional){a._injectStyles=d;var f=a.render;a.render=function(t,e){return d.call(e),f(t,e)}}else{var c=a.beforeCreate;a.beforeCreate=c?[].concat(c,d):[d]}return{exports:t,options:a}}var a=d(u,i,r,!1,null,null,null),f=a.exports,c=f;"undefined"!==typeof window&&window.Vue&&window.Vue.component("CountdownTimer",f);var p=c;return e}()}));