Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"file": "mapstv.plugin.php",
"events": [
"OnTVInputRenderList",
"OnDocFormRender"
"OnDocFormRender",
"OnManagerPageBeforeRender"
]
}]
},
Expand Down
2 changes: 2 additions & 0 deletions assets/components/mapstv/js/mgr/mapstv.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ mapsTv.panel = function(config) {
}
}
,afterrender: function(){
// return if no resource, maybe cmp
if (!Ext.getCmp("modx-resource-tabs")) return;
// Listen to the tabchange on the modx-resource-tabs section
// When TV tab is selected, recalculate and set the width of the gmappanel
Ext.onReady(function() {
Expand Down
20 changes: 13 additions & 7 deletions core/components/mapstv/elements/plugins/mapstv.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
$corePath = $modx->getOption('mapstv.core_path', null, $modx->getOption('core_path').'components/mapstv/');
$assetsUrl = $modx->getOption('mapstv.assets_url', null, $modx->getOption('assets_url').'components/mapstv/');
$gmapSource = "//maps.google.com/maps/api/js?key=".$modx->getOption("mapstv.api_key", null, null, true);

$modx->lexicon->load('mapstv:default');

Expand All @@ -39,12 +40,17 @@
break;

case 'OnDocFormRender':
// Add the Google Maps api to the resource form
$source = '//maps.google.com/maps/api/js';
if ($modx->getOption('mapstv.api_key', null, null, true)) {
$source .= '?key='.$modx->getOption('mapstv.api_key', null, null, true);
}
$modx->regClientStartupScript($source);
// Add the Google Maps api
$modx->regClientStartupScript($gmapSource);
break;


case "OnManagerPageBeforeRender":
// Add lexicon
$modx->controller->addLexiconTopic("mapstv:default");
// Register x-type
$modx->controller->addJavascript($assetsUrl . "js/mgr/mapstv.js");
$modx->controller->addJavascript($assetsUrl . "js/lib/Ext.ux.GMapPanel3.js");
// Add the Google Maps api
$modx->controller->addJavascript($gmapSource);
break;
}