forked from cocoo/easyui-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.datebox.js
119 lines (118 loc) · 3.05 KB
/
jquery.datebox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* EasyUi Bootstrap 1.3
*
* Licensed under the GPL terms
* To use it on other terms please contact us
*
* Copyright(c) 2009-2012 stworthy [ stworthy@gmail.com ]
*
*/
(function($){
function _1(_2){
var _3=$.data(_2,"datebox");
var _4=_3.options;
$(_2).addClass("datebox-f");
$(_2).combo($.extend({},_4,{onShowPanel:function(){
_3.calendar.calendar("resize");
_4.onShowPanel.call(_2);
}}));
$(_2).combo("textbox").parent().addClass("datebox");
if(!_3.calendar){
_5();
}
function _5(){
var _6=$(_2).combo("panel");
_3.calendar=$("<div></div>").appendTo(_6).wrap("<div class=\"datebox-calendar-inner\"></div>");
_3.calendar.calendar({fit:true,border:false,onSelect:function(_7){
var _8=_4.formatter(_7);
_c(_2,_8);
$(_2).combo("hidePanel");
_4.onSelect.call(_2,_7);
}});
_c(_2,_4.value);
var _9=$("<div class=\"datebox-button\"></div>").appendTo(_6);
$("<a href=\"javascript:void(0)\" class=\"datebox-current\"></a>").html(_4.currentText).appendTo(_9);
$("<a href=\"javascript:void(0)\" class=\"datebox-close\"></a>").html(_4.closeText).appendTo(_9);
_9.find(".datebox-current,.datebox-close").hover(function(){
$(this).addClass("datebox-button-hover");
},function(){
$(this).removeClass("datebox-button-hover");
});
_9.find(".datebox-current").click(function(){
_3.calendar.calendar({year:new Date().getFullYear(),month:new Date().getMonth()+1,current:new Date()});
});
_9.find(".datebox-close").click(function(){
$(_2).combo("hidePanel");
});
};
};
function _a(_b,q){
_c(_b,q);
};
function _d(_e){
var _f=$.data(_e,"datebox").options;
var c=$.data(_e,"datebox").calendar;
var _10=_f.formatter(c.calendar("options").current);
_c(_e,_10);
$(_e).combo("hidePanel");
};
function _c(_11,_12){
var _13=$.data(_11,"datebox");
var _14=_13.options;
$(_11).combo("setValue",_12).combo("setText",_12);
_13.calendar.calendar("moveTo",_14.parser(_12));
};
$.fn.datebox=function(_15,_16){
if(typeof _15=="string"){
var _17=$.fn.datebox.methods[_15];
if(_17){
return _17(this,_16);
}else{
return this.combo(_15,_16);
}
}
_15=_15||{};
return this.each(function(){
var _18=$.data(this,"datebox");
if(_18){
$.extend(_18.options,_15);
}else{
$.data(this,"datebox",{options:$.extend({},$.fn.datebox.defaults,$.fn.datebox.parseOptions(this),_15)});
}
_1(this);
});
};
$.fn.datebox.methods={options:function(jq){
return $.data(jq[0],"datebox").options;
},calendar:function(jq){
return $.data(jq[0],"datebox").calendar;
},setValue:function(jq,_19){
return jq.each(function(){
_c(this,_19);
});
}};
$.fn.datebox.parseOptions=function(_1a){
var t=$(_1a);
return $.extend({},$.fn.combo.parseOptions(_1a),{});
};
$.fn.datebox.defaults=$.extend({},$.fn.combo.defaults,{panelWidth:180,panelHeight:"auto",keyHandler:{up:function(){
},down:function(){
},enter:function(){
_d(this);
},query:function(q){
_a(this,q);
}},currentText:"Today",closeText:"Close",okText:"Ok",formatter:function(_1b){
var y=_1b.getFullYear();
var m=_1b.getMonth()+1;
var d=_1b.getDate();
return m+"/"+d+"/"+y;
},parser:function(s){
var t=Date.parse(s);
if(!isNaN(t)){
return new Date(t);
}else{
return new Date();
}
},onSelect:function(_1c){
}});
})(jQuery);