@@ -36,6 +36,11 @@ return $.widget( "ui.slider", $.ui.mouse, {
36
36
37
37
options : {
38
38
animate : false ,
39
+ classes : {
40
+ "ui-slider" : "ui-corner-all" ,
41
+ "ui-slider-handle" : "ui-corner-all" ,
42
+ "ui-slider-range" : "ui-corner-all"
43
+ } ,
39
44
distance : 0 ,
40
45
max : 100 ,
41
46
min : 0 ,
@@ -65,12 +70,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
65
70
this . _mouseInit ( ) ;
66
71
this . _calculateNewMax ( ) ;
67
72
68
- this . element
69
- . addClass ( "ui-slider" +
70
- " ui-slider-" + this . orientation +
71
- " ui-widget" +
72
- " ui-widget-content" +
73
- " ui-corner-all" ) ;
73
+ this . _addClass ( "ui-slider ui-slider-" + this . orientation ,
74
+ "ui-widget ui-widget-content ui-corner-all" ) ;
74
75
75
76
this . _refresh ( ) ;
76
77
this . _setOption ( "disabled" , this . options . disabled ) ;
@@ -88,8 +89,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
88
89
_createHandles : function ( ) {
89
90
var i , handleCount ,
90
91
options = this . options ,
91
- existingHandles = this . element . find ( ".ui-slider-handle" ) . addClass ( "ui-state-default ui-corner-all" ) ,
92
- handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>" ,
92
+ existingHandles = this . element . find ( ".ui-slider-handle" ) ,
93
+ handle = "<span tabindex='0'></span>" ,
93
94
handles = [ ] ;
94
95
95
96
handleCount = ( options . values && options . values . length ) || 1 ;
@@ -105,6 +106,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
105
106
106
107
this . handles = existingHandles . add ( $ ( handles . join ( "" ) ) . appendTo ( this . element ) ) ;
107
108
109
+ this . _addClass ( this . handles , "ui-slider-handle" , "ui-state-default" ) ;
110
+
108
111
this . handle = this . handles . eq ( 0 ) ;
109
112
110
113
this . handles . each ( function ( i ) {
@@ -113,8 +116,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
113
116
} ,
114
117
115
118
_createRange : function ( ) {
116
- var options = this . options ,
117
- classes = "" ;
119
+ var options = this . options ;
118
120
119
121
if ( options . range ) {
120
122
if ( options . range === true ) {
@@ -128,24 +130,24 @@ return $.widget( "ui.slider", $.ui.mouse, {
128
130
}
129
131
130
132
if ( ! this . range || ! this . range . length ) {
131
- this . range = $ ( "<div></div> " )
133
+ this . range = $ ( "<div>" )
132
134
. appendTo ( this . element ) ;
133
135
134
- classes = "ui-slider-range" +
135
- // note: this isn't the most fittingly semantic framework class for this element,
136
+ // Note: this isn't the most fittingly semantic framework class for this element,
136
137
// but worked best visually with a variety of themes
137
- " ui-widget-header ui-corner-all" ;
138
+ this . _addClass ( this . range , " ui-slider-range ui-widget-header" ) ;
138
139
} else {
139
- this . range . removeClass ( "ui-slider-range-min ui-slider-range-max" )
140
- // Handle range switching from true to min/max
141
- . css ( {
142
- "left" : "" ,
143
- "bottom" : ""
144
- } ) ;
145
- }
140
+ this . _removeClass ( this . range , "ui-slider-range-min ui-slider-range-max" ) ;
146
141
147
- this . range . addClass ( classes +
148
- ( ( options . range === "min" || options . range === "max" ) ? " ui-slider-range-" + options . range : "" ) ) ;
142
+ // Handle range switching from true to min/max
143
+ this . range . css ( {
144
+ "left" : "" ,
145
+ "bottom" : ""
146
+ } ) ;
147
+ }
148
+ if ( options . range === "min" || options . range === "max" ) {
149
+ this . _addClass ( this . range , "ui-slider-range-" + options . range ) ;
150
+ }
149
151
} else {
150
152
if ( this . range ) {
151
153
this . range . remove ( ) ;
@@ -167,14 +169,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
167
169
this . range . remove ( ) ;
168
170
}
169
171
170
- this . element
171
- . removeClass ( "ui-slider" +
172
- " ui-slider-horizontal" +
173
- " ui-slider-vertical" +
174
- " ui-widget" +
175
- " ui-widget-content" +
176
- " ui-corner-all" ) ;
177
-
178
172
this . _mouseDestroy ( ) ;
179
173
} ,
180
174
@@ -215,9 +209,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
215
209
216
210
this . _handleIndex = index ;
217
211
218
- closestHandle
219
- . addClass ( "ui-state-active" )
220
- . focus ( ) ;
212
+ this . _addClass ( closestHandle , null , "ui-state-active" ) ;
213
+ closestHandle . focus ( ) ;
221
214
222
215
offset = closestHandle . offset ( ) ;
223
216
mouseOverHandle = ! $ ( event . target ) . parents ( ) . addBack ( ) . is ( ".ui-slider-handle" ) ;
@@ -251,7 +244,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
251
244
} ,
252
245
253
246
_mouseStop : function ( event ) {
254
- this . handles . removeClass ( "ui-state-active" ) ;
247
+ this . _removeClass ( this . handles , null , "ui-state-active" ) ;
255
248
this . _mouseSliding = false ;
256
249
257
250
this . _stop ( event , this . _handleIndex ) ;
@@ -448,18 +441,17 @@ return $.widget( "ui.slider", $.ui.mouse, {
448
441
}
449
442
450
443
if ( key === "disabled" ) {
451
- this . element . toggleClass ( "ui-state-disabled" , ! ! value ) ;
444
+ this . _toggleClass ( null , "ui-state-disabled" , ! ! value ) ;
452
445
}
453
446
454
447
this . _super ( key , value ) ;
455
448
456
449
switch ( key ) {
457
450
case "orientation" :
458
451
this . _detectOrientation ( ) ;
459
- this . element
460
- . removeClass ( "ui-slider-horizontal ui-slider-vertical" )
461
- . addClass ( "ui-slider-" + this . orientation ) ;
462
- this . _refreshValue ( ) ;
452
+ this . _removeClass ( "ui-slider-horizontal ui-slider-vertical" )
453
+ . _addClass ( "ui-slider-" + this . orientation )
454
+ . _refreshValue ( ) ;
463
455
464
456
// Reset positioning from previous orientation
465
457
this . handles . css ( value === "horizontal" ? "bottom" : "left" , "" ) ;
@@ -656,7 +648,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
656
648
event . preventDefault ( ) ;
657
649
if ( ! this . _keySliding ) {
658
650
this . _keySliding = true ;
659
- $ ( event . target ) . addClass ( "ui-state-active" ) ;
651
+ this . _addClass ( $ ( event . target ) , null , "ui-state-active" ) ;
660
652
allowed = this . _start ( event , index ) ;
661
653
if ( allowed === false ) {
662
654
return ;
@@ -713,7 +705,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
713
705
this . _keySliding = false ;
714
706
this . _stop ( event , index ) ;
715
707
this . _change ( event , index ) ;
716
- $ ( event . target ) . removeClass ( "ui-state-active" ) ;
708
+ this . _removeClass ( $ ( event . target ) , null , "ui-state-active" ) ;
717
709
}
718
710
}
719
711
}
0 commit comments