diff --git a/application/config/config-defaults.php b/application/config/config-defaults.php index f571c053f62..dd6419a9d1c 100644 --- a/application/config/config-defaults.php +++ b/application/config/config-defaults.php @@ -612,5 +612,11 @@ // Use alias notation, we should move to this format everywhere. $config['plugindir'] = 'webroot.plugins'; +// (javascript) Fix automatically the value entered in numeric question type : 1: remove all non numeric caracters; 0 : leave all caracters +$config['bFixNumAuto'] = 1; +// (javascript) Send real value entered when using Numeric question type in Expression Manager : 0 : {NUMERIC} with bad caracters send '', 1 : {NUMERIC} send all caracters entered +$config['bNumRealValue'] = 0; + + return $config; //settings deleted diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index b2bb1bd2dc6..5a123f97e97 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -977,11 +977,11 @@ function run($surveyid,$args) { // in order to workaround an not-reproduced issue #4453 (lemeur) echo ""; - // lemradix and var for LemRadix - $sLemRadixVarScript=" LEMradix='" . $radix . "';\n" - ." numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');\n" - ." intRegex = new RegExp('[^-0-9]','g');\n"; - Yii::app()->clientScript->registerScript('LemRadixVarScript',$sLemRadixVarScript,CClientScript::POS_HEAD); +# // lemradix and var for LemRadix +# $sLemRadixVarScript=" LEMradix='" . $radix . "';\n" +# ." numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');\n" +# ." intRegex = new RegExp('[^-0-9]','g');\n"; +# Yii::app()->clientScript->registerScript('LemRadixVarScript',$sLemRadixVarScript,CClientScript::POS_HEAD); $showpopups=Yii::app()->getConfig('showpopups'); //Display the "mandatory" message on page if necessary diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index e08dd9f99cb..41969dd2562 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -2425,10 +2425,6 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL) }else{ $sq_equs[] = '( is_numeric('.$sq_name.') || is_empty('.$sq_name.') )'; } - if($type=="K") - $subqValidSelector = $sq['jsVarName_on']; - else - $subqValidSelector = ""; } if (!isset($validationEqn[$questionNum])) { diff --git a/application/helpers/replacements_helper.php b/application/helpers/replacements_helper.php index d5ab5609d30..936062857e7 100644 --- a/application/helpers/replacements_helper.php +++ b/application/helpers/replacements_helper.php @@ -155,11 +155,27 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de } if(stripos ($line,"{TEMPLATEJS}")) { - + // Javascript Var + $aLSJavascriptVar=array(); + $aLSJavascriptVar['bFixNumAuto']=(int)(bool)Yii::app()->getConfig('bFixNumAuto',1); + $aLSJavascriptVar['bNumRealValue']=(int)(bool)Yii::app()->getConfig('bNumRealValue',0); + if(isset($thissurvey['surveyls_numberformat'])) + { + $radix=getRadixPointData($thissurvey['surveyls_numberformat']); + } + else + { + $aLangData=getLanguageData(); + $radix=getRadixPointData($aLangData[ Yii::app()->getConfig('defaultlang')]['radixpoint']);// or $clang->langcode . defaultlang ensure it's same for each language ? + } + $aLSJavascriptVar['sLEMradix']=$radix['separator']; + $sLSJavascriptVar="LSvar=".json_encode($aLSJavascriptVar); + App()->clientScript->registerScript('sLSJavascriptVar',$sLSJavascriptVar,CClientScript::POS_HEAD); + App()->clientScript->registerScript('setJsVar',"setJsVar();",CClientScript::POS_BEGIN);// Ensure all js var is set before rendering the page (User can click before $.ready) App()->getClientScript()->registerPackage('jqueryui'); - App()->getClientScript()->registerPackage('jquery-touch-punch'); + App()->getClientScript()->registerPackage('jquery-touch-punch'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js"); - App()->getClientScript()->registerScriptFile($templateurl . 'template.js',CClientScript::POS_END); + App()->getClientScript()->registerScriptFile($templateurl . 'template.js',CClientScript::POS_BEGIN); useFirebug(); } diff --git a/scripts/survey_runtime.js b/scripts/survey_runtime.js index 93f789a2a16..f725a1e87ed 100644 --- a/scripts/survey_runtime.js +++ b/scripts/survey_runtime.js @@ -71,6 +71,23 @@ $(document).ready(function() }); +/** + * setJsVar : Get all global used var + */ +function setJsVar(){ + if (typeof LSvar!="undefined" && LSvar instanceof Object == false) { + bFixNumAuto=1; + bNumRealValue=0; + LEMradix="."; + } + else { + bFixNumAuto=LSvar.bFixNumAuto; + bNumRealValue=LSvar.bNumRealValue; + LEMradix=LSvar.LEMradix; + } + numRegex = new RegExp('[^-' + LEMradix + '0-9]','g'); + intRegex = new RegExp('[^-0-9]','g'); +} // Deactivate all other button on submit function limesurveySubmitHandler(){ $(document).on("click",".disabled",function(){return false;}); @@ -144,25 +161,25 @@ function checkconditions(value, name, type, evt_type) */ function fixnum_checkconditions(value, name, type, evt_type, intonly) { - if(typeof bFixNumAuto == 'undefined'){bFixNumAuto=true;} // Allow deactivate fixnum in template or in Plugin - if(typeof bNumRealValue == 'undefined'){bNumRealValue=false;} // Allow to update {QCODE} even with text - newval = new String(value); - if (typeof intonly !=='undefined' && intonly==1) { - newval = newval.replace(intRegex,''); - } - else { - newval = newval.replace(numRegex,''); - } - aNewval = newval.split(LEMradix); - if(aNewval.length>0){ - newval=aNewval[0]; - } - if(aNewval.length>1){ - newval=newval+"."+aNewval[1]; - } - if (newval != '-' && newval != '.' && newval != '-.' && newval != parseFloat(newval)) {// Todo : do it in reg - newval = ''; + if(!bNumRealValue) + { + if (typeof intonly !=='undefined' && intonly==1) { + newval = newval.replace(intRegex,''); + } + else { + newval = newval.replace(numRegex,''); + } + aNewval = newval.split(LEMradix); + if(aNewval.length>0){ + newval=aNewval[0]; + } + if(aNewval.length>1){ + newval=newval+"."+aNewval[1]; + } + if (newval != '-' && newval != '.' && newval != '-.' && newval != parseFloat(newval)) {// Todo : do it in reg + newval = ''; + } } if(bFixNumAuto) { @@ -179,14 +196,7 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly) { evt_type = 'onchange'; } - if(bNumRealValue) - { - checkconditions(value, name, type, evt_type); - } - else - { - checkconditions(newval, name, type, evt_type); - } + checkconditions(newval, name, type, evt_type); } // Set jquery-ui to LS Button diff --git a/templates/citronade/startpage.pstpl b/templates/citronade/startpage.pstpl index 8a5bcc06114..eb55cbdcb05 100644 --- a/templates/citronade/startpage.pstpl +++ b/templates/citronade/startpage.pstpl @@ -10,18 +10,18 @@ {TEMPLATEJS} {GOOGLE_ANALYTICS_JAVASCRIPT} - - - - - - -
+ + + + + +
+ -

{SURVEYNAME}

+

{SURVEYNAME}