changeset 443:089adc9e2a5f

placement of size menu
author hertzhaft
date Fri, 13 Jan 2006 12:03:25 +0100
parents 3d37d8eae372
children 5827dd2d3ccc
files client/digitallibrary/greyskin/diginew.jsp client/digitallibrary/greyskin/dllib.js
diffstat 2 files changed, 86 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/greyskin/diginew.jsp	Fri Jan 13 12:01:07 2006 +0100
+++ b/client/digitallibrary/greyskin/diginew.jsp	Fri Jan 13 12:03:25 2006 +0100
@@ -46,13 +46,16 @@
 
 	<script language="JavaScript">
 
-	var jspVersion = "diginew.jsp 1.011";
+	var jspVersion = "diginew.jsp 1.013";
 	var cookie = new Cookie();
 	// alert(strObject(cookie));
 
 	var isOptionDivVisible = cookie.getbool("isOptionDivVisible");
 	var isBirdDivVisible = cookie.getbool("isBirdDivVisible");
 	var isAboutDivVisible = false;
+	var isSizeMenuVisible = false;
+	var isOriginalSize = false;
+	var isPixelByPixel = false;
 	var dlTarget = window.name;
 	var baseUrl = '<%= dlRequest.getAsString("base.url") %>';
 	var toolbarEnabledURL = window.location.href;
@@ -75,21 +78,49 @@
 		showAboutDiv(isAboutDivVisible);
 		}
 
