Skip to content

Commit

Permalink
Dev: Fix slider with comma (after #11849)
Browse files Browse the repository at this point in the history
Dev: Must controle after #11849 #2
Dev: Fix validation issue : slider have an empty id : boostrap-slider don't set a default
  • Loading branch information
Shnoulle committed Nov 17, 2016
1 parent 67580f2 commit a918ebe
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 31 deletions.
18 changes: 16 additions & 2 deletions application/config/packages.php
@@ -1,14 +1,15 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Core packages , no third_party
*
* sees third_party.php for third party package
* @license GPL v3
* core path is application/core/packages
*
*/
return array(
/* For public template functionnality */
'limesurvey-public'=>array(
'basePath' => 'core.limesurvey',
'basePath' => 'core.limesurvey',/* public part only : rename directory ? */
'css'=> array(
'survey.css',
),
Expand All @@ -35,4 +36,17 @@
'jquery-actual',
)
),
/* numeric slider question : numerci question type with slider */
'question-numeric-slider'=>array(
'basePath' => 'core.questions.numeric-slider',
'css'=> array(
'numeric-slider.css',
),
'js'=>array(
'numeric-slider.js',
),
'depends' => array(
'bootstrap-slider',
)
),
);
9 changes: 9 additions & 0 deletions application/config/third_party.php
Expand Up @@ -46,6 +46,15 @@
)
),

// bootstrap-slider : for multinumeric with slider
'bootstrap-slider' => array(
'basePath' => 'third_party.bootstrap-slider',
'js' => array(
'bootstrap-slider.min.js'
),
/* according to readme : JQuery is optional and the plugin can operate with or without it. boostrap must be loaded for css only */
),

