!function(t){var e="undefined"!=typeof window?window:this;"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e):function(e){if(!e.document)throw new Error("document is a undefined");return t(e)}:t(e)}(function(t){function e(){var t=new Date;this.past=!1,this.hours=!1,this.hoursPast=!1,this.currentNode=null,this.minDate=null,this.maxDate=null,this.shield="[]",this.startDate="",this.startJSON={},this.fixDate={y:t.getFullYear(),m:t.getMonth()+1,d:0},this.init()}function a(t,e){function a(a){function n(t){if(w)return!1;var a=t.targetTouches?t.targetTouches[0]:t||event;return s=a.pageX-o,Math.abs(s)>=c&&(w=!0,e&&e(d,s)),a.preventDefault&&a.preventDefault(),!1}function i(){this.onmousemove&&(this.onmousemove=null),this.onmouseup&&(this.onmouseup=null),this.removeEventListener("touchmove",n,!1),this.removeEventListener("touchend",i,!1),w=!1}var s,r=a.targetTouches?a.targetTouches[0]:a||event,o=r.pageX,c=parseInt(document.documentElement.clientWidth/5,10),d=this;this.onmousemove=n,this.onmouseup=i,t.addEventListener("touchmove",n,!1),t.addEventListener("touchend",i,!1)}t.onmousedown=a,t.addEventListener("touchstart",a,!1)}function n(t,e,a){return void 0===t||void 0===e||void 0===a?null:new Date(t,e,a,23,59,59).getTime()}function i(t,e){switch(e.charAt(0)){case"#":return t.querySelector(e);case".":return t.querySelectorAll(e);default:return t.querySelectorAll(e)}}function s(t,e,a){if(t){e=e||{},a=a||"";var n=document.createElement(t);for(var i in e)n.setAttribute(i,e[i]);return n.innerHTML=a,n}}function r(){L.classList.add("close"),setTimeout(function(){L.classList.remove("active","close")},290)}function o(t,e){if(!t)return!1;var a=e||"y/m/d",n=t.split("/"),i=a.match(/[^a-z\d]/i)[0],s={y:n[0],m:d(n[1]),d:d(n[2])};return a.split(/[^a-z]/i).map(function(t){return s[t.charAt(0).toLocaleLowerCase()]}).join(i)}function c(t){if(!t)return[];var e=[];return/^\[|\]$/.test(t)?e=JSON.parse(t.replace(/\'/g,'"')):/^\d+[\/-]\d+[\/-]\d+$/.test(t)&&(e=[t]),e.map(function(t){var e=new Date(t+" 23:59:59");return{y:e.getFullYear(),m:e.getMonth()+1,d:e.getDate()}})}function d(t){return Number(t)<10?"0"+t:t}function l(t,e,a){switch(arguments.length){case 3:t.setAttribute(e,a);break;case 2:return t.getAttribute(e)}}var h,u,p,v,f,m,y,g=0,D=0,w=!1,L=s("div",{"class":"calendar"}),x=s("div",{"class":"calendar-mask"}),C=s("div",{"class":"calendar-content"}),N=s("div",{"class":"calendar-list"});return e.prototype.init=function(){var t=this,e=document.querySelectorAll(".calendars");if(e.length){L.appendChild(x),L.appendChild(C),document.body.appendChild(L),this.createHeader(function(){this.createWeek(),C.appendChild(N),a(N,function(t,e){e>0?g--:g++,this.startJSON.prev.m=g-1,this.startJSON.now.m=g,this.startJSON.next.m=g+1,this.transitions(t,e)}.bind(this)),h.forEach(function(t){t.onclick=function(){this.classList.contains("calendar-month-txt")?(y.classList.toggle("active"),m.show&&(m.show=!1,m.classList.remove("active")),u.forEach(function(t){l(t,"data-value")===l(this,"data-value")?t.classList.add("active"):t.classList.remove("active")}.bind(this)),y.show=!y.show):this.classList.contains("calendar-year-txt")&&(m.classList.toggle("active"),y.show&&(y.classList.remove("active"),y.show=!1),p.forEach(function(t){var e=t.classList;l(t,"data-value")===l(this,"data-value")?e.add("active"):e.remove("active")}.bind(this)),m.show=!m.show)}})}.bind(this)),this.createDate({},function(e){for(var a=0;a0?(m.index++,m.index>=0&&(m.index=0)):(m.index--,m.index<=-a&&(m.index=-(a-1)));var n="translate3D("+m.index*(100/a)+"%, 0, 0)";m.style.WebkitTransform=n,m.style.transform=n})})),L.classList.add("active"),t.currentNode=this}});C.onclick=function(t){var e=t.targetTouches?t.targetTouches[0]:t||event;e.cancelBubble=!0},x.onclick=r}},e.prototype.createCalenList=function(t,e){function a(t,e,a){if(!i.shield)return!1;for(var n=0;n0;C--)x.push(C);e&&(v.innerHTML=D,f.innerHTML=w<10?"0"+w:w,l(v,"data-value",D),l(f,"data-value",w-1));var N=y+7;N=N>=10?N-7:N;for(var C=0;CJ)&&S.classList.add("expire","pasted"),(T===j||i.fixDate.y===D&&i.fixDate.m===w&&i.fixDate.d===O)&&S.classList.add("today"),a(D,w,O)&&S.classList.add("pasted","shield"),b.appendChild(S),r.appendChild(b)}for(var M=42-r.children.length,C=0;C=12&&(a.appendChild(n),n=s("div"),r=0,o++),l==d&&(c=o),h.appendChild(v),n.appendChild(h)):(h.appendChild(v),a.appendChild(h)),r++}if("year"==t.type){m&&C&&C.removeChild(m),a.appendChild(n),m=a,p=i,r&&o++,a.style.width=100*o+"%";for(var l=0;l0?g++:g--,a.startJSON.prev.m=g-1,a.startJSON.now.m=g,a.startJSON.next.m=g+1,a.transitions(N,t>0?-1:1);break;case"year":a.appendList({prev:{m:g,y:D-1},next:{m:g,y:D+1}},function(){t>0?D++:D--,a.startJSON.prev.y=D,a.startJSON.now.y=D,a.startJSON.next.y=D,a.transitions(N,t>0?-1:1)})}},e.prototype.transitions=function(t,e){t.classList.add("silde",e>0?"prev-to":"next-to"),setTimeout(function(){this.appendList(this.startJSON,function(){t.classList.remove("silde","prev-to","next-to"),this.addEvent()}.bind(this))}.bind(this),500)},e.prototype.selectDate=function(t,e,a,n){var i=this;this.startJSON.prev[a]="m"==a?n-1:n,this.startJSON.now[a]=n,this.startJSON.next[a]="m"==a?n+1:n,this.appendList(this.startJSON,i.addEvent.bind(this)),t.classList.add("active"),e.classList.remove("active"),m.show=!1,y.show=!1},e.prototype.changes=function(){var e=t.jQuery||t.$||null;e?e(this.currentNode)&&e(this.currentNode).change&&e(this.currentNode).change():this.currentNode.onchange&&this.currentNode.onchange()},t.addEventListener("load",function(){new e},!1),e});