diff --git a/dist/vue-datepicker-local.css b/dist/vue-datepicker-local.css index 145b14a..54b1716 100644 --- a/dist/vue-datepicker-local.css +++ b/dist/vue-datepicker-local.css @@ -1,5 +1,5 @@ /*! - * vue-datetime-local.js v1.0.16 + * vue-datetime-local.js v1.0.17 * (c) 2017-2018 weifeiyue * Released under the MIT License. */ diff --git a/dist/vue-datepicker-local.js b/dist/vue-datepicker-local.js index eb9154e..cbb3d7c 100644 --- a/dist/vue-datepicker-local.js +++ b/dist/vue-datepicker-local.js @@ -1,6 +1,6 @@ /*! - * vue-datetime-local.js v1.0.16 + * vue-datetime-local.js v1.0.17 * (c) 2017-2018 weifeiyue * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vue-datepicker-local"]=t():e["vue-datepicker-local"]=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(s[n])return s[n].exports;var o=s[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var s={};return t.m=e,t.c=s,t.d=function(e,s,n){t.o(e,s)||Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var s=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(s,"a",s),s},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,s){"use strict";function n(e,t,s,n,o,a,r,i){e=e||{};var c=typeof e.default;"object"!==c&&"function"!==c||(e=e.default);var u="function"==typeof e?e.options:e;t&&(u.render=t,u.staticRenderFns=s,u._compiled=!0),n&&(u.functional=!0),a&&(u._scopeId=a);var l;if(r?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=l):o&&(l=i?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(u.functional){u._injectStyles=l;var h=u.render;u.render=function(e,t){return l.call(t),h(e,t)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:e,options:u}}function o(e){s(2)}function a(e){s(1)}function r(e){e.component(_.name,_)}Object.defineProperty(t,"__esModule",{value:!0});var i={name:"VueDatepickerLocalCalendar",props:{value:null,left:!1,right:!1},data:function(){var e=this.get(this.value);return{pre:"calendar",m:"D",showYears:!1,showMonths:!1,showHours:!1,showMinutes:!1,showSeconds:!1,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:e.second}},watch:{value:function(e){var t=this,s=t.get(e);t.year=s.year,t.month=s.month,t.day=s.day,t.hour=s.hour,t.minute=s.minute,t.second=s.second}},computed:{local:function(){return this.$parent.local},format:function(){return this.$parent.format},start:function(){return this.parse(this.$parent.dates[0])},end:function(){return this.parse(this.$parent.dates[1])},ys:function(){return 10*parseInt(this.year/10)},ye:function(){return this.ys+10},years:function(){for(var e=[],t=this.ys-1;e.length<12;)e.push(t++);return e},days:function(){var e=[],t=this,s=t.year,n=t.month,o=new Date(s,n,1),a=t.local.dow||7;o.setDate(0);for(var r=o.getDate(),i=o.getDay()||7,c=a<=i?i-a+1:i+(7-a+1);c>0;)e.push({i:r-c+1,y:n>0?s:s-1,m:n>0?n-1:11,p:!0}),c--;o.setMonth(o.getMonth()+2,0),r=o.getDate();var u=1;for(u=1;u<=r;u++)e.push({i:u,y:s,m:n});for(u=1;e.length<42;u++)e.push({i:u,y:n<11?s:s+1,m:n<11?n+1:0,n:!0});return e}},filters:{dd:function(e){return("0"+e).slice(-2)}},methods:{get:function(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}},parse:function(e){return parseInt(e/1e3)},status:function(e,t,s,n,o,a,r){var i=this,c=new Date(e,t+1,0).getDate(),u=new Date(e,t,s>c?c:s,n,o,a),l=i.parse(u),h=i.$parent.tf,d={},p=!1;return p="YYYY"===r?e===i.year:"YYYYMM"===r?t===i.month:h(i.value,r)===h(u,r),d[i.pre+"-date"]=!0,d[i.pre+"-date-disabled"]=i.right&&li.start||i.right&&l0?this.month--:(this.month=11,this.year--)},is:function(e){return-1===e.target.className.indexOf(this.pre+"-date-disabled")},ok:function(e){var t=this,s="",n="";if(e&&e.n&&t.nm(),e&&e.p&&t.pm(),"h"===e){var o=t.get(this.value);s=o.year,n=o.month}var a=new Date(s||t.year,n||t.month,t.day,t.hour,t.minute,t.second);t.left&&a>t.start&&(this.$parent.dates[1]=a),t.$emit("input",a),t.$parent.ok("h"===e)}},mounted:function(){var e=this,t=function(t){return-1!==e.format.indexOf(t)};t("s")&&t("m")&&(t("h")||t("H"))?e.m="H":t("D")?e.m="D":t("M")?(e.m="M",e.showMonths=!0):t("Y")&&(e.m="Y",e.showYears=!0)}},c=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{class:""+e.pre},[s("div",{class:e.pre+"-head"},[s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-prev-decade-btn",on:{click:function(t){e.year-=10}}},[e._v("«")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-prev-year-btn",on:{click:function(t){e.year--}}},[e._v("«")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-prev-month-btn",on:{click:e.pm}},[e._v("‹")]),s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-year-select"},[e._v(e._s(e.ys+"-"+e.ye))]),e.local.yearSuffix?[s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-year-select",on:{click:function(t){e.showYears=!e.showYears}}},[e._v(e._s(e.year)+e._s(e.local.yearSuffix))]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-month-select",on:{click:function(t){e.showMonths=!e.showMonths}}},[e._v(e._s(e.local.monthsHead[e.month]))])]:[s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-month-select",on:{click:function(t){e.showMonths=!e.showMonths}}},[e._v(e._s(e.local.monthsHead[e.month]))]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-year-select",on:{click:function(t){e.showYears=!e.showYears}}},[e._v(e._s(e.year))])],s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-next-month-btn",on:{click:e.nm}},[e._v("›")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-next-year-btn",on:{click:function(t){e.year++}}},[e._v("»")]),s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-next-decade-btn",on:{click:function(t){e.year+=10}}},[e._v("»")])],2),s("div",{class:e.pre+"-body"},[s("div",{class:e.pre+"-days"},[e._l(e.local.weeks,function(t){return s("a",{key:t,class:e.pre+"-week"},[e._v(e._s(t))])}),e._l(e.days,function(t,n){return s("a",{key:n,class:[t.p||t.n?e.pre+"-date-out":"",e.status(t.y,t.m,t.i,e.hour,e.minute,e.second,"YYYYMMDD")],on:{click:function(s){e.is(s)&&(e.day=t.i,e.ok(t))}}},[e._v(e._s(t.i))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showMonths,expression:"showMonths"}],class:e.pre+"-months"},e._l(e.local.months,function(t,n){return s("a",{key:n,class:[e.status(e.year,n,e.day,e.hour,e.minute,e.second,"YYYYMM")],on:{click:function(t){e.is(t)&&(e.showMonths="M"===e.m,e.month=n,"M"===e.m&&e.ok())}}},[e._v(e._s(t))])})),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-years"},e._l(e.years,function(t,n){return s("a",{key:n,class:[0===n||11===n?e.pre+"-date-out":"",e.status(t,e.month,e.day,e.hour,e.minute,e.second,"YYYY")],on:{click:function(s){e.is(s)&&(e.showYears="Y"===e.m,e.year=t,"Y"===e.m&&e.ok())}}},[e._v(e._s(t))])})),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showHours,expression:"showHours"}],class:e.pre+"-hours"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.hourTip))]),e._l(24,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,n,e.minute,e.second,"YYYYMMDDHH")],on:{click:function(t){e.is(t)&&(e.showHours=!1,e.hour=n,e.ok("h"))}}},[e._v(e._s(n))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showMinutes,expression:"showMinutes"}],class:e.pre+"-minutes"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.minuteTip))]),e._l(60,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,e.hour,n,e.second,"YYYYMMDDHHmm")],on:{click:function(t){e.is(t)&&(e.showMinutes=!1,e.minute=n,e.ok("h"))}}},[e._v(e._s(n))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showSeconds,expression:"showSeconds"}],class:e.pre+"-seconds"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.secondTip))]),e._l(60,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,e.hour,e.minute,n,"YYYYMMDDHHmmss")],on:{click:function(t){e.is(t)&&(e.showSeconds=!1,e.second=n,e.ok("h"))}}},[e._v(e._s(n))])})],2)]),"H"===e.m?s("div",{class:e.pre+"-foot"},[s("div",{class:e.pre+"-hour"},[s("a",{class:{on:e.showHours},attrs:{title:e.local.hourTip},on:{click:function(t){e.showHours=!e.showHours,e.showMinutes=e.showSeconds=!1}}},[e._v(e._s(e._f("dd")(e.hour)))]),s("span",[e._v(":")]),s("a",{class:{on:e.showMinutes},attrs:{title:e.local.minuteTip},on:{click:function(t){e.showMinutes=!e.showMinutes,e.showHours=e.showSeconds=!1}}},[e._v(e._s(e._f("dd")(e.minute)))]),s("span",[e._v(":")]),s("a",{class:{on:e.showSeconds},attrs:{title:e.local.secondTip},on:{click:function(t){e.showSeconds=!e.showSeconds,e.showHours=e.showMinutes=!1}}},[e._v(e._s(e._f("dd")(e.second)))])])]):e._e()])},u=[],l=o,h=n(i,c,u,!1,l,null,null),d=h.exports,p={name:"VueDatepickerLocal",components:{VueDatepickerLocalCalendar:d},props:{name:[String],inputClass:[String],popupClass:[String],value:[Date,Array,String],disabled:[Boolean],type:{type:String,default:"normal"},rangeSeparator:{type:String,default:"~"},clearable:{type:Boolean,default:!1},placeholder:[String],disabledDate:{type:Function,default:function(){return!1}},format:{type:String,default:"YYYY-MM-DD"},local:{type:Object,default:function(){return{dow:1,hourTip:"选择小时",minuteTip:"选择分钟",secondTip:"选择秒数",yearSuffix:"年",monthsHead:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),weeks:"一_二_三_四_五_六_日".split("_"),cancelTip:"取消",submitTip:"确定"}}},showButtons:{type:Boolean,default:!1},dateRangeSelect:[Function]},data:function(){return{show:!1,dates:this.vi(this.value)}},computed:{range:function(){return 2===this.dates.length},text:function(){var e=this,t=this.value,s=this.dates.map(function(t){return e.tf(t)}).join(" "+this.rangeSeparator+" ");return Array.isArray(t)?t.length>1?s:"":t?s:""}},watch:{value:function(e){this.dates=this.vi(this.value)}},methods:{get:function(){return Array.isArray(this.value)?this.dates:this.dates[0]},cls:function(){this.$emit("clear"),this.$emit("input",this.range?[]:"")},vi:function(e){return Array.isArray(e)?e.length>1?e.map(function(e){return new Date(e)}):[new Date,new Date]:e?new Array(new Date(e)):[new Date]},ok:function(e){var t=this;t.$emit("input",t.get()),!e&&!t.showButtons&&setTimeout(function(){t.show=t.range})},tf:function(e,t){var s=e.getFullYear(),n=e.getMonth(),o=e.getDate(),a=e.getHours(),r=a%12==0?12:a%12,i=e.getMinutes(),c=e.getSeconds(),u=e.getMilliseconds(),l=function(e){return("0"+e).slice(-2)},h={YYYY:s,MM:l(n+1),MMM:this.local.months[n],MMMM:this.local.monthsHead[n],M:n+1,DD:l(o),D:o,HH:l(a),H:a,hh:l(r),h:r,mm:l(i),m:i,ss:l(c),s:c,S:u};return(t||this.format).replace(/Y+|M+|D+|H+|h+|m+|s+|S+/g,function(e){return h[e]})},dc:function(e){this.show=this.$el.contains(e.target)&&!this.disabled},submit:function(){this.$emit("confirm",this.get()),this.show=!1},cancel:function(){this.$emit("cancel"),this.show=!1}},mounted:function(){document.addEventListener("click",this.dc,!0)},beforeDestroy:function(){document.removeEventListener("click",this.dc,!0)}},f=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"datepicker",class:{"datepicker-range":e.range,datepicker__clearable:e.clearable&&e.text&&!e.disabled}},["inline"!==e.type?s("input",{class:[e.show?"focus":"",e.inputClass],attrs:{readonly:"",disabled:e.disabled,placeholder:e.placeholder,name:e.name},domProps:{value:e.text}}):e._e(),s("a",{staticClass:"datepicker-close",on:{click:function(t){return t.stopPropagation(),e.cls(t)}}}),s("transition",{attrs:{name:"datepicker-anim"}},[e.show||"inline"===e.type?s("div",{staticClass:"datepicker-popup",class:[e.popupClass,{"datepicker-inline":"inline"===e.type}],attrs:{tabindex:"-1"}},[e.range?[s("vue-datepicker-local-calendar",{attrs:{left:!0},model:{value:e.dates[0],callback:function(t){e.$set(e.dates,0,t)},expression:"dates[0]"}}),s("vue-datepicker-local-calendar",{attrs:{right:!0},model:{value:e.dates[1],callback:function(t){e.$set(e.dates,1,t)},expression:"dates[1]"}})]:[s("vue-datepicker-local-calendar",{model:{value:e.dates[0],callback:function(t){e.$set(e.dates,0,t)},expression:"dates[0]"}})],e.showButtons?s("div",{staticClass:"datepicker__buttons"},[s("button",{staticClass:"datepicker__button-cancel",on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.cancel(t)}}},[e._v(e._s(this.local.cancelTip))]),s("button",{staticClass:"datepicker__button-select",on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.submit(t)}}},[e._v(e._s(this.local.submitTip))])]):e._e()],2):e._e()])],1)},m=[],w=a,v=n(p,f,m,!1,w,null,null),_=v.exports;_.install=r,"undefined"!=typeof window&&window.Vue&&r(window.Vue);t.default=_},function(e,t){},function(e,t){}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vue-datepicker-local"]=t():e["vue-datepicker-local"]=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(s[n])return s[n].exports;var o=s[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var s={};return t.m=e,t.c=s,t.d=function(e,s,n){t.o(e,s)||Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var s=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(s,"a",s),s},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,s){"use strict";function n(e,t,s,n,o,a,r,i){e=e||{};var c=typeof e.default;"object"!==c&&"function"!==c||(e=e.default);var u="function"==typeof e?e.options:e;t&&(u.render=t,u.staticRenderFns=s,u._compiled=!0),n&&(u.functional=!0),a&&(u._scopeId=a);var l;if(r?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},u._ssrRegister=l):o&&(l=i?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(u.functional){u._injectStyles=l;var h=u.render;u.render=function(e,t){return l.call(t),h(e,t)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:e,options:u}}function o(e){s(2)}function a(e){s(1)}function r(e){e.component(_.name,_)}Object.defineProperty(t,"__esModule",{value:!0});var i={name:"VueDatepickerLocalCalendar",props:{value:null,left:!1,right:!1},data:function(){var e=this.get(this.value);return{pre:"calendar",m:"D",showYears:!1,showMonths:!1,showHours:!1,showMinutes:!1,showSeconds:!1,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:e.second}},watch:{value:function(e){var t=this,s=t.get(e);t.year=s.year,t.month=s.month,t.day=s.day,t.hour=s.hour,t.minute=s.minute,t.second=s.second}},computed:{local:function(){return this.$parent.local},format:function(){return this.$parent.format},start:function(){return this.parse(this.$parent.dates[0])},end:function(){return this.parse(this.$parent.dates[1])},ys:function(){return 10*parseInt(this.year/10)},ye:function(){return this.ys+10},years:function(){for(var e=[],t=this.ys-1;e.length<12;)e.push(t++);return e},days:function(){var e=[],t=this,s=t.year,n=t.month,o=new Date(s,n,1),a=t.local.dow||7;o.setDate(0);for(var r=o.getDate(),i=o.getDay()||7,c=a<=i?i-a+1:i+(7-a+1);c>0;)e.push({i:r-c+1,y:n>0?s:s-1,m:n>0?n-1:11,p:!0}),c--;o.setMonth(o.getMonth()+2,0),r=o.getDate();var u=1;for(u=1;u<=r;u++)e.push({i:u,y:s,m:n});for(u=1;e.length<42;u++)e.push({i:u,y:n<11?s:s+1,m:n<11?n+1:0,n:!0});return e}},filters:{dd:function(e){return("0"+e).slice(-2)}},methods:{get:function(e){return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds()}},parse:function(e){return parseInt(e/1e3)},status:function(e,t,s,n,o,a,r){var i=this,c=new Date(e,t+1,0).getDate(),u=new Date(e,t,s>c?c:s,n,o,a),l=i.parse(u),h=i.$parent.tf,d={},p=!1;return p="YYYY"===r?e===i.year:"YYYYMM"===r?t===i.month:h(i.value,r)===h(u,r),d[i.pre+"-date"]=!0,d[i.pre+"-date-disabled"]=i.right&&li.start||i.right&&l0?this.month--:(this.month=11,this.year--)},is:function(e){return-1===e.target.className.indexOf(this.pre+"-date-disabled")},ok:function(e){var t=this,s="",n="";if(e&&e.n&&t.nm(),e&&e.p&&t.pm(),"h"===e){var o=t.get(this.value);s=o.year,n=o.month}var a=new Date(s||t.year,n||t.month,t.day,t.hour,t.minute,t.second);t.left&&parseInt(a.getTime()/1e3)>t.end&&(this.$parent.dates[1]=a),t.$emit("input",a),t.$parent.ok("h"===e)}},mounted:function(){var e=this,t=function(t){return-1!==e.format.indexOf(t)};t("s")&&t("m")&&(t("h")||t("H"))?e.m="H":t("D")?e.m="D":t("M")?(e.m="M",e.showMonths=!0):t("Y")&&(e.m="Y",e.showYears=!0)}},c=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{class:""+e.pre},[s("div",{class:e.pre+"-head"},[s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-prev-decade-btn",on:{click:function(t){e.year-=10}}},[e._v("«")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-prev-year-btn",on:{click:function(t){e.year--}}},[e._v("«")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-prev-month-btn",on:{click:e.pm}},[e._v("‹")]),s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-year-select"},[e._v(e._s(e.ys+"-"+e.ye))]),e.local.yearSuffix?[s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-year-select",on:{click:function(t){e.showYears=!e.showYears}}},[e._v(e._s(e.year)+e._s(e.local.yearSuffix))]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-month-select",on:{click:function(t){e.showMonths=!e.showMonths}}},[e._v(e._s(e.local.monthsHead[e.month]))])]:[s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-month-select",on:{click:function(t){e.showMonths=!e.showMonths}}},[e._v(e._s(e.local.monthsHead[e.month]))]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-year-select",on:{click:function(t){e.showYears=!e.showYears}}},[e._v(e._s(e.year))])],s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears&&!e.showMonths,expression:"!showYears&&!showMonths"}],class:e.pre+"-next-month-btn",on:{click:e.nm}},[e._v("›")]),s("a",{directives:[{name:"show",rawName:"v-show",value:!e.showYears,expression:"!showYears"}],class:e.pre+"-next-year-btn",on:{click:function(t){e.year++}}},[e._v("»")]),s("a",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-next-decade-btn",on:{click:function(t){e.year+=10}}},[e._v("»")])],2),s("div",{class:e.pre+"-body"},[s("div",{class:e.pre+"-days"},[e._l(e.local.weeks,function(t){return s("a",{key:t,class:e.pre+"-week"},[e._v(e._s(t))])}),e._l(e.days,function(t,n){return s("a",{key:n,class:[t.p||t.n?e.pre+"-date-out":"",e.status(t.y,t.m,t.i,e.hour,e.minute,e.second,"YYYYMMDD")],on:{click:function(s){e.is(s)&&(e.day=t.i,e.ok(t))}}},[e._v(e._s(t.i))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showMonths,expression:"showMonths"}],class:e.pre+"-months"},e._l(e.local.months,function(t,n){return s("a",{key:n,class:[e.status(e.year,n,e.day,e.hour,e.minute,e.second,"YYYYMM")],on:{click:function(t){e.is(t)&&(e.showMonths="M"===e.m,e.month=n,"M"===e.m&&e.ok())}}},[e._v(e._s(t))])})),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showYears,expression:"showYears"}],class:e.pre+"-years"},e._l(e.years,function(t,n){return s("a",{key:n,class:[0===n||11===n?e.pre+"-date-out":"",e.status(t,e.month,e.day,e.hour,e.minute,e.second,"YYYY")],on:{click:function(s){e.is(s)&&(e.showYears="Y"===e.m,e.year=t,"Y"===e.m&&e.ok())}}},[e._v(e._s(t))])})),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showHours,expression:"showHours"}],class:e.pre+"-hours"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.hourTip))]),e._l(24,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,n,e.minute,e.second,"YYYYMMDDHH")],on:{click:function(t){e.is(t)&&(e.showHours=!1,e.hour=n,e.ok("h"))}}},[e._v(e._s(n))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showMinutes,expression:"showMinutes"}],class:e.pre+"-minutes"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.minuteTip))]),e._l(60,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,e.hour,n,e.second,"YYYYMMDDHHmm")],on:{click:function(t){e.is(t)&&(e.showMinutes=!1,e.minute=n,e.ok("h"))}}},[e._v(e._s(n))])})],2),s("div",{directives:[{name:"show",rawName:"v-show",value:e.showSeconds,expression:"showSeconds"}],class:e.pre+"-seconds"},[s("div",{class:e.pre+"-title"},[e._v(e._s(e.local.secondTip))]),e._l(60,function(t,n){return s("a",{key:n,class:[e.status(e.year,e.month,e.day,e.hour,e.minute,n,"YYYYMMDDHHmmss")],on:{click:function(t){e.is(t)&&(e.showSeconds=!1,e.second=n,e.ok("h"))}}},[e._v(e._s(n))])})],2)]),"H"===e.m?s("div",{class:e.pre+"-foot"},[s("div",{class:e.pre+"-hour"},[s("a",{class:{on:e.showHours},attrs:{title:e.local.hourTip},on:{click:function(t){e.showHours=!e.showHours,e.showMinutes=e.showSeconds=!1}}},[e._v(e._s(e._f("dd")(e.hour)))]),s("span",[e._v(":")]),s("a",{class:{on:e.showMinutes},attrs:{title:e.local.minuteTip},on:{click:function(t){e.showMinutes=!e.showMinutes,e.showHours=e.showSeconds=!1}}},[e._v(e._s(e._f("dd")(e.minute)))]),s("span",[e._v(":")]),s("a",{class:{on:e.showSeconds},attrs:{title:e.local.secondTip},on:{click:function(t){e.showSeconds=!e.showSeconds,e.showHours=e.showMinutes=!1}}},[e._v(e._s(e._f("dd")(e.second)))])])]):e._e()])},u=[],l=o,h=n(i,c,u,!1,l,null,null),d=h.exports,p={name:"VueDatepickerLocal",components:{VueDatepickerLocalCalendar:d},props:{name:[String],inputClass:[String],popupClass:[String],value:[Date,Array,String],disabled:[Boolean],type:{type:String,default:"normal"},rangeSeparator:{type:String,default:"~"},clearable:{type:Boolean,default:!1},placeholder:[String],disabledDate:{type:Function,default:function(){return!1}},format:{type:String,default:"YYYY-MM-DD"},local:{type:Object,default:function(){return{dow:1,hourTip:"选择小时",minuteTip:"选择分钟",secondTip:"选择秒数",yearSuffix:"年",monthsHead:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),weeks:"一_二_三_四_五_六_日".split("_"),cancelTip:"取消",submitTip:"确定"}}},showButtons:{type:Boolean,default:!1},dateRangeSelect:[Function]},data:function(){return{show:!1,dates:this.vi(this.value)}},computed:{range:function(){return 2===this.dates.length},text:function(){var e=this,t=this.value,s=this.dates.map(function(t){return e.tf(t)}).join(" "+this.rangeSeparator+" ");return Array.isArray(t)?t.length>1?s:"":t?s:""}},watch:{value:function(e){this.dates=this.vi(this.value)}},methods:{get:function(){return Array.isArray(this.value)?this.dates:this.dates[0]},cls:function(){this.$emit("clear"),this.$emit("input",this.range?[]:"")},vi:function(e){return Array.isArray(e)?e.length>1?e.map(function(e){return new Date(e)}):[new Date,new Date]:e?new Array(new Date(e)):[new Date]},ok:function(e){var t=this;t.$emit("input",t.get()),!e&&!t.showButtons&&setTimeout(function(){t.show=t.range})},tf:function(e,t){var s=e.getFullYear(),n=e.getMonth(),o=e.getDate(),a=e.getHours(),r=a%12==0?12:a%12,i=e.getMinutes(),c=e.getSeconds(),u=e.getMilliseconds(),l=function(e){return("0"+e).slice(-2)},h={YYYY:s,MM:l(n+1),MMM:this.local.months[n],MMMM:this.local.monthsHead[n],M:n+1,DD:l(o),D:o,HH:l(a),H:a,hh:l(r),h:r,mm:l(i),m:i,ss:l(c),s:c,S:u};return(t||this.format).replace(/Y+|M+|D+|H+|h+|m+|s+|S+/g,function(e){return h[e]})},dc:function(e){this.show=this.$el.contains(e.target)&&!this.disabled},submit:function(){this.$emit("confirm",this.get()),this.show=!1},cancel:function(){this.$emit("cancel"),this.show=!1}},mounted:function(){document.addEventListener("click",this.dc,!0)},beforeDestroy:function(){document.removeEventListener("click",this.dc,!0)}},f=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"datepicker",class:{"datepicker-range":e.range,datepicker__clearable:e.clearable&&e.text&&!e.disabled}},["inline"!==e.type?s("input",{class:[e.show?"focus":"",e.inputClass],attrs:{readonly:"",disabled:e.disabled,placeholder:e.placeholder,name:e.name},domProps:{value:e.text}}):e._e(),s("a",{staticClass:"datepicker-close",on:{click:function(t){return t.stopPropagation(),e.cls(t)}}}),s("transition",{attrs:{name:"datepicker-anim"}},[e.show||"inline"===e.type?s("div",{staticClass:"datepicker-popup",class:[e.popupClass,{"datepicker-inline":"inline"===e.type}],attrs:{tabindex:"-1"}},[e.range?[s("vue-datepicker-local-calendar",{attrs:{left:!0},model:{value:e.dates[0],callback:function(t){e.$set(e.dates,0,t)},expression:"dates[0]"}}),s("vue-datepicker-local-calendar",{attrs:{right:!0},model:{value:e.dates[1],callback:function(t){e.$set(e.dates,1,t)},expression:"dates[1]"}})]:[s("vue-datepicker-local-calendar",{model:{value:e.dates[0],callback:function(t){e.$set(e.dates,0,t)},expression:"dates[0]"}})],e.showButtons?s("div",{staticClass:"datepicker__buttons"},[s("button",{staticClass:"datepicker__button-cancel",on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.cancel(t)}}},[e._v(e._s(this.local.cancelTip))]),s("button",{staticClass:"datepicker__button-select",on:{click:function(t){return t.preventDefault(),t.stopPropagation(),e.submit(t)}}},[e._v(e._s(this.local.submitTip))])]):e._e()],2):e._e()])],1)},m=[],w=a,v=n(p,f,m,!1,w,null,null),_=v.exports;_.install=r,"undefined"!=typeof window&&window.Vue&&r(window.Vue);t.default=_},function(e,t){},function(e,t){}])}); \ No newline at end of file diff --git a/package.json b/package.json index 73cd659..bc5a2df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-datepicker-local", - "version": "1.0.16", + "version": "1.0.17", "description": "A datepicker for Vue.js", "main": "src/index.js", "files": [ diff --git a/src/VueDatepickerLocalCalendar.vue b/src/VueDatepickerLocalCalendar.vue index 2273309..bb205f9 100644 --- a/src/VueDatepickerLocalCalendar.vue +++ b/src/VueDatepickerLocalCalendar.vue @@ -228,7 +228,7 @@ export default { month = time.month } const _time = new Date(year || $this.year, month || $this.month, $this.day, $this.hour, $this.minute, $this.second) - if ($this.left && _time > $this.start) { + if ($this.left && parseInt(_time.getTime() / 1000) > $this.end) { this.$parent.dates[1] = _time } $this.$emit('input', _time) diff --git a/webpack.config.js b/webpack.config.js index 00e72c3..0b55053 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path') const webpack = require('webpack') const ExtractTextPlugin = require('extract-text-webpack-plugin') const banner = - 'vue-datetime-local.js v1.0.16\n' + + 'vue-datetime-local.js v1.0.17\n' + '(c) 2017-' + new Date().getFullYear() + ' weifeiyue\n' + 'Released under the MIT License.' module.exports = {