Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
rangeslider: force update on mousedown to prevent situation where use…
Browse files Browse the repository at this point in the history
…r has typed in input but input has not yet blured. Fixes #5644 - Rangeslider makes FF (Mac OS) pause for few sec and throw error "too much recursion" when manually enter right value less than left one and click middle slider area
  • Loading branch information
arschmitz committed Apr 1, 2013
1 parent 70e2aed commit af3c4fa
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions js/widgets/forms/rangeslider.js
Expand Up @@ -64,6 +64,9 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
"blur": "_change",
"keyup": "_change"
});
this._on({
"mousedown":"_change"
});
this._on( firstHandle, {
"vmousedown": "_dragFirstHandle"
});
Expand Down Expand Up @@ -134,21 +137,27 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
return false;
}

var min = parseFloat( this._inputFirst.val(), 10 ),
var self = this,
min = parseFloat( this._inputFirst.val(), 10 ),
max = parseFloat( this._inputLast.val(), 10 ),
first = $( event.target ).hasClass( "ui-rangeslider-first" ),
thisSlider = first ? this._inputFirst : this._inputLast,
otherSlider = first ? this._inputLast : this._inputFirst;



if( ( this._inputFirst.val() > this._inputLast.val() && event.type === "mousedown" && !$(event.target).hasClass("ui-slider-handle")) ){
thisSlider.blur();
} else if( event.type === "mousedown" ){
return;
}
if ( min > max && !this._sliderTarget ) {
//this prevents min from being greater then max
thisSlider.val( first ? max: min ).slider( "refresh" );
this._trigger( "normalize" );
} else if ( min > max ) {
//this makes it so clicks on the target on either extreme go to the closest handle
thisSlider.val( this._targetVal ).slider( "refresh" );

var self = this;

//You must wait for the stack to unwind so first slider is updated before updating second
setTimeout( function() {
otherSlider.val( first ? min: max ).slider( "refresh" );
Expand Down

0 comments on commit af3c4fa

Please sign in to comment.