From a918ebe76e78de7dcb4eaa98a3b32c804ad155fe Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Thu, 17 Nov 2016 11:23:58 +0100 Subject: [PATCH] Dev: Fix slider with comma (after #11849) Dev: Must controle after #11849 #2 Dev: Fix validation issue : slider have an empty id : boostrap-slider don't set a default --- application/config/packages.php | 18 ++++++- application/config/third_party.php | 9 ++++ .../numeric-slider}/numeric-slider.css | 0 .../numeric-slider}/numeric-slider.js | 3 ++ application/helpers/qanda_helper.php | 7 +-- .../rows/sliders/answer_row.php | 48 +++++++++---------- 6 files changed, 54 insertions(+), 31 deletions(-) rename {styles-public => application/core/packages/questions/numeric-slider}/numeric-slider.css (100%) rename {scripts => application/core/packages/questions/numeric-slider}/numeric-slider.js (95%) diff --git a/application/config/packages.php b/application/config/packages.php index 6687770fe46..e76cdab7343 100644 --- a/application/config/packages.php +++ b/application/config/packages.php @@ -1,14 +1,15 @@ array( - 'basePath' => 'core.limesurvey', + 'basePath' => 'core.limesurvey',/* public part only : rename directory ? */ 'css'=> array( 'survey.css', ), @@ -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', + ) + ), ); diff --git a/application/config/third_party.php b/application/config/third_party.php index 4d22087b5c1..5cee6fcf015 100755 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -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', diff --git a/styles-public/numeric-slider.css b/application/core/packages/questions/numeric-slider/numeric-slider.css similarity index 100% rename from styles-public/numeric-slider.css rename to application/core/packages/questions/numeric-slider/numeric-slider.css diff --git a/scripts/numeric-slider.js b/application/core/packages/questions/numeric-slider/numeric-slider.js similarity index 95% rename from scripts/numeric-slider.js rename to application/core/packages/questions/numeric-slider/numeric-slider.js index e5ab5011fbd..ddf996f598b 100644 --- a/scripts/numeric-slider.js +++ b/application/core/packages/questions/numeric-slider/numeric-slider.js @@ -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; @@ -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 }); diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index d4ae6ac772b..e9146a874f6 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -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{ @@ -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 , @@ -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}}';"); } diff --git a/application/views/survey/questions/multiplenumeric/rows/sliders/answer_row.php b/application/views/survey/questions/multiplenumeric/rows/sliders/answer_row.php index 2df6160bfe4..a82378088f0 100644 --- a/application/views/survey/questions/multiplenumeric/rows/sliders/answer_row.php +++ b/application/views/survey/questions/multiplenumeric/rows/sliders/answer_row.php @@ -29,7 +29,7 @@ ?>
  • > -