From c696b34a84c3f506c0cf73c99d574791fa754ea6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 21 May 2012 08:44:38 +0200 Subject: [PATCH] Add new maximizeTitle and minimizeTitle options to Control.OverviewMap --- examples/overviewmap.html | 4 +++- lib/OpenLayers/Control/OverviewMap.js | 20 ++++++++++++++++++++ tests/Control/OverviewMap.html | 17 +++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/examples/overviewmap.html b/examples/overviewmap.html index 165c987e8b..5a8cc3fbc9 100644 --- a/examples/overviewmap.html +++ b/examples/overviewmap.html @@ -80,7 +80,9 @@

Overview Map

// create an overview map control with the default options var overview1 = new OpenLayers.Control.OverviewMap({ - maximized: true + maximized: true, + maximizeTitle: 'Show the overview map', + minimizeTitle: 'Hide the overview map' }); map1.addControl(overview1); diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index c6085d6bd5..55af687d08 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -127,6 +127,20 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { */ maximized: false, + /** + * APIProperty: maximizeTitle + * {String} This property is used for showing a tooltip over the + * maximize div. Defaults to "" (no title). + */ + maximizeTitle: "", + + /** + * APIProperty: minimizeTitle + * {String} This property is used for showing a tooltip over the + * minimize div. Defaults to "" (no title). + */ + minimizeTitle: "", + /** * Constructor: OpenLayers.Control.OverviewMap * Create a new overview map @@ -247,6 +261,9 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { 'absolute'); this.maximizeDiv.style.display = 'none'; this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton'; + if (this.maximizeTitle) { + this.maximizeDiv.title = this.maximizeTitle; + } this.div.appendChild(this.maximizeDiv); // minimize button div @@ -259,6 +276,9 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { 'absolute'); this.minimizeDiv.style.display = 'none'; this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton'; + if (this.minimizeTitle) { + this.minimizeDiv.title = this.minimizeTitle; + } this.div.appendChild(this.minimizeDiv); this.minimizeControl(); } else { diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index 6548e21e59..a5a598d0d5 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -14,6 +14,23 @@ "olControlOverviewMap", "displayClass is correct" ); } + function test_divs_title(t) { + t.plan(2); + + control = new OpenLayers.Control.OverviewMap({ + maximizeTitle: "maximize title", + minimizeTitle: "minimize title" + }); + map = new OpenLayers.Map('map', { + layers: [new OpenLayers.Layer("layer", {isBaseLayer: true})], + controls: [control] + }); + map.zoomToMaxExtent(); + t.eq(control.maximizeDiv.title, "maximize title", "maximizeDiv.title is correct"); + t.eq(control.minimizeDiv.title, "minimize title", "minimizeDiv.title is correct"); + map.destroy(); + } + function test_setMap(t) { t.plan(4);