[fusion-commits] r2671 - in trunk: text widgets widgets/Measure
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Mar 22 10:17:27 PDT 2013
Author: jng
Date: 2013-03-22 10:17:27 -0700 (Fri, 22 Mar 2013)
New Revision: 2671
Modified:
trunk/text/en
trunk/widgets/Measure.js
trunk/widgets/Measure/Measure.php
Log:
#550: Make Measure widget self-contained:
- Add manual start/stop buttons, that are properly enabled/disabled when measuring is in progress or not happening.
- Auto-deactivate the widget via onload and a SetWidget() hook function called from the Measure.js
Modified: trunk/text/en
===================================================================
--- trunk/text/en 2013-03-22 15:33:22 UTC (rev 2670)
+++ trunk/text/en 2013-03-22 17:17:27 UTC (rev 2671)
@@ -134,7 +134,9 @@
MEASUREPARTIAL = Partial
MEASURETOTAL = total
MEASURELAYER = Measure
-MEASUREHINT = To measure multiple distances, continue clicking new points. To finish, double click on the last point. You can cancel and restart the measuring by pressing the ESC key.
+MEASURESTOP = Stop
+MEASURESTART = Start
+MEASUREHINT = To measure multiple distances, continue clicking new points. To finish, double click on the last point. You can cancel and restart the measuring by pressing the ESC key or by using the Stop and Start buttons.
# FeatureInfoUI
FEATUREINFOTITLE = Feature Information
Modified: trunk/widgets/Measure/Measure.php
===================================================================
--- trunk/widgets/Measure/Measure.php 2013-03-22 15:33:22 UTC (rev 2670)
+++ trunk/widgets/Measure/Measure.php 2013-03-22 17:17:27 UTC (rev 2671)
@@ -60,6 +60,8 @@
$segment = GetLocalizedString( "SEGMENT", $locale );
$length = GetLocalizedString( "LENGTH", $locale );
+ $measureStop = GetLocalizedString( "MEASURESTOP", $locale );
+ $measureStart = GetLocalizedString( "MEASURESTART", $locale );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
@@ -71,11 +73,45 @@
<style type="text/css" media="screen">
@import url(Measure.css);
</style>
+ <script type="text/javascript">
+
+ var _widget = null;
+ var domInit = false;
+
+ function OnLoad() {
+ domInit = true;
+ }
+
+ function OnUnload() {
+ _widget.deactivate();
+ }
+
+ function SetWidget(widget) {
+ _widget = widget;
+ _widget.setButtons(document.getElementById("measureStopBtn"), document.getElementById("measureStartBtn"));
+ }
+
+ function OnStop() {
+ _widget.stopMeasurement();
+ }
+
+ function OnStart() {
+ _widget.startMeasurement();
+ }
+
+ </script>
</head>
-<body id="MeasurementWidgetResults">
+<body id="MeasurementWidgetResults" onload="OnLoad()" onunload="OnUnload()">
<h1><?php echo $title ?></h1>
<hr />
<p><?php echo $hint ?></p>
+ <table border="0">
+ <tr>
+ <td id="measureStopCnt"><input type="button" id="measureStopBtn" onclick="OnStop()" value="<?= $measureStop ?>" disabled="disabled" /></td>
+ <td id="measureStartCnt"><input type="button" id="measureStartBtn" onclick="OnStart()" value="<?= $measureStart ?>" disabled="disabled" /></td>
+ </tr>
+ </table>
+ <hr />
<table id="MeasurementWidgetResultsTable" border="0" cellspacing="5" cellpadding="5">
<?php if ($type & 1): ?>
<thead>
Modified: trunk/widgets/Measure.js
===================================================================
--- trunk/widgets/Measure.js 2013-03-22 15:33:22 UTC (rev 2670)
+++ trunk/widgets/Measure.js 2013-03-22 17:17:27 UTC (rev 2671)
@@ -449,13 +449,59 @@
},
activate: function() {
+ this.loadDisplayPanel();
+ this.startMeasurement();
+ },
+
+ startMeasurement: function() {
this.control.activate();
this.getMap().message.info(OpenLayers.i18n("measureInProgress"));
this.resetMeasure();
OpenLayers.Event.observe(document,"keypress",this.keyHandler);
- this.loadDisplayPanel();
this.getMap().supressContextMenu(true);
+ this.updateButtonStates();
},
+
+ stopMeasurement: function() {
+ OpenLayers.Event.stopObserving(document, 'keypress', this.keyHandler);
+ this.control.deactivate();
+ this.control.cancel();
+ this.getMap().message.clear();
+ this.getMap().supressContextMenu(false);
+ this.updateButtonStates();
+ },
+
+ updateButtonStates: function() {
+ if (this.startButton != null && this.stopButton != null) {
+ this.stopButton.disabled = !this.control.active;
+ this.startButton.disabled = this.control.active;
+ }
+ },
+
+ setButtons: function(stopBtn, startBtn) {
+ this.startButton = startBtn;
+ this.stopButton = stopBtn;
+ this.updateButtonStates();
+ },
+
+ initManualControls: function(outputWin) {
+ this.startButton = null;
+ this.stopButton = null;
+
+ var timer;
+ var that = this;
+ var watch = function() {
+ try {
+ if (outputWin.domInit) {
+ doc = outputWin.document;
+ clearInterval(timer);
+ outputWin.SetWidget(that); //Hook the widget for auto-deactivation
+ }
+ } catch (e) {
+ }
+ };
+ timer = setInterval(watch, 200);
+ },
loadDisplayPanel: function() {
if (this.sTarget) {
@@ -479,6 +525,7 @@
} else {
outputWin = window.open(url, this.sTarget, this.sWinFeatures);
}
+ this.initManualControls(outputWin);
this.registerForEvent(Fusion.Event.MEASURE_CLEAR, OpenLayers.Function.bind(this.clearDisplay, this, outputWin));
this.registerForEvent(Fusion.Event.MEASURE_SEGMENT_UPDATE, OpenLayers.Function.bind(this.updateDisplay, this, outputWin));
this.registerForEvent(Fusion.Event.MEASURE_COMPLETE, OpenLayers.Function.bind(this.updateDisplay, this, outputWin));
@@ -505,11 +552,7 @@
* deactivate the ruler tool
*/
deactivate: function() {
- OpenLayers.Event.stopObserving(document, 'keypress', this.keyHandler);
- this.control.deactivate();
- this.control.cancel();
- this.getMap().message.clear();
- this.getMap().supressContextMenu(false);
+ this.stopMeasurement();
},
resetMeasure: function() {
@@ -573,7 +616,7 @@
/*
* updates the summary display if it is loaded in a window somewhere
*/
- updateDisplay: function(outputWin) {
+ updateDisplay: function(outputWin) {
var outputDoc = outputWin.document;
var resolution = this.getMap().getResolution();
this.clearDisplay(outputWin);
More information about the fusion-commits
mailing list