Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 690:7c8d5bfc5243 jquery
more or less buttons buttons - with animation :-)
author | robcast |
---|---|
date | Wed, 26 Jan 2011 23:25:41 +0100 |
parents | 97c01b911754 |
children | fe2bb8f926be |
comparison
equal
deleted
inserted
replaced
687:97c01b911754 | 690:7c8d5bfc5243 |
---|---|
151 scale : { | 151 scale : { |
152 onclick : "javascript:toggleScaleMenu()", | 152 onclick : "javascript:toggleScaleMenu()", |
153 tooltip : "change image scale", | 153 tooltip : "change image scale", |
154 img : "original-size.png" | 154 img : "original-size.png" |
155 }, | 155 }, |
156 options : { | 156 moreoptions : { |
157 onclick : "javascript:toggleOptionDiv()", | 157 onclick : ["morebuttons", "+1"], |
158 tooltip : "hide options", | 158 tooltip : "more options", |
159 img : "options.png" | |
160 }, | |
161 lessoptions : { | |
162 onclick : ["morebuttons", "-1"], | |
163 tooltip : "less options", | |
159 img : "options.png" | 164 img : "options.png" |
160 }, | 165 }, |
161 SEP : { | 166 SEP : { |
162 img : "sep.png" | 167 img : "sep.png" |
163 } | 168 } |
205 // defaults for digilib buttons | 210 // defaults for digilib buttons |
206 'buttonSettings' : { | 211 'buttonSettings' : { |
207 'fullscreen' : { | 212 'fullscreen' : { |
208 // path to button images (must end with a slash) | 213 // path to button images (must end with a slash) |
209 'imagePath' : 'img/fullscreen/', | 214 'imagePath' : 'img/fullscreen/', |
210 //'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"], | 215 //'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","calibrationx","scale","bird","help","options"], |
211 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","calibrationx","scale","bird","help","options"], | 216 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","moreoptions"], |
212 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], | 217 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","lessoptions"], |
213 'buttonSets' : ['standardSet', 'specialSet'] | 218 'buttonSets' : ['standardSet', 'specialSet'] |
214 }, | 219 }, |
215 'embedded' : { | 220 'embedded' : { |
216 'imagePath' : 'img/embedded/16/', | 221 'imagePath' : 'img/embedded/16/', |
217 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","scale","bird","help","options"], | 222 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","scale","bird","help","options"], |
437 if (factor == null) { | 442 if (factor == null) { |
438 factor = window.prompt("Contrast (-8, 8)", cont); | 443 factor = window.prompt("Contrast (-8, 8)", cont); |
439 } | 444 } |
440 data.settings.cont = factor; | 445 data.settings.cont = factor; |
441 redisplay(data); | 446 redisplay(data); |
447 }, | |
448 | |
449 // display more (or less) button sets | |
450 morebuttons : function (data, more) { | |
451 if (more === '-1') { | |
452 // remove set | |
453 var setIdx = data.visibleButtonSets - 1; | |
454 var $lastSet = data.$buttonSets[setIdx]; | |
455 if ($lastSet == null) return; | |
456 var btnWidth = $lastSet.width(); | |
457 // hide last set | |
458 $lastSet.hide(); | |
459 // take remaining sets and move right | |
460 var $otherSets = data.$elem.find('div.buttons:visible'); | |
461 $otherSets.animate({left : '+='+btnWidth+'px'}); | |
462 data.visibleButtonSets -= 1; | |
463 } else { | |
464 // add set | |
465 var $oldSets = data.$elem.find('div.buttons:visible'); | |
466 var setIdx = data.visibleButtonSets; | |
467 var $newSet; | |
468 if (data.$buttonSets[setIdx]) { | |
469 // set exists | |
470 $newSet = data.$buttonSets[setIdx]; | |
471 } else { | |
472 $newSet = setupButtons(data, setIdx); | |
473 } | |
474 if ($newSet == null) return; | |
475 var btnWidth = $newSet.width(); | |
476 // move remaining sets left and show new set | |
477 $oldSets.animate({left : '-='+btnWidth+'px'}, | |
478 function () {$newSet.show();}); | |
479 data.visibleButtonSets += 1; | |
480 } | |
442 } | 481 } |
443 }; | 482 }; |
444 | 483 |
445 // returns parameters from page url | 484 // returns parameters from page url |
446 var parseQueryParams = function() { | 485 var parseQueryParams = function() { |
693 | 732 |
694 // creates HTML structure for buttons in elem | 733 // creates HTML structure for buttons in elem |
695 var setupButtons = function (data, buttonSetIdx) { | 734 var setupButtons = function (data, buttonSetIdx) { |
696 var $elem = data.$elem; | 735 var $elem = data.$elem; |
697 var settings = data.settings; | 736 var settings = data.settings; |
698 var $buttonsDiv = $('<div class="buttons"></div>'); | |
699 $elem.append($buttonsDiv); | |
700 var mode = settings.interactionMode; | 737 var mode = settings.interactionMode; |
701 var buttonSettings = settings.buttonSettings[mode]; | 738 var buttonSettings = settings.buttonSettings[mode]; |
702 var buttonGroup = buttonSettings.buttonSets[buttonSetIdx]; | 739 var buttonGroup = buttonSettings.buttonSets[buttonSetIdx]; |
740 if (buttonGroup == null) { | |
741 // no buttons here | |
742 return; | |
743 } | |
744 var $buttonsDiv = $('<div class="buttons"/>'); | |
703 var buttonNames = buttonSettings[buttonGroup]; | 745 var buttonNames = buttonSettings[buttonGroup]; |
704 for (var i = 0; i < buttonNames.length; i++) { | 746 for (var i = 0; i < buttonNames.length; i++) { |
705 var buttonName = buttonNames[i]; | 747 var buttonName = buttonNames[i]; |
706 var buttonConfig = settings.buttons[buttonName]; | 748 var buttonConfig = settings.buttons[buttonName]; |
707 // construct the button html | 749 // construct the button html |
733 return false; | 775 return false; |
734 }; | 776 }; |
735 } | 777 } |
736 })()); | 778 })()); |
737 $img.attr('src', buttonSettings.imagePath + buttonConfig.img); | 779 $img.attr('src', buttonSettings.imagePath + buttonConfig.img); |
738 } | 780 } |
739 // make buttons div scroll if too large for window | 781 // make buttons div scroll if too large for window |
740 if ($buttonsDiv.height() > $(window).height() - 10) { | 782 if ($buttonsDiv.height() > $(window).height() - 10) { |
741 $buttonsDiv.css('position', 'absolute'); | 783 $buttonsDiv.css('position', 'absolute'); |
742 } | 784 } |
743 if (data.$buttonSets == null) { | 785 if (data.$buttonSets == null) { |
786 // show first button set | |
787 $elem.append($buttonsDiv); | |
744 data.$buttonSets = [$buttonsDiv]; | 788 data.$buttonSets = [$buttonsDiv]; |
745 data.visibleButtonSets = 1; | 789 data.visibleButtonSets = 1; |
746 } else { | 790 } else { |
791 // hide later button sets | |
792 $buttonsDiv.hide(); | |
793 $elem.append($buttonsDiv); | |
747 data.$buttonSets[buttonSetIdx] = $buttonsDiv; | 794 data.$buttonSets[buttonSetIdx] = $buttonsDiv; |
748 } | 795 } |
749 return $buttonsDiv; | 796 return $buttonsDiv; |
750 }; | 797 }; |
751 | 798 |