diff --git a/crouton.php b/crouton.php
index 4fcd42c2..139ffb64 100644
--- a/crouton.php
+++ b/crouton.php
@@ -56,6 +56,7 @@ class Crouton
"root_server" => '',
"service_body" => '',
"service_body_parent" => '',
+ "jsInFooter" => true,
"venue_types" => '',
"formats" => '',
"has_tabs" => '1',
@@ -304,14 +305,25 @@ private function sharedRender()
return $output;
}
-
+ private function inlineScript($s)
+ {
+ wp_add_inline_script('croutonjs', $s);
+ }
+ private function outputScript($s)
+ {
+ if ($this->options['jsInFooter']) {
+ wp_add_inline_script('croutonjs', $s);
+ $s = "";
+ }
+ return $this->waitMsg.sprintf('%s
@@ -1040,13 +1056,12 @@ private function getAllFields($root_server)
private function templateToParameter($atts, $name)
{
if (isset($atts[$name]) && $atts[$name] !== null && $atts[$name] !== "") {
- $template = $atts[$name];
+ return $atts[$name];
} elseif (isset($this->options[$name])) {
- $template = $this->options[$name];
+ return $this->options[$name];
} else {
- $template = "";
+ return "";
}
- return html_entity_decode($template);
}
private function getAllMeetings($root_server)
{
diff --git a/croutonjs/meetingMap/js/meeting_map.js b/croutonjs/meetingMap/js/meeting_map.js
index 08db2367..20e6c37e 100644
--- a/croutonjs/meetingMap/js/meeting_map.js
+++ b/croutonjs/meetingMap/js/meeting_map.js
@@ -303,7 +303,7 @@ function MeetingMap(inConfig) {
showGeocodingDialog();
}
} else if (config.goto) {
- gDelegate.callGeocoder(goto, filterMeetingsAndBounds);
+ gDelegate.callGeocoder(config.goto, filterMeetingsAndBounds);
}
}
function createCityHash(allMeetings) {
@@ -363,6 +363,7 @@ function MeetingMap(inConfig) {
const newTop = -window.scrollY+'px';
body.style.overflowX = 'hidden';
body.style.position = 'fixed';
+ body.style.width="100%";
body.style.setProperty('top', newTop, 'important');
}
}
diff --git a/croutonjs/meetingMap/meeting_map.php b/croutonjs/meetingMap/meeting_map.php
index a6cee1b2..314b6679 100644
--- a/croutonjs/meetingMap/meeting_map.php
+++ b/croutonjs/meetingMap/meeting_map.php
@@ -188,48 +188,42 @@ private function hsc($field)
}
private function createJavascriptConfig($options)
{
- $ret = '{';
+ $ret = [];
//$ret .= 'BMLTPlugin_files_uri:\''.$this->hsc($this->getPluginPath()).'?\',' . (defined('_DEBUG_MODE_') ? "\n" : '');
- $ret .= "BMLTPlugin_images:'".$this->hsc(plugin_dir_url(__FILE__)."map_images")."'," . (defined('_DEBUG_MODE_') ? "\n" : '');
- $ret .= "BMLTPlugin_lang_dir:'".$this->hsc(plugin_dir_url(__FILE__)."lang")."'," . (defined('_DEBUG_MODE_') ? "\n" : '');
- $ret .= "BMLTPlugin_throbber_img_src:'".$this->hsc(plugin_dir_url(__FILE__)."map_images/Throbber.gif")."'," . (defined('_DEBUG_MODE_') ? "\n" : '');
- $ret .= 'region:"'.$options['region_bias'].'",';
- $ret .= 'bounds:{';
- $ret .= ' "north": "'.$options['bounds_north'].'",';
- $ret .= ' "east": "'.$options['bounds_east'].'",';
- $ret .= ' "south": "'.$options['bounds_south'].'",';
- $ret .= ' "west": "'.$options['bounds_west'].'"';
- $ret .= '},';
- $ret .= 'tileUrl:"'.$options['tile_url'].'",';
- $ret .= 'clustering:"'.$options['clustering'].'",';
- $ret .= 'nominatimUrl:"'.$options['nominatim_url'].'",';
- $ret .= 'tileOptions:{';
- foreach ($options['tile_params'] as $key => $value) {
- $ret .= " '".$key."': '".$value."',";
- }
- $ret .= '},';
- $ret .= 'api_key:"'.$options['api_key'].'",';
- $ret .= 'lat:"'.$options['lat'].'",';
- $ret .= 'lng:"'.$options['lng'].'",';
- $ret .= 'zoom:"'.$options['zoom'].'",';
- $ret .= 'minZoom:"'.$options['min_zoom'].'",';
- $ret .= 'maxZoom:"'.$options['max_zoom'].'",';
+ $ret["BMLTPlugin_images"] = $this->hsc(plugin_dir_url(__FILE__)."map_images");
+ $ret["BMLTPlugin_lang_dir"] = $this->hsc(plugin_dir_url(__FILE__)."lang");
+ $ret["BMLTPlugin_throbber_img_src"] = $this->hsc(plugin_dir_url(__FILE__)."map_images/Throbber.gif");
+ $ret['region'] = $options['region_bias'];
+ $ret['bounds'] = [
+ "north" => $options['bounds_north'],
+ "east" => $options['bounds_east'],
+ "south" => $options['bounds_south'],
+ "west" => $options['bounds_west']
+ ];
+ $ret['tileUrl'] = $options['tile_url'];
+ $ret['clustering'] = $options['clustering'];
+ $ret['nominatimUrl'] = $options['nominatim_url'];
+ $ret['tileOptions'] = $options['tile_params'];
+ $ret['api_key'] = $options['api_key'];
+ $ret['lat'] = $options['lat'];
+ $ret['lng'] = $options['lng'];
+ $ret['zoom'] = $options['zoom'];
+ $ret['minZoom'] = $options['min_zoom'];
+ $ret['maxZoom'] = $options['max_zoom'];
if (!empty($options['center_me'])) {
- $ret .= 'centerMe:"'.$options['center_me'].'",';
+ $ret['centerMe'] = $options['center_me'];
}
if (!empty($options['goto'])) {
- $ret .= 'goto:"'.$options['goto'].'",';
+ $ret['goto'] = $options['goto'];
+ if (isset($_GET['goto'])) {
+ $ret['centerMe'] = '';
+ }
}
if (isset($options['map_search'])) {
- $ret .= 'map_search: {';
- foreach ($options['map_search'] as $key => $value) {
- $ret .= $key.':"'.$value.'",';
- }
- $ret .= '},';
+ $ret['map_search'] = $options['map_search'];
}
- $ret .= '"marker_contents_template":'.json_encode($options['marker_contents_template']);
- $ret .= '},';
- return $ret;
+ $ret["marker_contents_template"] = $options['marker_contents_template'];
+ return json_encode($ret);
}
public function adminSection()
{
diff --git a/js/bmlt_tabs_admin.js b/js/bmlt_tabs_admin.js
index 6dc49eb6..aea8a127 100644
--- a/js/bmlt_tabs_admin.js
+++ b/js/bmlt_tabs_admin.js
@@ -36,7 +36,6 @@ function numbersonly(myfield, e, dec)
return false;
};
function resetCodemirrorToDefault(textAreaId) {
- console.log("in Function");
let cm = jQuery('#'+textAreaId).next()[0].CodeMirror;
cm.setValue(croutonDefaultTemplates[textAreaId]);
}
diff --git a/readme.txt b/readme.txt
index cc4eb9a3..19a33a17 100644
--- a/readme.txt
+++ b/readme.txt
@@ -37,7 +37,8 @@ https://demo.bmlt.app/crouton
== Changelog ==
= 3.19.5 =
-* Fix InfoWindow close button on GoogleMaps
+* Fix InfoWindow close button on GoogleMaps
+* Add option to place generated JavaScript in footer
= 3.19.4 =
* Bug fix