From 8d226a4b07500e866ff025e18b47613bf742636b Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 25 Oct 2016 21:08:37 +0800 Subject: [PATCH] build --- dist/date-picker.min.js | 2 +- dist/date-time-picker.min.css | 2 +- dist/date-time-picker.min.js | 2 +- dist/time-picker.min.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/date-picker.min.js b/dist/date-picker.min.js index 0ad0520..dabb4be 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 h(t){return"undefined"==typeof t}function c(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:c,isUndefined:h,each:d,noop:l,extend:p,pad:f,set2Null:m}},function(t,e,i){function n(t){this.options=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=i(1),r=i(2),o={C:{value:"year",rows:function(t){for(var e=[],i=1900,n=2100,a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=0,n=11,a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=s.getDaysInMonthOfDate(i),a=0,r=1,o=s.getFirstDayOfMonth(t.now),h=null;r<=n;)a%7===0&&(h=[],e.push(h)),h.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},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"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,i){var n=i.now,a=s.toDate(n);return a[e](t),a})}),s.extend(n.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),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.formatValue=null,this.options=t,this.needDefFormat=!this.options.format,this.init(),this.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),h="touchstart",c="touchmove",d="touchend",l="touchcancel",u=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=u,t.prototype=new i,t.prototype["super"]=u,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(u,{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.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)},desEvts:function(){this._removeEvt(h),this._removeEvt(c),this._removeEvt(d),this._removeEvt(l)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(h),this._addEvt(c),this._addEvt(d),this._addEvt(l)},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;this.shouldSet(i)&&this.changeTo(i)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__touchstart:function(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.__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.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;this["__"+e](t),this._handleEvent(t)},_handleEvent:function(t){for(var e=t.__target||t.target,i="data-"+(t.__type||t.type),n="";e&&e!==this.rootEle&&!(n=e.getAttribute(i));)e=e.parentNode;n&&(t.realTarget=e,this.panel&&this.panel[n]?this.panel[n](t):this[n]&&this[n](t))},show:function(){this.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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","formatValue","lang"],this)}},s);var p=["selfChange","render","__start","__move","__end"];p.forEach(function(t){u[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(h,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=c,a="",s=0,o=[""],h="",d=new Date(2e3,0,1);s
'+s.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=r.year===a.year&&r.month===a.month&&t===a.date?"picker-now":"";return t===r.date&&(e?e+=" picker-active":e="picker-active"),e&&(e=' class="'+e+'"'),'"+t+""}).join("")+"
"}).join("")+"
"}var s=i(1);s.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+'
'+s.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=s.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=s.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,r=a*Math.abs(t-e),o=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(s.prefixNames.transitionEnd,o,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[s.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=o,this.mainStyle[s.prefixNames.transform]="translateX("+t+"%) translateZ(0)",r>0?(this._slideEndFn.tid=window.setTimeout(o,r),r+="ms",this.mainStyle.webkitTransition=r,this.mainStyle.transition=r):o(),this.main.addEventListener(s.prefixNames.transitionEnd,o,!1)},_befChange:function(t){return s.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,r=a,o=!1;this.__move=function(t){var e=t.touches[0],h=e.pageX-i;h=100*h/n.mainWidth;var c=Math.abs(h);c>100&&(h=h>0?100:-100),o=c>55,r=a+h,n.arrowStyle.opacity=(100-.9*c)/100,n.mainStyle[s.prefixNames.transform]="translateX("+r+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,o?n[r>a?"prevMonth":"nextMonth"](r):n._slideTo(a,r)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),s.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),h={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=h[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,h=a,c=t.timeStamp,d=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;h=a+s;var r=t.timeStamp;r-c>300&&(c=r,d=h),n.mainStyle[o.prefixNames.transform]="translateY("+h+"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,h=n.rows[0][0],c=n.rows[n.rows.length-1][0];return oc?(s=r-c,o=c,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-c;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;du&&(d=u);var p=r(h,d,a);h=p.destination,e=p.speed}var f=l(h),m=f.realTo,v=f.targetV;void 0===e?(e=100*Math.abs(m-h)/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),h=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(){this.prevDateTime=new r(s.extend({},this.options,{"default":s.prevMonth(this.dateTime.now)})),this.nextDateTime=new r(s.extend({},this.options,{"default":s.nextMonth(this.dateTime.now)}))},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.setNow(this.nextDateTime.now)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;this.shouldSet(i)&&this.changeTo(i,!0)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new h(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=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=i(1),r=i(2),o={C:{value:"year",rows:function(t){for(var e=[],i=1900,n=2100,a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=0,n=11,a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=s.getDaysInMonthOfDate(i),a=0,r=1,o=s.getFirstDayOfMonth(t.now),c=null;r<=n;)a%7===0&&(c=[],e.push(c)),c.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},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"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,i){var n=i.now,a=s.toDate(n);return a[e](t),a})}),s.extend(n.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),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.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c="touchstart",h="touchmove",d="touchend",l="touchcancel",u=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=u,t.prototype=new i,t.prototype["super"]=u,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(u,{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.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)},desEvts:function(){this._removeEvt(c),this._removeEvt(h),this._removeEvt(d),this._removeEvt(l)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(c),this._addEvt(h),this._addEvt(d),this._addEvt(l)},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;this.shouldSet(i)&&this.changeTo(i)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__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;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.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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 p=["selfChange","render","__start","__move","__end"];p.forEach(function(t){u[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(2e3,0,1);s
'+s.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=r.year===a.year&&r.month===a.month&&t===a.date?"picker-now":"";t===r.date&&(e?e+=" picker-active":e="picker-active"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}var s=i(1);s.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+'
'+s.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=s.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=s.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,r=a*Math.abs(t-e),o=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(s.prefixNames.transitionEnd,o,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[s.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=o,this.mainStyle[s.prefixNames.transform]="translateX("+t+"%) translateZ(0)",r>0?(this._slideEndFn.tid=window.setTimeout(o,r),r+="ms",this.mainStyle.webkitTransition=r,this.mainStyle.transition=r):o(),this.main.addEventListener(s.prefixNames.transitionEnd,o,!1)},_befChange:function(t){return s.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,r=a,o=!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),o=h>55,r=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[s.prefixNames.transform]="translateX("+r+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,o?n[r>a?"prevMonth":"nextMonth"](r):n._slideTo(a,r)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),s.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(){this.prevDateTime=new r(s.extend({},this.options,{"default":s.prevMonth(this.dateTime.now)})),this.nextDateTime=new r(s.extend({},this.options,{"default":s.nextMonth(this.dateTime.now)}))},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.setNow(this.nextDateTime.now)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;this.shouldSet(i)&&this.changeTo(i,!0)},_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.css b/dist/date-time-picker.min.css index 4ead5c0..0e8bafd 100644 --- a/dist/date-time-picker.min.css +++ b/dist/date-time-picker.min.css @@ -1 +1 @@ -.picker-mask{position:fixed;z-index:1000;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.54)}@-webkit-keyframes pickerShow{0%{opacity:0}to{opacity:1}}@keyframes pickerShow{0%{opacity:0}to{opacity:1}}.picker-mask.time-picker-ani{-webkit-animation:pickerShow .2s linear;animation:pickerShow .2s linear}.picker-container{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);width:280px;opacity:1;font-family:PingFang SC,HanHei SC,Helvetica Neue,Helvetica,sans-serif;line-height:1.5;box-shadow:0 0 10px rgba(0,0,0,.8);-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}.picker-container i{font-style:normal}.picker-head{padding:10px 16px;line-height:1.5;color:#ececec;background-color:#00bcd4}.picker-head-active{color:#fff}.picker-year{font-size:14px;width:4em}.picker-date{font-size:24px;text-indent:-2px}.picker-content{position:relative;overflow:hidden;width:100%;height:224px;font-size:12px;color:rgba(0,0,0,.8);background-color:#fff}.picker-content li,.picker-content ul{list-style:none;margin:0;padding:0}.date-picker-main{width:100%;-webkit-transform:translateX(-100%) translateZ(0);transform:translateX(-100%) translateZ(0)}.date-picker-main:after{content:"";display:table;clear:both}.scroller-picker-main{position:relative;text-align:center}.scroller-picker-main li{padding:10px 0;overflow:hidden}.scroller-picker-main .picker-active{color:#00bcd4}.scroller-picker-midd{position:absolute;top:50%;width:100%;height:40px;margin-top:-20px;box-sizing:border-box}.scroller-picker-midd:after,.scroller-picker-midd:before{content:"";position:absolute;left:0;width:100%;border-top:1px solid #e2e3e5}.scroller-picker-midd:before{top:0;-webkit-transform:scaleY(.5) translateZ(0);-webkit-transform-origin:left top;transform-origin:left top;transform:scaleY(.5) translateZ(0)}.scroller-picker-midd:after{bottom:0;-webkit-transform:scaleY(.5) translateZ(0);-webkit-transform-origin:left bottom;transform-origin:left bottom;transform:scaleY(.5) translateZ(0)}.picker-actions-arrow{z-index:1;position:absolute;top:0;left:8px;right:8px;font-size:14px;line-height:20px}.picker-actions-arrow i{cursor:pointer;float:left;padding:16px 14px}.picker-actions-arrow i:last-child{float:right}.picker-bdy{float:left;width:100%;padding:0 8px;margin-right:-100%;position:relative;box-sizing:border-box}.picker-bdy-curr{left:100%}.picker-bdy-next{left:200%}.date-picker-title{text-align:center;padding:16px;font-size:14px;font-weight:800;line-height:20px}.date-picker-days i{position:relative;width:14.28%;height:12px;padding:6px 0;text-align:center;display:inline-block;line-height:1;vertical-align:top;cursor:pointer;overflow:hidden}.date-picker-days-bdy i span{position:relative}.date-picker-days-bdy i:before{content:"";left:50%;top:50%;width:0;height:0;position:absolute;border-radius:50%;background-color:#00bcd4;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.picker-bdy-curr .date-picker-days-bdy i.picker-active{color:#fff}.picker-bdy-curr .date-picker-days-bdy i.picker-active:before{width:24px;height:24px}.date-picker-days-bdy .picker-now{color:#00bcd4}.date-picker-days-title{font-weight:500}.date-picker-days-bdy i[data-val="0"]{color:transparent}.date-picker-days-bdy i[data-val="0"]:before{content:none}.picker-foot{padding:6px 10px;text-align:right;background-color:#fff}.picker-act{padding:5px 15px;margin-left:10px;color:#393939;text-decoration:none;display:inline-block;font-size:14px;font-weight:600;background-color:transparent;border-radius:2px;-webkit-transition:background-color .2s linear;transition:background-color .2s linear}.picker-act:hover{background-color:hsla(0,0%,60%,.2)}.time-picker-container .picker-head{text-align:center;font-size:38px;font-weight:300}.time-picker-container .picker-cell{margin-left:-20px}.time-picker-container .picker-cell-inner{margin-left:-12px}.time-picker-container .picker-active{z-index:1;color:#fff;pointer-events:none}.time-picker-container .picker-active b{position:absolute;left:50%;top:50%;margin-top:-1px;margin-left:-1px;width:2px;height:2px;background-color:#fff;border-radius:50%}.time-picker-main{position:absolute;top:50%;left:50%;height:200px;width:200px;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);border-radius:50%;background-color:rgba(0,0,0,.05)}.time-picker-main>ul{position:absolute;top:1px;right:1px;bottom:1px;left:1px}.time-picker-main:before{content:"";position:absolute;top:50%;left:50%;width:8px;height:8px;border-radius:50%;background-color:rgba(0,188,212,.9);-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.time-picker-main-minutes>.time-picker-minutes-1{top:10px;right:10px;bottom:10px;left:10px}.time-picker-minutes-1 .picker-cell{width:6px;margin-left:-3px;margin-top:-6px;-webkit-transform-origin:50% 96px;transform-origin:50% 96px}.time-picker-minutes-1 .picker-cell i{margin-top:-3px}.time-picker-minutes-1 .picker-active b{margin-top:-4px}.time-picker-minutes-10 .picker-cell{width:80px;margin-left:-40px}.picker-hour,.picker-minute{display:inline-block;width:46px}.picker-hour{text-align:right}.picker-minute{text-align:left}.picker-cell{position:absolute;color:rgba(0,0,0,.8);top:0;left:50%;width:40px;height:28px;-webkit-transform-origin:50% 99px;transform-origin:50% 99px;-webkit-transition:all .2s;transition:all .2s}.picker-cell i{position:absolute;top:50%;left:50%;pointer-events:none}.picker-cell-inner{top:30px;width:24px;height:24px;-webkit-transform-origin:50% 69px;transform-origin:50% 69px}.time-picker-line{top:99px;left:100px;width:70px;height:2px;pointer-events:none;-webkit-transform-origin:0 50%;transform-origin:0 50%;-webkit-transition:all .2s;transition:all .2s}.time-picker-line,.time-picker-line:before{position:absolute;background-color:rgba(0,188,212,.9)}.time-picker-line:before{content:"";left:100%;top:0;margin-top:-14px;width:30px;height:30px;border-radius:50%}.time-picker-line-inner{width:42px} \ No newline at end of file +.picker-mask{position:fixed;z-index:1000;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.54)}@-webkit-keyframes pickerShow{0%{opacity:0}to{opacity:1}}@keyframes pickerShow{0%{opacity:0}to{opacity:1}}.picker-mask.time-picker-ani{-webkit-animation:pickerShow .2s linear;animation:pickerShow .2s linear}.picker-container{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);width:280px;opacity:1;font-family:PingFang SC,HanHei SC,Helvetica Neue,Helvetica,sans-serif;line-height:1.5;box-shadow:0 0 10px rgba(0,0,0,.8);-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}.picker-container i{font-style:normal}.picker-container [data-active]{position:relative}.picker-container [data-active]:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;background-image:-webkit-radial-gradient(circle,#000 10%,transparent 10.01%);background-image:radial-gradient(circle,#000 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;pointer-events:none;background-size:0 0;opacity:0;-webkit-transition:background .5s,opacity 1s;transition:background .5s,opacity 1s}.picker-container .active:after{background-size:1000% 1000%;opacity:.2}.picker-head{padding:10px 16px;line-height:1.5;color:#ececec;background-color:#00bcd4}.picker-head-active{color:#fff}.picker-year{font-size:14px;width:4em}.picker-date{font-size:24px;text-indent:-2px}.picker-content{position:relative;overflow:hidden;width:100%;height:224px;font-size:12px;color:rgba(0,0,0,.8);background-color:#fff}.picker-content li,.picker-content ul{list-style:none;margin:0;padding:0}.date-picker-main{width:100%;-webkit-transform:translateX(-100%) translateZ(0);transform:translateX(-100%) translateZ(0)}.date-picker-main:after{content:"";display:table;clear:both}.scroller-picker-main{position:relative;text-align:center}.scroller-picker-main li{padding:10px 0;overflow:hidden}.scroller-picker-main .picker-active{color:#00bcd4}.scroller-picker-midd{position:absolute;top:50%;width:100%;height:40px;margin-top:-20px;box-sizing:border-box}.scroller-picker-midd:after,.scroller-picker-midd:before{content:"";position:absolute;left:0;width:100%;border-top:1px solid #e2e3e5}.scroller-picker-midd:before{top:0;-webkit-transform:scaleY(.5) translateZ(0);-webkit-transform-origin:left top;transform-origin:left top;transform:scaleY(.5) translateZ(0)}.scroller-picker-midd:after{bottom:0;-webkit-transform:scaleY(.5) translateZ(0);-webkit-transform-origin:left bottom;transform-origin:left bottom;transform:scaleY(.5) translateZ(0)}.picker-actions-arrow{z-index:1;position:absolute;top:0;left:8px;right:8px;font-size:14px;line-height:20px}.picker-actions-arrow i{cursor:pointer;float:left;padding:16px 14px}.picker-actions-arrow i:last-child{float:right}.picker-actions-arrow i[data-active]:after{height:42px;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);border-radius:50%}.picker-bdy{float:left;width:100%;padding:0 8px;margin-right:-100%;position:relative;box-sizing:border-box}.picker-bdy-curr{left:100%}.picker-bdy-next{left:200%}.date-picker-title{text-align:center;padding:16px;font-size:14px;font-weight:800;line-height:20px}.date-picker-days i{position:relative;width:14.28%;height:12px;padding:6px 0;text-align:center;display:inline-block;line-height:1;vertical-align:top;cursor:pointer;overflow:hidden}.date-picker-days i[data-active]:after{width:24px;left:50%;-webkit-transform:translate(-50%);transform:translate(-50%);border-radius:50%}.date-picker-days-bdy i span{position:relative}.date-picker-days-bdy i:before{content:"";left:50%;top:50%;width:0;height:0;position:absolute;border-radius:50%;background-color:#00bcd4;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.picker-bdy-curr .date-picker-days-bdy i.picker-active{color:#fff}.picker-bdy-curr .date-picker-days-bdy i.picker-active:before{width:24px;height:24px}.date-picker-days-bdy .picker-now{color:#00bcd4}.date-picker-days-title{font-weight:500}.date-picker-days-bdy i[data-val="0"]{color:transparent}.date-picker-days-bdy i[data-val="0"]:before{content:none}.picker-foot{padding:6px 10px;text-align:right;background-color:#fff}.picker-act{padding:5px 15px;margin-left:10px;color:#393939;text-decoration:none;display:inline-block;font-size:14px;font-weight:600;background-color:transparent;border-radius:2px;-webkit-transition:background-color .2s linear;transition:background-color .2s linear}.picker-act:hover{background-color:hsla(0,0%,60%,.2)}.time-picker-container .picker-head{text-align:center;font-size:38px;font-weight:300}.time-picker-container .picker-cell{margin-left:-20px}.time-picker-container .picker-cell[data-active]:after{width:30px;height:30px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);border-radius:50%}.time-picker-container .picker-cell-inner{margin-left:-12px}.time-picker-container .picker-active{z-index:1;color:#fff;pointer-events:none}.time-picker-container .picker-active b{position:absolute;left:50%;top:50%;margin-top:-1px;margin-left:-1px;width:2px;height:2px;background-color:#fff;border-radius:50%}.time-picker-main{position:absolute;top:50%;left:50%;height:200px;width:200px;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);border-radius:50%;background-color:rgba(0,0,0,.05)}.time-picker-main>ul{position:absolute;top:1px;right:1px;bottom:1px;left:1px}.time-picker-main:before{content:"";position:absolute;top:50%;left:50%;width:8px;height:8px;border-radius:50%;background-color:rgba(0,188,212,.9);-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.time-picker-main-minutes>.time-picker-minutes-1{top:10px;right:10px;bottom:10px;left:10px}.time-picker-minutes-1 .picker-cell{width:6px;margin-left:-3px;margin-top:-6px;-webkit-transform-origin:50% 96px;transform-origin:50% 96px}.time-picker-minutes-1 .picker-cell i{margin-top:-3px}.time-picker-minutes-1 .picker-active b{margin-top:-4px}.time-picker-minutes-10 .picker-cell{width:80px;margin-left:-40px}.picker-hour,.picker-minute{display:inline-block;width:46px}.picker-hour[data-active]:after,.picker-minute[data-active]:after{height:46px;top:5px}.picker-hour{text-align:right}.picker-minute{text-align:left}.picker-cell{position:absolute!important;color:rgba(0,0,0,.8);top:0;left:50%;width:40px;height:28px;-webkit-transform-origin:50% 99px;transform-origin:50% 99px;-webkit-transition:all .2s;transition:all .2s}.picker-cell i{position:absolute;top:50%;left:50%;pointer-events:none}.picker-cell-inner{top:30px;width:24px;height:24px;-webkit-transform-origin:50% 69px;transform-origin:50% 69px}.time-picker-line{top:99px;left:100px;width:70px;height:2px;pointer-events:none;-webkit-transform-origin:0 50%;transform-origin:0 50%;-webkit-transition:all .2s;transition:all .2s}.time-picker-line,.time-picker-line:before{position:absolute;background-color:rgba(0,188,212,.9)}.time-picker-line:before{content:"";left:100%;top:0;margin-top:-14px;width:30px;height:30px;border-radius:50%}.time-picker-line-inner{width:42px} \ No newline at end of file diff --git a/dist/date-time-picker.min.js b/dist/date-time-picker.min.js index 7e7f349..889603c 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 h(t){return"undefined"==typeof t}function c(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 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:c,isUndefined:h,each:l,noop:d,extend:p,pad:f,set2Null:m}},function(t,e,i){function n(t){this.options=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=i(1),r=i(2),o={C:{value:"year",rows:function(t){for(var e=[],i=1900,n=2100,a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=0,n=11,a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=s.getDaysInMonthOfDate(i),a=0,r=1,o=s.getFirstDayOfMonth(t.now),h=null;r<=n;)a%7===0&&(h=[],e.push(h)),h.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},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"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,i){var n=i.now,a=s.toDate(n);return a[e](t),a})}),s.extend(n.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),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.formatValue=null,this.options=t,this.needDefFormat=!this.options.format,this.init(),this.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),h="touchstart",c="touchmove",l="touchend",d="touchcancel",u=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=u,t.prototype=new i,t.prototype["super"]=u,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(u,{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.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)},desEvts:function(){this._removeEvt(h),this._removeEvt(c),this._removeEvt(l),this._removeEvt(d)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(h),this._addEvt(c),this._addEvt(l),this._addEvt(d)},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;this.shouldSet(i)&&this.changeTo(i)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__touchstart:function(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.__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.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;this["__"+e](t),this._handleEvent(t)},_handleEvent:function(t){for(var e=t.__target||t.target,i="data-"+(t.__type||t.type),n="";e&&e!==this.rootEle&&!(n=e.getAttribute(i));)e=e.parentNode;n&&(t.realTarget=e,this.panel&&this.panel[n]?this.panel[n](t):this[n]&&this[n](t))},show:function(){this.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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","formatValue","lang"],this)}},s);var p=["selfChange","render","__start","__move","__end"];p.forEach(function(t){u[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(h,function(t,e){var i=n[e];return void 0===i?e:i})}function a(t,e){for(var i,n=c,a="",s=0,o=[""],h="",l=new Date(2e3,0,1);s
'+s.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=r.year===a.year&&r.month===a.month&&t===a.date?"picker-now":"";return t===r.date&&(e?e+=" picker-active":e="picker-active"),e&&(e=' class="'+e+'"'),'"+t+""}).join("")+"
"}).join("")+"
"}var s=i(1);s.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+'
'+s.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=s.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=s.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,r=a*Math.abs(t-e),o=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(s.prefixNames.transitionEnd,o,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[s.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=o,this.mainStyle[s.prefixNames.transform]="translateX("+t+"%) translateZ(0)",r>0?(this._slideEndFn.tid=window.setTimeout(o,r),r+="ms",this.mainStyle.webkitTransition=r,this.mainStyle.transition=r):o(),this.main.addEventListener(s.prefixNames.transitionEnd,o,!1)},_befChange:function(t){return s.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,r=a,o=!1;this.__move=function(t){var e=t.touches[0],h=e.pageX-i;h=100*h/n.mainWidth;var c=Math.abs(h);c>100&&(h=h>0?100:-100),o=c>55,r=a+h,n.arrowStyle.opacity=(100-.9*c)/100,n.mainStyle[s.prefixNames.transform]="translateX("+r+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,o?n[r>a?"prevMonth":"nextMonth"](r):n._slideTo(a,r)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),s.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),h={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=h[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,h=a,c=t.timeStamp,l=a;this.__move=function(t){var e=t.touches[0],s=e.pageY-i;h=a+s;var r=t.timeStamp;r-c>300&&(c=r,l=h),n.mainStyle[o.prefixNames.transform]="translateY("+h+"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,h=n.rows[0][0],c=n.rows[n.rows.length-1][0];return oc?(s=r-c,o=c,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-c;if(a<300){var o=-n.rows.length*n.itemHeight,u=n.contentHeight;lu&&(l=u);var p=r(h,l,a);h=p.destination,e=p.speed}var f=d(h),m=f.realTo,v=f.targetV;void 0===e?(e=100*Math.abs(m-h)/n.itemHeight,e>50&&(e=20)):e=Math.abs(m-l)/e,n._slideTo(m,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 s=a.length,r=i(a),o=r!==s,h=360/r,c="",l=1;"minutes"===t&&(l=n.options.minuteStep||5,c+="time-picker-minutes-"+l);var d=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+";"},u=n.parsedNow[t],p="",f="";return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===u){a=" picker-active";var s="rotate("+(h*i-90)+"deg)";p="-webkit-transform:"+s+";transform:"+s,o&&(!n||n>12)&&(f+=" time-picker-line-inner")}return l>1&&i%l!==0?"":(o&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,d)+"
  • ")}).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),h=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(){this.prevDateTime=new r(s.extend({},this.options,{"default":s.prevMonth(this.dateTime.now)})),this.nextDateTime=new r(s.extend({},this.options,{"default":s.nextMonth(this.dateTime.now)}))},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.setNow(this.nextDateTime.now)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;this.shouldSet(i)&&this.changeTo(i,!0)},_to:function(t,e){s.extend(this.options,{type:t}),this.panel.hide(),this[e]?this[e].show():this[e]=new h(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 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:l,noop:d,extend:p,pad:f,set2Null:m}},function(t,e,i){function n(t){this.options=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=i(1),r=i(2),o={C:{value:"year",rows:function(t){for(var e=[],i=1900,n=2100,a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=0,n=11,a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=s.getDaysInMonthOfDate(i),a=0,r=1,o=s.getFirstDayOfMonth(t.now),c=null;r<=n;)a%7===0&&(c=[],e.push(c)),c.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},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"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,i){var n=i.now,a=s.toDate(n);return a[e](t),a})}),s.extend(n.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),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.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c="touchstart",h="touchmove",l="touchend",d="touchcancel",u=n.prototype;n.extend=function(t,e){var i=function(){};return i.prototype=u,t.prototype=new i,t.prototype["super"]=u,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(u,{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.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)},desEvts:function(){this._removeEvt(c),this._removeEvt(h),this._removeEvt(l),this._removeEvt(d)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(c),this._addEvt(h),this._addEvt(l),this._addEvt(d)},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;this.shouldSet(i)&&this.changeTo(i)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__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;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.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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 p=["selfChange","render","__start","__move","__end"];p.forEach(function(t){u[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(2e3,0,1);s
'+s.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=r.year===a.year&&r.month===a.month&&t===a.date?"picker-now":"";t===r.date&&(e?e+=" picker-active":e="picker-active"),e&&(e=' class="'+e+'"');var i=' data-val="'+t+'" ';return t&&(i+='data-active="active" data-click="selV" data-val="'+t+'"'),""+t+""}).join("")+"
"}).join("")+"
"}var s=i(1);s.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+'
'+s.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=s.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=s.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,r=a*Math.abs(t-e),o=function(){n._slideEndFn&&(window.clearTimeout(n._slideEndFn.tid),n._slideEndFn=null,n.main.removeEventListener(s.prefixNames.transitionEnd,o,!1),n.mainStyle.webkitTransition="none 0ms",n.mainStyle.transition="none 0ms",n.mainStyle[s.prefixNames.transform]="translateX(-100%) translateZ(0)",i&&i.call(n))};this._slideEndFn&&this._slideEndFn(),this._slideEndFn=o,this.mainStyle[s.prefixNames.transform]="translateX("+t+"%) translateZ(0)",r>0?(this._slideEndFn.tid=window.setTimeout(o,r),r+="ms",this.mainStyle.webkitTransition=r,this.mainStyle.transition=r):o(),this.main.addEventListener(s.prefixNames.transitionEnd,o,!1)},_befChange:function(t){return s.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,r=a,o=!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),o=h>55,r=a+c,n.arrowStyle.opacity=(100-.9*h)/100,n.mainStyle[s.prefixNames.transform]="translateX("+r+"%) translateZ(0)"},this.__end=function(t){this.__move=null,this.__end=null,n.arrowStyle.opacity=1,o?n[r>a?"prevMonth":"nextMonth"](r):n._slideTo(a,r)},this._slideEndFn&&this._slideEndFn()},destroy:function(){this._slideEndFn&&this._slideEndFn(),this.picker.content.removeChild(this.main),this.picker.content.removeChild(this.arrow),s.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 f=d(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-l)/e,n._slideTo(m,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 s=a.length,r=i(a),o=r!==s,c=360/r,h="",l=1;"minutes"===t&&(l=n.options.minuteStep||5,h+="time-picker-minutes-"+l);var d=function(t,e){var i=c*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},u=n.parsedNow[t],p="",f="";return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===u){a=" picker-active";var s="rotate("+(c*i-90)+"deg)";p="-webkit-transform:"+s+";transform:"+s,o&&(!n||n>12)&&(f+=" time-picker-line-inner")}return l>1&&i%l!==0?"":(o&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,d)+"
  • ")}).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(){this.prevDateTime=new r(s.extend({},this.options,{"default":s.prevMonth(this.dateTime.now)})),this.nextDateTime=new r(s.extend({},this.options,{"default":s.nextMonth(this.dateTime.now)}))},initEle:function(){this.ele.classList.add("date-picker-container")},shouldSet:function(t){return!!t},setNowToPrev:function(){this.setNow(this.prevDateTime.now)},setNowToNext:function(){this.setNow(this.nextDateTime.now)},selV:function(t){var e=t.realTarget,i=e.getAttribute("data-val")-0;this.shouldSet(i)&&this.changeTo(i,!0)},_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 4c7d2c7..f9cb207 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(i){if(n[i])return n[i].exports;var a=n[i]={exports:{},id:i,loaded:!1};return t[i].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){var i=n(11);i.Time=n(18),t.exports=i},function(t,e,n){var i=n(3),a=n(9),s=n(8),r=n(10);t.exports=i.extend({},i,a,s,r)},function(t,e,n){var i=n(1),a={on:function(t,e){this._eventData||(this._eventData={}),this._eventData[t]||(this._eventData[t]=[]);var n=!1;return i.each(this._eventData[t],function(t){if(t===e)return n=!0,!1}),n||this._eventData[t].push(e),this},once:function(t,e){var n=this,i=function(){e.apply(this,arguments),n.off(t,i)};return this.on(t,i),this},off:function(t,e){return this._eventData||(this._eventData={}),this._eventData[t]&&this._eventData[t].length?(e?i.each(this._eventData[t],function(n,i){if(n===e)return this._eventData[t].splice(i,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 i.each(this._eventData[t],function(t){t.apply(null,e)}),this}};t.exports=a},function(t,e){function n(t,e){return v.toString.call(t)==="[object "+e+"]"}function i(t){return n(t,"Function")}function a(t){return n(t,"String")}function s(t){return n(t,"Number")}function r(t){return n(t,"Object")}function o(t){return Array.isArray?Array.isArray(t):n(t,"Array")}function c(t){return"undefined"==typeof t}function h(t){return n(t,"Date")}function u(t,e,n){if(t&&i(e))if(n=n||t,t.length){for(var a=0,s=t.length;a0?e:i)}function m(t,e){t.forEach(function(t){e[t]=null})}var v=Object.prototype;t.exports={isFn:i,isStr:a,isNum:s,isObj:r,isArray:o,isDate:h,isUndefined:c,each:u,noop:l,extend:p,pad:d,set2Null:m}},function(t,e,n){function i(t){this.options=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=n(1),r=n(2),o={C:{value:"year",rows:function(t){for(var e=[],n=1900,i=2100,a=n;a<=i;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],n=0,i=11,a=n;a<=i;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],n=t.now,i=s.getDaysInMonthOfDate(n),a=0,r=1,o=s.getFirstDayOfMonth(t.now),c=null;r<=i;)a%7===0&&(c=[],e.push(c)),c.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},D:{value:"hours",rows:function(t){for(var e=[],n=0,i=23,a=n;a<=i;)e.push([a++]);return e},input:"setHours"},H:{value:"minutes",rows:function(t){for(var e=[],n=0,i=59,a=n;a<=i;)e.push([a++]);return e},input:"setMinutes"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,n){var i=n.now,a=s.toDate(i);return a[e](t),a})}),s.extend(i.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),t.exports=i},function(t,e,n){function i(t,e){this.container=document.body,t||(t={}),this.lang=t.lang||"EN",this.lang=t.lang;var n=o[this.lang];n||(n=o.EN),this.config=a.extend(n,e||{}),this.formatValue=null,this.options=t,this.needDefFormat=!this.options.format,this.init(),this.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=n(1),s=n(2),r=n(4),o=n(12),c="touchstart",h="touchmove",u="touchend",l="touchcancel",f=i.prototype;i.extend=function(t,e){var n=function(){};return n.prototype=f,t.prototype=new n,t.prototype["super"]=f,t.prototype.constructor=t,a.extend(t.prototype,e||{}),t},a.extend(f,{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.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)},desEvts:function(){this._removeEvt(c),this._removeEvt(h),this._removeEvt(u),this._removeEvt(l)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(c),this._addEvt(h),this._addEvt(u),this._addEvt(l)},changeTo:function(t,e){this.options["default"]=this.dateTime.getInputValue(t),this.setDateTime(e)},selV:function(t){var e=t.realTarget,n=e.getAttribute("data-val")-0;this.shouldSet(n)&&this.changeTo(n)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__touchstart:function(t){this.__start(t);var e=t.target,n=t.targetTouches[0];this.__s_x=n.pageX,this.__s_y=n.pageY,this.__startTime=t.timeStamp,this.__target=e},__touchmove:function(t){if(this.__move(t),this.__target){var e=t.changedTouches[0],n=10;(this.__target!==t.target||Math.abs(e.pageX-this.__s_x)>n||Math.abs(e.pageY-this.__s_y)>n)&&(this.__target=null)}},__touchend:function(t){if(this.__end(t),this.__target){var e=t.timeStamp;if(!(e-this.__lastTime<200||e-this.__startTime>700)){var n=this.__target;this.__lastTime=e,this.__target=null,t.__target=n,t.__type="click"}}},__touchcancel:function(t){this.__end(t),this.__target=null},handleEvent:function(t){this._stop(t);var e=t.type;this["__"+e](t),this._handleEvent(t)},_handleEvent:function(t){for(var e=t.__target||t.target,n="data-"+(t.__type||t.type),i="";e&&e!==this.rootEle&&!(i=e.getAttribute(n));)e=e.parentNode;i&&(t.realTarget=e,this.panel&&this.panel[i]?this.panel[i](t):this[i]&&this[i](t))},show:function(){this.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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","formatValue","lang"],this)}},s);var p=["selfChange","render","__start","__move","__end"];p.forEach(function(t){f[t]=function(){this.panel&&this.panel[t]&&this.panel[t].apply(this.panel,arguments)}}),t.exports=i},function(t,e,n){function i(t,e){var n,i={},a=e.indexOf("a")!==-1||e.indexOf("A")!==-1;return i.d=t.getDate(),i.dd=o(i.d,2),n=t.getDay(),i.D=n,i.DD=n,i.M=t.getMonth()+1,n=i.M,i.MM=o(n,2),i.yyyy=t.getFullYear(),n=i.yyyy,i.yyy=o(n,2)+"y",i.yy=o(n,2),i.y="y",i.H=t.getHours(),n=i.H,i.hh=o(a?s(n):n,2),i.h=a?s(n):n,i.HH=o(n,2),n=i.H<12,i.ap=n?"am":"pm",i.a=n?"am":"pm",i.AP=n?"AM":"PM",i.A=n?"AM":"PM",i.m=t.getMinutes(),i.mm=o(i.m,2),i.s=t.getSeconds(),i.ss=o(i.s,2),i.z=t.getMilliseconds(),n=i.z,i.zz=n+"z",i.zzz=o(n,3),e.replace(c,function(t,e){var n=i[e];return void 0===n?e:n})}function a(t,e){for(var n,i=h,a="",s=0,o=[""],c="",u=new Date(2e3,0,1);s'+t+""}),n||(n=function(t){return t.length}),function(i,a){var s=a.length,r=n(a),o=r!==s,c=360/r,h="",u=1;"minutes"===t&&(u=i.options.minuteStep||5,h+="time-picker-minutes-"+u);var l=function(t,e){var n=c*t,i="";return e&&(n=-n,i="translate(-50%, -50%) "),i+="rotate("+n+"deg)","-webkit-transform:"+i+";transform:"+i+";"},f=i.parsedNow[t],p="",d="";return'
    '+a.map(function(t,n){var i=t[0],a="";if(i===f){a=" picker-active";var s="rotate("+(c*n-90)+"deg)";p="-webkit-transform:"+s+";transform:"+s,o&&(!i||i>12)&&(d+=" time-picker-line-inner")}return u>1&&n%u!==0?"":(o&&(!i||i>12)&&(a+=" picker-cell-inner"),'
  • '+e(i,n,l)+"
  • ")}).join("")+'
'}}var s=n(1),r={D:a("hours",null,function(t){return t.length/2}),H:a("minutes",function(t,e,n){return e%5===0?''+s.pad(t,2)+"":""})};s.extend(i.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 n=+e.style[s.prefixNames.transform].match(/rotate\((-?\d+)deg\)/)[1];n-=90,this.pickerLineEle.style[s.prefixNames.transform]="rotate("+n+"deg)",this.pickerLineEle.classList[e.classList.contains("picker-cell-inner")?"add":"remove"]("time-picker-line-inner")},_start:function(t){var e=this,n=null,i=function(t){var i=document.elementFromPoint(t.pageX,t.pageY);(i&&i.classList.contains("picker-cell")||(i=i.parentElement)&&i.classList.contains("picker-cell"))&&(n=i,e.picker.changeTo(i.getAttribute("data-val"),!0))};i(t.touches[0]),this.__move=function(t){i(t.touches[0])},this.__end=function(t){this.__move=null,this.__end=null,n&&e.picker.selV({realTarget:n})}},destroy:function(){this.picker.content.removeChild(this.main),s.set2Null(["picker","main","mainStyle","headActiveEle","activeEle","pickerLineEle","__move","__end"],this)}}),t.exports=i},,function(t,e,n){function i(){a.apply(this,arguments)}var a=n(5),s=n(1),r=n(16);a.extend(i,{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=i}])}); \ 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:p,pad:d,set2Null:m}},function(t,e,i){function n(t){this.options=s.extend({"default":new Date,type:"M"},t||{});var e=s.toDate(this.options["default"]);e||(e=new Date),this.updateNow(e)}function a(t){return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),hours:t.getHours(),minutes:t.getMinutes()}}var s=i(1),r=i(2),o={C:{value:"year",rows:function(t){for(var e=[],i=1900,n=2100,a=i;a<=n;)e.push([a++]);return e},input:"setFullYear"},Y:{value:"month",rows:function(t){for(var e=[],i=0,n=11,a=i;a<=n;)e.push([a++]);return e},input:"setMonth"},M:{value:"date",rows:function(t){for(var e=[],i=t.now,n=s.getDaysInMonthOfDate(i),a=0,r=1,o=s.getFirstDayOfMonth(t.now),c=null;r<=n;)a%7===0&&(c=[],e.push(c)),c.push(ar?(a.setDate(t),a=s.nextMonth(a)):(a.setDate(t),a=s.prevMonth(a)),a}},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"}};s.each(o,function(t){var e=t.input;s.isStr(e)&&(t.input=function(t,i){var n=i.now,a=s.toDate(n);return a[e](t),a})}),s.extend(n.prototype,{updateNow:function(t){this.now=new Date(t.getTime()),this.parsedNow=a(this.now)},_getConf:function(){return o[this.options.type]||o.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}},r),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.options.format&&this.options["default"]&&a.isStr(this.options["default"])&&(this.options["default"]=a.parseDate(this.options["default"],this.options.format)),this._init()}var a=i(1),s=i(2),r=i(4),o=i(12),c="touchstart",h="touchmove",u="touchend",l="touchcancel",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,{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.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)},desEvts:function(){this._removeEvt(c),this._removeEvt(h),this._removeEvt(u),this._removeEvt(l)},_stop:function(t){t.preventDefault(),t.stopPropagation()},bindEvts:function(){this._addEvt(c),this._addEvt(h),this._addEvt(u),this._addEvt(l)},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;this.shouldSet(i)&&this.changeTo(i)},shouldSet:function(t){return!0},cancel:function(){this.trigger("canceled"),this.hide(),this.destroy()},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(),this.destroy()},__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;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.ele&&(this.ele.style.display="block")},hide:function(){this.ele&&(this.ele.style.display="none")},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 p=["selfChange","render","__start","__move","__end"];p.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="",u=new Date(2e3,0,1);s'+t+""}),i||(i=function(t){return t.length}),function(n,a){var s=a.length,r=i(a),o=r!==s,c=360/r,h="",u=1;"minutes"===t&&(u=n.options.minuteStep||5,h+="time-picker-minutes-"+u);var l=function(t,e){var i=c*t,n="";return e&&(i=-i,n="translate(-50%, -50%) "),n+="rotate("+i+"deg)","-webkit-transform:"+n+";transform:"+n+";"},f=n.parsedNow[t],p="",d="";return'
    '+a.map(function(t,i){var n=t[0],a="";if(n===f){a=" picker-active";var s="rotate("+(c*i-90)+"deg)";p="-webkit-transform:"+s+";transform:"+s,o&&(!n||n>12)&&(d+=" time-picker-line-inner")}return u>1&&i%u!==0?"":(o&&(!n||n>12)&&(a+=" picker-cell-inner"),'
  • '+e(n,i,l)+"
  • ")}).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