From 39c3d110438a9ecd37991ba9e40c6047e65c0c31 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 7 Jun 2007 19:19:06 +0000 Subject: [PATCH] Patch from #674, approved by SDE, plus an example. git-svn-id: http://svn.openlayers.org/trunk/openlayers@3285 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/layerswitcher.html | 46 +++++++++++++++++++++++++ lib/OpenLayers/Control/LayerSwitcher.js | 6 ++-- tests/Control/test_LayerSwitcher.html | 13 +++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 examples/layerswitcher.html diff --git a/examples/layerswitcher.html b/examples/layerswitcher.html new file mode 100644 index 0000000000..909e05dcfb --- /dev/null +++ b/examples/layerswitcher.html @@ -0,0 +1,46 @@ + + + + + + + +

OpenLayers Example

+
+
+ + diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index 8531d536e9..4bd3930d6a 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -99,8 +99,10 @@ OpenLayers.Control.LayerSwitcher.prototype = this.loadContents(); // set mode to minimize - this.minimizeControl(); - + if(!this.outsideViewport) { + this.minimizeControl(); + } + // populate div with current info this.redraw(); diff --git a/tests/Control/test_LayerSwitcher.html b/tests/Control/test_LayerSwitcher.html index 43d3da63f8..cecc307edf 100644 --- a/tests/Control/test_LayerSwitcher.html +++ b/tests/Control/test_LayerSwitcher.html @@ -22,6 +22,18 @@ t.ok( control.div != null, "draw makes a div" ); t.ok( div != null, "draw returns its div" ); } + function test_Control_LayerSwitcher_outsideViewport (t) { + t.plan( 2 ); + + map = new OpenLayers.Map('map'); + control = new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')}); + map.addControl(control); + console.log(control.outsideViewport); + t.eq(control.div.style.width, "250px", "Div is not minimized when added."); + control = new OpenLayers.Control.LayerSwitcher(); + map.addControl(control); + t.eq(control.div.style.width, "0px", "Div is minimized when added."); + } function test_03_Control_LayerSwitcher_loadContents(t) { @@ -110,5 +122,6 @@
+