Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 778:f8235c42f4a0 jquery
more preparations for SVG measuring tool
author | hertzhaft |
---|---|
date | Sun, 13 Feb 2011 01:12:45 +0100 |
parents | 34bba748004d |
children | 62c3b902f878 |
comparison
equal
deleted
inserted
replaced
777:34bba748004d | 778:f8235c42f4a0 |
---|---|
245 // parameters used by bird's eye div | 245 // parameters used by bird's eye div |
246 'birdDivParams' : ['fn','pn','dw','dh'], | 246 'birdDivParams' : ['fn','pn','dw','dh'], |
247 // is the "about" window shown? | 247 // is the "about" window shown? |
248 'isAboutDivVisible' : false, | 248 'isAboutDivVisible' : false, |
249 // maximum width of background image for drag-scroll | 249 // maximum width of background image for drag-scroll |
250 'maxBgSize' : 10000 | 250 'maxBgSize' : 10000, |
251 | 251 // space to be left free in full page display |
252 'scalerInset' : 0, | |
252 }; | 253 }; |
253 | 254 |
254 // affine geometry classes | 255 // affine geometry classes |
255 var geom = dlGeometry(); | 256 var geom = dlGeometry(); |
256 | 257 |
903 } | 904 } |
904 // TODO: update event subscriber? | 905 // TODO: update event subscriber? |
905 }; | 906 }; |
906 | 907 |
907 // returns maximum size for scaler img in fullscreen mode | 908 // returns maximum size for scaler img in fullscreen mode |
908 var getFullscreenImgSize = function ($elem) { | 909 var getFullscreenImgSize = function (data) { |
909 var $win = $(window); | 910 var $win = $(window); |
910 var winH = $win.height(); | 911 var winH = $win.height(); |
911 var winW = $win.width(); | 912 var winW = $win.width() - data.settings.scalerInset; |
912 // TODO: account for borders? | 913 // TODO: account for borders? |
914 console.debug(winW, winH); | |
913 return geom.size(winW, winH); | 915 return geom.size(winW, winH); |
914 }; | 916 }; |
915 | 917 |
916 // creates HTML structure for digilib in elem | 918 // creates HTML structure for digilib in elem |
917 var setupScalerDiv = function (data) { | 919 var setupScalerDiv = function (data) { |
921 var $img; | 923 var $img; |
922 var scalerUrl; | 924 var scalerUrl; |
923 if (settings.interactionMode === 'fullscreen') { | 925 if (settings.interactionMode === 'fullscreen') { |
924 // fullscreen | 926 // fullscreen |
925 $elem.addClass('dl_fullscreen'); | 927 $elem.addClass('dl_fullscreen'); |
926 var imgSize = getFullscreenImgSize($elem); | 928 var imgSize = getFullscreenImgSize(data); |
927 // fitwidth/height omits destination height/width | 929 // fitwidth/height omits destination height/width |
928 if (data.dlOpts.fitheight == null) { | 930 if (data.dlOpts.fitheight == null) { |
929 settings.dw = imgSize.width; | 931 settings.dw = imgSize.width; |
930 } | 932 } |
931 if (data.dlOpts.fitwidth == null) { | 933 if (data.dlOpts.fitwidth == null) { |
1735 console.debug = logFunction('_debug'); | 1737 console.debug = logFunction('_debug'); |
1736 console.error = logFunction('_error'); | 1738 console.error = logFunction('_error'); |
1737 } | 1739 } |
1738 | 1740 |
1739 // hook plugin into jquery | 1741 // hook plugin into jquery |
1740 $.fn.digilib = function(action, obj) { | 1742 $.fn.digilib = function(action) { |
1741 // plugin extension mechanism | 1743 // plugin extension mechanism |
1742 if (action === 'extendPlugin') { | 1744 if (action === 'extendPlugin') { |
1743 // for each digilib $elem extend data.settings with obj.options | 1745 // for each digilib $elem extend data.settings with obj.options |
1746 // TODO: couldn't other plugins just access $elem.data('digilib')? | |
1744 if (obj.options) { | 1747 if (obj.options) { |
1745 this.each(function() { | 1748 this.each(function() { |
1746 var $elem = $(this); | 1749 var $elem = $(this); |
1747 // console.debug('extending:', $elem); | 1750 // console.debug('extending:', $elem); |
1748 var data = $elem.data('digilib'); | 1751 var data = $elem.data('digilib'); |
1751 } | 1754 } |
1752 var settings = data.settings; | 1755 var settings = data.settings; |
1753 $.extend(settings, obj.options); | 1756 $.extend(settings, obj.options); |
1754 // console.log('settings:', settings); | 1757 // console.log('settings:', settings); |
1755 }); | 1758 }); |
1756 } | 1759 delete(obj.options); |
1757 delete(obj.options); | 1760 } |
1758 // extend the plugin actions (to make this useful, | 1761 // extend the plugin actions (to make this useful, |
1759 // maybe we need to expose some more internal functions) | 1762 // maybe we need to expose some more internal functions) |
1760 $.extend(actions, obj); | 1763 $.extend(actions, obj); |
1761 } else if (actions[action]) { | 1764 } else if (actions[action]) { |
1762 // call action on this with the remaining arguments (inserting data as first argument) | 1765 // call action on this with the remaining arguments (inserting data as first argument) |