From 661d0b33ef1cca8f0d80f8f4618044b67a52eb64 Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 28 Nov 2017 10:16:55 +0800 Subject: [PATCH] build 0.5.1 --- dist/date-picker.min.js | 2 +- dist/date-time-picker.min.js | 2 +- dist/time-picker.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/date-picker.min.js b/dist/date-picker.min.js index 8acda50..9cc1867 100644 --- a/dist/date-picker.min.js +++ b/dist/date-picker.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Date=i(17),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function d(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function m(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:d,noop:l,extend:p,pad:f,set2Null:m}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,d=h?"touchstart":"mousedown",l=h?"touchmove":"mousemove",u=h?"touchend":"mouseup",p=h?"touchcancel":"mouseup",f=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=f,t.prototype=new i,t.prototype["super"]=f,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(f,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(d),this._addEvt(l),this._addEvt(u),this._addEvt(p)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(d),this._removeEvt(l),this._removeEvt(u),this._removeEvt(p)},destroy:function(){this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this)}},s);var m=["selfChange","render","__start","__move","__end"];m.forEach(function(t){f[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",d=new Date;s
'+o.formatDate(t.now,e.YM)+'
'+e.shortDay.map(function(t){return""+t+""}).join("")+'
'+t.getRows().map(function(t){return'
'+t.map(function(t){var e=c.year===a.year&&c.month===a.month&&t===a.date?"picker-now":"";t===c.date&&(e=e?e+" picker-active":"picker-active"),l&&!r(t,c,h,d)||(e=e?e+" picker-disabled":"picker-disabled"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}function s(t,e,i){var n=!1;return t.year>e.year?n=!0:t.year===e.year&&(n=t.month>=e.month),n&&(t.yearn.date}var o=i(1);o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=a(this.picker.prevDateTime,this.picker.config,"prev")+a(this.picker.dateTime,this.picker.config,"curr")+a(this.picker.nextDateTime,this.picker.config,"next"),this.afterRender()},_renderHead:function(){this.picker.head.innerHTML='
'+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},afterRender:function(){this.activeDateEle=this.main.querySelector(".picker-bdy-curr .picker-active")},selfChange:function(){this._renderHead(),this.activeDateEle&&this.activeDateEle.classList.remove("picker-active");var t=this.picker.dateTime.getLevelValue(),e=this.main.querySelector('.picker-bdy-curr i[data-val="'+t+'"]');e.classList.add("picker-active"),this.activeDateEle=e},_init:function(){this._initMain(),this._initArrow()},_initMain:function(){this.main=o.createElement("div",{className:"date-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.mainWidth=this.main.offsetWidth},_initArrow:function(){this.arrow=o.createElement("div",{className:"picker-actions-arrow"}),this.arrow.innerHTML='',this.arrowStyle=this.arrow.style,this.picker.content.appendChild(this.arrow)},show:function(){this.mainStyle.display="block",this.arrowStyle.display="block"},hide:function(){this.mainStyle.display="none",this.arrowStyle.display="none"},_slideTo:function(t,e,i){var n=this,a=3,s=a*Math.abs(t-e),r=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,r,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[o.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=r,this.mainStyle[o.prefixNames.transform]="translateX("+t+"%) translateZ(0)",s>0?(this._slideEndFn.tid=window.setTimeout(r,s),s+="ms",this.mainStyle.webkitTransition=s,this.mainStyle.transition=s):r(),this.main.addEventListener(o.prefixNames.transitionEnd,r,!1)},_befChange:function(t){return o.isNum(t)||(t=-100),this._slideEndFn&&this._slideEndFn(),t},prevMonth:function(t){t=this._befChange(t),this._slideTo(0,t,function(){this.picker.setNowToPrev()})},nextMonth:function(t){t=this._befChange(t),this._slideTo(-200,t,function(){this.picker.setNowToNext()})},_start:function(t){var e=t.touches[0],i=e.pageX,n=this,a=-100,s=a,r=!1;this.__move=function(t){var e=t.touches[0],c=e.pageX-i;c=100*c/n.mainWidth;var h=Math.abs(c);h>100&&(c=c>0?100:-100),r=h>55,s=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[o.prefixNames.transform]="translateX("+s+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,r?n[s>a?"prevMonth":"nextMonth"](s):n._slideTo(a,s)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),o.set2Null(["picker","main","mainStyle","arrow","arrowStyle","activeDateEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.posY=0,this.type=t.options.type}function a(t,e){return e||(e=function(t){return t}),function(i,n){var a=i.parsedNow[t];return"
    "+n.map(function(t){var i=t[0],n="";return i===a&&(n=" picker-active"),'
  • '+e(i)+"
  • "}).join("")+"
"}}function s(t){var e=window.getComputedStyle(t,null);e=e[o.prefixNames.transform].split(")")[0].split(", ");var i=+(e[13]||e[5]);return i}function r(t,e,i){var n=6e-4,a=t-e,s=Math.abs(a)/i,r=t+s*s/(2*n)*(a<0?-1:1);return{destination:r,speed:s}}var o=i(1),c={C:a("year"),Y:a("month",function(t){return t+1})};o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=c[this.type](this.picker.dateTime,this.rows),this._afterRender()},_renderHead:function(){var t="C"===this.type;this.picker.head.innerHTML='
"+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},_afterRender:function(){var t=this.main.querySelector(".picker-active");this.itemHeight=t.offsetHeight,this.activeEle=t;var e=t.offsetTop-(this.contentHeight-this.itemHeight)/2;this._slideTo(-e,0)},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain(),this._initMidd()},_initMain:function(){this.main=o.createElement("div",{className:"scroller-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.contentHeight=this.picker.content.offsetHeight},_initMidd:function(){this.midd=o.createElement("div",{className:"scroller-picker-midd"}),this.middStyle=this.midd.style,this.picker.content.appendChild(this.midd)},show:function(){this.mainStyle.display="block",this.middStyle.display="block"},hide:function(){this.mainStyle.display="none",this.middStyle.display="none"},selfChange:function(){if(!this.__ani){var t=this;this._renderHead(),this.activeEle.classList.remove("picker-active");var e=this.picker.dateTime.getLevelValue(),i=this.main.querySelector('.picker-row[data-val="'+e+'"]'),n=(this.activeEle.dataset.val-e)*this.itemHeight+this.posY;t._slideTo(n,0,function(){i.classList.add("picker-active"),t.activeEle=i})}},_slideTo:function(t,e,i){var n=this,a=function(t){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,a,!1),i&&i.call(n,t),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms")};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=a,this.posY=t,this.mainStyle[o.prefixNames.transform]="translateY("+this.posY+"px) translateZ(0)";var s=" cubic-bezier(0.25, 0.46, 0.45, 0.94)";e>0?(this._slideEndFn.tid=window.setTimeout(function(){a({})},e+20),e+="ms",this.mainStyle.webkitTransition=e+s,this.mainStyle.transition=e+s,this.main.addEventListener(o.prefixNames.transitionEnd,a,!1)):a()},_start:function(t){this._slideEndFn&&this._slideEndFn();var e=t.touches[0],i=e.pageY,n=this,a=this.posY,c=a,h=t.timeStamp,d=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;c=a+s;var r=t.timeStamp;r-h>300&&(h=r,d=c),n.mainStyle[o.prefixNames.transform]="translateY("+c+"px) translateZ(0)"};var l=function(t){var e,i=t-a,s=Math.round(i/n.itemHeight),r=n.picker.dateTime.getLevelValue(),o=r-s,c=n.rows[0][0],h=n.rows[n.rows.length-1][0];return oh?(s=r-h,o=h,e=s*n.itemHeight+a):e=s*n.itemHeight+a,{realTo:e,targetV:o}};this.__end=function(t){this.__move=null,this.__end=null;var e,i=t.timeStamp,a=i-h;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;du&&(d=u);var p=r(c,d,a);c=p.destination,e=p.speed}var f=l(c),m=f.realTo,v=f.targetV;void 0===e?(e=100*Math.abs(m-c)/n.itemHeight,e>50&&(e=20)):e=Math.abs(m-d)/e,n._slideTo(m,e,function(t){if(t||!e)n.picker.changeTo(v);else{var i=s(n.main),a=l(i);n._slideTo(a.realTo,0,function(){n.__ani=!0,n.picker.changeTo(a.targetV,!0),n.__ani=!1})}})}},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.midd),o.set2Null(["picker","main","mainStyle","midd","middStyle","activeEle","__move","__end"],this)}}),t.exports=n},,function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(4),o=i(14),c=i(15);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="yyyy-MM-dd"),s.extend(this.options,{type:"M"}),this.panel=this.daysPanel=new o(this)},_setDateTime:function(){var t=s.prevMonth(this.dateTime.now),e=s.nextMonth(this.dateTime.now);this.prevDateTime=new r(s.extend({},this.options,{"default":t})),this.prevDateTime.parsedNow.month!==t.getMonth()&&(this.prevDateTime.destroy(),this.prevDateTime=null),this.nextDateTime=new r(s.extend({},this.options,{"default":e})),this.nextDateTime.parsedNow.month!==e.getMonth()&&(this.nextDateTime.destroy(),this.nextDateTime=null)},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.prevDateTime&&this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.nextDateTime&&this.setNow(this.nextDateTime.now)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new c(this),this.panel=this[e],this.setDateTime()},toYears:function(){this._to("C","yearsPanel")},toMonths:function(){this._to("Y","monthsPanel")},toDays:function(){this._to("M","daysPanel")}}),t.exports=n}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Date=i(17),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function d(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function m(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:d,noop:l,extend:p,pad:f,set2Null:m}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang,this.destroyed=!1;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,d=h?"touchstart":"mousedown",l=h?"touchmove":"mousemove",u=h?"touchend":"mouseup",p=h?"touchcancel":"mouseup",f=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=f,t.prototype=new i,t.prototype["super"]=f,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(f,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(d),this._addEvt(l),this._addEvt(u),this._addEvt(p)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(d),this._removeEvt(l),this._removeEvt(u),this._removeEvt(p)},destroy:function(){this.destroyed||(this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this),this.destroyed=!0)}},s);var m=["selfChange","render","__start","__move","__end"];m.forEach(function(t){f[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",d=new Date;s
'+o.formatDate(t.now,e.YM)+'
'+e.shortDay.map(function(t){return""+t+""}).join("")+'
'+t.getRows().map(function(t){return'
'+t.map(function(t){var e=c.year===a.year&&c.month===a.month&&t===a.date?"picker-now":"";t===c.date&&(e=e?e+" picker-active":"picker-active"),l&&!r(t,c,h,d)||(e=e?e+" picker-disabled":"picker-disabled"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}function s(t,e,i){var n=!1;return t.year>e.year?n=!0:t.year===e.year&&(n=t.month>=e.month),n&&(t.yearn.date}var o=i(1);o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=a(this.picker.prevDateTime,this.picker.config,"prev")+a(this.picker.dateTime,this.picker.config,"curr")+a(this.picker.nextDateTime,this.picker.config,"next"),this.afterRender()},_renderHead:function(){this.picker.head.innerHTML='
'+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},afterRender:function(){this.activeDateEle=this.main.querySelector(".picker-bdy-curr .picker-active")},selfChange:function(){this._renderHead(),this.activeDateEle&&this.activeDateEle.classList.remove("picker-active");var t=this.picker.dateTime.getLevelValue(),e=this.main.querySelector('.picker-bdy-curr i[data-val="'+t+'"]');e.classList.add("picker-active"),this.activeDateEle=e},_init:function(){this._initMain(),this._initArrow()},_initMain:function(){this.main=o.createElement("div",{className:"date-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.mainWidth=this.main.offsetWidth},_initArrow:function(){this.arrow=o.createElement("div",{className:"picker-actions-arrow"}),this.arrow.innerHTML='',this.arrowStyle=this.arrow.style,this.picker.content.appendChild(this.arrow)},show:function(){this.mainStyle.display="block",this.arrowStyle.display="block"},hide:function(){this.mainStyle.display="none",this.arrowStyle.display="none"},_slideTo:function(t,e,i){var n=this,a=3,s=a*Math.abs(t-e),r=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,r,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[o.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=r,this.mainStyle[o.prefixNames.transform]="translateX("+t+"%) translateZ(0)",s>0?(this._slideEndFn.tid=window.setTimeout(r,s),s+="ms",this.mainStyle.webkitTransition=s,this.mainStyle.transition=s):r(),this.main.addEventListener(o.prefixNames.transitionEnd,r,!1)},_befChange:function(t){return o.isNum(t)||(t=-100),this._slideEndFn&&this._slideEndFn(),t},prevMonth:function(t){t=this._befChange(t),this._slideTo(0,t,function(){this.picker.setNowToPrev()})},nextMonth:function(t){t=this._befChange(t),this._slideTo(-200,t,function(){this.picker.setNowToNext()})},_start:function(t){var e=t.touches[0],i=e.pageX,n=this,a=-100,s=a,r=!1;this.__move=function(t){var e=t.touches[0],c=e.pageX-i;c=100*c/n.mainWidth;var h=Math.abs(c);h>100&&(c=c>0?100:-100),r=h>55,s=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[o.prefixNames.transform]="translateX("+s+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,r?n[s>a?"prevMonth":"nextMonth"](s):n._slideTo(a,s)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),o.set2Null(["picker","main","mainStyle","arrow","arrowStyle","activeDateEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.posY=0,this.type=t.options.type}function a(t,e){return e||(e=function(t){return t}),function(i,n){var a=i.parsedNow[t];return"
    "+n.map(function(t){var i=t[0],n="";return i===a&&(n=" picker-active"),'
  • '+e(i)+"
  • "}).join("")+"
"}}function s(t){var e=window.getComputedStyle(t,null);e=e[o.prefixNames.transform].split(")")[0].split(", ");var i=+(e[13]||e[5]);return i}function r(t,e,i){var n=6e-4,a=t-e,s=Math.abs(a)/i,r=t+s*s/(2*n)*(a<0?-1:1);return{destination:r,speed:s}}var o=i(1),c={C:a("year"),Y:a("month",function(t){return t+1})};o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=c[this.type](this.picker.dateTime,this.rows),this._afterRender()},_renderHead:function(){var t="C"===this.type;this.picker.head.innerHTML='
"+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},_afterRender:function(){var t=this.main.querySelector(".picker-active");this.itemHeight=t.offsetHeight,this.activeEle=t;var e=t.offsetTop-(this.contentHeight-this.itemHeight)/2;this._slideTo(-e,0)},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain(),this._initMidd()},_initMain:function(){this.main=o.createElement("div",{className:"scroller-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.contentHeight=this.picker.content.offsetHeight},_initMidd:function(){this.midd=o.createElement("div",{className:"scroller-picker-midd"}),this.middStyle=this.midd.style,this.picker.content.appendChild(this.midd)},show:function(){this.mainStyle.display="block",this.middStyle.display="block"},hide:function(){this.mainStyle.display="none",this.middStyle.display="none"},selfChange:function(){if(!this.__ani){var t=this;this._renderHead(),this.activeEle.classList.remove("picker-active");var e=this.picker.dateTime.getLevelValue(),i=this.main.querySelector('.picker-row[data-val="'+e+'"]'),n=(this.activeEle.dataset.val-e)*this.itemHeight+this.posY;t._slideTo(n,0,function(){i.classList.add("picker-active"),t.activeEle=i})}},_slideTo:function(t,e,i){var n=this,a=function(t){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,a,!1),i&&i.call(n,t),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms")};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=a,this.posY=t,this.mainStyle[o.prefixNames.transform]="translateY("+this.posY+"px) translateZ(0)";var s=" cubic-bezier(0.25, 0.46, 0.45, 0.94)";e>0?(this._slideEndFn.tid=window.setTimeout(function(){a({})},e+20),e+="ms",this.mainStyle.webkitTransition=e+s,this.mainStyle.transition=e+s,this.main.addEventListener(o.prefixNames.transitionEnd,a,!1)):a()},_start:function(t){this._slideEndFn&&this._slideEndFn();var e=t.touches[0],i=e.pageY,n=this,a=this.posY,c=a,h=t.timeStamp,d=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;c=a+s;var r=t.timeStamp;r-h>300&&(h=r,d=c),n.mainStyle[o.prefixNames.transform]="translateY("+c+"px) translateZ(0)"};var l=function(t){var e,i=t-a,s=Math.round(i/n.itemHeight),r=n.picker.dateTime.getLevelValue(),o=r-s,c=n.rows[0][0],h=n.rows[n.rows.length-1][0];return oh?(s=r-h,o=h,e=s*n.itemHeight+a):e=s*n.itemHeight+a,{realTo:e,targetV:o}};this.__end=function(t){this.__move=null,this.__end=null;var e,i=t.timeStamp,a=i-h;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;du&&(d=u);var p=r(c,d,a);c=p.destination,e=p.speed}var f=l(c),m=f.realTo,v=f.targetV;void 0===e?(e=100*Math.abs(m-c)/n.itemHeight,e>50&&(e=20)):e=Math.abs(m-d)/e,n._slideTo(m,e,function(t){if(t||!e)n.picker.changeTo(v);else{var i=s(n.main),a=l(i);n._slideTo(a.realTo,0,function(){n.__ani=!0,n.picker.changeTo(a.targetV,!0),n.__ani=!1})}})}},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.midd),o.set2Null(["picker","main","mainStyle","midd","middStyle","activeEle","__move","__end"],this)}}),t.exports=n},,function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(4),o=i(14),c=i(15);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="yyyy-MM-dd"),s.extend(this.options,{type:"M"}),this.panel=this.daysPanel=new o(this)},_setDateTime:function(){var t=s.prevMonth(this.dateTime.now),e=s.nextMonth(this.dateTime.now);this.prevDateTime=new r(s.extend({},this.options,{"default":t})),this.prevDateTime.parsedNow.month!==t.getMonth()&&(this.prevDateTime.destroy(),this.prevDateTime=null),this.nextDateTime=new r(s.extend({},this.options,{"default":e})),this.nextDateTime.parsedNow.month!==e.getMonth()&&(this.nextDateTime.destroy(),this.nextDateTime=null)},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.prevDateTime&&this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.nextDateTime&&this.setNow(this.nextDateTime.now)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new c(this),this.panel=this[e],this.setDateTime()},toYears:function(){this._to("C","yearsPanel")},toMonths:function(){this._to("Y","monthsPanel")},toDays:function(){this._to("M","daysPanel")}}),t.exports=n}])}); \ No newline at end of file diff --git a/dist/date-time-picker.min.js b/dist/date-time-picker.min.js index 5b5e11e..de74b86 100644 --- a/dist/date-time-picker.min.js +++ b/dist/date-time-picker.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Date=i(17),n.Time=i(18),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function l(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function f(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:l,noop:d,extend:p,pad:m,set2Null:f}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,l=h?"touchstart":"mousedown",d=h?"touchmove":"mousemove",u=h?"touchend":"mouseup",p=h?"touchcancel":"mouseup",m=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=m,t.prototype=new i,t.prototype["super"]=m,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(m,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(l),this._addEvt(d),this._addEvt(u),this._addEvt(p)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(l),this._removeEvt(d),this._removeEvt(u),this._removeEvt(p)},destroy:function(){this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this)}},s);var f=["selfChange","render","__start","__move","__end"];f.forEach(function(t){m[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",l=new Date;s
'+o.formatDate(t.now,e.YM)+'
'+e.shortDay.map(function(t){return""+t+""}).join("")+'
'+t.getRows().map(function(t){return'
'+t.map(function(t){var e=c.year===a.year&&c.month===a.month&&t===a.date?"picker-now":"";t===c.date&&(e=e?e+" picker-active":"picker-active"),d&&!r(t,c,h,l)||(e=e?e+" picker-disabled":"picker-disabled"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}function s(t,e,i){var n=!1;return t.year>e.year?n=!0:t.year===e.year&&(n=t.month>=e.month),n&&(t.yearn.date}var o=i(1);o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=a(this.picker.prevDateTime,this.picker.config,"prev")+a(this.picker.dateTime,this.picker.config,"curr")+a(this.picker.nextDateTime,this.picker.config,"next"),this.afterRender()},_renderHead:function(){this.picker.head.innerHTML='
'+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},afterRender:function(){this.activeDateEle=this.main.querySelector(".picker-bdy-curr .picker-active")},selfChange:function(){this._renderHead(),this.activeDateEle&&this.activeDateEle.classList.remove("picker-active");var t=this.picker.dateTime.getLevelValue(),e=this.main.querySelector('.picker-bdy-curr i[data-val="'+t+'"]');e.classList.add("picker-active"),this.activeDateEle=e},_init:function(){this._initMain(),this._initArrow()},_initMain:function(){this.main=o.createElement("div",{className:"date-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.mainWidth=this.main.offsetWidth},_initArrow:function(){this.arrow=o.createElement("div",{className:"picker-actions-arrow"}),this.arrow.innerHTML='',this.arrowStyle=this.arrow.style,this.picker.content.appendChild(this.arrow)},show:function(){this.mainStyle.display="block",this.arrowStyle.display="block"},hide:function(){this.mainStyle.display="none",this.arrowStyle.display="none"},_slideTo:function(t,e,i){var n=this,a=3,s=a*Math.abs(t-e),r=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,r,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[o.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=r,this.mainStyle[o.prefixNames.transform]="translateX("+t+"%) translateZ(0)",s>0?(this._slideEndFn.tid=window.setTimeout(r,s),s+="ms",this.mainStyle.webkitTransition=s,this.mainStyle.transition=s):r(),this.main.addEventListener(o.prefixNames.transitionEnd,r,!1)},_befChange:function(t){return o.isNum(t)||(t=-100),this._slideEndFn&&this._slideEndFn(),t},prevMonth:function(t){t=this._befChange(t),this._slideTo(0,t,function(){this.picker.setNowToPrev()})},nextMonth:function(t){t=this._befChange(t),this._slideTo(-200,t,function(){this.picker.setNowToNext()})},_start:function(t){var e=t.touches[0],i=e.pageX,n=this,a=-100,s=a,r=!1;this.__move=function(t){var e=t.touches[0],c=e.pageX-i;c=100*c/n.mainWidth;var h=Math.abs(c);h>100&&(c=c>0?100:-100),r=h>55,s=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[o.prefixNames.transform]="translateX("+s+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,r?n[s>a?"prevMonth":"nextMonth"](s):n._slideTo(a,s)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),o.set2Null(["picker","main","mainStyle","arrow","arrowStyle","activeDateEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.posY=0,this.type=t.options.type}function a(t,e){return e||(e=function(t){return t}),function(i,n){var a=i.parsedNow[t];return"
    "+n.map(function(t){var i=t[0],n="";return i===a&&(n=" picker-active"),'
  • '+e(i)+"
  • "}).join("")+"
"}}function s(t){var e=window.getComputedStyle(t,null);e=e[o.prefixNames.transform].split(")")[0].split(", ");var i=+(e[13]||e[5]);return i}function r(t,e,i){var n=6e-4,a=t-e,s=Math.abs(a)/i,r=t+s*s/(2*n)*(a<0?-1:1);return{destination:r,speed:s}}var o=i(1),c={C:a("year"),Y:a("month",function(t){return t+1})};o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=c[this.type](this.picker.dateTime,this.rows),this._afterRender()},_renderHead:function(){var t="C"===this.type;this.picker.head.innerHTML='
"+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},_afterRender:function(){var t=this.main.querySelector(".picker-active");this.itemHeight=t.offsetHeight,this.activeEle=t;var e=t.offsetTop-(this.contentHeight-this.itemHeight)/2;this._slideTo(-e,0)},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain(),this._initMidd()},_initMain:function(){this.main=o.createElement("div",{className:"scroller-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.contentHeight=this.picker.content.offsetHeight},_initMidd:function(){this.midd=o.createElement("div",{className:"scroller-picker-midd"}),this.middStyle=this.midd.style,this.picker.content.appendChild(this.midd)},show:function(){this.mainStyle.display="block",this.middStyle.display="block"},hide:function(){this.mainStyle.display="none",this.middStyle.display="none"},selfChange:function(){if(!this.__ani){var t=this;this._renderHead(),this.activeEle.classList.remove("picker-active");var e=this.picker.dateTime.getLevelValue(),i=this.main.querySelector('.picker-row[data-val="'+e+'"]'),n=(this.activeEle.dataset.val-e)*this.itemHeight+this.posY;t._slideTo(n,0,function(){i.classList.add("picker-active"),t.activeEle=i})}},_slideTo:function(t,e,i){var n=this,a=function(t){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,a,!1),i&&i.call(n,t),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms")};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=a,this.posY=t,this.mainStyle[o.prefixNames.transform]="translateY("+this.posY+"px) translateZ(0)";var s=" cubic-bezier(0.25, 0.46, 0.45, 0.94)";e>0?(this._slideEndFn.tid=window.setTimeout(function(){a({})},e+20),e+="ms",this.mainStyle.webkitTransition=e+s,this.mainStyle.transition=e+s,this.main.addEventListener(o.prefixNames.transitionEnd,a,!1)):a()},_start:function(t){this._slideEndFn&&this._slideEndFn();var e=t.touches[0],i=e.pageY,n=this,a=this.posY,c=a,h=t.timeStamp,l=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;c=a+s;var r=t.timeStamp;r-h>300&&(h=r,l=c),n.mainStyle[o.prefixNames.transform]="translateY("+c+"px) translateZ(0)"};var d=function(t){var e,i=t-a,s=Math.round(i/n.itemHeight),r=n.picker.dateTime.getLevelValue(),o=r-s,c=n.rows[0][0],h=n.rows[n.rows.length-1][0];return oh?(s=r-h,o=h,e=s*n.itemHeight+a):e=s*n.itemHeight+a,{realTo:e,targetV:o}};this.__end=function(t){this.__move=null,this.__end=null;var e,i=t.timeStamp,a=i-h;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;lu&&(l=u);var p=r(c,l,a);c=p.destination,e=p.speed}var m=d(c),f=m.realTo,v=m.targetV;void 0===e?(e=100*Math.abs(f-c)/n.itemHeight,e>50&&(e=20)):e=Math.abs(f-l)/e,n._slideTo(f,e,function(t){if(t||!e)n.picker.changeTo(v);else{var i=s(n.main),a=d(i);n._slideTo(a.realTo,0,function(){n.__ani=!0,n.picker.changeTo(a.targetV,!0),n.__ani=!1})}})}},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.midd),o.set2Null(["picker","main","mainStyle","midd","middStyle","activeEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.headActiveEle=null,this.activeEle=null,this.pickerLineEle=null,this.type=t.options.type}function a(t,e,i){return e||(e=function(t,e,i){return''+t+""}),i||(i=function(t){return t.length}),function(n,a){var r=a.length,o=i(a),c=o!==r,h=360/o,l="",d=1,u="minutes"===t;u&&(d=n.options.minuteStep||5,l+="time-picker-minutes-"+d);var p=function(t,e){var i=h*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},m=s.date2Details(n.options.min),f=s.date2Details(n.options.max),v=n.parsedNow[t],_="",y="",g=function(t){if(u){var e=n.parsedNow.hours;return e===m.hours?tf.minutes}return tf.hours};return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===v){a=" picker-active";var s="rotate("+(h*i-90)+"deg)";_="-webkit-transform:"+s+";transform:"+s,c&&(!n||n>12)&&(y+=" time-picker-line-inner")}return d>1&&i%d!==0?"":(g(n)&&(a+=" picker-disabled"),c&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,p)+"
  • ")}).join("")+'
'}}var s=i(1),r={D:a("hours",null,function(t){return t.length/2}),H:a("minutes",function(t,e,i){return e%5===0?''+s.pad(t,2)+"":""})};s.extend(n.prototype,{render:function(){this.main||this._init();var t="D"===this.type;this.picker.head.innerHTML='
"+s.formatDate(this.picker.dateTime.now,"HH")+'
:
"+s.formatDate(this.picker.dateTime.now,"mm")+"
",this.main.innerHTML=r[this.type](this.picker.dateTime,this.rows),this.afterRender()},afterRender:function(){this.headActiveEle=this.picker.head.querySelector(".picker-head-active"),this.activeEle=this.main.querySelector(".picker-active"),this.pickerLineEle=this.main.querySelector(".time-picker-line")},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain()},_initMain:function(){this.main=s.createElement("div",{className:"time-picker-main "+("D"===this.type?"time-picker-main-hours":"time-picker-main-minutes")}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main)},show:function(){this.mainStyle.display="block"},hide:function(){this.mainStyle.display="none"},selfChange:function(){var t=this.picker.dateTime.getLevelValue();this.headActiveEle.innerHTML=s.pad(t,2);var e=this.main.querySelector('.picker-cell[data-val="'+t+'"]');this.activeEle&&this.activeEle.classList.remove("picker-active"),e.classList.add("picker-active"),this.activeEle=e;var i=+e.style[s.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1];i-=90,this.pickerLineEle.style[s.prefixNames.transform]="rotate("+i+"deg)",this.pickerLineEle.classList[e.classList.contains("picker-cell-inner")?"add":"remove"]("time-picker-line-inner")},_start:function(t){var e=this,i=null,n=function(t){var n=document.elementFromPoint(t.pageX,t.pageY);n&&(n.classList.contains("picker-cell")||(n=n.parentElement)&&n.classList.contains("picker-cell"))&&(i=n,e.picker.changeTo(n.getAttribute("data-val"),!0))};n(t.touches[0]),this.__move=function(t){n(t.touches[0])},this.__end=function(t){this.__move=null,this.__end=null,i&&e.picker.selV({realTarget:i})}},destroy:function(){this.picker.content.removeChild(this.main),s.set2Null(["picker","main","mainStyle","headActiveEle","activeEle","pickerLineEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(4),o=i(14),c=i(15);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="yyyy-MM-dd"),s.extend(this.options,{type:"M"}),this.panel=this.daysPanel=new o(this)},_setDateTime:function(){var t=s.prevMonth(this.dateTime.now),e=s.nextMonth(this.dateTime.now);this.prevDateTime=new r(s.extend({},this.options,{"default":t})),this.prevDateTime.parsedNow.month!==t.getMonth()&&(this.prevDateTime.destroy(),this.prevDateTime=null),this.nextDateTime=new r(s.extend({},this.options,{"default":e})),this.nextDateTime.parsedNow.month!==e.getMonth()&&(this.nextDateTime.destroy(),this.nextDateTime=null)},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.prevDateTime&&this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.nextDateTime&&this.setNow(this.nextDateTime.now)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new c(this),this.panel=this[e],this.setDateTime()},toYears:function(){this._to("C","yearsPanel")},toMonths:function(){this._to("Y","monthsPanel")},toDays:function(){this._to("M","daysPanel")}}),t.exports=n},function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(16);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="HH:mm");var t=this.options.minuteStep;t||(t=5),1!==t&&5!==t&&10!==t&&(t=5),s.extend(this.options,{type:"D",minuteStep:t}),this.panel=this.hoursPanel=new r(this)},initEle:function(){this.ele.classList.add("time-picker-container")},_selV:function(t){var e=this;this["super"]._selV.call(this,t),setTimeout(function(){e.toMinutes()})},_to:function(t,e){this.options.type!==t&&(s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new r(this),this.panel=this[e],this.setDateTime())},toHours:function(){this._to("D","hoursPanel")},toMinutes:function(){this._to("H","minutesPanel")}}),t.exports=n}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Date=i(17),n.Time=i(18),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function l(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function f(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:l,noop:d,extend:p,pad:m,set2Null:f}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang,this.destroyed=!1;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,l=h?"touchstart":"mousedown",d=h?"touchmove":"mousemove",u=h?"touchend":"mouseup",p=h?"touchcancel":"mouseup",m=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=m,t.prototype=new i,t.prototype["super"]=m,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(m,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(l),this._addEvt(d),this._addEvt(u),this._addEvt(p)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(l),this._removeEvt(d),this._removeEvt(u),this._removeEvt(p)},destroy:function(){this.destroyed||(this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this),this.destroyed=!0)}},s);var f=["selfChange","render","__start","__move","__end"];f.forEach(function(t){m[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",l=new Date;s
'+o.formatDate(t.now,e.YM)+'
'+e.shortDay.map(function(t){return""+t+""}).join("")+'
'+t.getRows().map(function(t){return'
'+t.map(function(t){var e=c.year===a.year&&c.month===a.month&&t===a.date?"picker-now":"";t===c.date&&(e=e?e+" picker-active":"picker-active"),d&&!r(t,c,h,l)||(e=e?e+" picker-disabled":"picker-disabled"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}function s(t,e,i){var n=!1;return t.year>e.year?n=!0:t.year===e.year&&(n=t.month>=e.month),n&&(t.yearn.date}var o=i(1);o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=a(this.picker.prevDateTime,this.picker.config,"prev")+a(this.picker.dateTime,this.picker.config,"curr")+a(this.picker.nextDateTime,this.picker.config,"next"),this.afterRender()},_renderHead:function(){this.picker.head.innerHTML='
'+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},afterRender:function(){this.activeDateEle=this.main.querySelector(".picker-bdy-curr .picker-active")},selfChange:function(){this._renderHead(),this.activeDateEle&&this.activeDateEle.classList.remove("picker-active");var t=this.picker.dateTime.getLevelValue(),e=this.main.querySelector('.picker-bdy-curr i[data-val="'+t+'"]');e.classList.add("picker-active"),this.activeDateEle=e},_init:function(){this._initMain(),this._initArrow()},_initMain:function(){this.main=o.createElement("div",{className:"date-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.mainWidth=this.main.offsetWidth},_initArrow:function(){this.arrow=o.createElement("div",{className:"picker-actions-arrow"}),this.arrow.innerHTML='',this.arrowStyle=this.arrow.style,this.picker.content.appendChild(this.arrow)},show:function(){this.mainStyle.display="block",this.arrowStyle.display="block"},hide:function(){this.mainStyle.display="none",this.arrowStyle.display="none"},_slideTo:function(t,e,i){var n=this,a=3,s=a*Math.abs(t-e),r=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,r,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[o.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=r,this.mainStyle[o.prefixNames.transform]="translateX("+t+"%) translateZ(0)",s>0?(this._slideEndFn.tid=window.setTimeout(r,s),s+="ms",this.mainStyle.webkitTransition=s,this.mainStyle.transition=s):r(),this.main.addEventListener(o.prefixNames.transitionEnd,r,!1)},_befChange:function(t){return o.isNum(t)||(t=-100),this._slideEndFn&&this._slideEndFn(),t},prevMonth:function(t){t=this._befChange(t),this._slideTo(0,t,function(){this.picker.setNowToPrev()})},nextMonth:function(t){t=this._befChange(t),this._slideTo(-200,t,function(){this.picker.setNowToNext()})},_start:function(t){var e=t.touches[0],i=e.pageX,n=this,a=-100,s=a,r=!1;this.__move=function(t){var e=t.touches[0],c=e.pageX-i;c=100*c/n.mainWidth;var h=Math.abs(c);h>100&&(c=c>0?100:-100),r=h>55,s=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[o.prefixNames.transform]="translateX("+s+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,r?n[s>a?"prevMonth":"nextMonth"](s):n._slideTo(a,s)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),o.set2Null(["picker","main","mainStyle","arrow","arrowStyle","activeDateEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.posY=0,this.type=t.options.type}function a(t,e){return e||(e=function(t){return t}),function(i,n){var a=i.parsedNow[t];return"
    "+n.map(function(t){var i=t[0],n="";return i===a&&(n=" picker-active"),'
  • '+e(i)+"
  • "}).join("")+"
"}}function s(t){var e=window.getComputedStyle(t,null);e=e[o.prefixNames.transform].split(")")[0].split(", ");var i=+(e[13]||e[5]);return i}function r(t,e,i){var n=6e-4,a=t-e,s=Math.abs(a)/i,r=t+s*s/(2*n)*(a<0?-1:1);return{destination:r,speed:s}}var o=i(1),c={C:a("year"),Y:a("month",function(t){return t+1})};o.extend(n.prototype,{render:function(){this.main||this._init(),this._renderHead(),this.main.innerHTML=c[this.type](this.picker.dateTime,this.rows),this._afterRender()},_renderHead:function(){var t="C"===this.type;this.picker.head.innerHTML='
"+this.picker.dateTime.parsedNow.year+'
'+o.formatDate(this.picker.dateTime.now,this.picker.config.MDW.replace("D","#")).replace("#",this.picker.config.day[this.picker.dateTime.parsedNow.day])+"
"},_afterRender:function(){var t=this.main.querySelector(".picker-active");this.itemHeight=t.offsetHeight,this.activeEle=t;var e=t.offsetTop-(this.contentHeight-this.itemHeight)/2;this._slideTo(-e,0)},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain(),this._initMidd()},_initMain:function(){this.main=o.createElement("div",{className:"scroller-picker-main"}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main),this.contentHeight=this.picker.content.offsetHeight},_initMidd:function(){this.midd=o.createElement("div",{className:"scroller-picker-midd"}),this.middStyle=this.midd.style,this.picker.content.appendChild(this.midd)},show:function(){this.mainStyle.display="block",this.middStyle.display="block"},hide:function(){this.mainStyle.display="none",this.middStyle.display="none"},selfChange:function(){if(!this.__ani){var t=this;this._renderHead(),this.activeEle.classList.remove("picker-active");var e=this.picker.dateTime.getLevelValue(),i=this.main.querySelector('.picker-row[data-val="'+e+'"]'),n=(this.activeEle.dataset.val-e)*this.itemHeight+this.posY;t._slideTo(n,0,function(){i.classList.add("picker-active"),t.activeEle=i})}},_slideTo:function(t,e,i){var n=this,a=function(t){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(o.prefixNames.transitionEnd,a,!1),i&&i.call(n,t),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms")};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=a,this.posY=t,this.mainStyle[o.prefixNames.transform]="translateY("+this.posY+"px) translateZ(0)";var s=" cubic-bezier(0.25, 0.46, 0.45, 0.94)";e>0?(this._slideEndFn.tid=window.setTimeout(function(){a({})},e+20),e+="ms",this.mainStyle.webkitTransition=e+s,this.mainStyle.transition=e+s,this.main.addEventListener(o.prefixNames.transitionEnd,a,!1)):a()},_start:function(t){this._slideEndFn&&this._slideEndFn();var e=t.touches[0],i=e.pageY,n=this,a=this.posY,c=a,h=t.timeStamp,l=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;c=a+s;var r=t.timeStamp;r-h>300&&(h=r,l=c),n.mainStyle[o.prefixNames.transform]="translateY("+c+"px) translateZ(0)"};var d=function(t){var e,i=t-a,s=Math.round(i/n.itemHeight),r=n.picker.dateTime.getLevelValue(),o=r-s,c=n.rows[0][0],h=n.rows[n.rows.length-1][0];return oh?(s=r-h,o=h,e=s*n.itemHeight+a):e=s*n.itemHeight+a,{realTo:e,targetV:o}};this.__end=function(t){this.__move=null,this.__end=null;var e,i=t.timeStamp,a=i-h;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;lu&&(l=u);var p=r(c,l,a);c=p.destination,e=p.speed}var m=d(c),f=m.realTo,v=m.targetV;void 0===e?(e=100*Math.abs(f-c)/n.itemHeight,e>50&&(e=20)):e=Math.abs(f-l)/e,n._slideTo(f,e,function(t){if(t||!e)n.picker.changeTo(v);else{var i=s(n.main),a=d(i);n._slideTo(a.realTo,0,function(){n.__ani=!0,n.picker.changeTo(a.targetV,!0),n.__ani=!1})}})}},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.midd),o.set2Null(["picker","main","mainStyle","midd","middStyle","activeEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(t){this.picker=t,this.main=null,this.mainStyle=null,this.headActiveEle=null,this.activeEle=null,this.pickerLineEle=null,this.type=t.options.type}function a(t,e,i){return e||(e=function(t,e,i){return''+t+""}),i||(i=function(t){return t.length}),function(n,a){var r=a.length,o=i(a),c=o!==r,h=360/o,l="",d=1,u="minutes"===t;u&&(d=n.options.minuteStep||5,l+="time-picker-minutes-"+d);var p=function(t,e){var i=h*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},m=s.date2Details(n.options.min),f=s.date2Details(n.options.max),v=n.parsedNow[t],y="",_="",g=function(t){if(u){var e=n.parsedNow.hours;return e===m.hours?tf.minutes}return tf.hours};return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===v){a=" picker-active";var s="rotate("+(h*i-90)+"deg)";y="-webkit-transform:"+s+";transform:"+s,c&&(!n||n>12)&&(_+=" time-picker-line-inner")}return d>1&&i%d!==0?"":(g(n)&&(a+=" picker-disabled"),c&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,p)+"
  • ")}).join("")+'
'}}var s=i(1),r={D:a("hours",null,function(t){return t.length/2}),H:a("minutes",function(t,e,i){return e%5===0?''+s.pad(t,2)+"":""})};s.extend(n.prototype,{render:function(){this.main||this._init();var t="D"===this.type;this.picker.head.innerHTML='
"+s.formatDate(this.picker.dateTime.now,"HH")+'
:
"+s.formatDate(this.picker.dateTime.now,"mm")+"
",this.main.innerHTML=r[this.type](this.picker.dateTime,this.rows),this.afterRender()},afterRender:function(){this.headActiveEle=this.picker.head.querySelector(".picker-head-active"),this.activeEle=this.main.querySelector(".picker-active"),this.pickerLineEle=this.main.querySelector(".time-picker-line")},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain()},_initMain:function(){this.main=s.createElement("div",{className:"time-picker-main "+("D"===this.type?"time-picker-main-hours":"time-picker-main-minutes")}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main)},show:function(){this.mainStyle.display="block"},hide:function(){this.mainStyle.display="none"},selfChange:function(){var t=this.picker.dateTime.getLevelValue();this.headActiveEle.innerHTML=s.pad(t,2);var e=this.main.querySelector('.picker-cell[data-val="'+t+'"]');this.activeEle&&this.activeEle.classList.remove("picker-active"),e.classList.add("picker-active"),this.activeEle=e;var i=+e.style[s.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1];i-=90,this.pickerLineEle.style[s.prefixNames.transform]="rotate("+i+"deg)",this.pickerLineEle.classList[e.classList.contains("picker-cell-inner")?"add":"remove"]("time-picker-line-inner")},_start:function(t){var e=this,i=null,n=function(t){var n=document.elementFromPoint(t.pageX,t.pageY);n&&(n.classList.contains("picker-cell")||(n=n.parentElement)&&n.classList.contains("picker-cell"))&&(i=n,e.picker.changeTo(n.getAttribute("data-val"),!0))};n(t.touches[0]),this.__move=function(t){n(t.touches[0])},this.__end=function(t){this.__move=null,this.__end=null,i&&e.picker.selV({realTarget:i})}},destroy:function(){this.picker.content.removeChild(this.main),s.set2Null(["picker","main","mainStyle","headActiveEle","activeEle","pickerLineEle","__move","__end"],this)}}),t.exports=n},function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(4),o=i(14),c=i(15);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="yyyy-MM-dd"),s.extend(this.options,{type:"M"}),this.panel=this.daysPanel=new o(this)},_setDateTime:function(){var t=s.prevMonth(this.dateTime.now),e=s.nextMonth(this.dateTime.now);this.prevDateTime=new r(s.extend({},this.options,{"default":t})),this.prevDateTime.parsedNow.month!==t.getMonth()&&(this.prevDateTime.destroy(),this.prevDateTime=null),this.nextDateTime=new r(s.extend({},this.options,{"default":e})),this.nextDateTime.parsedNow.month!==e.getMonth()&&(this.nextDateTime.destroy(),this.nextDateTime=null)},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.prevDateTime&&this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.nextDateTime&&this.setNow(this.nextDateTime.now)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new c(this),this.panel=this[e],this.setDateTime()},toYears:function(){this._to("C","yearsPanel")},toMonths:function(){this._to("Y","monthsPanel")},toDays:function(){this._to("M","daysPanel")}}),t.exports=n},function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(16);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="HH:mm");var t=this.options.minuteStep;t||(t=5),1!==t&&5!==t&&10!==t&&(t=5),s.extend(this.options,{type:"D",minuteStep:t}),this.panel=this.hoursPanel=new r(this)},initEle:function(){this.ele.classList.add("time-picker-container")},_selV:function(t){var e=this;this["super"]._selV.call(this,t),setTimeout(function(){e.toMinutes()})},_to:function(t,e){this.options.type!==t&&(s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new r(this),this.panel=this[e],this.setDateTime())},toHours:function(){this._to("D","hoursPanel")},toMinutes:function(){this._to("H","minutesPanel")}}),t.exports=n}])}); \ No newline at end of file diff --git a/dist/time-picker.min.js b/dist/time-picker.min.js index 585aa63..3339b38 100644 --- a/dist/time-picker.min.js +++ b/dist/time-picker.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Time=i(18),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function u(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function m(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:u,noop:l,extend:f,pad:d,set2Null:m}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,u=h?"touchstart":"mousedown",l=h?"touchmove":"mousemove",p=h?"touchend":"mouseup",f=h?"touchcancel":"mouseup",d=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=d,t.prototype=new i,t.prototype["super"]=d,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(d,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(u),this._addEvt(l),this._addEvt(p),this._addEvt(f)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(u),this._removeEvt(l),this._removeEvt(p),this._removeEvt(f)},destroy:function(){this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this)}},s);var m=["selfChange","render","__start","__move","__end"];m.forEach(function(t){d[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",u=new Date;s'+t+""}),i||(i=function(t){return t.length}),function(n,a){var r=a.length,o=i(a),c=o!==r,h=360/o,u="",l=1,p="minutes"===t;p&&(l=n.options.minuteStep||5,u+="time-picker-minutes-"+l);var f=function(t,e){var i=h*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},d=s.date2Details(n.options.min),m=s.date2Details(n.options.max),v=n.parsedNow[t],_="",g="",y=function(t){if(p){var e=n.parsedNow.hours;return e===d.hours?tm.minutes}return tm.hours};return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===v){a=" picker-active";var s="rotate("+(h*i-90)+"deg)";_="-webkit-transform:"+s+";transform:"+s,c&&(!n||n>12)&&(g+=" time-picker-line-inner")}return l>1&&i%l!==0?"":(y(n)&&(a+=" picker-disabled"),c&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,f)+"
  • ")}).join("")+'
'}}var s=i(1),r={D:a("hours",null,function(t){return t.length/2}),H:a("minutes",function(t,e,i){return e%5===0?''+s.pad(t,2)+"":""})};s.extend(n.prototype,{render:function(){this.main||this._init();var t="D"===this.type;this.picker.head.innerHTML='
"+s.formatDate(this.picker.dateTime.now,"HH")+'
:
"+s.formatDate(this.picker.dateTime.now,"mm")+"
",this.main.innerHTML=r[this.type](this.picker.dateTime,this.rows),this.afterRender()},afterRender:function(){this.headActiveEle=this.picker.head.querySelector(".picker-head-active"),this.activeEle=this.main.querySelector(".picker-active"),this.pickerLineEle=this.main.querySelector(".time-picker-line")},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain()},_initMain:function(){this.main=s.createElement("div",{className:"time-picker-main "+("D"===this.type?"time-picker-main-hours":"time-picker-main-minutes")}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main)},show:function(){this.mainStyle.display="block"},hide:function(){this.mainStyle.display="none"},selfChange:function(){var t=this.picker.dateTime.getLevelValue();this.headActiveEle.innerHTML=s.pad(t,2);var e=this.main.querySelector('.picker-cell[data-val="'+t+'"]');this.activeEle&&this.activeEle.classList.remove("picker-active"),e.classList.add("picker-active"),this.activeEle=e;var i=+e.style[s.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1];i-=90,this.pickerLineEle.style[s.prefixNames.transform]="rotate("+i+"deg)",this.pickerLineEle.classList[e.classList.contains("picker-cell-inner")?"add":"remove"]("time-picker-line-inner")},_start:function(t){var e=this,i=null,n=function(t){var n=document.elementFromPoint(t.pageX,t.pageY);n&&(n.classList.contains("picker-cell")||(n=n.parentElement)&&n.classList.contains("picker-cell"))&&(i=n,e.picker.changeTo(n.getAttribute("data-val"),!0))};n(t.touches[0]),this.__move=function(t){n(t.touches[0])},this.__end=function(t){this.__move=null,this.__end=null,i&&e.picker.selV({realTarget:i})}},destroy:function(){this.picker.content.removeChild(this.main),s.set2Null(["picker","main","mainStyle","headActiveEle","activeEle","pickerLineEle","__move","__end"],this)}}),t.exports=n},,function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(16);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="HH:mm");var t=this.options.minuteStep;t||(t=5),1!==t&&5!==t&&10!==t&&(t=5),s.extend(this.options,{type:"D",minuteStep:t}),this.panel=this.hoursPanel=new r(this)},initEle:function(){this.ele.classList.add("time-picker-container")},_selV:function(t){var e=this;this["super"]._selV.call(this,t),setTimeout(function(){e.toMinutes()})},_to:function(t,e){this.options.type!==t&&(s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new r(this),this.panel=this[e],this.setDateTime())},toHours:function(){this._to("D","hoursPanel")},toMinutes:function(){this._to("H","minutesPanel")}}),t.exports=n}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DateTimePicker=e():t.DateTimePicker=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var n=i(11);n.Time=i(18),t.exports=n},function(t,e,i){var n=i(3),a=i(9),s=i(8),r=i(10);t.exports=n.extend({},n,a,s,r)},function(t,e,i){var n=i(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var i=!1;return n.each(this._eventData[t],function(t){if(t===e)return i=!0,!1}),i||this._eventData[t].push(e),this},once:function(t,e){var i=this,n=function(){e.apply(this,arguments),i.off(t,n)};return this.on(t,n),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?n.each(this._eventData[t],function(i,n){if(i===e)return this._eventData[t].splice(n,1),!1}):this._eventData[t]=[],this):this},trigger:function(t){if(this._eventData||(this._eventData={}),!this._eventData[t])return this;var e=this._eventData[t].slice.call(arguments,1);return n.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function i(t,e){return v.toString.call(t)==="[object "+e+"]"}function n(t){return i(t,"Function")}function a(t){return i(t,"String")}function s(t){return i(t,"Number")}function r(t){return i(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):i(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return i(t,"Date")}function u(t,e,i){if(t&&n(e))if(i=i||t,t.length){for(var a=0,s=t.length;a0?e:n)}function m(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:n,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:u,noop:l,extend:f,pad:d,set2Null:m}},function(t,e,i){function n(t){this.options=a.extend({"default":new Date,type:"M"},t||{});var e=a.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}var a=i(1),s=i(2),r={C:{value:"year",rows:function(t){for(var e=[],i=t.options.min.getFullYear(),n=t.options.max.getFullYear(),a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=t.options.min.getMonth(),n=t.options.max.getMonth(),a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=a.getDaysInMonthOfDate(i),s=0,r=1,o=a.getFirstDayOfMonth(t.now),c=null;r<=n;)s%7===0&&(c=[],e.push(c)),c.push(sr?(s.setDate(t),s=a.nextMonth(s)):(s.setDate(t),s=a.prevMonth(s)),s}},D:{value:"hours",rows:function(t){for(var e=[],i=0,n=23,a=i;a<=n;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],i=0,n=59,a=i;a<=n;)e.push([a++]);return e},input:"setMinutes"}};a.each(r,function(t){var e=t.input;a.isStr(e)&&(t.input=function(t,i){var n=i.now,s=a.toDate(n);return s[e](t),s})}),a.extend(n.prototype,{updateNow:function(t){tthis.options.max&&(t=this.options.max),this.now=new Date(t.getTime()),this.parsedNow=a.date2Details(this.now)},_getConf:function(){return r[this.options.type]||r.M},getRows:function(){var t=this._getConf();return t.rows(this)},getInputValue:function(t){var e=this._getConf();return e.input(t,this)},getLevelValue:function(){var t=this._getConf();return this.parsedNow[t.value]},destroy:function(){this.now=null,this.parsedNow=null,this.options=null}},s),t.exports=n},function(t,e,i){function n(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang,this.destroyed=!1;var i=o[this.lang];i||(i=o.EN),this.config=a.extend(i,e||{}),this.options=t,this.needDefFormat=!this.options.format,this.init(),this._setOptions(),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},h="ontouchstart"in window,u=h?"touchstart":"mousedown",l=h?"touchmove":"mousemove",p=h?"touchend":"mouseup",f=h?"touchcancel":"mouseup",d=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=d,t.prototype=new i,t.prototype["super"]=d,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(d,{_setOptions:function(){var t=this,e={min:new Date(1900,0,1,0,0,0,0),max:new Date(2100,11,31,23,59,59,999)},i=["default","min","max"];i.forEach(function(i){t.options.format&&t.options[i]&&a.isStr(t.options[i])?t.options[i]=a.parseDate(t.options[i],t.options.format):e[i]&&(t.options[i]=e[i])})},setDateTime:function(t){this.dateTime=new r(this.options),this._setDateTime(t),t?this.selfChange():(this.render(),this.afterRender())},setNow:function(t){this.options["default"]=t,this.setDateTime()},afterRender:a.noop,_setDateTime:a.noop,init:a.noop,_init:function(){this._initEle(),this.bindEvts(),this.setDateTime()},_initEle:function(){var t=a.createElement("div",{className:"picker-mask"}),e=a.createElement("div",{className:"picker-container"});this.rootEle=t,this.ele=e,this._initHead(),this._initContent(),this._initFoot(),this.initEle(),this._handleAni(),t.appendChild(e),this.container.appendChild(t)},initEle:a.noop,_initHead:function(){this.head=a.createElement("div",{className:"picker-head"}),this.ele.appendChild(this.head)},_initContent:function(){this.content=a.createElement("div",{className:"picker-content"},{"data-touchstart":"_start"}),this.ele.appendChild(this.content)},_initFoot:function(){this.foot=a.createElement("div",{className:"picker-foot",innerHTML:''+this.config.CLEAR+''+this.config.CANCEL+''+this.config.OK+""}),this.ele.appendChild(this.foot)},_handleAni:function(){var t=this.rootEle,e=function(){t.classList.remove("time-picker-ani"),t.removeEventListener(a.prefixNames.aniEnd,e,!1)};t.classList.add("time-picker-ani"),t.addEventListener(a.prefixNames.aniEnd,e,!1)},_addEvt:function(t){this.rootEle.addEventListener(t,this,!1)},_removeEvt:function(t){this.rootEle.removeEventListener(t,this,!1)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(u),this._addEvt(l),this._addEvt(p),this._addEvt(f)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;!e.classList.contains("picker-disabled")&&this.shouldSet(i)&&this._selV(i)},_selV:function(t){this.changeTo(t,!0)},shouldSet:function(t){return!0},clear:function(){this.setNow(),this.trigger("cleared"),this.hide()},cancel:function(){this.trigger("canceled"),this.hide()},ok:function(){var t=this.dateTime.now,e=this.options.format;e&&(t=a.formatDate(t,e)),this.trigger("selected",t,this.dateTime.now),this.hide()},__activeStart:function(t){this.__activeEnd();var e=this._getTargetAction(t,"active");e.action&&(this.activeTA=e,e.target.classList.add(e.action))},__activeEnd:function(){this.activeTA&&this.activeTA.target.classList.remove(this.activeTA.action),this.activeTA=null},__touchstart:function(t){this.__activeStart(t),this.__start(t);var e=t.target,i=t.targetTouches[0];this.__s_x=i.pageX,this.__s_y=i.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],i=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>i||Math.abs(e.pageY-this.__s_y)>i)&&(this.__target=null)}},__touchend:function(t){if(this.__activeEnd(t),this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var i=this.__target;this.__lastTime=e,this.__target=null,t.__target=i,t.__type="click"}}},__touchcancel:function(t){this.__activeEnd(t),this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;c[e]&&(e=c[e],t.__type=e,t.touches=t.changedTouches=t.targetTouches=[t]),this["__"+e](t),this._handleEvent(t)},_getTargetAction:function(t,e){for(var i=t.__target||t.target,n="data-"+(e||t.__type||t.type),a="";i&&i!==this.rootEle&&!(a=i.getAttribute(n));)i=i.parentNode;return{target:i,action:a}},_handleEvent:function(t){var e=this._getTargetAction(t);e.action&&(t.realTarget=e.target,this.panel&&this.panel[e.action]?this.panel[e.action](t):this[e.action]&&this[e.action](t))},show:function(){this.rootEle&&(this.rootEle.style.display="block",this._handleAni())},hide:function(){this.rootEle&&(this.rootEle.style.display="none")},desEvts:function(){this._removeEvt(u),this._removeEvt(l),this._removeEvt(p),this._removeEvt(f)},destroy:function(){this.destroyed||(this.trigger("destroy"),this.hide(),this.desEvts(),this.container.removeChild(this.rootEle),this.dateTime.destroy(),this.panel&&this.panel.destroy(),a.set2Null(["container","rootEle","ele","head","content","foot","dateTime","panel","config","lang"],this),this.destroyed=!0)}},s);var m=["selfChange","render","__start","__move","__end"];m.forEach(function(t){d[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=n},function(t,e,i){function n(t,e){var i,n={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return n.d=t.getDate(),n.dd=o(n.d,2),i=t.getDay(),n.D=i,n.DD=i,n.M=t.getMonth()+1,i=n.M,n.MM=o(i,2),n.yyyy=t.getFullYear(),i=n.yyyy,n.yyy=o(i,2)+"y",n.yy=o(i,2),n.y="y",n.H=t.getHours(),i=n.H,n.hh=o(a?s(i):i,2),n.h=a?s(i):i,n.HH=o(i,2),i=n.H<12,n.ap=i?"am":"pm",n.a=i?"am":"pm",n.AP=i?"AM":"PM",n.A=i?"AM":"PM",n.m=t.getMinutes(),n.mm=o(n.m,2),n.s=t.getSeconds(),n.ss=o(n.s,2),n.z=t.getMilliseconds(),i=n.z,n.zz=i+"z",n.zzz=o(i,3),e.replace(c,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=h,a="",s=0,o=[""],c="",u=new Date;s'+t+""}),i||(i=function(t){return t.length}),function(n,a){var r=a.length,o=i(a),c=o!==r,h=360/o,u="",l=1,p="minutes"===t;p&&(l=n.options.minuteStep||5,u+="time-picker-minutes-"+l);var f=function(t,e){var i=h*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},d=s.date2Details(n.options.min),m=s.date2Details(n.options.max),v=n.parsedNow[t],_="",g="",y=function(t){if(p){var e=n.parsedNow.hours;return e===d.hours?tm.minutes}return tm.hours};return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===v){a=" picker-active";var s="rotate("+(h*i-90)+"deg)";_="-webkit-transform:"+s+";transform:"+s,c&&(!n||n>12)&&(g+=" time-picker-line-inner")}return l>1&&i%l!==0?"":(y(n)&&(a+=" picker-disabled"),c&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,f)+"
  • ")}).join("")+'
'}}var s=i(1),r={D:a("hours",null,function(t){return t.length/2}),H:a("minutes",function(t,e,i){return e%5===0?''+s.pad(t,2)+"":""})};s.extend(n.prototype,{render:function(){this.main||this._init();var t="D"===this.type;this.picker.head.innerHTML='
"+s.formatDate(this.picker.dateTime.now,"HH")+'
:
"+s.formatDate(this.picker.dateTime.now,"mm")+"
",this.main.innerHTML=r[this.type](this.picker.dateTime,this.rows),this.afterRender()},afterRender:function(){this.headActiveEle=this.picker.head.querySelector(".picker-head-active"),this.activeEle=this.main.querySelector(".picker-active"),this.pickerLineEle=this.main.querySelector(".time-picker-line")},_init:function(){this.rows=this.picker.dateTime.getRows(),this._initMain()},_initMain:function(){this.main=s.createElement("div",{className:"time-picker-main "+("D"===this.type?"time-picker-main-hours":"time-picker-main-minutes")}),this.mainStyle=this.main.style,this.picker.content.appendChild(this.main)},show:function(){this.mainStyle.display="block"},hide:function(){this.mainStyle.display="none"},selfChange:function(){var t=this.picker.dateTime.getLevelValue();this.headActiveEle.innerHTML=s.pad(t,2);var e=this.main.querySelector('.picker-cell[data-val="'+t+'"]');this.activeEle&&this.activeEle.classList.remove("picker-active"),e.classList.add("picker-active"),this.activeEle=e;var i=+e.style[s.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1];i-=90,this.pickerLineEle.style[s.prefixNames.transform]="rotate("+i+"deg)",this.pickerLineEle.classList[e.classList.contains("picker-cell-inner")?"add":"remove"]("time-picker-line-inner")},_start:function(t){var e=this,i=null,n=function(t){var n=document.elementFromPoint(t.pageX,t.pageY);n&&(n.classList.contains("picker-cell")||(n=n.parentElement)&&n.classList.contains("picker-cell"))&&(i=n,e.picker.changeTo(n.getAttribute("data-val"),!0))};n(t.touches[0]),this.__move=function(t){n(t.touches[0])},this.__end=function(t){this.__move=null,this.__end=null,i&&e.picker.selV({realTarget:i})}},destroy:function(){this.picker.content.removeChild(this.main),s.set2Null(["picker","main","mainStyle","headActiveEle","activeEle","pickerLineEle","__move","__end"],this)}}),t.exports=n},,function(t,e,i){function n(){a.apply(this,arguments)}var a=i(5),s=i(1),r=i(16);a.extend(n,{init:function(){this.needDefFormat&&(this.options.format="HH:mm");var t=this.options.minuteStep;t||(t=5),1!==t&&5!==t&&10!==t&&(t=5),s.extend(this.options,{type:"D",minuteStep:t}),this.panel=this.hoursPanel=new r(this)},initEle:function(){this.ele.classList.add("time-picker-container")},_selV:function(t){var e=this;this["super"]._selV.call(this,t),setTimeout(function(){e.toMinutes()})},_to:function(t,e){this.options.type!==t&&(s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new r(this),this.panel=this[e],this.setDateTime())},toHours:function(){this._to("D","hoursPanel")},toMinutes:function(){this._to("H","minutesPanel")}}),t.exports=n}])}); \ No newline at end of file diff --git a/package.json b/package.json index 508e42c..b37dc38 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "date-time-picker", "library": "DateTimePicker", - "version": "0.5.0", + "version": "0.5.1", "description": "No Dependencies Lightweight Material Date/Time Picker For Mobile Web", "main": "src/date+time.js", "scripts": {