Mercurial > hg > digilib-old
annotate webapp/src/main/webapp/jquery/jquery.digilib.arrows.js @ 994:8be56a27db58
fixed problem when using arrows.js without buttons.js.
handling of settings.buttons reference still not perfect.
| author | robcast |
|---|---|
| date | Thu, 09 Feb 2012 17:54:59 +0100 |
| parents | 2feb71b40e10 |
| children | 0b63093d598e |
| rev | line source |
|---|---|
| 983 | 1 /** |
| 2 * digilib pan arrows for scrolling the zoomed area. | |
| 3 */ | |
| 4 | |
| 5 (function($) { | |
| 6 | |
| 7 // affine geometry | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
8 var geom = null; |
| 983 | 9 // plugin object with digilib data |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
10 var digilib = null; |
| 983 | 11 |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
12 var FULL_AREA = null; |
| 983 | 13 |
| 14 var defaults = { | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
15 // arrow bars for moving the zoomed area |
| 983 | 16 'showZoomArrows' : true, |
| 17 // by what percentage should the arrows move the zoomed area? | |
| 18 'zoomArrowMoveFactor' : 0.5, | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
19 // defaults for digilib buttons |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
20 'buttonSettings' : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
21 'fullscreen' : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
22 // path to button images (must end with a slash) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
23 'imagePath' : 'img/fullscreen/', |
| 990 | 24 'arrowSetSize' : 18, |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
25 'arrowSet' : [ "up", "down", "left", "right" ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
26 }, |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
27 'embedded' : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
28 'imagePath' : 'img/embedded/16/', |
| 990 | 29 'arrowSetSize' : 9, |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
30 'arrowSet' : [ "up", "down", "left", "right" ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
31 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
32 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
33 }; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
34 |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
35 var buttons = { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
36 up : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
37 onclick : [ "moveZoomArea", 0, -1 ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
38 tooltip : "move zoom area up", |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
39 icon : "up.png" |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
40 }, |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
41 down : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
42 onclick : [ "moveZoomArea", 0, 1 ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
43 tooltip : "move zoom area down", |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
44 icon : "down.png" |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
45 }, |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
46 left : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
47 onclick : [ "moveZoomArea", -1, 0 ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
48 tooltip : "move zoom area left", |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
49 icon : "left.png" |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
50 }, |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
51 right : { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
52 onclick : [ "moveZoomArea", 1, 0 ], |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
53 tooltip : "move zoom area right", |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
54 icon : "right.png" |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
55 } |
| 983 | 56 }; |
| 57 | |
| 58 var actions = { | |
| 59 /** | |
| 60 * move zoomed area | |
| 61 * | |
| 62 * @param data | |
| 63 * @param dx | |
| 64 * @param dy | |
| 65 */ | |
| 66 moveZoomArea : function(data, dx, dy) { | |
| 67 var za = data.zoomArea.copy(); | |
| 68 var factor = data.settings.zoomArrowMoveFactor; | |
| 69 var deltaX = dx * factor * za.width; | |
| 70 var deltaY = dy * factor * za.height; | |
| 71 var delta = geom.position(deltaX, deltaY); | |
| 72 za.addPosition(delta); | |
| 73 za = FULL_AREA.fit(za); | |
| 74 digilib.fn.setZoomArea(data, za); | |
| 75 digilib.fn.redisplay(data); | |
| 76 } | |
| 77 | |
| 78 }; | |
| 79 | |
| 80 // plugin installation called by digilib on plugin object. | |
| 81 var install = function(plugin) { | |
| 82 digilib = plugin; | |
| 83 console.debug('installing arrows plugin. digilib:', digilib); | |
| 84 // import geometry classes | |
| 85 geom = digilib.fn.geometry; | |
| 86 FULL_AREA = geom.rectangle(0, 0, 1, 1); | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
87 // add defaults, actions |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
88 $.extend(true, digilib.defaults, defaults); // make deep copy |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
89 $.extend(digilib.buttons, buttons); |
| 983 | 90 $.extend(digilib.actions, actions); |
|
994
8be56a27db58
fixed problem when using arrows.js without buttons.js.
robcast
parents:
990
diff
changeset
|
91 // update buttons reference in defaults |
|
8be56a27db58
fixed problem when using arrows.js without buttons.js.
robcast
parents:
990
diff
changeset
|
92 digilib.defaults.buttons = digilib.buttons; |
| 983 | 93 }; |
| 94 | |
| 95 // plugin initialization | |
| 96 var init = function(data) { | |
| 97 console.debug('initialising arrows plugin. data:', data); | |
| 98 var $data = $(data); | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
99 // adjust insets |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
100 data.currentInsets['arrows'] = getInsets(data); |
| 983 | 101 // install event handler |
| 102 $data.bind('setup', handleSetup); | |
| 103 $data.bind('update', handleUpdate); | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
104 // $data.bind('redisplay', handleRedisplay); |
| 983 | 105 }; |
| 106 | |
| 107 var handleSetup = function(evt) { | |
| 108 console.debug("arrows: handleSetup"); | |
| 109 var data = this; | |
| 110 setupZoomArrows(data); | |
| 111 }; | |
| 112 | |
| 113 var handleUpdate = function(evt) { | |
| 114 console.debug("arrows: handleUpdate"); | |
| 115 var data = this; | |
| 116 renderZoomArrows(data); | |
| 117 }; | |
| 118 | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
119 |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
120 /** |
| 990 | 121 * returns insets for arrows (based on canMove and arrowSetSize |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
122 */ |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
123 var getInsets = function(data) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
124 var settings = data.settings; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
125 var insets = { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
126 'x' : 0, |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
127 'y' : 0 |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
128 }; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
129 if (settings.showZoomArrows) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
130 var mode = settings.interactionMode; |
| 990 | 131 var bw = settings.buttonSettings[mode].arrowSetSize; |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
132 if (digilib.fn.canMove(data, 0, -1)) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
133 insets.y += bw; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
134 if (digilib.fn.canMove(data, 0, 1)) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
135 insets.y += bw; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
136 if (digilib.fn.canMove(data, -1, 0)) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
137 insets.x += bw; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
138 if (digilib.fn.canMove(data, 1, 0)) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
139 insets.x += bw; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
140 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
141 return insets; |
| 983 | 142 }; |
| 143 | |
| 144 /** | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
145 * creates HTML structure for a single button |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
146 */ |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
147 var createButton = function(data, $div, buttonName, show) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
148 var $elem = data.$elem; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
149 var settings = data.settings; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
150 var mode = settings.interactionMode; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
151 var imagePath = settings.buttonSettings[mode].imagePath; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
152 // make relative imagePath absolute |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
153 if (imagePath.charAt(0) !== '/' && imagePath.substring(0, 3) !== 'http') { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
154 imagePath = settings.digilibBaseUrl + '/jquery/' + imagePath; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
155 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
156 var buttonConfig = settings.buttons[buttonName]; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
157 // button properties |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
158 var action = buttonConfig.onclick; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
159 var tooltip = buttonConfig.tooltip; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
160 var icon = imagePath + buttonConfig.icon; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
161 // construct the button html |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
162 var $button = $('<div class="keep"><a href=""><img class="button" src="' + icon + '"/></a></div>'); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
163 if (!show) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
164 $button.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
165 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
166 $div.append($button); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
167 // add attributes and bindings |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
168 $button.attr('title', tooltip); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
169 $button.addClass('arrow-' + buttonName); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
170 // create handler for the buttons on the div (necessary for horizontal |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
171 // scroll arrows) |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
172 $div.on('click.digilib', function(evt) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
173 // the handler function calls digilib with action and parameters |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
174 console.debug('click action=', action, ' evt=', evt); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
175 $elem.digilib.apply($elem, action); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
176 return false; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
177 }); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
178 return $button; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
179 }; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
180 |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
181 /** |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
182 * create arrows for moving the zoomed area. |
| 983 | 183 */ |
| 184 var setupZoomArrows = function(data) { | |
| 185 var $elem = data.$elem; | |
| 186 var settings = data.settings; | |
| 187 var show = settings.showZoomArrows; | |
| 188 console.log('zoom arrows:', show); | |
| 189 if (!show) | |
| 190 return; | |
| 191 var mode = settings.interactionMode; | |
| 192 var arrowNames = settings.buttonSettings[mode].arrowSet; | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
193 if (arrowNames == null) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
194 console.error("No buttons for scroll arrows!"); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
195 settings.showZoomArrows = false; |
| 983 | 196 return; |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
197 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
198 // wrap scaler img in table |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
199 data.$scaler.wrap('<table class="scalertable"><tbody><tr class="midrow"><td/></tr></tbody></table>'); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
200 // middle row with img has three elements |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
201 data.$scaler.parent().before('<td class="arrow left" valign="middle"/>').after('<td class="arrow right" valign="middle"/>'); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
202 // first and last row has only one |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
203 var $table = $elem.find('table.scalertable'); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
204 $table.find('tr.midrow').before('<tr class="firstrow"><td colspan="3" class="arrow up" align="center"/></tr>').after( |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
205 '<tr class="lasttrow"><td colspan="3" class="arrow down" align="center"/></tr>'); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
206 // add arrow buttons |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
207 var ar = {}; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
208 ar.$up = createButton(data, $table.find('td.up'), 'up', digilib.fn.canMove(data, 0, -1)); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
209 ar.$down = createButton(data, $table.find('td.down'), 'down', digilib.fn.canMove(data, 0, 1)); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
210 ar.$left = createButton(data, $table.find('td.left'), 'left', digilib.fn.canMove(data, -1, 0)); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
211 ar.$right = createButton(data, $table.find('td.right'), 'right', digilib.fn.canMove(data, 1, 0)); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
212 data.arrows = ar; |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
213 |
| 983 | 214 }; |
| 215 | |
| 216 /** | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
217 * show or hide arrows, called after scaler img is loaded. |
| 983 | 218 * |
| 219 */ | |
| 220 var renderZoomArrows = function(data) { | |
| 221 var settings = data.settings; | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
222 var arrows = data.arrows; |
| 983 | 223 if (digilib.fn.isFullArea(data.zoomArea) || !settings.showZoomArrows) { |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
224 arrows.$up.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
225 arrows.$down.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
226 arrows.$left.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
227 arrows.$right.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
228 data.currentInsets['arrows'] = {'x' : 0, 'y' : 0}; |
| 983 | 229 return; |
| 230 } | |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
231 if (digilib.fn.canMove(data, 0, -1)) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
232 arrows.$up.show(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
233 } else { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
234 arrows.$up.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
235 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
236 if (digilib.fn.canMove(data, 0, 1)) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
237 arrows.$down.show(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
238 } else { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
239 arrows.$down.hide(); |
| 983 | 240 } |
|
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
241 if (digilib.fn.canMove(data, -1, 0)) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
242 arrows.$left.show(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
243 } else { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
244 arrows.$left.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
245 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
246 if (digilib.fn.canMove(data, 1, 0)) { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
247 arrows.$right.show(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
248 } else { |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
249 arrows.$right.hide(); |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
250 } |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
251 // adjust insets |
|
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
252 data.currentInsets['arrows'] = getInsets(data); |
| 983 | 253 }; |
| 254 | |
| 255 // plugin object with name and init | |
| 256 // shared objects filled by digilib on registration | |
| 257 var plugin = { | |
| 258 name : 'arrows', | |
| 259 install : install, | |
| 260 init : init, | |
| 261 buttons : {}, | |
| 262 actions : {}, | |
| 263 fn : {}, | |
| 264 plugins : {} | |
| 265 }; | |
| 266 | |
| 267 if ($.fn.digilib == null) { | |
| 268 $.error("jquery.digilib.arrows must be loaded after jquery.digilib!"); | |
| 269 } else { | |
| 270 $.fn.digilib('plugin', plugin); | |
| 271 } | |
| 272 })(jQuery); |
