Skip to content

Commit

Permalink
Fixed issue #12999: OpenLayer question type doesn't work in AJax Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Dec 13, 2017
1 parent 2ddbe14 commit d119bf7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions application/config/third_party.php
Expand Up @@ -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'
),
Expand All @@ -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'
),
Expand Down
3 changes: 2 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -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 ?*/
Expand Down
10 changes: 5 additions & 5 deletions application/helpers/qanda_helper.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -18,9 +18,13 @@
*/
?>

<script type="text/javascript">
zoom['<?php echo $name;?>'] = <?php echo $location_mapzoom;?>;
</script>
<?php
App()->getClientScript()->registerScript('MAP_VARS_'.$basename,
" var zoom = zoom || [];
zoom['".$name."'] = ".$location_mapzoom.";"
, LSYii_ClientScript::POS_END);
?>


<div class="<?php echo $coreClass; ?> <?php echo $extraclass;?>" row" role="group" aria-labelledby="ls-question-text-<?php echo $basename; ?>">
<!-- Input Text Location -->
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/map.js
Expand Up @@ -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){
Expand All @@ -28,10 +32,6 @@ $(document).on('ready pjax:scriptcomplete',function()

});

gmaps = new Object;
osmaps = new Object;
zoom = [];


function isvalidCoord(val,type){
if(type=='lat'){
Expand Down
5 changes: 4 additions & 1 deletion themes/survey/vanilla/scripts/ajaxify.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit d119bf7

Please sign in to comment.