@@ -39,6 +39,14 @@ return $.widget( "ui.slider", $.ui.mouse, {
39
39
40
40
options : {
41
41
animate : false ,
42
+ classes : {
43
+ "ui-slider" : "ui-corner-all" ,
44
+ "ui-slider-handle" : "ui-corner-all" ,
45
+
46
+ // Note: ui-widget-header isn't the most fittingly semantic framework class for this
47
+ // element, but worked best visually with a variety of themes
48
+ "ui-slider-range" : "ui-corner-all ui-widget-header"
49
+ } ,
42
50
distance : 0 ,
43
51
max : 100 ,
44
52
min : 0 ,
@@ -68,12 +76,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
68
76
this . _mouseInit ( ) ;
69
77
this . _calculateNewMax ( ) ;
70
78
71
- this . element
72
- . addClass ( "ui-slider" +
73
- " ui-slider-" + this . orientation +
74
- " ui-widget" +
75
- " ui-widget-content" +
76
- " ui-corner-all" ) ;
79
+ this . _addClass ( "ui-slider ui-slider-" + this . orientation ,
80
+ "ui-widget ui-widget-content" ) ;
77
81
78
82
this . _refresh ( ) ;
79
83
this . _setOption ( "disabled" , this . options . disabled ) ;
@@ -91,8 +95,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
91
95
_createHandles : function ( ) {
92
96
var i , handleCount ,
93
97
options = this . options ,
94
- existingHandles = this . element . find ( ".ui-slider-handle" ) . addClass ( "ui-state-default ui-corner-all" ) ,
95
- handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>" ,
98
+ existingHandles = this . element . find ( ".ui-slider-handle" ) ,
99
+ handle = "<span tabindex='0'></span>" ,
96
100
handles = [ ] ;
97
101
98
102
handleCount = ( options . values && options . values . length ) || 1 ;
@@ -108,6 +112,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
108
112
109
113
this . handles = existingHandles . add ( $ ( handles . join ( "" ) ) . appendTo ( this . element ) ) ;
110
114
115
+ this . _addClass ( this . handles , "ui-slider-handle" , "ui-state-default" ) ;
116
+
111
117
this . handle = this . handles . eq ( 0 ) ;
112
118
113
119
this . handles . each ( function ( i ) {
@@ -116,8 +122,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
116
122
} ,
117
123
118
124
_createRange : function ( ) {
119
- var options = this . options ,
120
- classes = "" ;
125
+ var options = this . options ;
121
126
122
127
if ( options . range ) {
123
128
if ( options . range === true ) {
@@ -131,24 +136,22 @@ return $.widget( "ui.slider", $.ui.mouse, {
131
136
}
132
137
133
138
if ( ! this . range || ! this . range . length ) {
134
- this . range = $ ( "<div></div> " )
139
+ this . range = $ ( "<div>" )
135
140
. appendTo ( this . element ) ;
136
141
137
- classes = "ui-slider-range" +
138
- // note: this isn't the most fittingly semantic framework class for this element,
139
- // but worked best visually with a variety of themes
140
- " ui-widget-header ui-corner-all" ;
142
+ this . _addClass ( this . range , "ui-slider-range" ) ;
141
143
} else {
142
- this . range . removeClass ( "ui-slider-range-min ui-slider-range-max" )
143
- // Handle range switching from true to min/max
144
- . css ( {
145
- "left" : "" ,
146
- "bottom" : ""
147
- } ) ;
148
- }
144
+ this . _removeClass ( this . range , "ui-slider-range-min ui-slider-range-max" ) ;
149
145
150
- this . range . addClass ( classes +
151
- ( ( options . range === "min" || options . range === "max" ) ? " ui-slider-range-" + options . range : "" ) ) ;
146
+ // Handle range switching from true to min/max
147
+ this . range . css ( {
148
+ "left" : "" ,
149
+ "bottom" : ""
150
+ } ) ;
151
+ }
152
+ if ( options . range === "min" || options . range === "max" ) {
153
+ this . _addClass ( this . range , "ui-slider-range-" + options . range ) ;
154
+ }
152
155
} else {
153
156
if ( this . range ) {
154
157
this . range . remove ( ) ;
@@ -170,14 +173,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
170
173
this . range . remove ( ) ;
171
174
}
172
175
173
- this . element
174
- . removeClass ( "ui-slider" +
175
- " ui-slider-horizontal" +
176
- " ui-slider-vertical" +
177
- " ui-widget" +
178
- " ui-widget-content" +
179
- " ui-corner-all" ) ;
180
-
181
176
this . _mouseDestroy ( ) ;
182
177
} ,
183
178
@@ -218,9 +213,8 @@ return $.widget( "ui.slider", $.ui.mouse, {
218
213
219
214
this . _handleIndex = index ;
220
215
221
- closestHandle
222
- . addClass ( "ui-state-active" )
223
- . focus ( ) ;
216
+ this . _addClass ( closestHandle , null , "ui-state-active" ) ;
217
+ closestHandle . focus ( ) ;
224
218
225
219
offset = closestHandle . offset ( ) ;
226
220
mouseOverHandle = ! $ ( event . target ) . parents ( ) . addBack ( ) . is ( ".ui-slider-handle" ) ;
@@ -254,7 +248,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
254
248
} ,
255
249
256
250
_mouseStop : function ( event ) {
257
- this . handles . removeClass ( "ui-state-active" ) ;
251
+ this . _removeClass ( this . handles , null , "ui-state-active" ) ;
258
252
this . _mouseSliding = false ;
259
253
260
254
this . _stop ( event , this . _handleIndex ) ;
@@ -451,17 +445,16 @@ return $.widget( "ui.slider", $.ui.mouse, {
451
445
}
452
446
453
447
if ( key === "disabled" ) {
454
- this . element . toggleClass ( "ui-state-disabled" , ! ! value ) ;
448
+ this . _toggleClass ( null , "ui-state-disabled" , ! ! value ) ;
455
449
}
456
450
457
451
this . _super ( key , value ) ;
458
452
459
453
switch ( key ) {
460
454
case "orientation" :
461
455
this . _detectOrientation ( ) ;
462
- this . element
463
- . removeClass ( "ui-slider-horizontal ui-slider-vertical" )
464
- . addClass ( "ui-slider-" + this . orientation ) ;
456
+ this . _removeClass ( "ui-slider-horizontal ui-slider-vertical" )
457
+ . _addClass ( "ui-slider-" + this . orientation ) ;
465
458
this . _refreshValue ( ) ;
466
459
467
460
// Reset positioning from previous orientation
@@ -659,7 +652,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
659
652
event . preventDefault ( ) ;
660
653
if ( ! this . _keySliding ) {
661
654
this . _keySliding = true ;
662
- $ ( event . target ) . addClass ( "ui-state-active" ) ;
655
+ this . _addClass ( $ ( event . target ) , null , "ui-state-active" ) ;
663
656
allowed = this . _start ( event , index ) ;
664
657
if ( allowed === false ) {
665
658
return ;
@@ -716,7 +709,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
716
709
this . _keySliding = false ;
717
710
this . _stop ( event , index ) ;
718
711
this . _change ( event , index ) ;
719
- $ ( event . target ) . removeClass ( "ui-state-active" ) ;
712
+ this . _removeClass ( $ ( event . target ) , null , "ui-state-active" ) ;
720
713
}
721
714
}
722
715
}
0 commit comments