2
2
//= require jquery.ui.widget
3
3
4
4
/*!
5
- * jQuery UI Button 1.10.3
5
+ * jQuery UI Button 1.10.4
6
6
* http://jqueryui.com
7
7
*
8
- * Copyright 2013 jQuery Foundation and other contributors
8
+ * Copyright 2014 jQuery Foundation and other contributors
9
9
* Released under the MIT license.
10
10
* http://jquery.org/license
11
11
*
17
17
*/
18
18
( function ( $ , undefined ) {
19
19
20
- var lastActive , startXPos , startYPos , clickDragged ,
20
+ var lastActive ,
21
21
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all" ,
22
- stateClasses = "ui-state-hover ui-state-active " ,
23
22
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only" ,
24
23
formResetHandler = function ( ) {
25
24
var form = $ ( this ) ;
@@ -46,7 +45,7 @@ var lastActive, startXPos, startYPos, clickDragged,
46
45
} ;
47
46
48
47
$ . widget ( "ui.button" , {
49
- version : "1.10.3 " ,
48
+ version : "1.10.4 " ,
50
49
defaultElement : "<button>" ,
51
50
options : {
52
51
disabled : null ,
@@ -74,8 +73,7 @@ $.widget( "ui.button", {
74
73
var that = this ,
75
74
options = this . options ,
76
75
toggleButton = this . type === "checkbox" || this . type === "radio" ,
77
- activeClass = ! toggleButton ? "ui-state-active" : "" ,
78
- focusClass = "ui-state-focus" ;
76
+ activeClass = ! toggleButton ? "ui-state-active" : "" ;
79
77
80
78
if ( options . label === null ) {
81
79
options . label = ( this . type === "input" ? this . buttonElement . val ( ) : this . buttonElement . html ( ) ) ;
@@ -107,53 +105,32 @@ $.widget( "ui.button", {
107
105
}
108
106
} ) ;
109
107
110
- this . element
111
- . bind ( "focus" + this . eventNamespace , function ( ) {
112
- // no need to check disabled, focus won't be triggered anyway
113
- that . buttonElement . addClass ( focusClass ) ;
114
- } )
115
- . bind ( "blur" + this . eventNamespace , function ( ) {
116
- that . buttonElement . removeClass ( focusClass ) ;
117
- } ) ;
108
+ // Can't use _focusable() because the element that receives focus
109
+ // and the element that gets the ui-state-focus class are different
110
+ this . _on ( {
111
+ focus : function ( ) {
112
+ this . buttonElement . addClass ( "ui-state-focus" ) ;
113
+ } ,
114
+ blur : function ( ) {
115
+ this . buttonElement . removeClass ( "ui-state-focus" ) ;
116
+ }
117
+ } ) ;
118
118
119
119
if ( toggleButton ) {
120
120
this . element . bind ( "change" + this . eventNamespace , function ( ) {
121
- if ( clickDragged ) {
122
- return ;
123
- }
124
121
that . refresh ( ) ;
125
122
} ) ;
126
- // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
127
- // prevents issue where button state changes but checkbox/radio checked state
128
- // does not in Firefox (see ticket #6970)
129
- this . buttonElement
130
- . bind ( "mousedown" + this . eventNamespace , function ( event ) {
131
- if ( options . disabled ) {
132
- return ;
133
- }
134
- clickDragged = false ;
135
- startXPos = event . pageX ;
136
- startYPos = event . pageY ;
137
- } )
138
- . bind ( "mouseup" + this . eventNamespace , function ( event ) {
139
- if ( options . disabled ) {
140
- return ;
141
- }
142
- if ( startXPos !== event . pageX || startYPos !== event . pageY ) {
143
- clickDragged = true ;
144
- }
145
- } ) ;
146
123
}
147
124
148
125
if ( this . type === "checkbox" ) {
149
126
this . buttonElement . bind ( "click" + this . eventNamespace , function ( ) {
150
- if ( options . disabled || clickDragged ) {
127
+ if ( options . disabled ) {
151
128
return false ;
152
129
}
153
130
} ) ;
154
131
} else if ( this . type === "radio" ) {
155
132
this . buttonElement . bind ( "click" + this . eventNamespace , function ( ) {
156
- if ( options . disabled || clickDragged ) {
133
+ if ( options . disabled ) {
157
134
return false ;
158
135
}
159
136
$ ( this ) . addClass ( "ui-state-active" ) ;
@@ -263,7 +240,7 @@ $.widget( "ui.button", {
263
240
this . element
264
241
. removeClass ( "ui-helper-hidden-accessible" ) ;
265
242
this . buttonElement
266
- . removeClass ( baseClasses + " " + stateClasses + " " + typeClasses )
243
+ . removeClass ( baseClasses + " ui-state-active " + typeClasses )
267
244
. removeAttr ( "role" )
268
245
. removeAttr ( "aria-pressed" )
269
246
. html ( this . buttonElement . find ( ".ui-button-text" ) . html ( ) ) ;
@@ -276,10 +253,9 @@ $.widget( "ui.button", {
276
253
_setOption : function ( key , value ) {
277
254
this . _super ( key , value ) ;
278
255
if ( key === "disabled" ) {
256
+ this . element . prop ( "disabled" , ! ! value ) ;
279
257
if ( value ) {
280
- this . element . prop ( "disabled" , true ) ;
281
- } else {
282
- this . element . prop ( "disabled" , false ) ;
258
+ this . buttonElement . removeClass ( "ui-state-focus" ) ;
283
259
}
284
260
return ;
285
261
}
@@ -363,7 +339,7 @@ $.widget( "ui.button", {
363
339
} ) ;
364
340
365
341
$ . widget ( "ui.buttonset" , {
366
- version : "1.10.3 " ,
342
+ version : "1.10.4 " ,
367
343
options : {
368
344
items : "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
369
345
} ,
0 commit comments