Prepare for backend usage.

This commit is contained in:
David Molineus
2015-01-28 16:41:21 +01:00
parent ff0d2d9ec6
commit 417e208d85
3 changed files with 13 additions and 12 deletions

View File

@@ -1,8 +1,6 @@
<div id="<?php echo $mapId; ?>" style="<?php echo $style; ?>"></div>
<?php $GLOBALS['TL_BODY'][] = <<<HTML
<script>
L.contao.addMap('{$mapId}', function() {
{$javascript}
<?php echo $javascript; ?>
return { map: map, layers: layers, controls: controls, icons: icons };
}());</script>
HTML;

View File

@@ -40,7 +40,7 @@ class ContaoAssets implements Assets
break;
case static::TYPE_FILE:
if (!\Config::get('debugMode')) {
if (!\Config::get('debugMode') && TL_MODE === 'FE') {
$script .= '|static';
}

View File

@@ -116,10 +116,7 @@ class BootSubscriber implements EventSubscriberInterface
*/
public function loadAssets()
{
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/maps/contao-leaflet.js' . (\Config::get('debugMode')
? ''
: '|static'
);
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/maps/contao-leaflet.js' . $this->staticFlag();
}
/**
@@ -160,10 +157,16 @@ class BootSubscriber implements EventSubscriberInterface
// @codingStandardsIgnoreStart
// TODO: Cache it.
// codingStandardsIgnoreEnd
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/js/icons.js' . (\Config::get('debugMode')
? ''
: '|static'
);
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/js/icons.js' . $this->staticFlag();
}
}
private function staticFlag()
{
if (\Config::get('debugMode') || TL_MODE !== 'FE') {
return '';
}
return '|static';
}
}