'fontawesome' => array(
//'basePath' => 'third_party.bootstrap', // Need fix third_party alias
'basePath' => 'third_party.fontawesome',
Expand Down
File renamed without changes.
Expand Up @@ -22,6 +22,7 @@ function doNumericSlider(qID,options) {
var separator = $(inputEl).data('separator');
// We start the slider, and provide it the formated value with prefix and suffix for its tooltip
var theSlider = $(inputEl).bootstrapSlider({
id : 'slider-'+myfname,
formatter: function (value) {
displayValue = value.toString().replace('.',separator);
return prefix + displayValue + suffix;
Expand All @@ -48,6 +49,8 @@ function doNumericSlider(qID,options) {
theSlider.on('change', function(event) {
});
theSlider.on('slideStop', function(event) {
console.log(separator);
console.log(event.value.toString().replace('.',separator));
$(inputEl).val(event.value.toString().replace('.',separator)).trigger('keyup');// We call the EM by the event
});

Expand Down
7 changes: 2 additions & 5 deletions application/helpers/qanda_helper.php
Expand Up @@ -3269,7 +3269,6 @@ function do_multiplenumeric($ia)
'dispVal' => $sValue,
'maxlength' => $maxlength,
'labelText' => $labelText,
'checkconditionFunction' => $checkconditionFunction.'(this.value, this.name, this.type, \'onchange\','.$integeronly.')',
'integeronly'=> $integeronly,
), true);
}else{
Expand All @@ -3295,8 +3294,8 @@ function do_multiplenumeric($ia)
'dispVal' => $sValue,
'maxlength' => $maxlength,
'labelText' => $labelText,
'checkconditionFunction' => $checkconditionFunction.'(this.value, this.name, this.type)',
'slider_orientation' => $slider_orientation,
'slider_value' => $sUnformatedValue,
'slider_step' => $slider_step ,
'slider_min' => $slider_min ,
'slider_mintext' => $slider_mintext ,
Expand Down Expand Up @@ -3365,9 +3364,7 @@ function do_multiplenumeric($ia)
'help'=>gT('Please click and drag the slider handles to enter your answer.')
);
App()->getClientScript()->registerScript("sliderTranslation","var sliderTranslation=".json_encode($sliderTranslation).";\n",CClientScript::POS_HEAD);
App()->getClientScript()->registerScriptFile(App()->baseUrl . "/third_party/bootstrap-slider/bootstrap-slider.js");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."numeric-slider.js");
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') ."numeric-slider.css");
App()->getClientScript()->registerPackage("question-numeric-slider");
if($slider_handle == 'custom'){/* unsure we still need it : in aJsonOptions : must choose the best */
App()->getClientScript()->registerCss("cssNumericSlider{$ia[0]}","#question{$ia[0]} .slider-handle.custom::before{ content: '\\{$slider_custom_handle}}';");
}
Expand Down
Expand Up @@ -29,36 +29,37 @@
?>

<li id='javatbd<?php echo $myfname; ?>' class="question-item answer-item numeric-item text-item slider-item form-group <?php echo $extraclass;?><?php if($alert):?> has-error<?php endif; ?>" <?php echo $sDisplayStyle;?>>
<label class='control-label col-xs-12 col-sm-<?php echo $sLabelWidth; ?><?php if($alert):?> errormandatory<?php endif; ?>' for="answer<?php echo$myfname;?>">
<label id="label-<?php echo $myfname; ?>" class='control-label col-xs-12 col-sm-<?php echo $sLabelWidth; ?><?php if($alert):?> errormandatory<?php endif; ?>' for="answer<?php echo$myfname;?>">
<?php echo $labelText; ?>
</label>
<div class="col-xs-12 col-sm-<?php echo $sInputContainerWidth; ?> container-fluid">
<?php if (!empty($sliderleft)): ?>
<div class='col-xs-12 col-sm-2 slider-left text-right'><?php echo $sliderleft;?></div>
<?php endif; ?>
<div class="slider-container ls-input-group col-xs-12 col-sm-<?php echo $sliderWidth ?>">
<?php
/* FF show issue + prefix/suffix must be encoded */
echo CHtml::textField($myfname,$dispVal,array(
'class'=>'form-control',
'id'=>"answer{$myfname}",
'data-slider-value'=>$dispVal,
'data-slider-min'=>$slider_min,
'data-slider-max'=>$slider_max,
'data-slider-step'=>$slider_step,
'data-slider-orientation'=>$slider_orientation,
'data-slider-handle'=>$slider_handle,
'data-slider-tooltip'=>'always',
'data-slider-reset'=>$slider_reset,
'data-slider-prefix'=>$prefix,
'data-slider-suffix'=>$suffix,
'data-separator'=>$sSeparator,
'data-number'=>true,
'data-integer'=>$integeronly,
'data-position'=>$slider_position,
'data-set-position'=>$slider_reset_set
));
?>
<?php
/* FF show issue + prefix/suffix must be encoded */
echo CHtml::textField($myfname,$dispVal,array(
'class'=>'form-control answer-item numeric-item',
'id'=>"answer{$myfname}",
'data-slider-value'=>$slider_value,
'data-slider-min'=>$slider_min,
'data-slider-max'=>$slider_max,
'data-slider-step'=>$slider_step,
'data-slider-orientation'=>$slider_orientation,
'data-slider-handle'=>$slider_handle,
'data-slider-tooltip'=>'always',
'data-slider-reset'=>$slider_reset,
'data-slider-prefix'=>$prefix,
'data-slider-suffix'=>$suffix,
'data-separator'=>$sSeparator,
'data-number'=>true,
'data-integer'=>$integeronly,
'data-position'=>$slider_position,
'data-set-position'=>$slider_reset_set,
'aria-labelledby'=>"label-{$myfname}"
));
?>
<?php if($slider_showminmax): ?>
<div class='pull-left help-block'><?php echo $slider_min; ?></div>
<div class='pull-right help-block'><?php echo $slider_max; ?></div>
Expand All @@ -74,7 +75,6 @@
<?php if (!empty($sliderright)): ?>
<div class='col-xs-12 col-sm-2 slider-right text-left'><?php echo $sliderright;?></div>
<?php endif; ?>
<input type="hidden" name="slider_user_no_action_<?php echo $myfname; ?>" id="slider_user_no_action_<?php echo $myfname; ?>" value="<?php echo ($dispVal ? 0 : 1);?>" />
</div>
</li>
<!-- end of answer_row -->

0 comments on commit a918ebe

Please sign in to comment.