changeset 691:fe2bb8f926be jquery

merge with f5f2b262be07f41fa6c8d2f60332b198eaa2d603
author robcast
date Wed, 26 Jan 2011 23:43:39 +0100
parents 7c8d5bfc5243 (diff) f5f2b262be07 (current diff)
children ab8054bba8d3
files client/digitallibrary/jquery/jquery-test-full.html client/digitallibrary/jquery/jquery.digilib.js
diffstat 2 files changed, 57 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery-test-full.html	Wed Jan 26 23:11:50 2011 +0100
+++ b/client/digitallibrary/jquery/jquery-test-full.html	Wed Jan 26 23:43:39 2011 +0100
@@ -82,7 +82,7 @@
             $(document).ready(function(){
                 var opts = {
                     interactionMode : 'fullscreen',
-                    scalerBaseUrl : 'http://digilib.biblhertz.it/digilib04/servlet/Scaler'
+                    scalerBaseUrl : 'http://localhost:18080/digitallibrary/servlet/Scaler'
                     };
                  $('div.digilib').digilib(opts);
 
--- a/client/digitallibrary/jquery/jquery.digilib.js	Wed Jan 26 23:11:50 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Wed Jan 26 23:43:39 2011 +0100
@@ -153,9 +153,14 @@
             tooltip : "change image scale",
             img : "original-size.png"
             },
-        options : {
-            onclick : "javascript:toggleOptionDiv()",
-            tooltip : "hide options",
+        moreoptions : {
+            onclick : ["morebuttons", "+1"],
+            tooltip : "more options",
+            img : "options.png"
+            },
+        lessoptions : {
+            onclick : ["morebuttons", "-1"],
+            tooltip : "less options",
             img : "options.png"
             },
         SEP : {
@@ -207,9 +212,8 @@
             'fullscreen' : {
                 // path to button images (must end with a slash)
                 'imagePath' : 'img/fullscreen/',
-                //'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"],
-                'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","calibrationx","scale","bird","help","reset","options"],
-                'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","options"],
+                'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","moreoptions"],
+                'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","lessoptions"],
                 'buttonSets' : ['standardSet', 'specialSet']
                 },
             'embedded' : {
@@ -441,6 +445,40 @@
             data.settings.cont = factor;
             redisplay(data);
         },
+        
+        // display more (or less) button sets
+        morebuttons : function (data, more) {
+            if (more === '-1') {
+                // remove set
+                var setIdx = data.visibleButtonSets - 1;
+                var $lastSet = data.$buttonSets[setIdx];
+                if ($lastSet == null) return;
+                var btnWidth = $lastSet.width();
+                // hide last set
+                $lastSet.hide();
+                // take remaining sets and move right
+                var $otherSets = data.$elem.find('div.buttons:visible');
+                $otherSets.animate({left : '+='+btnWidth+'px'});
+                data.visibleButtonSets -= 1;
+            } else {
+                // add set
+                var $oldSets = data.$elem.find('div.buttons:visible');
+                var setIdx = data.visibleButtonSets;
+                var $newSet;
+                if (data.$buttonSets[setIdx]) {
+                    // set exists
+                    $newSet = data.$buttonSets[setIdx];
+                } else {
+                    $newSet = setupButtons(data, setIdx);
+                }
+                if ($newSet == null) return;
+                var btnWidth = $newSet.width();
+                // move remaining sets left and show new set
+                $oldSets.animate({left : '-='+btnWidth+'px'},
+                        function () {$newSet.show();});
+                data.visibleButtonSets += 1;
+            }
+        },
 
         reset : function (data) {
             var settings = data.settings;
@@ -737,11 +775,14 @@
     var setupButtons = function (data, buttonSetIdx) {
         var $elem = data.$elem;
         var settings = data.settings;
-        var $buttonsDiv = $('<div class="buttons"></div>');
-        $elem.append($buttonsDiv);
         var mode = settings.interactionMode;
         var buttonSettings = settings.buttonSettings[mode];
         var buttonGroup = buttonSettings.buttonSets[buttonSetIdx];
+        if (buttonGroup == null) {
+            // no buttons here
+            return;
+        }
+        var $buttonsDiv = $('<div class="buttons"/>');
         var buttonNames = buttonSettings[buttonGroup];
         for (var i = 0; i < buttonNames.length; i++) {
             var buttonName = buttonNames[i];
@@ -777,15 +818,20 @@
                 }
             })());
             $img.attr('src', buttonSettings.imagePath + buttonConfig.img);
-            }
+        }
         // make buttons div scroll if too large for window
         if ($buttonsDiv.height() > $(window).height() - 10) {
             $buttonsDiv.css('position', 'absolute');
         }
         if (data.$buttonSets == null) {
+            // show first button set
+            $elem.append($buttonsDiv);
             data.$buttonSets = [$buttonsDiv];
             data.visibleButtonSets = 1;
         } else {
+            // hide later button sets
+            $buttonsDiv.hide();
+            $elem.append($buttonsDiv);
             data.$buttonSets[buttonSetIdx] = $buttonsDiv;
         }
         return $buttonsDiv;
@@ -1184,5 +1230,5 @@
             $.error( 'action ' + action + ' does not exist on jQuery.digilib' );
         }
     };
-
+    
 })(jQuery);
\ No newline at end of file