diff --git a/application/config/third_party.php b/application/config/third_party.php index e8408994043..f50e455e841 100755 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -416,6 +416,7 @@ /* Used by short text with map by leaflet */ 'leaflet' => array( 'basePath' => 'third_party.leaflet', + 'position' => CClientScript::POS_BEGIN, 'js' => array( 'leaflet.js' ), @@ -425,6 +426,7 @@ ), 'devbridge-autocomplete' => array( 'basePath' => 'third_party.devbridge-autocomplete.dist', /* For geoname search autocomplete without jquery */ + 'position' => CClientScript::POS_BEGIN, 'js' => array( 'jquery.autocomplete'.$minVersion.'.js' ), diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 3c680cd8e11..fb1fdc0d043 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -405,10 +405,11 @@ public function run($surveyid, $args) /** * Expression Manager Scrips and inputs */ + $step = isset($_SESSION[$this->LEMsessid]['step']) ? $_SESSION[$this->LEMsessid]['step'] : ''; LimeExpressionManager::FinishProcessingGroup($this->LEMskipReprocessing); $aScriptsAndHiddenInputs = LimeExpressionManager::GetRelevanceAndTailoringJavaScript(true); $sScripts = implode('', $aScriptsAndHiddenInputs['scripts']); - Yii::app()->clientScript->registerScript('lemscripts', $sScripts, CClientScript::POS_BEGIN); + Yii::app()->clientScript->registerScript('lemscripts_'.$step, $sScripts, CClientScript::POS_BEGIN); $this->aSurveyInfo['EM']['ScriptsAndHiddenInputs'] = implode('', $aScriptsAndHiddenInputs['inputs']); Yii::app()->clientScript->registerScript('triggerEmRelevance', "triggerEmRelevance();", CClientScript::POS_END); Yii::app()->clientScript->registerScript('updateMandatoryErrorClass', "updateMandatoryErrorClass();", CClientScript::POS_END); /* Maybe only if we have mandatory error ?*/ diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index 321172ee803..b42e855cd23 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -3185,13 +3185,13 @@ function do_shortfreetext($ia) $currentLocation = $currentLatLong[0]." ".$currentLatLong[1]; - Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."map.js"); + Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."map.js", LSYii_ClientScript::POS_END); if ($aQuestionAttributes['location_mapservice'] == 1 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") { - Yii::app()->getClientScript()->registerScriptFile("https://maps.googleapis.com/maps/api/js?sensor=false$sGoogleMapsAPIKey"); + Yii::app()->getClientScript()->registerScriptFile("https://maps.googleapis.com/maps/api/js?sensor=false$sGoogleMapsAPIKey", LSYii_ClientScript::POS_BEGIN); } else if ($aQuestionAttributes['location_mapservice'] == 1) { - Yii::app()->getClientScript()->registerScriptFile("http://maps.googleapis.com/maps/api/js?sensor=false$sGoogleMapsAPIKey"); + Yii::app()->getClientScript()->registerScriptFile("http://maps.googleapis.com/maps/api/js?sensor=false$sGoogleMapsAPIKey", LSYii_ClientScript::POS_BEGIN); } elseif ($aQuestionAttributes['location_mapservice'] == 2) { - Yii::app()->getClientScript()->registerScriptFile("http://www.openlayers.org/api/OpenLayers.js"); + Yii::app()->getClientScript()->registerScriptFile("http://www.openlayers.org/api/OpenLayers.js", LSYii_ClientScript::POS_BEGIN); } $questionHelp = false; @@ -3258,7 +3258,7 @@ function do_shortfreetext($ia) Yii::app()->getClientScript()->registerScript('sGlobalMapScriptVar', "LSmap=".ls_json_encode($aGlobalMapScriptVar).";\nLSmaps= new Array();", CClientScript::POS_BEGIN); Yii::app()->getClientScript()->registerScript('sThisMapScriptVar'.$ia[1], "LSmaps['{$ia[1]}']=".ls_json_encode($aThisMapScriptVar).";", CClientScript::POS_BEGIN); Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."map.js", CClientScript::POS_END); - Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl').'map.css', CClientScript::POS_END); + Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl').'map.css'); if (isset($aQuestionAttributes['hide_tip']) && $aQuestionAttributes['hide_tip'] == 0) { $questionHelp = true; diff --git a/application/views/survey/questions/answer/shortfreetext/location_mapservice/item.php b/application/views/survey/questions/answer/shortfreetext/location_mapservice/item.php index 54ab7f4e0af..df99edf18e6 100644 --- a/application/views/survey/questions/answer/shortfreetext/location_mapservice/item.php +++ b/application/views/survey/questions/answer/shortfreetext/location_mapservice/item.php @@ -18,9 +18,13 @@ */ ?> - +getClientScript()->registerScript('MAP_VARS_'.$basename, + " var zoom = zoom || []; + zoom['".$name."'] = ".$location_mapzoom.";" + , LSYii_ClientScript::POS_END); +?> +
diff --git a/assets/scripts/map.js b/assets/scripts/map.js index ea87ac11550..00a270d5556 100644 --- a/assets/scripts/map.js +++ b/assets/scripts/map.js @@ -4,6 +4,10 @@ * */ +var gmaps = gmaps || new Object; +var osmaps = osmaps || new Object; +var zoom = zoom || []; + $(document).on('ready pjax:scriptcomplete',function() { $(".ls-answers .location").each(function(index,element){ @@ -28,10 +32,6 @@ $(document).on('ready pjax:scriptcomplete',function() }); -gmaps = new Object; -osmaps = new Object; -zoom = []; - function isvalidCoord(val,type){ if(type=='lat'){ diff --git a/themes/survey/vanilla/scripts/ajaxify.js b/themes/survey/vanilla/scripts/ajaxify.js index 5495b0e4d9f..c9402470c2d 100644 --- a/themes/survey/vanilla/scripts/ajaxify.js +++ b/themes/survey/vanilla/scripts/ajaxify.js @@ -74,7 +74,10 @@ var AjaxSubmitObject = function () { var globalPjax = new Pjax({ elements: "#limesurvey", // default is "a[href], form[action]" selectors: ["#dynamicReloadContainer", "#beginScripts", "#bottomScripts"], - + debug: window.debugState>1, + forceRedirectOnFail: true, + reRenderCSS : true, + scriptloadtimeout: 1500 }); // Always bind to document to not need to bind again $(document).on("click", ".ls-move-btn",function () {