forked from cocoo/easyui-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.linkbutton.js
103 lines (102 loc) · 2.49 KB
/
jquery.linkbutton.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
/**
* 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,"linkbutton").options;
$(_2).empty();
$(_2).addClass("l-btn");
if(_3.id){
$(_2).attr("id",_3.id);
}else{
$(_2).attr("id","");
}
if(_3.plain){
$(_2).addClass("l-btn-plain");
}else{
$(_2).removeClass("l-btn-plain");
}
if(_3.text){
$(_2).html(_3.text).wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"</span>"+"</span>");
if(_3.iconCls){
$(_2).find(".l-btn-text").addClass(_3.iconCls).css("padding-left","20px");
}
}else{
$(_2).html(" ").wrapInner("<span class=\"l-btn-left\">"+"<span class=\"l-btn-text\">"+"<span class=\"l-btn-empty\"></span>"+"</span>"+"</span>");
if(_3.iconCls){
$(_2).find(".l-btn-empty").addClass(_3.iconCls);
}
}
$(_2).unbind(".linkbutton").bind("focus.linkbutton",function(){
if(!_3.disabled){
$(this).find("span.l-btn-text").addClass("l-btn-focus");
}
}).bind("blur.linkbutton",function(){
$(this).find("span.l-btn-text").removeClass("l-btn-focus");
});
_4(_2,_3.disabled);
};
function _4(_5,_6){
var _7=$.data(_5,"linkbutton");
if(_6){
_7.options.disabled=true;
var _8=$(_5).attr("href");
if(_8){
_7.href=_8;
$(_5).attr("href","javascript:void(0)");
}
if(_5.onclick){
_7.onclick=_5.onclick;
_5.onclick=null;
}
$(_5).addClass("l-btn-disabled");
}else{
_7.options.disabled=false;
if(_7.href){
$(_5).attr("href",_7.href);
}
if(_7.onclick){
_5.onclick=_7.onclick;
}
$(_5).removeClass("l-btn-disabled");
}
};
$.fn.linkbutton=function(_9,_a){
if(typeof _9=="string"){
return $.fn.linkbutton.methods[_9](this,_a);
}
_9=_9||{};
return this.each(function(){
var _b=$.data(this,"linkbutton");
if(_b){
$.extend(_b.options,_9);
}else{
$.data(this,"linkbutton",{options:$.extend({},$.fn.linkbutton.defaults,$.fn.linkbutton.parseOptions(this),_9)});
$(this).removeAttr("disabled");
}
_1(this);
});
};
$.fn.linkbutton.methods={options:function(jq){
return $.data(jq[0],"linkbutton").options;
},enable:function(jq){
return jq.each(function(){
_4(this,false);
});
},disable:function(jq){
return jq.each(function(){
_4(this,true);
});
}};
$.fn.linkbutton.parseOptions=function(_c){
var t=$(_c);
return $.extend({},$.parser.parseOptions(_c,["id","iconCls",{plain:"boolean"}]),{disabled:(t.attr("disabled")?true:undefined),text:$.trim(t.html()),iconCls:(t.attr("icon")||t.attr("iconCls"))});
};
$.fn.linkbutton.defaults={id:null,disabled:false,plain:false,text:"",iconCls:null};
})(jQuery);