changeset 1045:6329b7f8d7f8

method for reassigning a button
author hertzhaft
date Fri, 23 Mar 2012 12:33:31 +0100
parents 2d04f160ce09
children b67f388df888
files webapp/src/main/webapp/jquery/jquery.digilib.buttons.js webapp/src/main/webapp/jquery/jquery.digilib.sliders.js
diffstat 2 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.buttons.js	Fri Mar 23 12:17:15 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.buttons.js	Fri Mar 23 12:33:31 2012 +0100
@@ -263,6 +263,7 @@
         // export functions
         fn.createButton = createButton;
         fn.highlightButtons = highlightButtons;
+        fn.setButtonAction = setButtonAction;
     };
 
     // plugin initialization
@@ -561,6 +562,17 @@
         highlight('zoomin', ! isFullArea(data.zoomArea));
         };
 
+    // set standard button "onclick" field to a new action
+    var setButtonAction = function(buttonName, action) {
+        var button = buttons[buttonName];
+        if (button == null) {
+            console.log('could not set button action ' + action 
+                + ', button ' + buttonName + ' not available' );
+            return;
+            }
+        button.onclick = action;
+    };
+
     // plugin object with name and init
     // shared objects filled by digilib on registration
     var plugin = {
--- a/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js	Fri Mar 23 12:17:15 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js	Fri Mar 23 12:33:31 2012 +0100
@@ -271,25 +271,16 @@
             });
     };
 
-
-    // set standard button "onclick" field to slider action
-    var setButtonAction = function(buttons, buttonName, action) {
-        var button = buttons[buttonName];
-        if (button == null) {
-            // normally this means that jquery.digilib.buttons.js was not loaded
-            console.log('could not attach slider action ' + action 
-                + ', button ' + buttonName + ' not available' );
+    // assign button actions to sliders (rotate, brightness, contrast) 
+    var setButtonActions = function () {
+        if (fn.setButtonAction == null) {
+            console.debug('sliders: could not assign button actions. Maybe jquery.digilib.buttons.js was not loaded?');
             return;
             }
-        button.onclick = action;
-    };
-
-    // set standard button actions (rotate, brightness, contrast) to slider
-    var setButtonActions = function (buttons) {
-        console.debug('sliders: setting button acions. digilib:', digilib);
-        setButtonAction(buttons, 'brgt', 'tinySliderBrgt');
-        setButtonAction(buttons, 'cont', 'tinySliderCont');
-        setButtonAction(buttons, 'rot', 'tinySliderRot');
+        console.debug('sliders: assign new button actions. digilib:', digilib);
+        fn.setButtonAction('brgt', 'tinySliderBrgt');
+        fn.setButtonAction('cont', 'tinySliderCont');
+        fn.setButtonAction('rot', 'tinySliderRot');
     };
 
     // plugin installation called by digilib on plugin object.