jedate.js 20 KB

1234567
  1. /**
  2. @Name : jeDate v2.0 日期控件
  3. @Author: chne guojun
  4. @Date: 2015-12-28
  5. @QQ群:516754269
  6. @Site:https://github.com/singod/jeDate
  7. */(function(G){var a={},A=document,e=a.query=function(){function a(t,p){p=p||document;if(!/^[\w\-_#]+$/.test(t)&&p.querySelectorAll)return b(p.querySelectorAll(t));if(-1<t.indexOf(",")){for(var u=t.split(/,/g),l=[],k=0,w=u.length;k<w;++k)l=l.concat(a(u[k],p));return v(l)}var u=t.match(f),l=u.pop(),w=(l.match(n)||h)[1],y=!w&&(l.match(m)||h)[1],k=!w&&(l.match(r)||h)[1],l=t.match(/\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\]/g);if(y&&!l&&!k&&p.getElementsByClassName)k=b(p.getElementsByClassName(y));else{k=!w&&b(p.getElementsByTagName(k||"*"));y&&(k=e(k,"className",RegExp("(^|\\s)"+y+"(\\s|$)")));if(w)return(u=p.getElementById(w))?[u]:[];if(l)for(w=0;w<l.length;w++)var y=(l[w].match(q)||h)[1],z=(l[w].match(q)||h)[2],z=z.replace(/\'/g,"").replace(/\-/g,"\\-").replace(/\[/g,"\\[").replace(/\]/g,"\\]"),k=e(k,y,RegExp("(^"+z+"$)"))}return u[0]&&k[0]?d(u,k):k}function b(a){try{return Array.prototype.slice.call(a)}catch(c){for(var b=[],d=0,l=a.length;d<l;++d)b[d]=a[d];return b}}function d(a,c,b){var l=a.pop();if("\x3e"===l)return d(a,c,!0);for(var k=[],e=-1,g=(l.match(n)||h)[1],f=!g&&(l.match(m)||h)[1],l=!g&&(l.match(r)||h)[1],q=-1,x,v,B,l=l&&l.toLowerCase();x=c[++q];){v=x.parentNode;do if(B=(B=(B=!l||"*"===l||l===v.nodeName.toLowerCase())&&(!g||v.id===g))&&(!f||RegExp("(^|\\s)"+f+"(\\s|$)").test(v.className)),b||B)break;while(v=v.parentNode);B&&(k[++e]=x)}return a[0]&&k[0]?d(a,k):k}function e(a,c,b){for(var d=-1,k,g=-1,h=[];k=a[++d];)b.test(k.getAttribute(c))&&(h[++g]=k);return h}var f=/(?:[\*\w\-\\.#]+)+(?:\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\])*|\*|>/gi,m=/^(?:[\w\-_]+)?\.([\w\-_]+)/,n=/^(?:[\w\-_]+)?#([\w\-_]+)/,r=/^([\w\*\-_]+)/,h=[null,null,null],q=/\[([\w\-_][^=]+)=([\'\[\]\w\-_]+)\]/,v=function(){var a=+new Date,c=function(){var c=1;return function(b){var d=b[a],e=c++;return d?!1:(b[a]=e,!0)}}();return function(b){for(var d=b.length,k=[],e=-1,g=0,h;g<d;++g)h=b[g],c(h)&&(k[++e]=h);a+=1;return k}}();return a}();a.each=function(a,b){for(var d=0,e=a.length;d<e&&!1!==b(d,a[d]);d++);};a.extend=function(){var a=function m(a,c){for(var b in a)a.hasOwnProperty(b)&&(a[b]instanceof Object&&c[b]instanceof Object&&m(a[b],c[b]),c.hasOwnProperty(b)||(c[b]=a[b]))},b={},d=arguments;if(!d.length)return{};for(var e=d.length-1;0<=e;e--)a(d[e],b);return d[0]=b};a.trim=function(a){return(a||"").replace(/^\s|\s$/g,"").replace(/\s+/g," ")};a.attr=function(a,b,d){if("string"===typeof b&&"undefined"===typeof d)return a.getAttribute(b);a.setAttribute(b,d);return this};a.stopmp=function(a){a=a||G.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0;return this};a.getCss=function(a,b){return a.currentStyle?a.currentStyle[b]:window.getComputedStyle?document.defaultView.getComputedStyle(a)[b]:null};a.hasClass=function(a,b){a=a||{};return(new RegExp("\\b"+b+"\\b")).test(a.className)};a.addClass=function(c,b){c=c||{};a.hasClass(c,b)||(c.className+=" "+b);c.className=a.trim(c.className);return this};a.removeClass=function(c,b){c=c||{};a.hasClass(c,b)&&(c.className=c.className.replace(new RegExp("(\\s|^)"+b+"(\\s|$)"),""));return this};a.on=function(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent?a.attachEvent("on"+b,d):a["on"+b]=d};a.stopMosup=function(c,b){if("mouseup"!==c)a.on(b,"mouseup",function(b){a.stopmp(b)})};a.html=function(a,b){if("undefined"!=typeof b||void 0!==b&&1===a.nodeType)a.innerHTML=b;else return a.innerHTML;return this};a.text=function(a,b){if(void 0!==b&&1===a.nodeType)document.all?a.innerText=b:a.textContent=b;else return document.all?a.innerText:a.textContent;return this};a.val=function(a,b){if(void 0!==b&&1===a.nodeType)a.value=b;else return a.value;return this};a.scroll=function(a){a=a?"scrollLeft":"scrollTop";return A.body[a]|A.documentElement[a]};a.winarea=function(a){return A.documentElement[a?"clientWidth":"clientHeight"]};a.parse=function(c,b,d){c=c.concat(b);return d.replace(/YYYY|MM|DD|hh|mm|ss/g,function(b,d){c.index=++c.index|0;return a.digit(c[c.index])})};a.nowDate=function(c,b){var d=Date,e;c|0?(e=parseInt(c),e=864E5>e?+new Date+864E5*e:e):e=+new Date;d=new d(e);return a.parse([d.getFullYear(),d.getMonth()+1,d.getDate()],[d.getHours(),d.getMinutes(),d.getSeconds()],b)};a.montharr=[1,2,3,4,5,6,7,8,9,10,11,12];a.isValHtml=function(a){return/textarea|input/.test(a.tagName.toLocaleLowerCase())};a.weeks="\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".split("");a.festival=function(a,b){var d;switch(a){case "01.01":d="\u5143\u65e6";break;case "02.14":d="\u60c5\u4eba";break;case "03.08":d="\u5987\u5973";break;case "04.05":d="\u6e05\u660e";break;case "05.01":d="\u52b3\u52a8";break;case "06.01":d="\u513f\u7ae5";break;case "08.01":d="\u5efa\u519b";break;case "09.10":d="\u6559\u5e08";break;case "10.01":d="\u56fd\u5e86";break;case "12.24":d="\u5e73\u5b89";break;case "12.25":d="\u5723\u8bde";break;default:d=b}return d};a.digit=function(a){return 10>a?"0"+(a|0):a};a.shdeCell=function(a){a?e("#jedatebox")[0].style.display="none":e("#jedatebox")[0].style.display="block"};var H={dateCell:"#dateval",format:"YYYY-MM-DD hh:mm:ss",minDate:"1900-01-01 00:00:00",maxDate:"2099-12-31 23:59:59",isinitVal:!1,isTime:!1,isClear:!0,festival:!1,zIndex:999,choosefun:function(a){},clearfun:function(a){},okfun:function(a){}},F=function(c){var b=JSON.parse(JSON.stringify(H));this.config=a.extend(b,c);this.init()},D=function(a){return new F(a||{})};F.prototype={init:function(){var c=this,b=c.config,d=e(b.dateCell)[0],g,f,m=window.event,n;g=A.createElement("div");e("#jedatebox")[0]||(g.className=g.id="#jedatebox".replace("#",""),g.style.zIndex=b.zIndex,A.body.appendChild(g));try{n=m.target||m.srcElement||{}}catch(h){n={}}g=b.dateCell?e(b.dateCell)[0]:n;var r=a.nowDate(null,b.format);b.isinitVal&&(""==(a.val(d)||a.text(d))?a.isValHtml(d)?a.val(d,r):a.text(d,r):a.isValHtml(d)?a.val(d):a.text(d));m&&n.tagName?g&&g!==a.elem&&(a.stopMosup(m.type,g),a.stopmp(m),c.setHtml(b,d)):(f=b.event||"click",a.each(0<(g.length|0)?g:[g],function(e,g){a.stopMosup(f,c);a.on(g,f,function(e){a.stopmp(e);g!==a.elem&&c.setHtml(b,d)})}))},setHtml:function(c,b){var d="",g=new Date,f=a.nowDate(null,c.format),m="YYYY-MM"==c.format.match(/\w+|d+/g).join("-")?!0:!1,f=c.isinitVal?a.isValHtml(b)?a.val(b):a.text(b):""==(a.val(b)||a.text(b))?f:a.isValHtml(b)?a.val(b):a.text(b),f=""!=a.val(b)||""!=a.text(b)?f.match(/\d+/g):[g.getFullYear(),g.getMonth()+1,g.getDate(),g.getHours(),g.getMinutes(),g.getSeconds()],n='\x3cdiv class\x3d"jedatetop"\x3e'+(m?'\x3cdiv class\x3d"jedateym" style\x3d"width:100%;"\x3e\x3ci class\x3d"prev triangle ymprev"\x3e\x3c/i\x3e\x3cspan class\x3d"jedateyy"\x3e\x3cem class\x3d"jedateyearmonth"\x3e\x3c/em\x3e\x3c/span\x3e\x3ci class\x3d"next triangle ymnext"\x3e\x3c/i\x3e\x3c/div\x3e':'\x3cdiv class\x3d"jedateym" style\x3d"width:50%;"\x3e\x3ci class\x3d"prev triangle yearprev"\x3e\x3c/i\x3e\x3cspan class\x3d"jedateyy" data-ym\x3d"24"\x3e\x3cem class\x3d"jedateyear"\x3e\x3c/em\x3e\x3cem class\x3d"pndrop"\x3e\x3c/em\x3e\x3c/span\x3e\x3ci class\x3d"next triangle yearnext"\x3e\x3c/i\x3e\x3c/div\x3e\x3cdiv class\x3d"jedateym" style\x3d"width:50%;"\x3e\x3ci class\x3d"prev triangle monthprev"\x3e\x3c/i\x3e\x3cspan class\x3d"jedatemm" data-ym\x3d"12"\x3e\x3cem class\x3d"jedatemonth"\x3e\x3c/em\x3e\x3cem class\x3d"pndrop"\x3e\x3c/em\x3e\x3c/span\x3e\x3ci class\x3d"next triangle monthnext"\x3e\x3c/i\x3e\x3c/div\x3e')+"\x3c/div\x3e",r=m?'\x3cul class\x3d"jedaym"\x3e\x3c/ul\x3e':'\x3cdiv class\x3d"jedatetopym" style\x3d"display: none;"\x3e\x3cul class\x3d"ymdropul"\x3e\x3c/ul\x3e\x3cp\x3e\x3cspan class\x3d"jedateymchle"\x3e\x26#8592;\x3c/span\x3e\x3cspan class\x3d"jedateymchri"\x3e\x26#8594;\x3c/span\x3e\x3cspan class\x3d"jedateymchok"\x3e\u5173\u95ed\x3c/span\x3e\x3c/p\x3e\x3c/div\x3e',h='\x3cdiv class\x3d"jedatebot"\x3e'+(m?'\x3cdiv class\x3d"botflex jedatebtn"\x3e\x3cspan class\x3d"jedateclear" style\x3d"width:31%;"\x3e\u6e05\u7a7a\x3c/span\x3e\x3cspan class\x3d"jedatetodaymonth" style\x3d"width:31%;"\x3e\u672c\u6708\x3c/span\x3e\x3cspan class\x3d"jedateok" style\x3d"width:31%;"\x3e\u786e\u8ba4\x3c/span\x3e\x3c/div\x3e':'\x3cul class\x3d"botflex jedatehms"\x3e\x3cli\x3e\x3cem data-hms\x3d"24"\x3e\x3c/em\x3e\x3ci\x3e:\x3c/i\x3e\x3c/li\x3e\x3cli\x3e\x3cem data-hms\x3d"60"\x3e\x3c/em\x3e\x3ci\x3e:\x3c/i\x3e\x3c/li\x3e\x3cli\x3e\x3cem data-hms\x3d"60"\x3e\x3c/em\x3e\x3c/li\x3e\x3c/ul\x3e\x3cdiv class\x3d"botflex jedatebtn"\x3e\x3cspan class\x3d"jedateclear" style\x3d"width:31%;"\x3e\u6e05\u7a7a\x3c/span\x3e\x3cspan class\x3d"jedatetodaymonth" style\x3d"width:31%;"\x3e\u4eca\u5929\x3c/span\x3e\x3cspan class\x3d"jedateok" style\x3d"width:31%;"\x3e\u786e\u8ba4\x3c/span\x3e\x3c/div\x3e')+"\x3c/div\x3e",n=m?n+r+h:n+r+'\x3col class\x3d"jedaol"\x3e\x3c/ol\x3e\x3cul class\x3d"jedaul"\x3e\x3c/ul\x3e'+h+'\x3cdiv class\x3d"jedateprophms"\x3e\x3c/div\x3e';a.html(e("#jedatebox")[0],n);c.isClear?"":e("#jedatebox .jedatebot .jedateclear")[0].style.display="none";if(c.isTime){var q=""!=a.val(b)||""!=a.text(b)?[f[3],f[4],f[5]]:[g.getHours(),g.getMinutes()+1,g.getSeconds()];a.each(e("#jedatebox .jedatebot .jedatehms em"),function(b,d){a.html(d,a.digit(q[b]))})}else m||(e("#jedatebox .jedatebot .jedatehms")[0].style.display="none"),e("#jedatebox .jedatebot .jedatebtn")[0].style.width="100%";if(m)a.html(e("#jedatebox .jedaym")[0],this.onlyYMStr(f[0],f[1])),a.text(e("#jedatebox .jedateym .jedateyearmonth")[0],f[0]+"\u5e74"+a.digit(f[1])+"\u6708"),this.onlyYMevents(this,c,b,f);else{for(g=0;g<a.weeks.length;g++)d+='\x3cli class\x3d"weeks" data-week\x3d"'+a.weeks[g]+'"\x3e'+a.weeks[g]+"\x3c/li\x3e";a.html(e("#jedatebox .jedaol")[0],d);this.getDateStr(f[0],f[1],f[2]);this.YearAndMonth(this,c,b,f)}a.shdeCell(!1);this.orien(e("#jedatebox")[0],b);this.events(this,c,b,f)},onlyYMStr:function(c,b){var d="";a.each(a.montharr,function(e,f){d+="\x3cli "+(b==f?'class\x3d"action"':"")+' data-onym\x3d"'+c+"-"+a.digit(f)+'"\x3e'+c+"\u5e74"+a.digit(f)+"\u6708\x3c/li\x3e"});return d},onlyYMevents:function(c,b,d,g){var f=e("#jedatebox .jedateym .ymprev")[0],m=e("#jedatebox .jedateym .ymnext")[0],n=parseInt(g[0]),r=parseInt(g[1]);a.each([f,m],function(h,m){a.on(m,"click",function(h){a.stopmp(h);h=m==f?--n:n+=1;a.html(e("#jedatebox .jedaym")[0],c.onlyYMStr(h,r));c.events(c,b,d,g)})})},orien:function(c,b,d){b=b.getBoundingClientRect();c.style.left=b.left+(d?0:a.scroll(1))+"px";b=b.bottom+c.offsetHeight/1.5<=a.winarea()?b.bottom-1:b.top>c.offsetHeight/1.5?b.top-c.offsetHeight+1:a.winarea()-c.offsetHeight;c.style.top=Math.max(b+(d?0:a.scroll())+1,1)+"px"},getDateStr:function(c,b,d){function g(a,b){return[31,0==a%4&&0!=a%100||0==a%400?29:28,31,30,31,30,31,31,30,31,30,31][b-1]}function f(a,b){return parseInt((new Date(a,b-1,0)).getDate())}var m=this.config,n="";b=a.digit(b);a.text(e("#jedatebox .jedateyear")[0],c+"\u5e74").attr(e("#jedatebox .jedateyear")[0],"data-year",c);a.text(e("#jedatebox .jedatemonth")[0],b+"\u6708").attr(e("#jedatebox .jedatemonth")[0],"data-month",b);var r=function(b,d){return m.festival?a.festival(b,d):d};g(c,b);var h=(new Date(c,parseInt(b)-1,1)).getDay(),q=0!=h?h:h+7,v=f(c,b),t=f(c,parseInt(b)+1),p=1,h=m.minDate.split(" ")[0].split("-"),u=m.maxDate.split(" ")[0].split("-"),l=t,k=new Date(c,b,1),w=new Date(c,b,t),y=new Date(h[0],h[1],h[2]),z=new Date(u[0],u[1],u[2]),E=y.getDate();y>w?p=parseInt(t)+1:y>=k&&y<=w&&(p=E);z&&(y=z.getDate(),z<k?l=p:z>=k&&z<=w&&(l=y));for(w=q-1;0<=w;w--){var x,C,z=a.digit(v-w);1==b?(x=parseInt(c)-1,C=13):(x=c,C=b);y=parseInt(x.toString()+a.digit(parseInt(C)-1).toString()+z.toString());E=parseInt(h[0].toString()+a.digit(h[1]).toString()+a.digit(h[2]).toString());k=parseInt(u[0].toString()+a.digit(u[1]).toString()+a.digit(u[2]).toString());k=y>=E&&y<=k?"prevdate":k="disabled";n+="\x3cli class\x3d'"+k+"' data-y\x3d'"+x+"' data-m\x3d'"+(parseInt(C)-1)+"' data-d\x3d'"+z+"'\x3e"+r(parseInt(C)-1+"."+z,z)+"\x3c/li\x3e"}for(x=1;x<p;x++)x=a.digit(x),n+='\x3cli class\x3d"disabled" data-y\x3d"'+c+'" data-m\x3d"'+b+'" data-d\x3d"'+x+'"\x3e'+r(b+"."+x,x)+"\x3c/li\x3e";for(;p<=l;p++)x="",p=a.digit(p),d==p&&(x="action"),n+='\x3cli class\x3d"'+x+'" data-y\x3d"'+c+'" data-m\x3d"'+b+'" data-d\x3d"'+p+'"\x3e'+r(b+"."+p,p)+"\x3c/li\x3e";for(d=l+1;d<=t;d++)d=a.digit(d),n+='\x3cli class\x3d"disabled" data-y\x3d"'+c+'" data-m\x3d"'+b+'" data-d\x3d"'+d+'"\x3e'+r(b+"."+d,d)+"\x3c/li\x3e";d=42-q-g(c,b);for(q=1;q<=d;q++){var B,A,q=a.digit(q);12<=b?(B=parseInt(c)+1,A=0):(B=c,A=b);t=parseInt(B.toString()+a.digit(parseInt(A)+1).toString()+a.digit(q).toString());l=parseInt(h[0].toString()+a.digit(h[1]).toString()+a.digit(h[2]).toString());k=parseInt(u[0].toString()+a.digit(u[1]).toString()+a.digit(u[2]).toString());t=t<=k&&t>=l?"nextdate":t="disabled";n+="\x3cli class\x3d'"+t+"' data-y\x3d'"+B+"' data-m\x3d'"+(parseInt(A)+1)+"' data-d\x3d'"+q+"'\x3e"+r(parseInt(A)+1+"."+q,q)+"\x3c/li\x3e"}a.html(e("#jedatebox .jedaul")[0],n);a.attr(e("#jedatebox .monthprev")[0],"data-y",a.digit(parseInt(b)-1));a.attr(e("#jedatebox .monthnext")[0],"data-y",a.digit(parseInt(b)+1))},events:function(c,b,d,g){var f=e("#jedatebox .yearprev")[0],m=e("#jedatebox .yearnext")[0],n=e("#jedatebox .monthprev")[0],r=e("#jedatebox .monthnext")[0],h=new Date,q=e("#jedatebox .jedateyear")[0],v=e("#jedatebox .jedatemonth")[0],t="YYYY-MM"==b.format.match(/\w+|d+/g).join("-")?!0:!1;t?(a.each(e("#jedatebox .jedaym li"),function(c,g){a.on(g,"click",function(c){a.stopmp(c);c=a.attr(g,"data-onym").match(/\w+|d+/g);c=a.parse([c[0],c[1],1],[0,0,0],b.format);a.isValHtml(d)?a.val(d,c):a.text(d,c);a.html(e("#jedatebox")[0],"");a.shdeCell(!0)})}),a.on(e("#jedatebox .jedatebot .jedatetodaymonth")[0],"click",function(){var c=a.attr(e("#jedatebox .jedaym .action")[0],"data-onym").match(/\w+|d+/g),c=a.parse([c[0],c[1],1],[0,0,0],b.format);a.isValHtml(d)?a.val(d,c):a.text(d,c);a.html(e("#jedatebox")[0],"");a.shdeCell(!0);"function"!==b.choosefun&&null==b.choosefun||b.choosefun(c)})):(a.each([f,m],function(e,u){a.on(u,"click",function(e){a.stopmp(e);e=parseInt(a.attr(q,"data-year"));var k=parseInt(a.attr(v,"data-month"));u==f?--e:e+=1;var p=h.toLocaleDateString()==e+"/"+k+"/"+h.getDate()?g[2]:1;c.getDateStr(e,k,p);c.clickLiDays(c,b,d)})}),a.each([n,r],function(e,f){a.on(f,"click",function(e){a.stopmp(e);e=parseInt(a.attr(q,"data-year"));var k=parseInt(a.attr(v,"data-month"));f==n?1==k?(--e,k=12):--k:12==k?(e+=1,k=1):k+=1;var p=h.toLocaleDateString()==e+"/"+k+"/"+h.getDate()?g[2]:1;c.getDateStr(e,k,p);c.clickLiDays(c,b,d)})}),a.each(e("#jedatebox .jedatebot .jedatehms em"),function(b,c){a.on(c,"click",function(){for(var d="",k,g=e("#jedatebox .jedateprophms")[0],h=a.attr(c,"data-hms"),f=function(){a.removeClass(g,24==h?"jedateh":"jedatems");a.html(g,"")},d=d+('\x3cdiv class\x3d"jedatehmstitle"\x3e'+["\u5c0f\u65f6","\u5206\u949f","\u79d2\u6570"][b]+'\x3cdiv class\x3d"jedatehmsclose"\x3e\x26times;\x3c/div\x3e\x3c/div\x3e'),m=0;m<h;m++)m=a.digit(m),k=a.text(c)==m?"action":"",d+='\x3cp class\x3d"'+k+'"\x3e'+m+"\x3c/p\x3e";a.removeClass(g,24==h?"jedatems":"jedateh").addClass(g,24==h?"jedateh":"jedatems");a.html(g,d);a.each(e("#jedatebox .jedateprophms p"),function(b,d){a.on(d,"click",function(){a.html(c,a.digit(a.text(d)));f()})});a.each(e("#jedatebox .jedateprophms .jedatehmstitle"),function(b,c){a.on(c,"click",function(){f()})})})}),a.on(e("#jedatebox .jedatebot .jedatetodaymonth")[0],"click",function(){var g=[h.getFullYear(),h.getMonth()+1,h.getDate(),h.getHours(),h.getMinutes(),h.getSeconds()],f=a.parse([g[0],g[1],g[2]],[g[3],g[4],g[5]],b.format);c.getDateStr(g[0],g[1],g[2]);a.isValHtml(d)?a.val(d,f):a.text(d,f);a.html(e("#jedatebox")[0],"");a.shdeCell(!0);"function"!==b.choosefun&&null==b.choosefun||b.choosefun(f)}));a.on(e("#jedatebox .jedatebot .jedateclear")[0],"click",function(){var c=a.isValHtml(d)?a.val(d):a.text(d);a.isValHtml(d)?a.val(d,""):a.text(d,"");a.html(e("#jedatebox")[0],"");a.shdeCell(!0);""!=c&&("function"!==b.clearfun&&null==b.clearfun||b.clearfun(c))});a.on(e("#jedatebox .jedatebot .jedateok")[0],"click",function(h){a.stopmp(h);h=t?e("#jedatebox .jedaym li"):e("#jedatebox .jedaul li");if(t)var f=""!=a.val(d)||""!=a.text(d)?a.attr(e("#jedatebox .jedaym .action")[0],"data-onym").match(/\w+|d+/g):"",l=""!=a.val(d)||""!=a.text(d)?a.parse([f[0],f[1],1],[0,0,0],b.format):"";else{var k=[],f=[parseInt(a.attr(q,"data-year")),parseInt(a.attr(v,"data-month")),g[2]];a.each(e("#jedatebox .jedatehms em"),function(b,c){k.push(a.text(c))});var l=""!=a.val(d)||""!=a.text(d)?a.parse([f[0],f[1],f[2]],[k[0],k[1],k[2]],b.format):"";c.getDateStr(f[0],f[1],f[2])}a.each(h,function(b,c){"action"==a.attr(c,"class")&&(a.isValHtml(d)?a.val(d,l):a.text(d,l))});a.html(e("#jedatebox")[0],"");a.shdeCell(!0);""!=l&&("function"!==b.okfun&&null==b.okfun||b.okfun(l))});a.on(document,"click",function(){a.shdeCell(!0);a.html(e("#jedatebox")[0],"")});a.on(e("#jedatebox")[0],"click",function(b){a.stopmp(b)});c.clickLiDays(c,b,d)},YearAndMonth:function(c,b,d,g){function f(b){var c="";a.each(Array(15),function(d){7===d?(d=a.attr(v,"data-year"),c+="\x3cli "+(d==b?'class\x3d"action"':"")+' data-y\x3d"'+b+'"\x3e'+b+"\u5e74\x3c/li\x3e"):c+='\x3cli data-y\x3d"'+(b-7+d)+'"\x3e'+(b-7+d)+"\u5e74\x3c/li\x3e"});return c}function m(b,c){var d="";12==c?(a.each(a.montharr,function(b,c){var e=a.attr(t,"data-month");c=a.digit(c);d+="\x3cli "+(e==c?'class\x3d"action"':"")+' data-m\x3d"'+c+'"\x3e'+c+"\u6708\x3c/li\x3e"}),a.each([p,u],function(a,b){b.style.display="none"})):(d=f(b),a.each([p,u],function(a,b){b.style.display="block"}));a.removeClass(r,12==c?"jedatesety":"jedatesetm").addClass(r,12==c?"jedatesetm":"jedatesety");a.html(e("#jedatebox .jedatetopym .ymdropul")[0],d);r.style.display="block"}function n(k){a.each(e("#jedatebox .ymdropul li"),function(e,f){a.on(f,"click",function(e){e=a.attr(this,"data-y");var f=a.attr(t,"data-month");a.attr(k,"data-year",e);a.html(k,e);r.style.display="none";c.getDateStr(e,f,g[2]);c.clickLiDays(c,b,d)})})}var r=e("#jedatebox .jedatetopym")[0],h=e("#jedatebox .jedateyy")[0],q=e("#jedatebox .jedatemm")[0],v=e("#jedatebox .jedateyy .jedateyear")[0],t=e("#jedatebox .jedatemm .jedatemonth")[0],p=e("#jedatebox .jedateymchri")[0],u=e("#jedatebox .jedateymchle")[0];a.on(h,"click",function(){var b=parseInt(a.attr(h,"data-ym")),c=parseInt(a.attr(v,"data-year"));m(c,b);n(v)});a.on(q,"click",function(){var f=parseInt(a.attr(q,"data-ym")),h=parseInt(a.attr(v,"data-year"));m(h,f);a.each(e("#jedatebox .ymdropul li"),function(e,f){a.on(f,"click",function(e){e=a.attr(v,"data-year");var f=a.attr(this,"data-m");a.attr(t,"data-month",f);a.html(t,f);r.style.display="none";c.getDateStr(e,f,g[2]);c.clickLiDays(c,b,d)})})});a.on(e("#jedatebox .jedateymchok")[0],"click",function(b){a.stopmp(b);r.style.display="none"});var l=parseInt(a.attr(v,"data-year"));a.each([u,p],function(b,c){a.on(c,"click",function(c){a.stopmp(c);0==b?l-=15:l+=15;c=f(l);a.html(e("#jedatebox .jedatetopym .ymdropul")[0],c);n(v)})})},clickLiDays:function(c,b,d){a.each(e("#jedatebox .jedaul li"),function(g,f){a.on(f,"click",function(g){if(!a.hasClass(f,"disabled")){a.stopmp(g);var n=[];a.each(e("#jedatebox .jedatehms em"),function(b,c){n.push(a.text(c))});g=parseInt(a.attr(f,"data-y"))|0;var r=parseInt(a.attr(f,"data-m"))|0,h=parseInt(a.attr(f,"data-d"))|0,q=a.parse([g,r,h],[n[0],n[1],n[2]],b.format);c.getDateStr(g,r,h);a.isValHtml(d)?a.val(d,q):a.text(d,q);a.html(e("#jedatebox")[0],"");a.shdeCell(!0);"function"!==b.choosefun&&null==b.choosefun||b.choosefun(q)}})})}};a.getPath=function(){var a=document.scripts,a=a[a.length-1].src;return a.substring(0,a.lastIndexOf("/")+1)}();a.creatlink=function(c){var b=document.createElement("link");b.type="text/css";b.rel="stylesheet";b.href=a.getPath+"skin/"+c+".css";b.id="jeDateSkin";e("head")[0].appendChild(b)};a.creatlink("jedate");D.skin=function(c){e("#jeDateSkin")[0].parentNode.removeChild(e("#jeDateSkin")[0]);a.creatlink(c)};D.now=function(a){var b=new Date;b.setDate(b.getDate()+a);a=b.getFullYear();var d=b.getMonth()+1,b=b.getDate();return a+"-"+d+"-"+b};"function"===typeof define?define(function(){return D}):window.jeDate=D})(window);