changeset 709:fca26721e8dd jquery

fixed some reset and cookie issues
author hertzhaft
date Sat, 29 Jan 2011 23:27:39 +0100
parents 120ace160386
children d533bdf0e64e
files client/digitallibrary/jquery/img/fullscreen.svg client/digitallibrary/jquery/jquery-test-embedded.html client/digitallibrary/jquery/jquery.digilib.js
diffstat 3 files changed, 69 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/jquery/img/fullscreen.svg	Fri Jan 28 19:50:50 2011 +0100
+++ b/client/digitallibrary/jquery/img/fullscreen.svg	Sat Jan 29 23:27:39 2011 +0100
@@ -119,7 +119,7 @@
      inkscape:groupmode="layer"
      id="layer6"
      inkscape:label="bg"
-     style="display:inline;opacity:0.94363257"
+     style="display:inline;opacity:1"
      sodipodi:insensitive="true">
     <rect
        style="color:#000000;fill:#924747;fill-opacity:0.59183673000000003;fill-rule:evenodd;stroke:none;stroke-width:0;marker:none;visibility:visible;display:inline;overflow:visible"
--- a/client/digitallibrary/jquery/jquery-test-embedded.html	Fri Jan 28 19:50:50 2011 +0100
+++ b/client/digitallibrary/jquery/jquery-test-embedded.html	Sat Jan 29 23:27:39 2011 +0100
@@ -73,6 +73,10 @@
             div._error {
                 color: red;
                 }
+                
+            div#test:hover {
+                background-color: cornsilk;
+                }
 
         </style>
 
@@ -128,6 +132,10 @@
             </tr>
         </table>
         <div id="debug">DEBUG</div>
+        <div id="test">
+            <img id="test" src="img/black-glass-16.png"></img>
+            <img id="test2" src="img/black-glass-32.png"></img>
+        </div>
     </body>
 </html>
 
--- a/client/digitallibrary/jquery/jquery.digilib.js	Fri Jan 28 19:50:50 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Sat Jan 29 23:27:39 2011 +0100
@@ -284,7 +284,7 @@
                     showButtons(data, true, i);
                 }
                 // bird's eye view creation
-                if (elemSettings.isBirdDivVisible) {
+                if (elemSettings.isBirdDivVisible ) {
                     setupBirdDiv(data);
                 }
                 // about window creation - TODO: could be deferred? restrict to only one item?
@@ -469,6 +469,7 @@
             var settings = data.settings;
             var paramNames = settings.digilibParamNames;
             var params = data.queryParams;
+            // resets zoomArea, marks, scalerflags
             resetData(data);
             // delete all digilib parameters
             for (var i = 0; i < paramNames.length; i++) {
@@ -477,12 +478,15 @@
                 };
             // fullscreen: restore only fn/pn parameters 
             if (settings.interactionMode === 'fullscreen') {
-                settings['fn'] = params.fn;
-                settings['pn'] = params.pn;
+                settings['fn'] = params.fn || ''; // no default defined
+                settings['pn'] = params.pn || defaults.pn;
             // embedded: restore original parameters 
             } else {
                 $.extend(settings, params);
                 };
+            // TODO: should we really reset all user preferences here?
+            settings.isBirdDivVisible = false;
+            settings.visibleButtonSets = 1;
             redisplay(data);
         },
 
@@ -627,32 +631,7 @@
             }
         }
         data.scalerFlags = flags;
-        // clop (digilib options)
-        var opts = {};
-        if (jQuery.cookie) {
-            // read from cookie
-            var ck = "digilib:fn:" + escape(settings.fn) + ":pn:" + settings.pn;
-            var cp = jQuery.cookie(ck);
-            console.debug("get cookie=", ck, " value=", cp);
-            // in query string format
-            opts = parseQueryString(cp);
-        }
-        /* read from parameter clop
-         * if (settings.clop) {
-            var pa = settings.clop.split(",");
-            for (var i = 0; i < pa.length ; i++) {
-                opts[pa[i]] = pa[i];
-            }
-        } */
-        data.dlOpts = opts;
-        // birdview option
-        if (opts.birdview != null) {
-            settings.isBirdDivVisible = opts.birdview;
-        }
-        // visible button sets
-        if (opts.buttons != null) {
-            settings.visibleButtonSets = opts.buttons;
-        }
+        retrieveOptionsCookie(data);
     };
 
     // put objects back into parameters
@@ -686,24 +665,12 @@
             }
             settings.mo = mo;
         }
-        // save digilib settings in options
-        data.dlOpts.birdview = settings.isBirdDivVisible ? 1 : 0;
-        data.dlOpts.buttons = settings.visibleButtonSets;
+        storeOptionsCookie(data);
+    };
 
+    var storeOptionsCookie = function (data) {
         // save digilib options in cookie
-        // TODO: in embedded mode this is not called 
-        if (data.dlOpts) {
-            var clop = '';
-            for (var o in data.dlOpts) {
-                if (clop) {
-                    clop += '&';
-                }
-                clop += o + '=' + data.dlOpts[o];
-            }
-            var ck = "digilib:fn:" + escape(settings.fn) + ":pn:" + settings.pn;
-            console.debug("set cookie=", ck, " value=", clop);
-            jQuery.cookie(ck, clop);
-        };
+        // TODO: in embedded mode this is not called
         /* store in parameter clop
          * if (data.dlOpts) {
             var clop = '';
@@ -715,14 +682,61 @@
             }
             settings.clop = clop;
         } */
+        var settings = data.settings;
+        if (data.dlOpts) {
+            // save digilib settings in options
+            data.dlOpts.birdview = settings.isBirdDivVisible ? 1 : 0;
+            data.dlOpts.buttons = settings.visibleButtonSets;
+            var clop = '';
+            for (var o in data.dlOpts) {
+                if (clop) {
+                    clop += '&';
+                }
+                clop += o + '=' + data.dlOpts[o];
+            }
+            if (jQuery.cookie) {
+                var ck = "digilib:fn:" + escape(settings.fn) + ":pn:" + settings.pn;
+                console.debug("set cookie=", ck, " value=", clop);
+                jQuery.cookie(ck, clop);
+                };
+        };
     };
 
+    var retrieveOptionsCookie = function (data) {
+        // clop (digilib options)
+        var opts = {};
+        var settings = data.settings;
+        if (jQuery.cookie) {
+            /* read from parameter clop
+             * if (settings.clop) {
+                var pa = settings.clop.split(",");
+                for (var i = 0; i < pa.length ; i++) {
+                    opts[pa[i]] = pa[i];
+                }
+            } */
+            // read from cookie
+            var ck = "digilib:fn:" + escape(settings.fn) + ":pn:" + settings.pn;
+            var cp = jQuery.cookie(ck);
+            console.debug("get cookie=", ck, " value=", cp);
+            // in query string format
+            opts = parseQueryString(cp);
+            };
+        data.dlOpts = opts;
+        // birdview option
+        if (opts.birdview != null) {
+            settings.isBirdDivVisible = opts.birdview === '1';
+            };
+        // visible button sets
+        if (opts.buttons != null) {
+            settings.visibleButtonSets = opts.buttons;
+            };
+    }
+
     // clear digilib data for reset
     var resetData = function (data) {
         if (data.zoomArea) delete data.zoomArea;
         if (data.marks) delete data.marks;
         if (data.scalerFlags) delete data.scalerFlags;
-        if (data.dlOpts) delete data.dlOpts;
     };
 
     // (re)load the img from a new scaler URL