/** @Name : jeDate v2.0 日期控件 @Author: chne guojun @Date: 2015-12-28 @QQ群:516754269 @Site:https://github.com/singod/jeDate */(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/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;ge?+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;gc.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&&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=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