You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
379 lines
10 KiB
379 lines
10 KiB
/**
|
|
* jQuery EasyUI 1.3.6
|
|
*
|
|
* Copyright (c) 2009-2014 www.jeasyui.com. All rights reserved.
|
|
*
|
|
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
|
|
* To use it on other terms please contact us at info@jeasyui.com
|
|
*
|
|
*/
|
|
(function($){
|
|
function _1(_2){
|
|
var _3=$.data(_2,"calendar").options;
|
|
var t=$(_2);
|
|
_3.fit?$.extend(_3,t._fit()):t._fit(false);
|
|
var _4=t.find(".calendar-header");
|
|
t._outerWidth(_3.width);
|
|
t._outerHeight(_3.height);
|
|
t.find(".calendar-body")._outerHeight(t.height()-_4._outerHeight());
|
|
};
|
|
function _5(_6){
|
|
$(_6).addClass("calendar").html("<div class=\"calendar-header\">"+"<div class=\"calendar-prevmonth\"></div>"+"<div class=\"calendar-nextmonth\"></div>"+"<div class=\"calendar-prevyear\"></div>"+"<div class=\"calendar-nextyear\"></div>"+"<div class=\"calendar-title\">"+"<span>Aprial 2010</span>"+"</div>"+"</div>"+"<div class=\"calendar-body\">"+"<div class=\"calendar-menu\">"+"<div class=\"calendar-menu-year-inner\">"+"<span class=\"calendar-menu-prev\"></span>"+"<span><input class=\"calendar-menu-year\" type=\"text\"></input></span>"+"<span class=\"calendar-menu-next\"></span>"+"</div>"+"<div class=\"calendar-menu-month-inner\">"+"</div>"+"</div>"+"</div>");
|
|
$(_6).find(".calendar-title span").hover(function(){
|
|
$(this).addClass("calendar-menu-hover");
|
|
},function(){
|
|
$(this).removeClass("calendar-menu-hover");
|
|
}).click(function(){
|
|
var _7=$(_6).find(".calendar-menu");
|
|
if(_7.is(":visible")){
|
|
_7.hide();
|
|
}else{
|
|
_14(_6);
|
|
}
|
|
});
|
|
$(".calendar-prevmonth,.calendar-nextmonth,.calendar-prevyear,.calendar-nextyear",_6).hover(function(){
|
|
$(this).addClass("calendar-nav-hover");
|
|
},function(){
|
|
$(this).removeClass("calendar-nav-hover");
|
|
});
|
|
$(_6).find(".calendar-nextmonth").click(function(){
|
|
_9(_6,1);
|
|
});
|
|
$(_6).find(".calendar-prevmonth").click(function(){
|
|
_9(_6,-1);
|
|
});
|
|
$(_6).find(".calendar-nextyear").click(function(){
|
|
_f(_6,1);
|
|
});
|
|
$(_6).find(".calendar-prevyear").click(function(){
|
|
_f(_6,-1);
|
|
});
|
|
$(_6).bind("_resize",function(){
|
|
var _8=$.data(_6,"calendar").options;
|
|
if(_8.fit==true){
|
|
_1(_6);
|
|
}
|
|
return false;
|
|
});
|
|
};
|
|
function _9(_a,_b){
|
|
var _c=$.data(_a,"calendar").options;
|
|
_c.month+=_b;
|
|
if(_c.month>12){
|
|
_c.year++;
|
|
_c.month=1;
|
|
}else{
|
|
if(_c.month<1){
|
|
_c.year--;
|
|
_c.month=12;
|
|
}
|
|
}
|
|
_d(_a);
|
|
var _e=$(_a).find(".calendar-menu-month-inner");
|
|
_e.find("td.calendar-selected").removeClass("calendar-selected");
|
|
_e.find("td:eq("+(_c.month-1)+")").addClass("calendar-selected");
|
|
};
|
|
function _f(_10,_11){
|
|
var _12=$.data(_10,"calendar").options;
|
|
_12.year+=_11;
|
|
_d(_10);
|
|
var _13=$(_10).find(".calendar-menu-year");
|
|
_13.val(_12.year);
|
|
};
|
|
function _14(_15){
|
|
var _16=$.data(_15,"calendar").options;
|
|
$(_15).find(".calendar-menu").show();
|
|
if($(_15).find(".calendar-menu-month-inner").is(":empty")){
|
|
$(_15).find(".calendar-menu-month-inner").empty();
|
|
var t=$("<table class=\"calendar-mtable\"></table>").appendTo($(_15).find(".calendar-menu-month-inner"));
|
|
var idx=0;
|
|
for(var i=0;i<3;i++){
|
|
var tr=$("<tr></tr>").appendTo(t);
|
|
for(var j=0;j<4;j++){
|
|
$("<td class=\"calendar-menu-month\"></td>").html(_16.months[idx++]).attr("abbr",idx).appendTo(tr);
|
|
}
|
|
}
|
|
$(_15).find(".calendar-menu-prev,.calendar-menu-next").hover(function(){
|
|
$(this).addClass("calendar-menu-hover");
|
|
},function(){
|
|
$(this).removeClass("calendar-menu-hover");
|
|
});
|
|
$(_15).find(".calendar-menu-next").click(function(){
|
|
var y=$(_15).find(".calendar-menu-year");
|
|
if(!isNaN(y.val())){
|
|
y.val(parseInt(y.val())+1);
|
|
_17();
|
|
}
|
|
});
|
|
$(_15).find(".calendar-menu-prev").click(function(){
|
|
var y=$(_15).find(".calendar-menu-year");
|
|
if(!isNaN(y.val())){
|
|
y.val(parseInt(y.val()-1));
|
|
_17();
|
|
}
|
|
});
|
|
$(_15).find(".calendar-menu-year").keypress(function(e){
|
|
if(e.keyCode==13){
|
|
_17(true);
|
|
}
|
|
});
|
|
$(_15).find(".calendar-menu-month").hover(function(){
|
|
$(this).addClass("calendar-menu-hover");
|
|
},function(){
|
|
$(this).removeClass("calendar-menu-hover");
|
|
}).click(function(){
|
|
var _18=$(_15).find(".calendar-menu");
|
|
_18.find(".calendar-selected").removeClass("calendar-selected");
|
|
$(this).addClass("calendar-selected");
|
|
_17(true);
|
|
});
|
|
}
|
|
function _17(_19){
|
|
var _1a=$(_15).find(".calendar-menu");
|
|
var _1b=_1a.find(".calendar-menu-year").val();
|
|
var _1c=_1a.find(".calendar-selected").attr("abbr");
|
|
if(!isNaN(_1b)){
|
|
_16.year=parseInt(_1b);
|
|
_16.month=parseInt(_1c);
|
|
_d(_15);
|
|
}
|
|
if(_19){
|
|
_1a.hide();
|
|
}
|
|
};
|
|
var _1d=$(_15).find(".calendar-body");
|
|
var _1e=$(_15).find(".calendar-menu");
|
|
var _1f=_1e.find(".calendar-menu-year-inner");
|
|
var _20=_1e.find(".calendar-menu-month-inner");
|
|
_1f.find("input").val(_16.year).focus();
|
|
_20.find("td.calendar-selected").removeClass("calendar-selected");
|
|
_20.find("td:eq("+(_16.month-1)+")").addClass("calendar-selected");
|
|
_1e._outerWidth(_1d._outerWidth());
|
|
_1e._outerHeight(_1d._outerHeight());
|
|
_20._outerHeight(_1e.height()-_1f._outerHeight());
|
|
};
|
|
function _21(_22,_23,_24){
|
|
var _25=$.data(_22,"calendar").options;
|
|
var _26=[];
|
|
var _27=new Date(_23,_24,0).getDate();
|
|
for(var i=1;i<=_27;i++){
|
|
_26.push([_23,_24,i]);
|
|
}
|
|
var _28=[],_29=[];
|
|
var _2a=-1;
|
|
while(_26.length>0){
|
|
var _2b=_26.shift();
|
|
_29.push(_2b);
|
|
var day=new Date(_2b[0],_2b[1]-1,_2b[2]).getDay();
|
|
if(_2a==day){
|
|
day=0;
|
|
}else{
|
|
if(day==(_25.firstDay==0?7:_25.firstDay)-1){
|
|
_28.push(_29);
|
|
_29=[];
|
|
}
|
|
}
|
|
_2a=day;
|
|
}
|
|
if(_29.length){
|
|
_28.push(_29);
|
|
}
|
|
var _2c=_28[0];
|
|
if(_2c.length<7){
|
|
while(_2c.length<7){
|
|
var _2d=_2c[0];
|
|
var _2b=new Date(_2d[0],_2d[1]-1,_2d[2]-1);
|
|
_2c.unshift([_2b.getFullYear(),_2b.getMonth()+1,_2b.getDate()]);
|
|
}
|
|
}else{
|
|
var _2d=_2c[0];
|
|
var _29=[];
|
|
for(var i=1;i<=7;i++){
|
|
var _2b=new Date(_2d[0],_2d[1]-1,_2d[2]-i);
|
|
_29.unshift([_2b.getFullYear(),_2b.getMonth()+1,_2b.getDate()]);
|
|
}
|
|
_28.unshift(_29);
|
|
}
|
|
var _2e=_28[_28.length-1];
|
|
while(_2e.length<7){
|
|
var _2f=_2e[_2e.length-1];
|
|
var _2b=new Date(_2f[0],_2f[1]-1,_2f[2]+1);
|
|
_2e.push([_2b.getFullYear(),_2b.getMonth()+1,_2b.getDate()]);
|
|
}
|
|
if(_28.length<6){
|
|
var _2f=_2e[_2e.length-1];
|
|
var _29=[];
|
|
for(var i=1;i<=7;i++){
|
|
var _2b=new Date(_2f[0],_2f[1]-1,_2f[2]+i);
|
|
_29.push([_2b.getFullYear(),_2b.getMonth()+1,_2b.getDate()]);
|
|
}
|
|
_28.push(_29);
|
|
}
|
|
return _28;
|
|
};
|
|
function _d(_30){
|
|
var _31=$.data(_30,"calendar").options;
|
|
if(_31.current&&!_31.validator.call(_30,_31.current)){
|
|
_31.current=null;
|
|
}
|
|
var now=new Date();
|
|
var _32=now.getFullYear()+","+(now.getMonth()+1)+","+now.getDate();
|
|
var _33=_31.current?(_31.current.getFullYear()+","+(_31.current.getMonth()+1)+","+_31.current.getDate()):"";
|
|
var _34=6-_31.firstDay;
|
|
var _35=_34+1;
|
|
if(_34>=7){
|
|
_34-=7;
|
|
}
|
|
if(_35>=7){
|
|
_35-=7;
|
|
}
|
|
$(_30).find(".calendar-title span").html(_31.months[_31.month-1]+" "+_31.year);
|
|
var _36=$(_30).find("div.calendar-body");
|
|
_36.children("table").remove();
|
|
var _37=["<table class=\"calendar-dtable\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"];
|
|
_37.push("<thead><tr>");
|
|
for(var i=_31.firstDay;i<_31.weeks.length;i++){
|
|
_37.push("<th>"+_31.weeks[i]+"</th>");
|
|
}
|
|
for(var i=0;i<_31.firstDay;i++){
|
|
_37.push("<th>"+_31.weeks[i]+"</th>");
|
|
}
|
|
_37.push("</tr></thead>");
|
|
_37.push("<tbody>");
|
|
var _38=_21(_30,_31.year,_31.month);
|
|
for(var i=0;i<_38.length;i++){
|
|
var _39=_38[i];
|
|
var cls="";
|
|
if(i==0){
|
|
cls="calendar-first";
|
|
}else{
|
|
if(i==_38.length-1){
|
|
cls="calendar-last";
|
|
}
|
|
}
|
|
_37.push("<tr class=\""+cls+"\">");
|
|
for(var j=0;j<_39.length;j++){
|
|
var day=_39[j];
|
|
var s=day[0]+","+day[1]+","+day[2];
|
|
var _3a=new Date(day[0],parseInt(day[1])-1,day[2]);
|
|
var d=_31.formatter.call(_30,_3a);
|
|
var css=_31.styler.call(_30,_3a);
|
|
var _3b="";
|
|
var _3c="";
|
|
if(typeof css=="string"){
|
|
_3c=css;
|
|
}else{
|
|
if(css){
|
|
_3b=css["class"]||"";
|
|
_3c=css["style"]||"";
|
|
}
|
|
}
|
|
var cls="calendar-day";
|
|
if(!(_31.year==day[0]&&_31.month==day[1])){
|
|
cls+=" calendar-other-month";
|
|
}
|
|
if(s==_32){
|
|
cls+=" calendar-today";
|
|
}
|
|
if(s==_33){
|
|
cls+=" calendar-selected";
|
|
}
|
|
if(j==_34){
|
|
cls+=" calendar-saturday";
|
|
}else{
|
|
if(j==_35){
|
|
cls+=" calendar-sunday";
|
|
}
|
|
}
|
|
if(j==0){
|
|
cls+=" calendar-first";
|
|
}else{
|
|
if(j==_39.length-1){
|
|
cls+=" calendar-last";
|
|
}
|
|
}
|
|
cls+=" "+_3b;
|
|
if(!_31.validator.call(_30,_3a)){
|
|
cls+=" calendar-disabled";
|
|
}
|
|
_37.push("<td class=\""+cls+"\" abbr=\""+s+"\" style=\""+_3c+"\">"+d+"</td>");
|
|
}
|
|
_37.push("</tr>");
|
|
}
|
|
_37.push("</tbody>");
|
|
_37.push("</table>");
|
|
_36.append(_37.join(""));
|
|
var t=_36.children("table.calendar-dtable").prependTo(_36);
|
|
t.find("td.calendar-day:not(.calendar-disabled)").hover(function(){
|
|
$(this).addClass("calendar-hover");
|
|
},function(){
|
|
$(this).removeClass("calendar-hover");
|
|
}).click(function(){
|
|
var _3d=_31.current;
|
|
t.find(".calendar-selected").removeClass("calendar-selected");
|
|
$(this).addClass("calendar-selected");
|
|
var _3e=$(this).attr("abbr").split(",");
|
|
_31.current=new Date(_3e[0],parseInt(_3e[1])-1,_3e[2]);
|
|
_31.onSelect.call(_30,_31.current);
|
|
if(!_3d||_3d.getTime()!=_31.current.getTime()){
|
|
_31.onChange.call(_30,_31.current,_3d);
|
|
}
|
|
});
|
|
};
|
|
$.fn.calendar=function(_3f,_40){
|
|
if(typeof _3f=="string"){
|
|
return $.fn.calendar.methods[_3f](this,_40);
|
|
}
|
|
_3f=_3f||{};
|
|
return this.each(function(){
|
|
var _41=$.data(this,"calendar");
|
|
if(_41){
|
|
$.extend(_41.options,_3f);
|
|
}else{
|
|
_41=$.data(this,"calendar",{options:$.extend({},$.fn.calendar.defaults,$.fn.calendar.parseOptions(this),_3f)});
|
|
_5(this);
|
|
}
|
|
if(_41.options.border==false){
|
|
$(this).addClass("calendar-noborder");
|
|
}
|
|
_1(this);
|
|
_d(this);
|
|
$(this).find("div.calendar-menu").hide();
|
|
});
|
|
};
|
|
$.fn.calendar.methods={options:function(jq){
|
|
return $.data(jq[0],"calendar").options;
|
|
},resize:function(jq){
|
|
return jq.each(function(){
|
|
_1(this);
|
|
});
|
|
},moveTo:function(jq,_42){
|
|
return jq.each(function(){
|
|
var _43=$(this).calendar("options");
|
|
if(_43.validator.call(this,_42)){
|
|
var _44=_43.current;
|
|
$(this).calendar({year:_42.getFullYear(),month:_42.getMonth()+1,current:_42});
|
|
if(!_44||_44.getTime()!=_42.getTime()){
|
|
_43.onChange.call(this,_43.current,_44);
|
|
}
|
|
}
|
|
});
|
|
}};
|
|
$.fn.calendar.parseOptions=function(_45){
|
|
var t=$(_45);
|
|
return $.extend({},$.parser.parseOptions(_45,["width","height",{firstDay:"number",fit:"boolean",border:"boolean"}]));
|
|
};
|
|
$.fn.calendar.defaults={width:180,height:180,fit:false,border:true,firstDay:0,weeks:["S","M","T","W","T","F","S"],months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],year:new Date().getFullYear(),month:new Date().getMonth()+1,current:(function(){
|
|
var d=new Date();
|
|
return new Date(d.getFullYear(),d.getMonth(),d.getDate());
|
|
})(),formatter:function(_46){
|
|
return _46.getDate();
|
|
},styler:function(_47){
|
|
return "";
|
|
},validator:function(_48){
|
|
return true;
|
|
},onSelect:function(_49){
|
|
},onChange:function(_4a,_4b){
|
|
}};
|
|
})(jQuery);
|
|
|
|
|