jedate.min.js
24.9 KB
/**
@Name : jeDate v3.2 日期控件
@Author: chen guojun
@Date: 2016-8-14
@QQ群:516754269
@官网:http://www.jayui.com/jedate/ 或 https://github.com/singod/jeDate
*/
window.console&&(console=console||{log:function(){}}),function(a,b){"function"==typeof define&&define.amd?define(["jeDate"],b):"object"==typeof exports?module.exports=b(require("jeDate")):a.jeDate=b(a.jeDate)}(this,function(a){var h,b={},c=document,d=/\w+|d+/g,e=window.parseInt,f=function(a){return e(a,10)},g=function(){function a(l,m){var n,o,p,q,r,s;if(m=m||document,!/^[\w\-_#]+$/.test(l)&&m.querySelectorAll)return b(m.querySelectorAll(l));if(-1<l.indexOf(",")){for(n=l.split(/,/g),o=[],p=0,q=n.length;q>p;++p)o=o.concat(a(n[p],m));return k(o)}if(n=l.match(e),o=n.pop(),q=(o.match(g)||i)[1],r=!q&&(o.match(f)||i)[1],p=!q&&(o.match(h)||i)[1],o=l.match(/\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\]/g),r&&!o&&!p&&m.getElementsByClassName)p=b(m.getElementsByClassName(r));else{if(p=!q&&b(m.getElementsByTagName(p||"*")),r&&(p=d(p,"className",RegExp("(^|\\s)"+r+"(\\s|$)"))),q)return(n=m.getElementById(q))?[n]:[];if(o)for(q=0;q<o.length;q++)r=(o[q].match(j)||i)[1],s=(o[q].match(j)||i)[2],s=s.replace(/\'/g,"").replace(/\-/g,"\\-").replace(/\[/g,"\\[").replace(/\]/g,"\\]"),p=d(p,r,RegExp("(^"+s+"$)"))}return n[0]&&p[0]?c(n,p):p}function b(a){try{return Array.prototype.slice.call(a)}catch(b){for(var c=[],d=0,e=a.length;e>d;++d)c[d]=a[d];return c}}function c(a,b,d){var o,p,q,j,k,l,m,n,e=a.pop();if(">"===e)return c(a,b,!0);for(j=[],k=-1,l=(e.match(g)||i)[1],m=!l&&(e.match(f)||i)[1],e=!l&&(e.match(h)||i)[1],n=-1,e=e&&e.toLowerCase();o=b[++n];){p=o.parentNode;do if(q=(q=(q=!e||"*"===e||e===p.nodeName.toLowerCase())&&(!l||p.id===l))&&(!m||RegExp("(^|\\s)"+m+"(\\s|$)").test(p.className)),d||q)break;while(p=p.parentNode);q&&(j[++k]=o)}return a[0]&&j[0]?c(a,j):j}function d(a,b,c){for(var e,d=-1,f=-1,g=[];e=a[++d];)c.test(e.getAttribute(b))&&(g[++f]=e);return g}var e=/(?:[\*\w\-\\.#]+)+(?:\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\])*|\*|>/gi,f=/^(?:[\w\-_]+)?\.([\w\-_]+)/,g=/^(?:[\w\-_]+)?#([\w\-_]+)/,h=/^([\w\*\-_]+)/,i=[null,null,null],j=/\[([\w\-_][^=]+)=([\'\[\]\w\-_]+)\]/,k=function(){var a=+new Date,b=function(){var b=1;return function(c){var d=c[a],e=b++;return d?!1:(c[a]=e,!0)}}();return function(c){for(var h,d=c.length,e=[],f=-1,g=0;d>g;++g)h=c[g],b(h)&&(e[++f]=h);return a+=1,e}}();return a}();return b.isType=function(a,b){return b=b.replace(/\b(\w)|\s(\w)/g,function(a){return a.toUpperCase()}),Object.prototype.toString.call(a)==="[object "+b+"]"},b.each=function(a,c){var d,e,f;if(b.isType(a,"array"))for(d=0,e=a.length;e>d&&c.call(a[d],d,a[d])!==!1;d++);else for(f in a)if(a.hasOwnProperty(f)&&c.call(a[f],f,a[f])===!1)break},b.attr=function(a,b,c){return"string"==typeof b&&"undefined"==typeof c?a.getAttribute(b):(a.setAttribute(b,c),this)},b.stopmp=function(a){return a=a||window.event,a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,this},b.hasClass=function(a,b){return a=a||{},new RegExp("\\b"+b+"\\b").test(a.className)},b.addClass=function(a,c){return a=a||{},b.hasClass(a,c)||(a.className+=" "+c),a.className=a.className.replace(/^\s|\s$/g,"").replace(/\s+/g," "),this},b.removeClass=function(a,c){return a=a||{},b.hasClass(a,c)&&(a.className=a.className.replace(new RegExp("(\\s|^)"+c+"(\\s|$)"),"")),this},b.getStyle=function(a,b){var c=document.defaultView?window.getComputedStyle(a,null)[b]:a.currentStyle[b];return c},b.isShow=function(a,b){a.style.display=1!=b?"none":"block"},b.html=function(a,b){return"undefined"!=typeof b||void 0!==b&&1===a.nodeType?(a.innerHTML=b,this):a.innerHTML},b.text=function(a,c){if(void 0===c||1!==a.nodeType){var d=document.all?a.innerText:a.textContent;return b.trim(d)}return document.all?a.innerText=c:a.textContent=c,this},b.val=function(a,c){return void 0===c||1!==a.nodeType?b.trim(a.value):(a.value=c,this)},b.bind=function(a,c,d){c=c.toLowerCase();var e=function(a){a.attachEvent?a.attachEvent("on"+c,function(){d.call(a,window.type)}):a.addEventListener(c,d,!1)};return a==document?e(document):b.each(a,function(a,b){e(b)})},b.docScroll=function(a){return a=a?"scrollLeft":"scrollTop",c.body[a]|c.documentElement[a]},b.winarea=function(a){return c.documentElement[a?"clientWidth":"clientHeight"]},b.digit=function(a){return 10>a?"0"+(0|a):a},b.parse=function(a,c,d){a=a.concat(c);var e="hh:mm"==b.parseCheck(d,!1).substring(0,5),f=2;return d.replace(/YYYY|MM|DD|hh|mm|ss/g,function(){var g=e?++f:a.index=0|++a.index;return b.digit(a[g])})},b.parseCheck=function(a,b){var c=[];return a.replace(/YYYY|MM|DD|hh|mm|ss/g,function(a){c.push(a)}),c.join(1==b?"-":":")},b.checkFormat=function(a){var b=[];return a.replace(/YYYY|MM|DD|hh|mm|ss/g,function(a){b.push(a)}),b.join("-")},b.parseMatch=function(a){var b=a.split(" ");return b[0].match(d)},b.checkDate=function(a){var b=a.match(/\w+|d+/g);if(isNaN(b[0])||isNaN(b[1])||isNaN(b[2]))return!1;if(b[1]>12||b[1]<1)return!1;if(b[2]<1||b[2]>31)return!1;if((4==b[1]||6==b[1]||9==b[1]||11==b[1])&&b[2]>30)return!1;if(2==b[1]){if(b[2]>29)return!1;if((0==b[0]%100&&0!=b[0]%400||0!=b[0]%4)&&b[2]>28)return!1}return!0},b.trim=function(a){return a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},b.nowDate=function(a,c){var d,e,g,h,i,j,k,l;return c=c||"YYYY-MM-DD hh:mm:ss","string"==typeof a?d=new Date(1e3*f(a)):(a=0|a,d=new Date,e=d.getTime()+864e5*a,d.setTime(e)),g=d.getFullYear(),h=d.getMonth()+1,i=d.getDate(),j=d.getHours(),k=d.getMinutes(),l=d.getSeconds(),b.parse([g,b.digit(h),b.digit(i)],[b.digit(j),b.digit(k),b.digit(l)],c)},b.montharr=[1,2,3,4,5,6,7,8,9,10,11,12],b.weeks=["日","一","二","三","四","五","六"],b.isValHtml=function(a){return/textarea|input/.test(a.tagName.toLocaleLowerCase())},b.festival=function(a,b){var c="";switch(a){case"01.01":c="元旦";break;case"02.14":c="情人";break;case"03.08":c="妇女";break;case"05.01":c="劳动";break;case"06.01":c="儿童";break;case"08.01":c="建军";break;case"09.10":c="教师";break;case"10.01":c="国庆";break;case"12.24":c="平安";break;case"12.25":c="圣诞";break;default:c=b}return c},h={initAddVal:[0],format:"YYYY-MM-DD hh:mm:ss",minDate:"1900-01-01 00:00:00",maxDate:"2099-12-31 23:59:59",startMin:b.nowDate(0),startMax:this.maxDate},b.index=Math.floor(9e3*Math.random()),b.boxCell="#jedatebox",b.find=function(a){return g(b.boxCell+" "+a)},b.isBool=function(a){return void 0==a||1==a?!0:!1},b.addDateTime=function(a,c,e,g){var j,h=a.match(d),i=new Date,k=f(h[0]),l=void 0==h[1]?i.getMonth()+1:f(h[1]),m=void 0==h[2]?i.getDate():f(h[2]),n=void 0==h[3]?i.getHours():f(h[3]),o=void 0==h[4]?i.getMinutes():f(h[4]),p=void 0==h[5]?i.getMinutes():f(h[5]),q=new Date(k,b.digit(l),b.digit(m),b.digit(n),b.digit(o),b.digit(p));switch(e){case"DD":j=864e5*c;break;case"hh":j=36e5*c;break;case"mm":j=6e4*c}return q.setTime(q.getTime()+j),b.parse([q.getFullYear(),q.getMonth(),q.getDate()],[q.getHours(),q.getMinutes(),q.getSeconds()],g)},b.initDate=function(a){var d=b.event?b.event:window.event,f=void 0==a.isinitVal||0==a.isinitVal?!1:!0,i=function(d,e){if(!g(e)[0]){b.opts=a,b.format=a.format||h.format,minTime=b.opts.minDate||h.minDate,maxTime=b.opts.maxDate||h.maxDate,b.fixed=b.isBool(a.fixed),/\YYYY-MM-DD/.test(b.checkFormat(b.format))?(b.checkDate(minTime)?b.minDate=minTime:alert("最小日期不合法"),b.checkDate(maxTime)?b.maxDate=maxTime:alert("最大日期不合法")):(b.minDate=minTime,b.maxDate=maxTime);var f=c.createElement("div"),i=void 0==a.zIndex?999:a.zIndex;f.className="jedatebox",f.id=b.boxCell.replace(/\#/g,""),a.isDisplay&&b.attr(f,"date",!0),f.style.cssText="z-index:"+i+";position:"+(1==b.fixed?"absolute":"fixed")+";display:block;",d.appendChild(f)}},j=function(c){var f,g,i,j,d=a.format||h.format,e=a.initAddVal||h.initAddVal;1==e.length?(f=e[0],g="DD"):(f=e[0],g=e[1]),i=b.nowDate(0,d),j=b.addDateTime(i,f,g,d),""==(b.val(c)||b.text(c))?b.isValHtml(c)?b.val(c,j):b.text(c,j):b.isValHtml(c)?b.val(c):b.text(c)};f&&b.each(g("body "+a.dateCell),function(a,b){j(b)}),d?(b.stopmp(d),i(c.body,b.boxCell),b.elemCell="string"==typeof a.dateCell?g(a.dateCell)[0]:a.dateCell,b.setHtml()):b.bind(g(a.dateCell),"click",function(a){b.stopmp(a),i(c.body,b.boxCell),b.elemCell=this,b.setHtml()})},b.orien=function(a,c,d){var e,f,g,h,i=b.fixed?c.getBoundingClientRect():a.getBoundingClientRect();b.fixed?(f=i.right+a.offsetWidth/1.5>=b.winarea(1)?i.right-a.offsetWidth:i.left+(d?0:b.docScroll(1)),e=i.bottom+a.offsetHeight/1<=b.winarea()?i.bottom-1:i.top>a.offsetHeight/1.5?i.top-a.offsetHeight-1:b.winarea()-a.offsetHeight,g=Math.max(e+(d?0:b.docScroll())+1,1)+"px",h=f+"px"):(g="50%",h="50%",a.style.marginTop=-(i.height/2)+"px",a.style.marginLeft=-(i.width/2)+"px"),a.style.top=g,a.style.left=h},b.setHtml=function(){var j,k,l,m,n,o,p,q,r,s,t,a="",c="",e=new Date,f=b.checkFormat(b.format),h="YYYY-MM"==f||"YYYY"==f?!0:!1,i="hh-mm"==f.substring(0,5)?!0:!1;""==(b.val(b.elemCell)||b.text(b.elemCell))?(b.currDate=e,c=[e.getFullYear(),e.getMonth()+1,e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()],b.ymdDate=c[0]+"-"+b.digit(c[1])+"-"+b.digit(c[2])):(j=b.isValHtml(b.elemCell)?b.val(b.elemCell):b.text(b.elemCell),k=j.match(d),i?(c="hh-mm"==f?[k[0],k[1],e.getSeconds()]:[k[0],k[1],k[2]],b.currDate=new Date(e.getFullYear(),e.getMonth(),e.getDate())):(c=[k[0],k[1],k[2],k[3],k[4],void 0==k[5]?e.getSeconds():k[5]],b.currDate=new Date(k[0],k[1],k[2]),b.ymdDate=c[0]+"-"+b.digit(c[1])+"-"+b.digit(c[2]))),i||(b.currMonth=""==(b.val(b.elemCell)||b.text(b.elemCell))?b.currDate.getMonth():b.currDate.getMonth()-1),l='<div class="jedatetop">'+(h?'<div class="jedateym" style="width:100%;"><i class="prev triangle ymprev"></i><span class="jedateyy"><em class="jedateyearmonth"></em></span><i class="next triangle ymnext"></i></div>':'<div class="jedateym" style="width:50%;"><i class="prev triangle yearprev"></i><span class="jedateyy" ym="24"><em class="jedateyear"></em><em class="pndrop"></em></span><i class="next triangle yearnext"></i></div><div class="jedateym" style="width:50%;"><i class="prev triangle monthprev"></i><span class="jedatemm" ym="12"><em class="jedatemonth"></em><em class="pndrop"></em></span><i class="next triangle monthnext"></i></div>')+"</div>",m=h?"YYYY"==f?'<ul class="jedayy"></ul>':'<ul class="jedaym"></ul>':'<div class="jedatetopym" style="display: none;"><ul class="ymdropul"></ul><p><span class="jedateymchle">←</span><span class="jedateymchri">→</span><span class="jedateymchok">关闭</span></p></div>',n='<ol class="jedaol"></ol><ul class="jedaul"></ul>',o=h?"YYYY"==f?'<div class="botflex jedatebtn"><span class="jedateok" style="width:47.8%">确认</span><span class="jedateclear" style="width:47.8%">清空</span></div>':'<div class="botflex jedatebtn"><span class="jedateok">确认</span><span class="jedatetodaymonth">本月</span><span class="jedateclear">清空</span></div>':'<div class="botflex jedatehmsshde"><ul class="jedatehms"><li><input type="text" /></li><i>:</i><li><input type="text" /></li><i>:</i><li><input type="text" /></li></ul></div><div class="botflex jedatebtn"><span class="jedateok">确认</span><span class="jedatetodaymonth">今天</span><span class="jedateclear">清空</span></div>',p='<div class="jedatebot">'+o+"</div>",q='<div class="jedateprophms '+(i?"jedatepropfix":"jedateproppos")+'"><div class="jedatepropcon"><div class="jedatehmstitle">时间选择<div class="jedatehmsclose">×</div></div><div class="jedateproptext">小时</div><div class="jedateproptext">分钟</div><div class="jedateproptext">秒数</div><div class="jedatehmscon jedateprophours"></div><div class="jedatehmscon jedatepropminutes"></div><div class="jedatehmscon jedatepropseconds"></div></div></div>',r=h?l+m+p:i?l+q+p:l+m+n+q+p,b.html(g(b.boxCell)[0],r),b.isBool(b.opts.isClear)?"":b.isShow(b.find(".jedatebot .jedateclear")[0],!1),h||(b.isBool(b.opts.isToday)?"":b.isShow(b.find(".jedatebot .jedatetodaymonth")[0],!1)),/\hh-mm/.test(f)?(s=function(a){var d;d=""!=b.val(b.elemCell)||""!=b.text(b.elemCell)?a?[c[0],c[1],c[2]]:[c[3],c[4],c[5]]:[b.currDate.getHours(),b.currDate.getMinutes(),b.currDate.getSeconds()],b.each(b.find(".jedatebot .jedatehms input"),function(a,c){b.val(c,b.digit(d[a])),b.isBool(b.opts.ishmsVal)?"":b.attr(c,"readOnly","true")})},i?(s(!0),b.text(b.find(".jedateyear")[0],b.currDate.getFullYear()+"年").text(b.find(".jedatemonth")[0],b.digit(b.currDate.getMonth()+1)+"月")):b.isBool(b.opts.isTime)?s(!1):(b.isShow(b.find(".jedatebot .jedatehmsshde")[0],!1),b.find(".jedatebot .jedatebtn")[0].style.width="100%")):(h||b.isShow(b.find(".jedatebot .jedatehmsshde")[0],!1),b.find(".jedatebot .jedatebtn")[0].style.width="100%"),/\YYYY-MM-DD/.test(f)&&(b.each(b.weeks,function(b,c){a+='<li class="weeks" data-week="'+c+'">'+c+"</li>"}),b.each(b.find(".jedaol"),function(c,d){b.html(d,a)}),b.getDateStr(b.currDate.getFullYear(),b.currMonth),b.chooseYM()),h&&(t=b.find(".jedateym .jedateyearmonth")[0],"YYYY"==f?(b.attr(t,"data-onyy",c[0]),b.text(t,c[0]+"年"),b.html(b.find(".jedayy")[0],b.onlyYear(c[0]))):(b.attr(t,"data-onym",c[0]+"-"+b.digit(c[1])),b.text(t,c[0]+"年"+b.digit(c[1])+"月"),b.html(b.find(".jedaym")[0],b.onlyYMStr(c[0],c[1]))),b.onlyYMevents(c)),b.orien(g(b.boxCell)[0],b.elemCell),setTimeout(function(){b.opts.success&&b.opts.success(b.elemCell)},2),b.events(c)},b.onlyYMStr=function(a,c){var d="";return b.each(b.montharr,function(e,f){var g=b.parseMatch(b.minDate),h=b.parseMatch(b.maxDate),i=new Date(a,b.digit(f),"01"),j=new Date(g[0],g[1],g[2]),k=new Date(h[0],h[1],h[2]);d+=j>i||i>k?"<li class='disabled' ym='"+a+"-"+b.digit(f)+"'>"+a+"年"+b.digit(f)+"月</li>":"<li "+(c==f?'class="action"':"")+' ym="'+a+"-"+b.digit(f)+'">'+a+"年"+b.digit(f)+"月</li>"}),d},b.onlyYear=function(a){var c="";return b.yearArr=new Array(15),b.each(b.yearArr,function(d){var e=b.parseMatch(b.minDate),f=b.parseMatch(b.maxDate),g=e[0],h=f[0],i=a-7+d,j=b.attr(b.find(".jedateym .jedateyearmonth")[0],"data-onyy");c+=g>i||i>h?"<li class='disabled' yy='"+i+"'>"+i+"年</li>":"<li "+(j==i?'class="action"':"")+" yy='"+i+"'>"+i+"年</li>"}),c},b.onlyYMevents=function(a){var c,d=b.find(".jedateym .ymprev"),e=b.find(".jedateym .ymnext"),g=f(a[0]),h=parseFloat(a[1]);b.each([d,e],function(a,e){b.bind(e,"click",function(a){b.stopmp(a),"YYYY"==b.checkFormat(b.format)?(c=e==d?b.attr(b.find(".jedayy li")[0],"yy"):b.attr(b.find(".jedayy li")[b.yearArr.length-1],"yy"),b.html(b.find(".jedayy")[0],b.onlyYear(f(c)))):(c=e==d?g-=1:g+=1,b.html(b.find(".jedaym")[0],b.onlyYMStr(c,h))),b.ymPremNextEvents()})})},b.getDateStr=function(a,c){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,d=b.minDate.match(/\w+|d+/g),e=d[0]+d[1]+d[2],g=b.maxDate.match(/\w+|d+/g),h=g[0]+g[1]+g[2];for(b.html(b.find(".jedaul")[0],""),i=new Date(a,c,1),j=i.getFullYear(),k=i.getMonth(),b.attr(b.find(".jedateyear")[0],"year",k>11?j+1:j),b.text(b.find(".jedateyear")[0],(k>11?j+1:j)+"年"),b.attr(b.find(".jedatemonth")[0],"month",b.digit(k+1)),b.text(b.find(".jedatemonth")[0],b.digit(k+1)+"月"),l=function(a,c,d){var e=b.opts.marks,f=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1};return b.isType(e,"array")&&e.length>0&&f(e,a+"-"+c+"-"+d)?'<i class="marks"></i>':""},m=function(a,c){return b.opts.festival?b.festival(a,c):c},n=1-i.getDay(),1==n&&(n=-6),i.setDate(n),o=0;42>o;o++)p=document.createElement("li"),q=i.getFullYear(),r=i.getMonth(),s=i.getDate(),t=k>r?0==r?1:k:r==k?k+1:11==r?12:k+2,u=q==j?j:q>j?j+1:j-1,b.find(".jedaul")[0].appendChild(p),b.html(p,m(b.digit(t)+"."+b.digit(s),b.digit(s))+l(u,b.digit(t),b.digit(s))),b.attr(p,"year",u).attr(p,"month",b.digit(t)).attr(p,"day",b.digit(s)),p.dateVals=j+"-"+b.digit(r+1)+"-"+b.digit(s),v=(u+"-"+b.digit(t)+"-"+b.digit(s)).replace(/\-/g,""),w=u+"-"+b.digit(t)+"-"+b.digit(1),x=j+"-"+b.digit(r+1)+"-"+b.digit(1),r!=k&&b.addClass(p,"other"),f(v)>=f(e)&&f(v)<=f(h)&&r==k&&(""==(b.val(b.elemCell)||b.text(b.elemCell))?(y=b.currDate.getFullYear()+"-"+b.digit(b.currDate.getMonth()+1)+"-"+b.digit(1),b.ymdDate==p.dateVals&&b.currDate.getMonth()+1==r+1?b.addClass(p,"action"):y!=x&&w==p.dateVals&&b.addClass(p,"action")):(z=b.currDate.getFullYear()+"-"+b.digit(b.currDate.getMonth())+"-"+b.digit(1),b.ymdDate==p.dateVals&&b.currDate.getMonth()==r+1?b.addClass(p,"action"):z!=x&&w==p.dateVals&&b.addClass(p,"action"))),(f(e)>f(v)||f(h)<f(v))&&b.addClass(p,"disabled"),i.setDate(s+1);b.chooseDays()},b.chooseDays=function(){b.bind(b.find(".jedaul li"),"click",function(a){var g,h,i,j,c=this,d=[],e=b.elemCell;b.hasClass(c,"disabled")||(b.stopmp(a),b.each(b.find(".jedatehms input"),function(a,c){d.push(b.val(c))}),g=f(b.attr(c,"year")),h=parseFloat(b.attr(c,"month")),i=parseFloat(b.attr(c,"day")),j=b.parse([g,h,i],[d[0],d[1],d[2]],b.format),b.isValHtml(e)?b.val(e,j):b.text(e,j),b.dateClose(),(b.isType(b.opts.choosefun,"function")||null!=b.opts.choosefun)&&b.opts.choosefun&&b.opts.choosefun(b.elemCell,j))})},b.setStrhms=function(){var k,l,m,n,a=b.format,c=[],e=b.find(".jedatehms li"),g=b.find(".jedatepropcon .jedateproptext"),h=b.find(".jedatepropcon .jedatehmscon"),i=function(a){var b=a.match(d).join("-"),c="YYYY-MM-DD-hh-mm"==b?a.split(" "):b,e="YYYY-MM-DD-hh-mm"==b?c[1]:c;return e.match(d).join("-")},j="hh-mm"==i(a);return j&&(k=b.getStyle(e[0],"width").replace(/\px|em|rem/g,""),l=b.getStyle(b.find(".jedatehms i")[0],"width").replace(/\px|em|rem/g,""),m=b.getStyle(g[0],"width").replace(/\px|em|rem/g,""),n=Math.round(f(k)+f(k)/2+f(l)/2),e[0].style.width=e[1].style.width=n+"px",g[0].style.width=g[1].style.width=h[0].style.width=h[1].style.width=Math.round(f(m)+f(m)/2+2)+"px"),b.each([24,60,60],function(a,d){var m,n,f="",i="",k=b.find(".jedatehms input"),l=b.val(k[a]);for(b.attr(k[a],"maxlength",2).attr(k[a],"numval",d-1).attr(k[a],"item",a),m=0;d>m;m++)m=b.digit(m),b.opts.ishmsLimit?i=l>m?"disabled":m==l?"action":"":(i=j&&2==a?l==m?"disabled action":"disabled":l==m?"action":"",j&&2==a&&(n=e[2],n.style.display=n.previousSibling.style.display="none",g[a].style.display=h[a].style.display="none")),f+='<p class="'+i+'">'+m+"</p>";c.push(f)}),c},b.dateClose=function(){c.body.removeChild(g(b.boxCell)[0])},b.chooseYM=function(){function k(a){var c="";return b.each(new Array(15),function(d){if(7===d){var f=b.attr(e[0],"year");c+="<li "+(f==a?'class="action"':"")+' yy="'+a+'">'+a+"年</li>"}else c+='<li yy="'+(a-7+d)+'">'+(a-7+d)+"年</li>"}),c}function l(c,d){var e="";12==d?(b.each(b.montharr,function(a,c){var d=b.attr(g[0],"month"),c=b.digit(c);e+="<li "+(d==c?'class="action"':"")+' mm="'+c+'">'+c+"月</li>"}),b.each([h,i],function(a,c){b.isShow(c[0],!1)})):(e=k(c),b.each([h,i],function(a,c){b.isShow(c[0],!0)})),b.removeClass(a[0],12==d?"jedatesety":"jedatesetm").addClass(a[0],12==d?"jedatesetm":"jedatesety"),b.html(b.find(".jedatetopym .ymdropul")[0],e),b.isShow(a[0],!0)}function m(c){b.bind(b.find(".ymdropul li"),"click",function(){var e=b.attr(this,"yy"),h=f(b.attr(g[0],"month"))-1;b.attr(c,"year",e),b.html(c,e+"年"),b.isShow(a[0],!1),b.getDateStr(e,h)})}var n,a=b.find(".jedatetopym"),c=b.find(".jedateyy"),d=b.find(".jedatemm"),e=b.find(".jedateyy .jedateyear"),g=b.find(".jedatemm .jedatemonth"),h=b.find(".jedateymchri"),i=b.find(".jedateymchle"),j="hh-mm"==b.checkFormat(b.format).substring(0,5)?!0:!1;!j&&b.bind(c,"click",function(){var a=f(b.attr(this,"ym")),c=f(b.attr(e[0],"year"));l(c,a),m(e[0])}),!j&&b.bind(d,"click",function(){var c=f(b.attr(this,"ym")),d=f(b.attr(e[0],"year"));l(d,c),b.bind(b.find(".ymdropul li"),"click",function(){var d=b.attr(e[0],"year"),h=f(b.attr(this,"mm"))-1;b.attr(g[0],"month",h),b.html(g[0],h+"月"),b.isShow(a[0],!1),b.getDateStr(d,h)})}),b.bind(b.find(".jedateymchok"),"click",function(c){b.stopmp(c),b.isShow(a[0],!1)}),n=f(b.attr(e[0],"year")),b.each([i,h],function(a,c){b.bind(c,"click",function(c){b.stopmp(c),0==a?n-=15:n+=15;var d=k(n);b.html(b.find(".jedatetopym .ymdropul")[0],d),m(e[0])})})},b.ymPremNextEvents=function(){var a=new Date,c=b.elemCell,d="YYYY"==b.checkFormat(b.format),e=d?b.find(".jedayy li"):b.find(".jedaym li");b.bind(e,"click",function(e){var g,h,f=this;b.hasClass(f,"disabled")||(b.stopmp(e),g=d?b.attr(f,"yy").match(/\w+|d+/g):b.attr(f,"ym").match(/\w+|d+/g),h=d?b.parse([g[0],a.getMonth()+1,1],[0,0,0],b.format):b.parse([g[0],g[1],1],[0,0,0],b.format),b.isValHtml(c)?b.val(c,h):b.text(c,h),b.dateClose(),(b.isType(b.opts.choosefun,"function")||null!=b.opts.choosefun)&&b.opts.choosefun(b.elemCell,h))})},b.events=function(a){var p,q,r,s,t,u,d=new Date,e=b.find(".yearprev"),i=b.find(".yearnext"),j=b.find(".monthprev"),k=b.find(".monthnext"),l=b.find(".jedateyear"),m=b.find(".jedatemonth"),n="YYYY-MM"==b.checkFormat(b.format)||"YYYY"==b.checkFormat(b.format)?!0:!1,o="hh-mm"==b.checkFormat(b.format).substring(0,5)?!0:!1;n?(u=b.elemCell,b.ymPremNextEvents(),b.bind(b.find(".jedatebot .jedatetodaymonth"),"click",function(a){b.stopmp(a);var c=[d.getFullYear(),d.getMonth()+1,d.getDate()],e=b.parse([c[0],c[1],0],[0,0,0],b.format);b.isValHtml(u)?b.val(u,e):b.text(u,e),b.dateClose(),(b.isType(b.opts.choosefun,"function")||null!=b.opts.choosefun)&&b.opts.choosefun(b.elemCell,e)})):(!o&&b.each([e,i],function(a,c){b.bind(c,"click",function(a){b.stopmp(a);var d=f(b.attr(b.find(".jedateyear")[0],"year"));c==e?b.getDateStr(--d,b.currMonth):b.getDateStr(++d,b.currMonth)})}),!o&&b.each([j,k],function(a,c){b.bind(c,"click",function(a){b.stopmp(a);var d=f(b.currDate.getFullYear());c==j?b.getDateStr(d,--b.currMonth):b.getDateStr(d,++b.currMonth)})}),p=b.setStrhms(),q=function(a){b.each(a,function(a,c){""==b.html(c[0])&&b.html(c[0],p[a])}),o?(b.isShow(b.find(".jedatehmsclose")[0],!1),b.isShow(b.find(".jedatetodaymonth")[0],!1)):b.isShow(b.find(".jedateprophms")[0],!0),b.each(["hours","minutes","seconds"],function(a,c){var f,d=b.find(".jedateprop"+c),e=b.find(".jedateprop"+c+" .action");d[0].scrollTop=e[0].offsetTop-118,f=b.find(".jedateprop"+c+" p"),b.bind(f,"click",function(){var c=this;b.hasClass(c,"disabled")||(b.each(f,function(a,c){b.removeClass(c,"action")}),b.addClass(c,"action"),b.val(b.find(".jedatebot .jedatehms input")[a],b.digit(b.text(c))),o||b.isShow(b.find(".jedateprophms")[0],!1))})})},r=b.find(".jedateprophours"),s=b.find(".jedatepropminutes"),t=b.find(".jedatepropseconds"),o?q([r,s,t]):b.bind(b.find(".jedatehms"),"click",function(){"block"!==b.find(".jedateprophms")[0].style.display&&q([r,s,t]),b.bind(b.find(".jedateprophms .jedatehmsclose"),"click",function(){b.isShow(b.find(".jedateprophms")[0],!1)})}),b.bind(b.find(".jedatebot .jedatetodaymonth"),"click",function(){var a=[d.getFullYear(),d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds()],c=b.parse([a[0],a[1],a[2]],[a[3],a[4],a[5]],b.format),e=b.elemCell;b.getDateStr(a[0],a[1],a[2]),b.isValHtml(e)?b.val(e,c):b.text(e,c),b.dateClose(),(b.isType(b.opts.choosefun,"function")||null!=b.opts.choosefun)&&b.opts.choosefun(b.elemCell,c),n||b.chooseDays()})),b.bind(b.find(".jedatehms input"),"keyup",function(){var a=this,c=a.value,d=f(b.attr(a,"numval")),e=f(b.attr(a,"item"));b.val(a,c.replace(/\D/g,"")),a.value>d&&(b.val(a,d),alert("输入值不能大于"+d)),""==this.value&&b.val(a,"00"),b.each(b.find(".jedatehmscon")[e].childNodes,function(a,c){b.removeClass(c,"action")}),b.addClass(b.find(".jedatehmscon")[e].childNodes[f(a.value.replace(/^0/g,""))],"action"),b.each(["hours","minutes","seconds"],function(a,c){var d=b.find(".jedateprop"+c),e=b.find(".jedateprop"+c+" .action");d[0].scrollTop=e[0].offsetTop-118})}),b.bind(b.find(".jedatebot .jedateclear"),"click",function(a){b.stopmp(a);var c=b.elemCell,d=b.isValHtml(c)?b.val(c):b.text(c);b.isValHtml(c)?b.val(c,""):b.text(c,""),b.dateClose(),""!=d&&(b.isBool(b.opts.clearRestore)&&(b.opts.minDate=b.opts.startMin||h.startMin,b.opts.maxDate=b.opts.startMax||h.startMax),(b.isType(b.opts.clearfun,"function")||null!=b.opts.clearfun)&&b.opts.clearfun(b.elemCell,d))}),b.bind(b.find(".jedatebot .jedateok"),"click",function(c){var e,g,h,i,j,k,p,q,r,s,t,u,v,w;b.stopmp(c),e=b.elemCell,g=""!=(b.val(e)||b.text(e)),h="YYYY"==b.checkFormat(b.format),i="",j=function(){var a=[];return b.each(b.find(".jedatehms input"),function(c,d){a.push(b.val(d))}),a},g?(k=b.isValHtml(e)?b.val(e):b.text(e),p=k.match(/\w+|d+/g),n?(s=h?b.find(".jedayy .action")[0]:b.find(".jedaym .action")[0],h?(t=s?b.attr(s,"yy").match(/\w+|d+/g):p,i=b.parse([f(t[0]),d.getMonth()+1,1],[0,0,0],b.format)):(u=s?b.attr(s,"ym").match(/\w+|d+/g):p,i=b.parse([f(u[0]),f(u[1]),1],[0,0,0],b.format))):(q=j(),r=[f(b.attr(l[0],"year")),f(b.attr(m[0],"month")),p[2]],i=g?b.parse([r[0],r[1],r[2]],[q[0],q[1],q[2]],b.format):"",o||b.getDateStr(r[0],r[1]),b.chooseDays())):(v=j(),w=b.find(".jedateyearmonth")[0],o?i=b.parse([a[0],a[1],a[2]],[v[0],v[1],v[2]],b.format):(t=n?"YYYY"==b.checkFormat(b.format)?b.attr(w,"data-onyy").match(/\w+|d+/g):b.attr(w,"data-onym").match(/\w+|d+/g):[d.getFullYear(),d.getMonth()+1,d.getDate()],i=h?b.parse([f(t[0]),d.getMonth()+1,1],[0,0,0],b.format):b.parse([f(t[0]),f(t[1]),d.getDate()],[v[0],v[1],v[2]],b.format))),b.isValHtml(e)?b.val(e,i):b.text(e,i),b.dateClose(),(b.isType(b.opts.okfun,"function")||null!=b.opts.okfun)&&b.opts.okfun(b.elemCell,i)}),b.bind(document,"mouseup",function(a){b.stopmp(a);var d=g(b.boxCell)[0];d&&"none"!==d.style.display&&c.body.removeChild(d)}),b.bind(g(b.boxCell),"mouseup",function(a){b.stopmp(a)})},a=function(c){try{b.event=window.event?window.event:a.caller.arguments[0]}catch(d){}return new b.initDate(c||{})},a.version="3.2",a.now=function(a){return b.nowDate(a)},a.addDate=function(a,c,d){return c=0|c,d=d||"DD",b.addDateTime(a,c,d,b.format)},a});