easyui.hp.myDatebox.js
1.04 KB
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
/**
* 显示一个日期选择框
* 继承与easyui的datebox
* 作者:黄平
* 日期:2016-11-21
*/
(function($) {
$.fn.myDatebox = function(options, param) {
var self = this;
if (typeof (options) == "string") {
var method = $.fn.myDatebox.methods[options];
if (method){
return method.call(this, param);
} else {
return this.datebox(options, param);
}
}
return this.each(function() {
var opt = $.extend({}, $.fn.myDatebox.defaults, options);
self.data("myDatebox", opt);
_createDatebox(self);
});
};
/**
* 创建
* @param jq
* @returns
*/
function _createDatebox(jq) {
var opt = jq.data("myDatebox");
var btns = $.extend([], $.fn.datebox.defaults.buttons);
btns.splice(1, 0, {
text : "清除",
handler : function(target) {
jq.datebox("clear");
}
});
jq.datebox($.extend({}, {
buttons : btns
}, opt));
}
$.fn.myDatebox.methods = {
};
$.fn.myDatebox.event = {
};
$.fn.myDatebox.defaults = $.extend({}, $.fn.myDatebox.event, {
editable : false
});
})(jQuery);