Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #10744: Numeric slider : no difference between unanswered +
no reset
  • Loading branch information
olleharstedt committed Mar 22, 2016
1 parent 0b21728 commit 5b26644
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
20 changes: 19 additions & 1 deletion application/helpers/qanda_helper.php
Expand Up @@ -3094,6 +3094,23 @@ function do_multiplenumeric($ia)

$slider_separator= (trim($aQuestionAttributes['slider_separator'])!='')?$aQuestionAttributes['slider_separator']:"";
$slider_reset=($aQuestionAttributes['slider_reset'])?1:0;

if ($slider_default != "")
{
$slider_startvalue = $slider_default;
$slider_displaycallout=1;
}
elseif ($slider_middlestart != '')
{
$slider_startvalue = $slider_middlestart;
$slider_displaycallout=0;
}
else
{
$slider_startvalue = 'NULL';
$slider_displaycallout=0;
}

}
else
{
Expand Down Expand Up @@ -3128,7 +3145,6 @@ function do_multiplenumeric($ia)
$anscount = count($aSubquestions)*2;
$fn = 1;


$answer = Yii::app()->getController()->renderPartial('/survey/questions/multiplenumeric/header', array('prefixclass'=>$prefixclass), true);
$answer_main = '';

Expand Down Expand Up @@ -3223,6 +3239,8 @@ function do_multiplenumeric($ia)
'slider_handle' => $slider_handle,
'slider_reset' => $slider_reset,
'slider_custom_handle' => $slider_custom_handle,
'slider_startvalue' => $slider_startvalue,
'slider_displaycallout' => $slider_displaycallout
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/multiplenumeric/item', $itemDatas, true);

Expand Down
47 changes: 43 additions & 4 deletions application/views/survey/questions/multiplenumeric/item.php
Expand Up @@ -63,13 +63,15 @@ class="text form-control <?php echo $kpclass;?>"
data-slider-reset='<?php echo $slider_reset; ?>'
data-slider-prefix='<?php echo $prefix; ?>'
data-slider-suffix='<?php echo $suffix; ?>'
data-slider-startvalue='<?php echo $slider_startvalue; ?>'
data-slider-displaycallout='<?php echo $slider_displaycallout; ?>'
/>
<?php endif;?>
<?php echo $sliderright;?>
</div> <!-- xs-12 -->
<div class='col-xs-12 col-sm-8'>
<?php if ($slider_reset): ?>
<span data-toggle='tooltip' data-title='<?php eT("Reset slider"); ?>' class='btn btn-default fa fa-times slider-reset'>&nbsp;<?php eT("Reset"); ?></span>
<span id="answer<?php echo $myfname; ?>_resetslider" class='btn btn-default fa fa-times slider-reset'>&nbsp;<?php eT("Reset"); ?></span>
<?php endif; ?>
</div>
</div> <!-- form group -->
Expand Down Expand Up @@ -100,17 +102,54 @@ class="text form-control <?php echo $kpclass;?>"
$(document).ready(function(){
var myfname = '<?php echo $myfname; ?>';
var id = '#answer' + myfname;
var resetSliderId = id + '_resetslider';
var slider_prefix = $(id).attr('data-slider-prefix')
var slider_suffix = $(id).attr('data-slider-suffix')

var mySlider_<?php echo $myfname; ?> = $(id).bootstrapSlider({
formatter: function (value) {
var slider_prefix = $(id).attr('data-slider-prefix')
var slider_suffix = $(id).attr('data-slider-suffix')
var displayValue = '' + value;
var displayValue = displayValue.replace(/\./,LSvar.sLEMradix);
return slider_prefix + displayValue + slider_suffix;
}
});

// Set "This value" at init
var slider_startvalue = $(id).attr('data-slider-startvalue');
var displayValue = '' + slider_startvalue;
var displayValue = displayValue.replace(/\./,LSvar.sLEMradix);
$(id).attr('stringvalue', displayValue);
$(id).triggerHandler("keyup");

// Reset on click on .slider-reset
$(resetSliderId).on("click", function() {
var slider_startvalue = $(id).attr('data-slider-startvalue');
var slider_displaycallout = $(id).attr('data-slider-displaycallout');

if(slider_startvalue == "NULL") {
$(id).bootstrapSlider('setValue', '');
$(id).attr('stringvalue', '');
}
else {
$(id).bootstrapSlider('setValue', parseFloat(slider_startvalue));
$(id).attr('stringvalue', slider_startvalue);
}

if(slider_displaycallout && slider_startvalue != "NULL") {
$(id).attr('stringvalue', slider_prefix + slider_startvalue.replace(/\./,LSvar.sLEMradix) + slider_suffix);
$(id).bootstrapSlider('setValue', parseFloat(slider_startvalue));
}
else {
$(id).bootstrapSlider('setValue', '');
$(id).attr('stringvalue', '');
}

LEMrel<?php echo $qid; ?>();
$(id).triggerHandler("keyup"); // Needed for EM
});

mySlider_<?php echo $myfname; ?>.on('slideStop', function(event) {
var displayValue = '' + event.value;
var displayValue = '' + event.value; // Type-cast to string
var displayValue = displayValue.replace(/\./,LSvar.sLEMradix);

// fixnum_checkconditions can't handle dot if it expects comma, and
Expand Down

0 comments on commit 5b26644

Please sign in to comment.