Commit 271c182f by Valera Rozuvan Committed by Alexander Kryklia

Fixed bug: jQuery slider default change event name is "slidechange", and it…

Fixed bug: jQuery slider default change event name is "slidechange", and it behaves a bit differently than "slide" event.
parent a75003ef
...@@ -18,8 +18,9 @@ define('Sliders', ['logme'], function (logme) { ...@@ -18,8 +18,9 @@ define('Sliders', ['logme'], function (logme) {
if (sliderDiv.length === 1) { if (sliderDiv.length === 1) {
onEvent = 'slide'; onEvent = 'slide';
if (sliderDiv.attr('data-on_event') === 'change') { if (sliderDiv.attr('data-on_event') === 'change') {
onEvent = 'change'; onEvent = 'slidechange';
} }
createSlider(sliderDiv, paramName, onEvent); createSlider(sliderDiv, paramName, onEvent);
} else if (sliderDiv.length > 1) { } else if (sliderDiv.length > 1) {
logme('ERROR: Found more than one slider for the parameter "' + paramName + '".'); logme('ERROR: Found more than one slider for the parameter "' + paramName + '".');
...@@ -48,9 +49,7 @@ define('Sliders', ['logme'], function (logme) { ...@@ -48,9 +49,7 @@ define('Sliders', ['logme'], function (logme) {
'min': paramObj.min, 'min': paramObj.min,
'max': paramObj.max, 'max': paramObj.max,
'value': paramObj.value, 'value': paramObj.value,
'step': paramObj.step, 'step': paramObj.step
onEvent: sliderOnSlide
}); });
// Tell the parameter object stored in state that we have a slider // Tell the parameter object stored in state that we have a slider
...@@ -58,6 +57,9 @@ define('Sliders', ['logme'], function (logme) { ...@@ -58,6 +57,9 @@ define('Sliders', ['logme'], function (logme) {
// will also update the value of this slider. // will also update the value of this slider.
paramObj.sliderDiv = sliderDiv; paramObj.sliderDiv = sliderDiv;
// Atach a callback to update the slider's parameter.
paramObj.sliderDiv.on(onEvent, sliderOnSlide);
return; return;
// Update the 'state' - i.e. set the value of the parameter this // Update the 'state' - i.e. set the value of the parameter this
...@@ -66,7 +68,6 @@ define('Sliders', ['logme'], function (logme) { ...@@ -66,7 +68,6 @@ define('Sliders', ['logme'], function (logme) {
// This will cause the plot to be redrawn each time after the user // This will cause the plot to be redrawn each time after the user
// drags the slider handle and releases it. // drags the slider handle and releases it.
function sliderOnSlide(event, ui) { function sliderOnSlide(event, ui) {
// Last parameter passed to setParameterValue() will be 'true' // Last parameter passed to setParameterValue() will be 'true'
// so that the function knows we are a slider, and it can // so that the function knows we are a slider, and it can
// change the our value back in the case when the new value is // change the our value back in the case when the new value is
......
...@@ -241,7 +241,7 @@ define('State', ['logme'], function (logme) { ...@@ -241,7 +241,7 @@ define('State', ['logme'], function (logme) {
} }
// Update the single slider with the new parameter's value. // Update the single slider with the new parameter's value.
if (parameters[paramName].sliderDiv !== null) { if ((slider === false) && (parameters[paramName].sliderDiv !== null)) {
parameters[paramName].sliderDiv.slider('value', paramValueNum); parameters[paramName].sliderDiv.slider('value', paramValueNum);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment