From cd326b87c3d77a94af2bc7e69db23ed759bf7209 Mon Sep 17 00:00:00 2001 From: RiverDonkey Date: Thu, 9 Feb 2012 14:49:37 +0100 Subject: [PATCH] Added possibility for default uncollapsed switcher in openlayers --- .../openlayers_behavior_layerswitcher.inc | 7 +++++++ .../behaviors/openlayers_behavior_layerswitcher.js | 5 +++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/plugins/behaviors/openlayers_behavior_layerswitcher.inc b/plugins/behaviors/openlayers_behavior_layerswitcher.inc index 94db375..f02a42c 100644 --- a/plugins/behaviors/openlayers_behavior_layerswitcher.inc +++ b/plugins/behaviors/openlayers_behavior_layerswitcher.inc @@ -31,6 +31,7 @@ class openlayers_behavior_layerswitcher extends openlayers_behavior { 'ascending' => TRUE, 'roundedCorner' => TRUE, 'roundedCornerColor' => '#222222', + 'collapsedByDefault' => FALSE, ); } @@ -58,6 +59,12 @@ class openlayers_behavior_layerswitcher extends openlayers_behavior { '#description' => t('For rounded corners, this is the CSS color to use for the corners.'), '#default_value' => isset($defaults['roundedCornerColor']) ? $defaults['roundedCornerColor'] : '#222222', ), + 'collapsedByDefault' => array( + '#type' => 'checkbox', + '#title' => t('Collapsed'), + '#description' => t('Choose whether the switcher should be collapsed or not, by default.'), + '#default_value' => isset($defaults['collapsedByDefault']) ? $defaults['collapsedByDefault'] : TRUE, + ), ); } diff --git a/plugins/behaviors/openlayers_behavior_layerswitcher.js b/plugins/behaviors/openlayers_behavior_layerswitcher.js index ae56e73..560e043 100644 --- a/plugins/behaviors/openlayers_behavior_layerswitcher.js +++ b/plugins/behaviors/openlayers_behavior_layerswitcher.js @@ -9,4 +9,9 @@ Drupal.openlayers.addBehavior('openlayers_behavior_layerswitcher', function (data, options) { options.ascending = !! options.ascending; Drupal.openlayers.addControl(data.openlayers, 'LayerSwitcher', options); + + if (data && !data.map.behaviors['openlayers_behavior_layerswitcher']['collapsedByDefault']) { + data.openlayers.getControlsByClass('OpenLayers.Control.LayerSwitcher')[0].maximizeControl(); + } + }); -- 1.7.5.4+GitX