Mercurial > hg > digilib-old
comparison client/digitallibrary/jquery/jquery.digilib.js @ 610:cd9f657d49fa jquery
code for generating the buttons
author | hertzhaft |
---|---|
date | Fri, 14 Jan 2011 13:47:30 +0100 |
parents | 435f81210a33 |
children | 1b6202aba26e |
comparison
equal
deleted
inserted
replaced
609:435f81210a33 | 610:cd9f657d49fa |
---|---|
2 * digilib jQuery plugin | 2 * digilib jQuery plugin |
3 * | 3 * |
4 */ | 4 */ |
5 | 5 |
6 (function($) { | 6 (function($) { |
7 | 7 var buttons = { |
8 reference : { | |
9 onclick : "javascript:getRefWin()", | |
10 tooltip : "get a reference URL", | |
11 img : "reference.png" | |
12 }, | |
13 zoomin : { | |
14 onclick : "javascript:dl.zoomBy(1.4)", | |
15 tooltip : "zoom in", | |
16 img : "zoom-in.png" | |
17 }, | |
18 zoomout : { | |
19 onclick : "javascript:zoomBy(0.7)", | |
20 tooltip : "zoom out", | |
21 img : "zoom-out.png" | |
22 }, | |
23 zoomarea : { | |
24 onclick : "javascript:zoomArea()", | |
25 tooltip : "zoom area", | |
26 img : "zoom-area.png" | |
27 }, | |
28 zoomfull : { | |
29 onclick : "javascript:zoomFullpage()", | |
30 tooltip : "view the whole image", | |
31 img : "zoom-full.png" | |
32 }, | |
33 pagewidth : { | |
34 onclick : "javascript:zoomFullpage('width')", | |
35 tooltip : "page width", | |
36 img : "pagewidth.png" | |
37 }, | |
38 back : { | |
39 onclick : "javascript:gotoPage('-1')", | |
40 tooltip : "goto previous image", | |
41 img : "back.png" | |
42 }, | |
43 fwd : { | |
44 onclick : "javascript:gotoPage('+1')", | |
45 tooltip : "goto next image", | |
46 img : "fwd.png" | |
47 }, | |
48 page : { | |
49 onclick : "javascript:gotoPageWin()", | |
50 tooltip : "specify image", | |
51 img : "page.png" | |
52 }, | |
53 bird : { | |
54 onclick : "javascript:toggleBirdDiv()", | |
55 tooltip : "show bird's eye view", | |
56 img : "birds-eye.png" | |
57 }, | |
58 help : { | |
59 onclick : "javascript:toggleAboutDiv()", | |
60 tooltip : "about Digilib", | |
61 img : "help.png" | |
62 }, | |
63 reset : { | |
64 onclick : "javascript:resetImage()", | |
65 tooltip : "reset image", | |
66 img : "reset.png" | |
67 }, | |
68 mark : { | |
69 onclick : "javascript:setMark()", | |
70 tooltip : "set a mark", | |
71 img : "mark.png" | |
72 }, | |
73 delmark : { | |
74 onclick : "javascript:removeMark()", | |
75 tooltip : "delete the last mark", | |
76 img : "delmark.png" | |
77 }, | |
78 hmir : { | |
79 onclick : "javascript:mirror('h')", | |
80 tooltip : "mirror horizontally", | |
81 img : "mirror-horizontal.png" | |
82 }, | |
83 vmir : { | |
84 onclick : "javascript:mirror('v')", | |
85 tooltip : "mirror vertically", | |
86 img : "mirror-vertical.png" | |
87 }, | |
88 rot : { | |
89 onclick : "javascript:setParamWin('rot', 'Rotate (0..360) clockwise')", | |
90 tooltip : "rotate image", | |
91 img : "rotate.png" | |
92 }, | |
93 brgt : { | |
94 onclick : "javascript:setParamWin('brgt', 'Brightness (-255..255)')", | |
95 tooltip : "set brightness", | |
96 img : "brightness.png" | |
97 }, | |
98 cont : { | |
99 onclick : "javascript:setParamWin('cont', 'Contrast (0..8)')", | |
100 tooltip : "set contrast", | |
101 img : "contrast.png" | |
102 }, | |
103 rgb : { | |
104 onclick : "javascript:setParamWin('rgb', '...')", | |
105 tooltip : "set rgb values", | |
106 img : "rgb.png" | |
107 }, | |
108 quality : { | |
109 onclick : "javascript:setQualityWin('Quality (0..2)')", | |
110 tooltip : "set image quality", | |
111 img : "quality.png" | |
112 }, | |
113 size : { | |
114 onclick : "javascript:toggleSizeMenu()", | |
115 tooltip : "set page size", | |
116 img : "size.png" | |
117 }, | |
118 calibrationx : { | |
119 onclick : "javascript:calibrate('x')", | |
120 tooltip : "calibrate screen x-ratio", | |
121 img : "calibration-x.png" | |
122 }, | |
123 scale : { | |
124 onclick : "javascript:toggleScaleMenu()", | |
125 tooltip : "change image scale", | |
126 img : "original-size.png" | |
127 }, | |
128 options : { | |
129 onclick : "javascript:toggleOptionDiv()", | |
130 tooltip : "hide options", | |
131 img : "options.png" | |
132 }, | |
133 SEP : { | |
134 img : "sep.png" | |
135 } | |
136 }; | |
137 | |
8 var defaults = { | 138 var defaults = { |
9 // base URL to Scaler servlet | 139 // base URL to Scaler servlet |
10 'scalerBaseUrl' : 'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler', | 140 'scalerBaseUrl' : 'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler', |
11 // list of Scaler parameters | 141 // list of Scaler parameters |
12 'scalerParamNames' : ['fn','pn','dw','dh','ww','wh','wx','wy','ws','mo', | 142 'scalerParamNames' : ['fn','pn','dw','dh','ww','wh','wx','wy','ws','mo', |
13 'rot','cont','brgt','rgbm','rgba','ddpi','ddpix','ddpiy'], | 143 'rot','cont','brgt','rgbm','rgba','ddpi','ddpix','ddpiy'], |
14 // mode of operation. | 144 // mode of operation. |
15 // fullscreen: takes parameters from page URL, keeps state in page URL | 145 // fullscreen: takes parameters from page URL, keeps state in page URL |
16 // embedded: takes parameters from Javascript options, keeps state inside object | 146 // embedded: takes parameters from Javascript options, keeps state inside object |
17 'interactionMode' : 'fullscreen' | 147 'interactionMode' : 'fullscreen', |
18 }; | 148 // buttons |
149 'buttons' : buttons, | |
150 // path to button images | |
151 'buttonsImagePath' : 'img/buttons/', | |
152 // button groups | |
153 'buttonsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"], | |
154 'buttonsSpecial' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"], | |
155 'buttonsCustom' : [], | |
156 }; | |
19 | 157 |
20 // parameters from the query string | 158 // parameters from the query string |
21 var queryParams = {}; | 159 var queryParams = {}; |
22 | 160 |
23 // affine geometry classes | 161 // affine geometry classes |
149 $elem.append($scaler); | 287 $elem.append($scaler); |
150 //$img.load(scalerImgLoaded); | 288 //$img.load(scalerImgLoaded); |
151 } | 289 } |
152 }; | 290 }; |
153 | 291 |
292 // creates HTML structure for buttons in elem | |
293 var setupButtons = function ($elem, settings, buttonGroup) { | |
294 var $buttonDiv; | |
295 if (settings.interactionMode === 'fullscreen') { | |
296 // fullscreen -- create new | |
297 $buttonDiv = $elem.append('<div class="buttons"/>'); | |
298 var buttonNames = settings[buttonGroup]; | |
299 for (var i = 0; i < buttonNames.length; i++) { | |
300 var buttonName = buttonNames[i]; | |
301 var buttonConfig = settings.buttons[buttonName]; | |
302 var $button = buttondiv.append('<div class="button"/>'); | |
303 $button | |
304 .attr('id', 'digilib-button-' + buttonName) | |
305 .bind('click', function(){ buttonConfig.onclick }) | |
306 .append('<a/>') | |
307 .attr('title', buttonConfig.toolTip ) | |
308 .append('<img class="button"/>') | |
309 .attr('src', settings.buttonsImagePath + buttonConfig.img); | |
310 }; | |
311 } | |
312 return $buttonDiv; | |
313 } | |
314 }; | |
315 | |
154 // hook plugin into jquery | 316 // hook plugin into jquery |
155 $.fn.digilib = function(method) { | 317 $.fn.digilib = function(method) { |
156 if (methods[method]) { | 318 if (methods[method]) { |
157 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | 319 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); |
158 } else if (typeof(method) === 'object' || !method) { | 320 } else if (typeof(method) === 'object' || !method) { |