From: <lph...@us...> - 2011-11-29 19:25:30
|
Revision: 39042 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=39042&view=rev Author: lphuberdeau Date: 2011-11-29 19:25:23 +0000 (Tue, 29 Nov 2011) Log Message: ----------- [MOD]?\194?\160Mode selection controls for maps Modified Paths: -------------- trunk/lib/jquery_tiki/tiki-maps.js trunk/lib/wiki-plugins/wikiplugin_map.php Added Paths: ----------- trunk/modules/mod-func-map_mode_selector.php trunk/templates/modules/mod-map_mode_selector.tpl Modified: trunk/lib/jquery_tiki/tiki-maps.js =================================================================== --- trunk/lib/jquery_tiki/tiki-maps.js 2011-11-29 18:27:45 UTC (rev 39041) +++ trunk/lib/jquery_tiki/tiki-maps.js 2011-11-29 19:25:23 UTC (rev 39042) @@ -127,7 +127,7 @@ map.addLayer(container.markers); map.zoomToMaxExtent(); - container.controlModes = { + container.modeManager = { modes: [], activeMode: null, addMode: function (options) { @@ -149,7 +149,17 @@ if (! this.activeMode) { this.activate(mode); } + + $(container).trigger('modechanged'); }, + switchTo: function (modeName) { + var manager = this; + $.each(this.modes, function (k, mode) { + if (mode.name === modeName) { + manager.activate(mode); + } + }); + }, activate: function (mode) { if (this.activeMode) { this.deactivate(); @@ -163,6 +173,8 @@ if (mode.activate) { mode.activate.apply([], container); } + + $(container).trigger('modechanged'); }, deactivate: function () { if (! this.activeMode) { @@ -170,7 +182,6 @@ } $.each(this.activeMode.controls, function (k, control) { - map.addControl(control); control.deactivate(); }); if (this.activeMode.deactivate) { @@ -187,11 +198,15 @@ if (layers.length > 1 && -1 !== $.inArray('controls', desiredControls)) { defaultMode.controls.push(new OpenLayers.Control.Navigation()); - defaultMode.controls.push(new OpenLayers.Control.PanZoom()); + if (-1 !== $.inArray('levels', desiredControls)) { + map.addControl(new OpenLayers.Control.PanZoomBar()); + } else { + map.addControl(new OpenLayers.Control.PanZoom()); + } } if (layers.length > 1 && -1 !== $.inArray('layers', desiredControls)) { - defaultMode.controls.push(new OpenLayers.Control.LayerSwitcher()); + map.addControl(new OpenLayers.Control.LayerSwitcher()); } container.markerIcons = { @@ -464,7 +479,7 @@ } } - container.controlModes.addMode(defaultMode); + container.modeManager.addMode(defaultMode); $(container).closest('.tab, #appframe').find('form.search-box') .unbind('submit') Modified: trunk/lib/wiki-plugins/wikiplugin_map.php =================================================================== --- trunk/lib/wiki-plugins/wikiplugin_map.php 2011-11-29 18:27:45 UTC (rev 39041) +++ trunk/lib/wiki-plugins/wikiplugin_map.php 2011-11-29 19:25:23 UTC (rev 39042) @@ -179,6 +179,7 @@ return array( 'controls', 'layers', + 'levels', 'search_location', 'current_location', 'streetview', Added: trunk/modules/mod-func-map_mode_selector.php =================================================================== --- trunk/modules/mod-func-map_mode_selector.php (rev 0) +++ trunk/modules/mod-func-map_mode_selector.php 2011-11-29 19:25:23 UTC (rev 39042) @@ -0,0 +1,28 @@ +<?php +// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project +// +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. +// $Id: mod-func-map_layer_selector.php 38675 2011-11-03 20:49:19Z pkdille $ + +if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { + header("location: index.php"); + exit; +} + + +function module_map_mode_selector_info() +{ + return array( + 'name' => tra('Mode Selector'), + 'description' => tra("Toggle input modes for the map."), + 'prefs' => array(), + 'params' => array( + ), + ); +} + +function module_map_mode_selector($mod_reference, $module_params) +{ +} + Added: trunk/templates/modules/mod-map_mode_selector.tpl =================================================================== --- trunk/templates/modules/mod-map_mode_selector.tpl (rev 0) +++ trunk/templates/modules/mod-map_mode_selector.tpl 2011-11-29 19:25:23 UTC (rev 39042) @@ -0,0 +1,44 @@ +{tikimodule error=$module_params.error title=$tpl_module_title name="map_mode_selector" flip=$module_params.flip decorations=$module_params.decorations nobox=$module_params.nobox notitle=$module_params.notitle} + <form class="map-mode-selector" method="post" action=""> + <select name="modeControl"> + </select> + </form> + {jq} + $('.map-mode-selector').hide(); + $(function () { + $('.map-mode-selector').removeClass('map-mode-selector').each(function () { + var map = $(this).closest('.tab, #appframe, body').find('.map-container:first')[0]; + var modeControl= $(this.modeControl); + + if (! map) { + return; + } + + $(this).show(); + + modeControl.change(function () { + if (map.modeManager) { + map.modeManager.switchTo($(this).val()); + } + }); + + var refreshModes = function () { + modeControl.empty(); + $.each(map.modeManager.modes, function (k, mode) { + modeControl.append($('<option/>') + .attr('value', mode.name) + .text(mode.name) + .attr('selected', mode === map.modeManager.activeMode)); + }); + }; + + setTimeout(function () { + // Wait for OpenLayers to initialize + refreshModes(); + + $(map).bind('modechanged', refreshModes); + }, 500); + }); + }); + {/jq} +{/tikimodule} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |