changeset 889:65ad22044e13 jquery

merge with 80a695f683c702570c981aef4471a13d2d7f7f87
author robcast
date Wed, 06 Apr 2011 13:26:40 +0200
parents 7e79829579f6 (diff) 80a695f683c7 (current diff)
children 613c2089bc7a
files client/digitallibrary/jquery/jquery.digilib.js
diffstat 4 files changed, 181 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/WEB-INF/web-2.3.xml	Tue Mar 22 18:33:52 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
- 
-<web-app>
-  <!-- General description of your web application -->
-  <display-name>
-        digilib
-  </display-name>
-  <description>
-        This is the web frontend of the Digital Document Library.
-  </description>
-  <!-- The Intialisation Listener -->
-  <listener>
-        <listener-class>
-            digilib.servlet.Initialiser
-        </listener-class>
-  </listener>
-  <!-- The Scaler servlet -->
-  <servlet>
-        <servlet-name>
-            Scaler
-        </servlet-name>
-        <servlet-class>
-            digilib.servlet.ScalerNoAsync
-        </servlet-class>
-        <!-- Load this servlet at server startup time -->
-        <load-on-startup>
-            5
-        </load-on-startup>
-  </servlet>
-  <!-- The Texter servlet -->
-  <servlet>
-        <servlet-name>
-            Texter
-        </servlet-name>
-        <servlet-class>
-            digilib.servlet.Texter
-        </servlet-class>
-  </servlet>
-  <!-- The PDFCache servlet -->
-  <servlet>
-        <servlet-name>
-            PDFCache
-        </servlet-name>
-        <servlet-class>
-            digilib.servlet.PDFCache
-        </servlet-class>
-  </servlet>
-  <!-- The mapping for the Scaler servlet -->
-  <servlet-mapping>
-        <servlet-name>
-            Scaler
-        </servlet-name>
-        <url-pattern>
-            /servlet/Scaler/*
-        </url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-        <servlet-name>
-            Scaler
-        </servlet-name>
-        <url-pattern>
-            /Scaler
-        </url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-        <servlet-name>
-            Scaler
-        </servlet-name>
-        <url-pattern>
-            /authenticated/servlet/Scaler/*
-        </url-pattern>
-  </servlet-mapping>
-  <!-- The mapping for the Texter servlet -->
-  <servlet-mapping>
-        <servlet-name>
-            Texter
-        </servlet-name>
-        <url-pattern>
-            /servlet/Texter/*
-        </url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-        <servlet-name>
-            Texter
-        </servlet-name>
-        <url-pattern>
-            /authenticated/servlet/Texter/*
-        </url-pattern>
-  </servlet-mapping>
-  <!-- The mapping for the Texter servlet -->
-  <servlet-mapping>
-        <servlet-name>
-            PDFCache
-        </servlet-name>
-        <url-pattern>
-            /servlet/PDFCache/*
-        </url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-        <servlet-name>
-            PDFCache
-        </servlet-name>
-        <url-pattern>
-            /authenticated/servlet/PDFCache/*
-        </url-pattern>
-  </servlet-mapping>
-  <!-- region for authenticated access -->
-  <security-constraint>
-        <web-resource-collection>
-            <web-resource-name>
-                Authenticated Digilib
-            </web-resource-name>
-            <url-pattern>
-                /authenticated/*
-            </url-pattern>
-        </web-resource-collection>
-        <!-- we need a default user -->
-<!--         <auth-constraint>
-            <role-name>
-                user
-            </role-name>
-        </auth-constraint>  -->
-  </security-constraint>
-  <login-config>
-  <!--
-        <auth-method>BASIC</auth-method>
-        <realm-name>digilib</realm-name> 
-   -->
-        <auth-method>
-            FORM
-        </auth-method>
-        <form-login-config>
-            <form-login-page>
-                /digilib-login.html
-            </form-login-page>
-            <form-error-page>
-                /digilib-fail.html
-            </form-error-page>
-        </form-login-config>
-  </login-config>
-</web-app>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/digitallibrary/WEB-INF/web-3.0.xml	Wed Apr 06 13:26:40 2011 +0200
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app
+        version="3.0"
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+        
+  <!-- General description of your web application -->
+  <display-name>
+        digilib
+  </display-name>
+  <description>
+        This is the web frontend of the Digital Document Library.
+  </description>
+  <!-- The Intialisation Listener (also configured by annotation) -->
+  <listener>
+        <listener-class>
+            digilib.servlet.Initialiser
+        </listener-class>
+  </listener>
+  <!-- The Scaler servlet (also configured by annotation) -->
+  <servlet>
+        <servlet-name>
+            Scaler
+        </servlet-name>
+        <servlet-class>
+            digilib.servlet.Scaler
+        </servlet-class>
+        <!-- Load this servlet at server startup time -->
+        <load-on-startup>
+            5
+        </load-on-startup>
+  </servlet>
+  <!-- The Texter servlet -->
+  <servlet>
+        <servlet-name>
+            Texter
+        </servlet-name>
+        <servlet-class>
+            digilib.servlet.Texter
+        </servlet-class>
+  </servlet>
+  <!-- The PDFCache servlet -->
+  <servlet>
+        <servlet-name>
+            PDFCache
+        </servlet-name>
+        <servlet-class>
+            digilib.servlet.PDFCache
+        </servlet-class>
+  </servlet>
+  <!-- The mapping for the Scaler servlet -->
+  <servlet-mapping>
+        <servlet-name>
+            Scaler
+        </servlet-name>
+        <url-pattern>
+            /servlet/Scaler/*
+        </url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+        <servlet-name>
+            Scaler
+        </servlet-name>
+        <url-pattern>
+            /Scaler
+        </url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+        <servlet-name>
+            Scaler
+        </servlet-name>
+        <url-pattern>
+            /authenticated/servlet/Scaler/*
+        </url-pattern>
+  </servlet-mapping>
+  <!-- The mapping for the Texter servlet -->
+  <servlet-mapping>
+        <servlet-name>
+            Texter
+        </servlet-name>
+        <url-pattern>
+            /servlet/Texter/*
+        </url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+        <servlet-name>
+            Texter
+        </servlet-name>
+        <url-pattern>
+            /authenticated/servlet/Texter/*
+        </url-pattern>
+  </servlet-mapping>
+  <!-- The mapping for the Texter servlet -->
+  <servlet-mapping>
+        <servlet-name>
+            PDFCache
+        </servlet-name>
+        <url-pattern>
+            /servlet/PDFCache/*
+        </url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+        <servlet-name>
+            PDFCache
+        </servlet-name>
+        <url-pattern>
+            /authenticated/servlet/PDFCache/*
+        </url-pattern>
+  </servlet-mapping>
+  <!-- region for authenticated access -->
+  <security-constraint>
+        <web-resource-collection>
+            <web-resource-name>
+                Authenticated Digilib
+            </web-resource-name>
+            <url-pattern>
+                /authenticated/*
+            </url-pattern>
+        </web-resource-collection>
+        <!-- we need a default user -->
+<!--         <auth-constraint>
+            <role-name>
+                user
+            </role-name>
+        </auth-constraint>  -->
+  </security-constraint>
+  <login-config>
+  <!--
+        <auth-method>BASIC</auth-method>
+        <realm-name>digilib</realm-name> 
+   -->
+        <auth-method>
+            FORM
+        </auth-method>
+        <form-login-config>
+            <form-login-page>
+                /digilib-login.html
+            </form-login-page>
+            <form-error-page>
+                /digilib-fail.html
+            </form-error-page>
+        </form-login-config>
+  </login-config>
+</web-app>
--- a/client/digitallibrary/WEB-INF/web.xml	Tue Mar 22 18:33:52 2011 +0100
+++ b/client/digitallibrary/WEB-INF/web.xml	Wed Apr 06 13:26:40 2011 +0200
@@ -1,10 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<web-app
-        version="3.0"
-        xmlns="http://java.sun.com/xml/ns/javaee"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
-        
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+ 
+<web-app>
   <!-- General description of your web application -->
   <display-name>
         digilib
@@ -12,19 +9,19 @@
   <description>
         This is the web frontend of the Digital Document Library.
   </description>
-  <!-- The Intialisation Listener (also configured by annotation) -->
+  <!-- The Intialisation Listener -->
   <listener>
         <listener-class>
             digilib.servlet.Initialiser
         </listener-class>
   </listener>
-  <!-- The Scaler servlet (also configured by annotation) -->
+  <!-- The Scaler servlet -->
   <servlet>
         <servlet-name>
             Scaler
         </servlet-name>
         <servlet-class>
-            digilib.servlet.Scaler
+            digilib.servlet.ScalerNoAsync
         </servlet-class>
         <!-- Load this servlet at server startup time -->
         <load-on-startup>
--- a/client/digitallibrary/jquery/jquery.digilib.js	Tue Mar 22 18:33:52 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Wed Apr 06 13:26:40 2011 +0200
@@ -237,6 +237,7 @@
             'fullscreen' : {
                 // path to button images (must end with a slash)
                 'imagePath' : 'img/fullscreen/',
+                'buttonSetWidth' : 36,
                 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","help","reset","toggleoptions"],
                 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","lessoptions"],
                 'arrowSet' : ["up", "down", "left", "right"],
@@ -244,11 +245,12 @@
                 },
             'embedded' : {
                 'imagePath' : 'img/embedded/16/',
+                'buttonSetWidth' : 18,
                 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","help","reset","toggleoptions"],
                 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","scale","lessoptions"],
                 'arrowSet' : ["up", "down", "left", "right"],
                 'buttonSets' : ['standardSet', 'specialSet']
-                }
+                },
         },
         // arrow bar overlays for moving the zoomed area
         'showZoomArrows' : true,
@@ -929,6 +931,8 @@
             if (typeof history.pushState === 'function') {
                 console.debug("faking reload to "+url);
                 // change url without reloading (stateObj, title, url)
+                // TODO: we really need to put the state in stateObj and listen to pop-events
+                // TODO: use replace-state(?)
                 history.pushState({}, '', url);
                 // change img src
                 var imgurl = getScalerUrl(data);
@@ -962,31 +966,33 @@
 
     // returns maximum size for scaler img in fullscreen mode
     var getFullscreenImgSize = function (data) {
+        var mode = data.settings.interactionMode;
         var $win = $(window);
         var winH = $win.height();
         var winW = $win.width();
-        console.debug("window size="+winW+"x"+winH);
         var $body = $('body');
-         // include standard body margins
+        // include standard body margins and check plausibility
         var borderW = $body.outerWidth(true) - $body.width();
+        if (borderW === 0 || borderW > 100) {
+            console.debug("fixing border width for getFullscreenImgSize!");
+            borderW = data.settings.scalerInset;
+        }
         var borderH = $body.outerHeight(true) - $body.height();
-        console.debug("body outerwidth="+$body.outerWidth(true)+" width="+$body.width());
-        // get width of first button div
+        if (borderH === 0 || borderH > 100) {
+            console.debug("fixing border height for getFullscreenImgSize!");
+            borderH = 5;
+        }
         var buttonsW = 0; 
-        if (data.$buttonSets) {
-            buttonsW = data.$buttonSets[0].outerWidth();
-            // try to fix ipad...
-            if (buttonsW === $body.width()) {
-                console.error("buttons width can't be measured -- using 32");
-                buttonsW = 32;
-            }
+        if (data.settings.visibleButtonSets) {
+            // get button width from settings
+            buttonsW = data.settings.buttonSettings[mode].buttonSetWidth;
+            // TODO: leave space for all button sets?
         }
         // account for left/right border, body margins and additional requirements
-        var calcW = winW - borderW - buttonsW - data.settings.scalerInset;
-        var calcH = winH - borderH;
-        console.debug("calcw="+calcW+" buttonsw="+buttonsW+" inset="+data.settings.scalerInset+" calcH="+calcH);
-        console.debug(winW, winH, 'winW:', $win.width(), 'border:', borderW, 'buttonsW:', buttonsW, 'calc:', calcW);
-        return geom.size(calcW, calcH);
+        var imgW = winW - borderW - buttonsW;
+        var imgH = winH - borderH;
+        console.debug(winW, winH, 'winW:', $win.width(), 'border:', borderW, 'buttonsW:', buttonsW, 'calc:', imgW);
+        return geom.size(imgW, imgH);
     };
 
     // creates HTML structure for digilib in elem
@@ -1210,7 +1216,7 @@
         var $elem = data.$elem;
         var settings = data.settings;
         var $aboutDiv = $('<div class="about" style="display:none"/>');
-        var $header = $('<p>Digilib Graphic Viewer</p>');
+        var $header = $('<p>Digilib Image Viewer</p>');
         var $link = $('<a/>');
         var $logo = $('<img class="logo" title="digilib"/>');
         var $content = $('<p/>');
@@ -1249,6 +1255,9 @@
     // display more (or less) button sets
     var showButtons = function (data, more, setIdx, animated) {
         var atime = animated ? 'fast': 0;
+        // get button width from settings
+        var mode = data.settings.interactionMode;
+        var btnWidth = data.settings.buttonSettings[mode].buttonSetWidth;
         if (more) {
             // add set
             var $otherSets = data.$elem.find('div.buttons:visible');
@@ -1261,7 +1270,7 @@
                 }
             if ($set == null) return false;
             // include border in calculation
-            var btnWidth = $set.outerWidth();
+            //var btnWidth = $set.outerWidth();
             // console.debug("btnWidth", btnWidth);
             // move remaining sets left and show new set
             if ($otherSets.length > 0) {
@@ -1274,7 +1283,7 @@
             // remove set
             var $set = data.$buttonSets[setIdx];
             if ($set == null) return false;
-            var btnWidth = $set.outerWidth();
+            //var btnWidth = $set.outerWidth();
             // hide last set
             $set.hide();
             // take remaining sets and move right
@@ -1713,7 +1722,7 @@
         return ((movx < 0) && (za.x > 0))
             || ((movx > 0) && (x2 < 1.0))
             || ((movy < 0) && (za.y > 0))
-            || ((movy > 0) && (y2 < 1.0));
+            || ((movy > 0) && (y2 < 1.0))
     };
 
     // auxiliary function (from old dllib.js)