changeset 703:0d49c33646da jquery

set quality works now (window.prompt only)
author robcast
date Fri, 28 Jan 2011 11:51:13 +0100
parents a343240a6f7c
children cdf6a0d04bf9
files client/digitallibrary/jquery/jquery.digilib.js
diffstat 1 files changed, 39 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js	Thu Jan 27 19:45:26 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Fri Jan 28 11:51:13 2011 +0100
@@ -116,7 +116,7 @@
             img : "rgb.png"
             },
         quality : {
-            onclick : "javascript:setQualityWin('Quality (0..2)')",
+            onclick : "setquality",
             tooltip : "set image quality",
             img : "quality.png"
             },
@@ -439,7 +439,7 @@
         morebuttons : function (data, more) {
             var settings = data.settings;
             if (more == null) {
-                // toggle more or less
+                // toggle more or less (only works for 2 sets)
                 var maxbtns = settings.buttonSettings[settings.interactionMode].buttonSets.length;
                 if (settings.visibleButtonSets >= maxbtns) {
                     more = '-1';
@@ -462,6 +462,7 @@
             }
         },
 
+        // reset image parameters to defaults
         reset : function (data) {
             var settings = data.settings;
             var paramNames = settings.digilibParamNames;
@@ -483,7 +484,8 @@
             redisplay(data);
         },
 
-        reference : function (data) {
+        // presents a reference url (returns value if noprompt)
+        reference : function (data, noprompt) {
             var settings = data.settings;
             var url;
             if (settings.interactionMode === 'fullscreen') {
@@ -491,7 +493,23 @@
             } else {
                 url = getScalerUrl(data);
                 };
-            window.prompt("URL reference to the current view", url);
+            if (noprompt == null) {
+                window.prompt("URL reference to the current view", url);
+            }
+            return url;
+        },
+        
+        // set image quality
+        setquality : function (data, qual) {
+            var oldq = getQuality(data);
+            if (qual == null) {
+                qual = window.prompt("Image quality (0..2)", oldq);
+            }
+            qual = parseInt(qual, 10);
+            if (qual >= 0 && qual <= 2) {
+                setQuality(data, qual);
+                redisplay(data);
+            }
         }
     };
 
@@ -1232,6 +1250,23 @@
         $birdZoom.bind("mousedown.digilib", birdZoomStartDrag);
     };
 
+    // get image quality as a number (0..2)
+    var getQuality = function (data) {
+        var flags = data.scalerFlags;
+        var q = flags.q2 || flags.q1 || 'q0'; // assume q0 as default
+        return parseInt(q[1], 10);
+    };
+
+    // set image quality as a number (0..2)
+    var setQuality = function (data, qual) {
+        var flags = data.scalerFlags;
+        // clear flags
+        for (var i = 0; i < 3; ++i) {
+            delete flags['q'+i];
+        }
+        flags['q'+qual] = 'q'+qual;
+    };
+    
     // sets a key to a value (relative values with +/- if relative=true)
     var setNumValue = function(settings, key, value) {
         if (isNumber(value)) return settings[key] = value;