changeset 1320:97974dbf0ce0

better shape info on click
author hertzhaft
date Fri, 23 Jan 2015 17:31:17 +0100
parents bf94aaa0a2c1
children e37a171cb056
files webapp/src/main/webapp/jquery/jquery.digilib.measure.css webapp/src/main/webapp/jquery/jquery.digilib.measure.js
diffstat 2 files changed, 34 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.css	Fri Jan 23 16:23:10 2015 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.css	Fri Jan 23 17:31:17 2015 +0100
@@ -19,15 +19,16 @@
     width: 8em;
 }
 
-div#dl-measure-toolbar select {
-    font-size: 100%;
-    width: 12em;
-}
-
 span.dl-measure-label {
     padding: 0px 5px;
     }
 
+span#dl-measure-shapeinfo {
+    display: inline-block;
+    width: 5em;
+    }
+
+
 span.dl-measure-number {
     display: inline-block;
     color: lightgreen;
@@ -40,12 +41,19 @@
 input#dl-measure-val2, select#dl-measure-shape, select#dl-measure-unit1, select#dl-measure-unit2 {
     color: lightgreen;
     background-color: #606060;
+    width: 12em;
+    margin: 0px 2px;
     }
 
-select#dl-measure-shape:focus  {
+select#dl-measure-shape  {
+    width: 9em;
+    }
+
+/* select#dl-measure-shape:focus  {
     color: black;
     background-color: white;
     }
+*/
 
 option:disabled {
     color: black;
--- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.js	Fri Jan 23 16:23:10 2015 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.js	Fri Jan 23 17:31:17 2015 +0100
@@ -806,7 +806,7 @@
             };
         var data = this;
         var $elem = shape.$elem;
-        $elem.on('mouseover.measure', shapeInfo);
+        $elem.on('click.measure', shapeInfo);
         console.debug('measure: onRenderShape', data, shape);
         };
 
@@ -878,6 +878,8 @@
         var widgets = data.measureWidgets;
         widgets.value1.val(fn.cropFloatStr(mRound(val)));
         widgets.value2.val(fn.cropFloatStr(mRound(conv)));
+        widgets.info.text('length');
+        setSelectedShape(data, shape);
         data.lastMeasuredValue = val;
         data.lastMeasuredDistance = dist;
         };
@@ -891,6 +893,8 @@
         var widgets = data.measureWidgets;
         widgets.value1.val(fn.cropFloatStr(mRound(val)));
         widgets.value2.val(fn.cropFloatStr(mRound(conv)));
+        widgets.info.text('area');
+        setSelectedShape(data, shape);
         };
 
     // info window for rectangle
@@ -898,6 +902,7 @@
         var widgets = data.measureWidgets;
         widgets.value1.val('rect 1');
         widgets.value2.val('rect 2');
+        setSelectedShape(data, shape);
         };
 
     // recalculate after measuring
@@ -935,6 +940,18 @@
         return shape;
         };
 
+    // return a shape of the currently selected shape type
+    var setSelectedShape = function(data, shape) {
+        var type = shape.geometry.type;
+        var types = data.settings.shapeTypes;
+        for (var i = 0; i < types.length; i++) {
+            if (types[i].type === type) break;
+            }
+        if (i === types.length) i = 0;
+        data.settings.selectedShape = i;
+        data.measureWidgets.shape.val(i);
+        };
+
     // return shape type selected by user (on the toolbar)
     var getSelectedShapeType = function(data) {
         var val = data.measureWidgets.shape.val();
@@ -1009,6 +1026,7 @@
             names : [
                 'move', 'startb', 'shape',
                 // 'lenlabel', 'len', 'eq1',
+                'info',
                 'value1', 'unit1', 'eq2',
                 'value2', 'unit2'
                 ],
@@ -1020,6 +1038,7 @@
 			// eq1 : $('<span class="dl-measure-label">=</span>'),
 			eq2 : $('<span class="dl-measure-label">=</span>'),
 			// len : $('<span id="dl-measure-len" class="dl-measure-number">0.0</span>'),
+			info : $('<span id="dl-measure-shapeinfo" class="dl-measure-label">length</span>'),
 			fac : $('<span id="dl-measure-factor" class="dl-measure-number" />'),
 			value1 : $('<input id="dl-measure-value1" class="dl-measure-input" title="value of the last measured distance - click to change the value" value="0.0" />'),
 			value2 : $('<input id="dl-measure-value2" class="dl-measure-input" title="value of the last measured distance, converted to the secondary unit" value="0.0"/>'),