+	function toggleSizeMenu() {
+		isSizeMenuVisible = !isSizeMenuVisible;
+		showSizeMenu(isSizeMenuVisible);
+		}
+
+	function toggleOriginalSize(on) {
+		isOriginalSize = (arguments.length == 1)
+			? on
+			: !isOriginalSize;
+		togglePixelByPixel(false);
+		originalSize(isOriginalSize);
+		}
+
+	function togglePixelByPixel(on) {
+		isPixelByPixel = (arguments.length == 1)
+			? on
+			: !isPixelByPixel;
+		toggleOriginalSize(false);
+		pixelByPixel(isPixelByPixel);
+		}
+
+	function setOnImage(id, src, value) {
 	// replace img src and display "on" status
-	function setOnImage(id, src) {
 		var elem = getElement(id);
 		elem.src = src;
-		elem.title += ": on";
+		if (value)
+			elem.title += ": " + value;
+		else
+			elem.title += ": on";
 		}
 
 	// change icons if image functions are on
 	function reflectImageStatus() {
 		if (hasFlag("hmir")) setOnImage("hmir", "mirror-horizontal-on.png");
 		if (hasFlag("vmir")) setOnImage("vmir", "mirror-vertical-on.png");
-		if (hasParameter("brgt")) setOnImage("brgt", "brightness-on.png");
-		if (hasParameter("cont")) setOnImage("cont", "contrast-on.png");
-		if (hasParameter("rot")) setOnImage("rot", "rotate-on.png");
-		if (hasParameter("rgb")) setOnImage("rgb", "rgb-on.png");
+		if (hasParameter("brgt"))
+			setOnImage("brgt", "brightness-on.png", getParameter("brgt"));
+		if (hasParameter("cont"))
+			setOnImage("cont", "contrast-on.png", getParameter("cont"));
+		if (hasParameter("rot"))
+			setOnImage("rot", "rotate-on.png", getParameter("rot"));
+		if (hasParameter("rgb"))
+			setOnImage("rgb", "rgb-on.png", getParameter("rgb"));
 		}
 		
 	// initialize image; called by body.onload
@@ -165,10 +196,10 @@
 
  <!-- the size menu -->
  <div id="sizes">
-	<p><a href="javascript:resize(1)">1</a></p>
-	<p><a href="javascript:resize(1.41)">1.41</a></p>
-	<p><a href="javascript:resize(2)">2</a></p>
-	<p><a href="javascript:resize(3)">3</a></p>
+	<p><a href="javascript:resize(1)">1 x</a></p>
+	<p><a href="javascript:resize(1.41)">1.41 x</a></p>
+	<p><a href="javascript:resize(2)">2 x</a></p>
+	<p><a href="javascript:resize(3)">3 x</a></p>
  </div>
 
  <!-- the buttons -->
@@ -269,7 +300,7 @@
 	<div class="button">
 		<a
 			class="icon"
-			href="javascript:sizeMenu()"
+			href="javascript:toggleSizeMenu()"
 			>
 
 			<img
--- a/client/digitallibrary/greyskin/dllib.js	Fri Jan 13 12:01:07 2006 +0100
+++ b/client/digitallibrary/greyskin/dllib.js	Fri Jan 13 12:03:25 2006 +0100
@@ -24,7 +24,7 @@
 
 */
 digilibVersion = "Digilib NG";
-dllibVersion = "2.029";
+dllibVersion = "2.031";
 isDigilibInitialized = false;    // gets set to true in dl_param_init
 reloadPage = true; // reload the page when parameters are changed, otherwise update only "src" attribute of scaler img 
 
@@ -355,7 +355,7 @@
     var scaler = getElement('scaler');
     var zoomdiv = getElement("zoom");    // test for presence only
     var overlay = getElement("overlay");    // test for presence only
-    var about = getElement("bird");        // test for presence only
+    var about = getElement("about");        // test for presence only
     var bird = getElement("bird");        // test for presence only
     var picsize = bestPicSize(scaler, 50);
     var src = "../servlet/Scaler?" 
@@ -395,7 +395,7 @@
     dlTrafo = parseTrafo(scalerImg);
     // debugProps(dlArea, "dlArea");
     for (var i = 0; i < dlMarks.length; i++) {
-    var div = document.getElementById("mark" + i) || createMarkDiv(i);
+    var div = getElement("mark" + i) || createMarkDiv(i);
         var mark = dlMarks[i];
     // debugProps(mark, "mark");
     if (dlArea.containsPosition(mark)) {
@@ -583,7 +583,8 @@
 
 function isFullArea(area) {
     if (!area) area = dlArea;
-    return ((area.width == 1.0) && (area.height == 1.0));
+    // pixel by pixel is not always full area
+    return (area.width == 1.0) && (area.height == 1.0) && ! hasFlag("clip");
 }
 
 function canMove(movx, movy) {
@@ -719,18 +720,22 @@
     // show or hide "about" div
     var elem = getElement("about");
     if (elem == null) {
-        if (!show) return;
-        alert("About Digilib - dialog missing in HTML code!"
+        if (show) alert("About Digilib - dialog missing in HTML code!"
             + "\nDigilib Version: " + digilibVersion
             + "\JSP Version: " + jspVersion
             + "\ndlLib Version: " + dllibVersion
             + "\nbaseLib Version: " + baseLibVersion);
         return;
         }
-    document.getElementById("digilib-version").innerHTML = "Digilib Version: " + digilibVersion;
-    document.getElementById("jsp-version").innerHTML = "JSP Version: " + jspVersion;
-    document.getElementById("baselib-version").innerHTML = "baseLib Version: " + baseLibVersion;
-    document.getElementById("dllib-version").innerHTML = "dlLib Version: " + dllibVersion;
+    if (show) {
+        getElement("digilib-version").innerHTML = "Digilib Version: " + digilibVersion;
+        getElement("jsp-version").innerHTML = "JSP Version: " + jspVersion;
+        getElement("baselib-version").innerHTML = "baseLib Version: " + baseLibVersion;
+        getElement("dllib-version").innerHTML = "dlLib Version: " + dllibVersion;
+        var aboutRect = getElementRect(elem);
+        aboutRect.setCenter(getWinRect().getCenter());
+        moveElement(elem, aboutRect);
+        }
     showElement(elem, show);
     }
     
@@ -829,6 +834,7 @@
 	}
 	
 function showArrows() {
+    // show the 4 arrow bars on top of scaler img according to current dlArea
     if (defined(scalerImg.complete) && !scalerImg.complete && !browserType.isN4 ) {
         setTimeout("showArrows()", 100);
         return;
@@ -871,8 +877,6 @@
         unregisterEvent("mousedown", document, calibrationStartDrag);
         registerEvent("mousemove", document, calibrationMove);
         registerEvent("mouseup",   document, calibrationEndDrag);
-        registerEvent("mousemove", calDiv, calibrationMove);
-        registerEvent("mouseup",   calDiv, calibrationEndDrag);
         newRect = new Rectangle(
             startPos.x,
             startPos.y,
@@ -902,8 +906,6 @@
     // mouseup handler: calibrate
         unregisterEvent("mousemove", document, calibrationMove);
         unregisterEvent("mouseup",   document, calibrationEndDrag);
-        unregisterEvent("mousemove", calDiv, calibrationMove);
-        unregisterEvent("mouseup",   calDiv, calibrationEndDrag);
         if (xDir) {
             var val = newRect.width * 0.254; // ratio dm/inch
             cookie.add("ddpi", val);
@@ -919,33 +921,44 @@
         }
     }
 
-function originalSize() {
-    var dpi = cookie.get("ddpi");
-    if (dpi == null) {
-        alert("Screen has not yet been calibrated - using default value of 72 dpi");
-        dpi = 72;
+function originalSize(on) {
+    // set osize flag, needs calibrated screen
+    if (on) {
+        var dpi = cookie.get("ddpi");
+        if (dpi == null) {
+            alert("Screen has not yet been calibrated - using default value of 72 dpi");
+            dpi = 72;
+            }
+        setParameter("ddpi", dpi);
+        addFlag("osize");
+        display();
         }
-    setParameter("ddpi", dpi);
-    addFlag("osize");
-    display();
+    else removeFlag("osize");
 }
     
-function pixelByPixel() {
-    addFlag("clip");
-    display();
+function pixelByPixel(on) {
+    // sets clip flag
+    if (on) { 
+        addFlag("clip");
+        display();
+        }
+    else removeFlag("clip");
 }
 
 function resize(factor) {
     setParameter("ws", factor);
+    showSizeMenu(false);
     display();
-    var menu = getElement("sizes");
-    showElement(menu, false);
 }
 
-function sizeMenu() {
+function showSizeMenu(show) {
     var menu = getElement("sizes");
-    showElement(menu, true);
+    if (show) {
+        // align menu with button
+        var buttonPos = getElementPosition(getElement("size"));
+        moveElement(menu, new Position(buttonPos.x - 50, buttonPos.y));
+        }
+    showElement(menu, show);
 }
-
 // :tabSize=4:indentSize=4:noTabs=true: