easyui.hp.myDatetimebox.js
1.1 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的datetimebox
* 作者:黄平
* 日期:2016-11-21
*/
(function($) {
$.fn.myDatetimebox = function(options, param) {
var self = this;
if (typeof (options) == "string") {
var method = $.fn.myDatetimebox.methods[options];
if (method){
return method.call(this, param);
} else {
return this.form(options, param);
}
}
return this.each(function() {
var opt = $.extend({}, $.fn.myDatetimebox.defaults, options);
self.data("myDatetimebox", opt);
_createDatetimebox(self);
});
};
/**
* 创建
* @param jq
* @returns
*/
function _createDatetimebox(jq) {
var opt = jq.data("myDatetimebox");
var btns = $.extend([], $.fn.datetimebox.defaults.buttons);
btns.splice(1, 0, {
text : "清除",
handler : function(target) {
jq.datetimebox("clear");
}
});
jq.datetimebox($.extend({}, {
buttons : btns
}, opt));
}
$.fn.myDatetimebox.methods = {
};
$.fn.myDatetimebox.event = {
};
$.fn.myDatetimebox.defaults = $.extend({}, $.fn.myDatetimebox.event, {
editable : false
});
})(jQuery);