From 8ddfdc753bc9a6b96e3c4f4e656685c068520dde Mon Sep 17 00:00:00 2001 From: David Molineus Date: Tue, 20 Jan 2015 17:36:19 +0100 Subject: [PATCH] Add fullscreen control. --- module/config/config.php | 3 +- module/dca/tl_leaflet_control.php | 21 +++- module/languages/en/leaflet.php | 2 + module/languages/en/tl_leaflet_control.php | 106 +++++++++--------- .../Control/FullscreenControlMapper.php | 49 ++++++++ 5 files changed, 129 insertions(+), 52 deletions(-) create mode 100644 src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php diff --git a/module/config/config.php b/module/config/config.php index 202aeb3..71ff8e6 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -99,6 +99,7 @@ $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\ScaleCo $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LayersControlMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\AttributionControlMapper'; $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\LoadingControlMapper'; +$GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Control\FullscreenControlMapper'; // Vector mappers. $GLOBALS['LEAFLET_MAPPERS'][] = 'Netzmacht\Contao\Leaflet\Mapper\Vector\PolylineMapper'; @@ -216,7 +217,7 @@ $GLOBALS['LEAFLET_LAYERS'] = array * * Supported leaflet control types. Register your type for the database driven definition here. */ -$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading'); +$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading', 'fullscreen'); /* diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php index 847ce46..3e02557 100644 --- a/module/dca/tl_leaflet_control.php +++ b/module/dca/tl_leaflet_control.php @@ -119,7 +119,10 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ), 'loading extends default' => array( 'config' => array('separate', 'zoomControl', 'spinjs') - ) + ), + 'fullscreen extends default' => array( + 'config' => array('buttonTitle', 'separate', 'simulateFullScreen') + ), ), 'metasubpalettes' => array( @@ -399,5 +402,21 @@ $GLOBALS['TL_DCA']['tl_leaflet_control'] = array ), 'sql' => "mediumtext NULL" ), + 'simulateFullScreen' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class' => 'w50 m12'), + 'sql' => "char(1) NOT NULL default ''" + ), + 'buttonTitle' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array('mandatory' => false, 'maxlength' => 255, 'tl_class' => 'w50'), + 'sql' => "varchar(255) NOT NULL default ''" + ), ), ); diff --git a/module/languages/en/leaflet.php b/module/languages/en/leaflet.php index 5ee5ca2..dbc5184 100644 --- a/module/languages/en/leaflet.php +++ b/module/languages/en/leaflet.php @@ -10,6 +10,8 @@ $GLOBALS['TL_LANG']['leaflet_control']['scale'][0] = 'Scale control'; $GLOBALS['TL_LANG']['leaflet_control']['scale'][1] = 'A simple scale control that shows the scale of the current center of the screen. For more details read the Leaflet documentation.'; $GLOBALS['TL_LANG']['leaflet_control']['loading'][0] = 'Loading indicator'; $GLOBALS['TL_LANG']['leaflet_control']['loading'][1] = 'Leaflet.loading is a simple loading indicator implemented as control. For more details read the Plugin documentation.'; +$GLOBALS['TL_LANG']['leaflet_control']['fullscreen'][0] = 'Fullscreen control'; +$GLOBALS['TL_LANG']['leaflet_control']['fullscreen'][1] = 'Add a fullscreen toggle button. For more details read the Plugin documentation.'; $GLOBALS['TL_LANG']['leaflet_layer']['provider'][0] = 'Leaflet provider'; $GLOBALS['TL_LANG']['leaflet_layer']['provider'][1] = 'Leaflet tile provider. For more details read the plugin documentation.'; diff --git a/module/languages/en/tl_leaflet_control.php b/module/languages/en/tl_leaflet_control.php index 42ba2bd..3d5ca86 100644 --- a/module/languages/en/tl_leaflet_control.php +++ b/module/languages/en/tl_leaflet_control.php @@ -19,56 +19,62 @@ $GLOBALS['TL_LANG']['tl_leaflet_control']['show'][1] = 'Show control ID %s d $GLOBALS['TL_LANG']['tl_leaflet_control']['pastenew'][0] = 'Copy control'; $GLOBALS['TL_LANG']['tl_leaflet_control']['pastenew'][1] = 'Create new copy of control ID %s'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['title'][0] = 'Title'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['title'][1] = 'Title of the control.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'][0] = 'Alias'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'][1] = 'Alias of the control.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['type'][0] = 'Type'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['type'][1] = 'Choose the control type.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['position'][0] = 'Position'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['position'][1] = 'Position of the control.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'][0] = 'Zoom in text'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'][1] = 'The text set on the zoom in button. By default its the "+" sign. Leave empty for the default value'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutText'][0] = 'Zoom out text'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutText'][1] = 'The text set on the zoom out button. By default its the "-" sign. Leave empty for the default value'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'][0] = 'Zoom in title'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'][1] = 'The title set on the zoom in button.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'][0] = 'Zoom out title'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'][1] = 'The title set on the zoom out button.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['active'][0] = 'Activate control'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['active'][1] = 'Activate control on the map.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'][0] = 'Attributions'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'][1] = 'Add attribution texts. HTML is allowed here.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'][0] = 'Attribution prefix'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'][1] = 'Customize the attribution prefix. By default it\'s the Leaflet link. HTML is allowed here.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'][0] = 'Max width'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'][1] = 'Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'][0] = 'Metric scale'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'][1] = 'Whether to show the metric scale line (m/km).'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'][0] = 'Imperial scale'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'][1] = 'Whether to show the imperial scale line (mi/ft).'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'][0] = 'Update when idle'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'][1] = 'If true, the control is updated on moveend, otherwise it\'s always up-to-date (updated on move).'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'][0] = 'Layers'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'][1] = 'Add layers to the control.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'][0] = 'Layer'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'][1] = 'Choose a layer. Each layer can only be added once.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][0] = 'Mode'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][1] = 'Add layer as baselayer or overlay.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'][0] = 'Collapsed'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'][1] = 'If true, the control will be collapsed into an icon and expanded on mouse hover or touch.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'][0] = 'Auto zIndex'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'][1] = 'If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'][0] = 'Spin.js configuration'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'][1] = 'Use valid json to configure the spin.js plugin. For more details see http://fgnass.github.io/spin.js/.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'][0] = 'Use spin.js'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'][1] = 'Instead of an background image the spin.js plugin is used.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'][0] = 'Separate'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'][1] = 'Display control separate from zoom control.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'][0] = 'Zoom control'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'][1] = 'Assign loading control to a specific zoom control. If it\'s not used on the map/activated the default one is used.'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][0] = 'Mode'; -$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][1] = 'Add layer as baselayer or overlay.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['title'][0] = 'Title'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['title'][1] = 'Title of the control.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'][0] = 'Alias'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['alias'][1] = 'Alias of the control.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['type'][0] = 'Type'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['type'][1] = 'Choose the control type.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['position'][0] = 'Position'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['position'][1] = 'Position of the control.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'][0] = 'Zoom in text'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInText'][1] = 'The text set on the zoom in button. By default its the "+" sign. Leave empty for the default value'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutText'][0] = 'Zoom out text'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutText'][1] = 'The text set on the zoom out button. By default its the "-" sign. Leave empty for the default value'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'][0] = 'Zoom in title'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomInTitle'][1] = 'The title set on the zoom in button.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'][0] = 'Zoom out title'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomOutTitle'][1] = 'The title set on the zoom out button.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['active'][0] = 'Activate control'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['active'][1] = 'Activate control on the map.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'][0] = 'Attributions'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['attributions'][1] = 'Add attribution texts. HTML is allowed here.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'][0] = 'Attribution prefix'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['prefix'][1] = 'Customize the attribution prefix. By default it\'s the Leaflet link. HTML is allowed here.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'][0] = 'Max width'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['maxWidth'][1] = 'Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'][0] = 'Metric scale'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['metric'][1] = 'Whether to show the metric scale line (m/km).'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'][0] = 'Imperial scale'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['imperial'][1] = 'Whether to show the imperial scale line (mi/ft).'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'][0] = 'Update when idle'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['updateWhenIdle'][1] = 'If true, the control is updated on moveend, otherwise it\'s always up-to-date (updated on move).'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'][0] = 'Layers'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layers'][1] = 'Add layers to the control.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'][0] = 'Layer'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layer'][1] = 'Choose a layer. Each layer can only be added once.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][0] = 'Mode'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][1] = 'Add layer as baselayer or overlay.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'][0] = 'Collapsed'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['collapsed'][1] = 'If true, the control will be collapsed into an icon and expanded on mouse hover or touch.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'][0] = 'Auto zIndex'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['autoZIndex'][1] = 'If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'][0] = 'Spin.js configuration'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['spin'][1] = 'Use valid json to configure the spin.js plugin. For more details see http://fgnass.github.io/spin.js/.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'][0] = 'Use spin.js'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['spinjs'][1] = 'Instead of an background image the spin.js plugin is used.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'][0] = 'Separate'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['separate'][1] = 'Display control separate from zoom control.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'][0] = 'Zoom control'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['zoomControl'][1] = 'Assign loading control to a specific zoom control. If it\'s not used on the map/activated the default one is used.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][0] = 'Mode'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][1] = 'Add layer as baselayer or overlay.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][0] = 'Mode'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['layerMode'][1] = 'Add layer as baselayer or overlay.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][0] = 'Button title'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['buttonTitle'][1] = 'Title attribute of the control button.'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][0] = 'Always simulate fullscreen'; +$GLOBALS['TL_LANG']['tl_leaflet_control']['simulateFullScreen'][1] = 'Simulate fullscreen no matter if the browser supports the Fullscreen API.'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][0] = 'Bottom left'; $GLOBALS['TL_LANG']['tl_leaflet_control']['bottomleft'][1] = 'Bottom left of the map.'; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php new file mode 100644 index 0000000..11cdc64 --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/FullscreenControlMapper.php @@ -0,0 +1,49 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Mapper\Control; + +use Netzmacht\LeafletPHP\Definition; + +/** + * Class FullscreenControlMapper. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ +class FullscreenControlMapper extends AbstractControlMapper +{ + /** + * Class of the definition being created. + * + * @var string + */ + protected static $definitionClass = 'Netzmacht\LeafletPHP\Plugins\FullScreen\FullScreenControl'; + + /** + * Layer type. + * + * @var string + */ + protected static $type = 'fullscreen'; + + /** + * {@inheritdoc} + */ + protected function initialize() + { + parent::initialize(); + + $this + ->addOption('forceSeparateButton', 'separate') + ->addConditionalOption('title', 'title', 'buttonTitle') + ->addOption('forcePseudoFullScreen', 'simulateFullScreen'); + } +}