@@ -67,6 +67,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
67
67
this . _detectOrientation ( ) ;
68
68
this . _mouseInit ( ) ;
69
69
this . _calculateNewMax ( ) ;
70
+ this . _cleanValues ( ) ;
70
71
71
72
this . element
72
73
. addClass ( "ui-slider" +
@@ -159,12 +160,28 @@ return $.widget( "ui.slider", $.ui.mouse, {
159
160
160
161
_cleanValues : function ( index , newValue ) {
161
162
var values ,
162
- i = 0 ;
163
+ i = 0 ;
164
+
165
+ if ( this . options . range === true ) {
166
+ if ( arguments . length === 2 ) {
167
+ values = this . options . values ;
168
+ if ( index === 0 && newValue < this . _valueMin ( ) ) {
169
+ newValue = this . _valueMin ( ) ;
170
+ } else if ( index === 1 && newValue > this . _valueMax ( ) ) {
171
+ newValue = this . _valueMax ( ) ;
172
+ }
173
+
174
+ if ( index === 0 && newValue > values [ 1 ] ) {
175
+ newValue = values [ 1 ] ;
176
+ } else if ( index === 1 && newValue < values [ 0 ] ) {
177
+ newValue = values [ 0 ] ;
178
+ }
179
+ return newValue ;
180
+ }
163
181
164
- if ( $ . isArray ( arguments [ 0 ] ) ) {
165
182
values = arguments [ 0 ] || this . options . values ;
166
183
if ( values ) {
167
- for ( ; i < values . length ; i ++ ) {
184
+ for ( ; i < values . length ; i ++ ) {
168
185
if ( values [ i ] < this . _valueMin ( ) ) {
169
186
values [ i ] = this . _valueMin ( ) ;
170
187
}
@@ -176,26 +193,19 @@ return $.widget( "ui.slider", $.ui.mouse, {
176
193
if ( values [ 0 ] > values [ 1 ] ) {
177
194
values [ 1 ] = values [ 0 ] ;
178
195
}
179
- return values ;
180
- }
181
- }
182
-
183
- if ( arguments . length > 1 ) {
184
- values = this . options . values ;
185
- if ( index === 0 && newValue < this . _valueMin ( ) ) {
186
- newValue = this . _valueMin ( ) ;
187
- } else if ( index === 1 && newValue > this . _valueMax ( ) ) {
188
- newValue = this . _valueMax ( ) ;
189
- }
190
196
191
- if ( this . options . range === true && values . length === 2 ) {
192
- if ( index === 0 && newValue > values [ index + 1 ] ) {
193
- newValue = values [ index + 1 ] ;
194
- } else if ( index === 1 && newValue < values [ index - 1 ] ) {
195
- newValue = values [ index - 1 ] ;
197
+ if ( arguments [ 0 ] ) {
198
+ return values ;
199
+ } else {
200
+ this . options . values = values ;
196
201
}
197
202
}
198
- return newValue ;
203
+ } else {
204
+ if ( $ . isArray ( arguments [ 0 ] ) ) {
205
+ return arguments [ 0 ] ;
206
+ } else {
207
+ return newValue ;
208
+ }
199
209
}
200
210
} ,
201
211
@@ -465,7 +475,6 @@ return $.widget( "ui.slider", $.ui.mouse, {
465
475
this . _refreshValue ( ) ;
466
476
} else {
467
477
if ( this . options . values && this . options . values . length ) {
468
- this . options . values = this . _cleanValues ( this . options . values ) ;
469
478
return this . _values ( index ) ;
470
479
} else {
471
480
return this . value ( ) ;
0 commit comments