Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 665:3de056c96bcf jquery
small buttons for embedded mode
author | hertzhaft |
---|---|
date | Mon, 24 Jan 2011 00:43:00 +0100 |
parents | d5a5ee4cbf04 |
children | ad4a2edcbdbc |
comparison
equal
deleted
inserted
replaced
664:d5a5ee4cbf04 | 665:3de056c96bcf |
---|---|
181 // fullscreen = take parameters from page URL, keep state in page URL | 181 // fullscreen = take parameters from page URL, keep state in page URL |
182 // embedded = take parameters from Javascript options, keep state inside object | 182 // embedded = take parameters from Javascript options, keep state inside object |
183 'interactionMode' : 'fullscreen', | 183 'interactionMode' : 'fullscreen', |
184 // buttons | 184 // buttons |
185 'buttons' : buttons, | 185 'buttons' : buttons, |
186 'buttonSettings' : { | |
186 // path to button images (must end with a slash) | 187 // path to button images (must end with a slash) |
187 'buttonsImagePath' : '../greyskin/', | 188 'fullscreen' : { |
189 'imagePath' : 'img/fullscreen/', | |
190 //'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"], | |
191 '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"], | |
192 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], | |
193 'customSet' : [] | |
194 }, | |
195 'embedded' : { | |
196 'imagePath' : 'img/embedded/16/', | |
197 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","scale","bird","help","options"], | |
198 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], | |
199 'customSet' : [] | |
200 } | |
201 }, | |
188 // button groups | 202 // button groups |
189 //'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"], | |
190 'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","mark","delmark","hmir","vmir","back","fwd","page","rot","brgt","cont","rgb","quality","size","calibrationx","scale","bird","help","options"], | |
191 'buttonsSpecial' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], | |
192 'buttonsCustom' : [], | |
193 // is birdView shown? | 203 // is birdView shown? |
194 'isBirdDivVisible' : false, | 204 'isBirdDivVisible' : false, |
195 // dimensions of bird's eye window | 205 // dimensions of bird's eye window |
196 'birdDivOptions' : {'dw' : 200, 'dh' : 200}, | 206 'birdDivOptions' : {'dw' : 200, 'dh' : 200}, |
197 // style of bird's eye window | 207 // style of bird's eye window |
251 $elem.data('digilib', data); | 261 $elem.data('digilib', data); |
252 } | 262 } |
253 unpackParams(data); | 263 unpackParams(data); |
254 // create HTML structure | 264 // create HTML structure |
255 setupScalerDiv(data); | 265 setupScalerDiv(data); |
256 setupButtons(data, 'buttonsStandard'); | 266 setupButtons(data, 'standardSet'); |
257 // bird's eye view creation | 267 // bird's eye view creation |
258 if (elemSettings.isBirdDivVisible) { | 268 if (elemSettings.isBirdDivVisible) { |
259 setupBirdDiv(data); | 269 setupBirdDiv(data); |
260 } | 270 } |
261 // about window creation - TODO: could be deferred? restrict to only one item? | 271 // about window creation - TODO: could be deferred? restrict to only one item? |
467 var getScalerUrl = function (data) { | 477 var getScalerUrl = function (data) { |
468 var settings = data.settings; | 478 var settings = data.settings; |
469 if (settings.scalerBaseUrl == null) { | 479 if (settings.scalerBaseUrl == null) { |
470 alert("ERROR: URL of digilib Scaler servlet missing!"); | 480 alert("ERROR: URL of digilib Scaler servlet missing!"); |
471 } | 481 } |
482 packParams(data); | |
472 var keys = settings.scalerParamNames; | 483 var keys = settings.scalerParamNames; |
473 var queryString = getParamString(settings, keys, defaults); | 484 var queryString = getParamString(settings, keys, defaults); |
474 var url = settings.scalerBaseUrl + '?' + queryString; | 485 var url = settings.scalerBaseUrl + '?' + queryString; |
475 return url; | 486 return url; |
476 }; | 487 }; |
654 | 665 |
655 // creates HTML structure for buttons in elem | 666 // creates HTML structure for buttons in elem |
656 var setupButtons = function (data, actionGroup) { | 667 var setupButtons = function (data, actionGroup) { |
657 var $elem = data.$elem; | 668 var $elem = data.$elem; |
658 var settings = data.settings; | 669 var settings = data.settings; |
659 if (settings.interactionMode === 'fullscreen') { | 670 // if (settings.interactionMode === 'fullscreen') { |
660 // fullscreen -- create new | 671 var $buttonsDiv = $('<div class="buttons"></div>'); |
661 var $buttonsDiv = $('<div class="buttons"></div>'); | 672 $elem.append($buttonsDiv); |
662 $elem.append($buttonsDiv); | 673 var mode = settings.interactionMode; |
663 var actionNames = settings[actionGroup]; | 674 var buttonSettings = settings.buttonSettings[mode] |
664 for (var i = 0; i < actionNames.length; i++) { | 675 var actionNames = buttonSettings[actionGroup]; |
665 var actionName = actionNames[i]; | 676 for (var i = 0; i < actionNames.length; i++) { |
666 var buttonSettings = settings.buttons[actionName]; | 677 var actionName = actionNames[i]; |
667 // construct the button html | 678 var buttonConfig = settings.buttons[actionName]; |
668 var $button = $('<div class="button"></div>'); | 679 // construct the button html |
669 var $a = $('<a/>'); | 680 var $button = $('<div class="button"></div>'); |
670 var $img = $('<img class="button"/>'); | 681 var $a = $('<a/>'); |
671 $buttonsDiv.append($button); | 682 var $img = $('<img class="button"/>'); |
672 $button.append($a); | 683 $buttonsDiv.append($button); |
673 $a.append($img); | 684 $button.append($a); |
674 // add attributes and bindings | 685 $a.append($img); |
675 $button.attr('title', buttonSettings.tooltip); | 686 // add attributes and bindings |
676 $button.addClass('button-' + actionName); | 687 $button.attr('title', buttonConfig.tooltip); |
677 // create handler for the buttons | 688 $button.addClass('button-' + actionName); |
678 $a.bind('click.digilib', (function () { | 689 // create handler for the buttons |
679 // we create a new closure to capture the value of action | 690 $a.bind('click.digilib', (function () { |
680 var action = buttonSettings.onclick; | 691 // we create a new closure to capture the value of action |
681 if ($.isArray(action)) { | 692 var action = buttonConfig.onclick; |
682 // the handler function calls digilib with action and parameters | 693 if ($.isArray(action)) { |
683 return function (evt) { | 694 // the handler function calls digilib with action and parameters |
684 console.debug('click action=', action, ' evt=', evt); | 695 return function (evt) { |
685 $elem.digilib.apply($elem, action); | 696 console.debug('click action=', action, ' evt=', evt); |
686 return false; | 697 $elem.digilib.apply($elem, action); |
687 }; | 698 return false; |
688 } else { | 699 }; |
689 // the handler function calls digilib with action | 700 } else { |
690 return function (evt) { | 701 // the handler function calls digilib with action |
691 console.debug('click action=', action, ' evt=', evt); | 702 return function (evt) { |
692 $elem.digilib(action); | 703 console.debug('click action=', action, ' evt=', evt); |
693 return false; | 704 $elem.digilib(action); |
694 }; | 705 return false; |
695 } | 706 }; |
696 })()); | 707 } |
697 $img.attr('src', settings.buttonsImagePath + buttonSettings.img); | 708 })()); |
698 } | 709 $img.attr('src', buttonSettings.imagePath + buttonConfig.img); |
699 } | 710 } |
700 // make buttons div scroll if too large for window | 711 // make buttons div scroll if too large for window |
701 if ($buttonsDiv.height() > $(window).height() - 10) { | 712 if ($buttonsDiv.height() > $(window).height() - 10) { |
702 $buttonsDiv.css('position', 'absolute'); | 713 $buttonsDiv.css('position', 'absolute'); |
703 } | 714 } |
704 return $buttonsDiv; | 715 return $buttonsDiv; |