Mercurial > hg > digilib-old
annotate webapp/src/main/webapp/jquery/jquery.digilib.arrows.js @ 1000:f7bfc40bffea
IE still doesn't like commas
author | hertzhaft |
---|---|
date | Mon, 13 Feb 2012 15:30:06 +0100 |
parents | 0b63093d598e |
children | 1e4f4964e9c2 |
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, |
1000 | 25 'arrowSet' : [ "up", "down", "left", "right" ] |
989
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, |
1000 | 30 'arrowSet' : [ "up", "down", "left", "right" ] |
989
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; |
996 | 151 var cssPrefix = settings.cssPrefix; |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
152 var imagePath = settings.buttonSettings[mode].imagePath; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
153 // make relative imagePath absolute |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
154 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
|
155 imagePath = settings.digilibBaseUrl + '/jquery/' + imagePath; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
156 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
157 var buttonConfig = settings.buttons[buttonName]; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
158 // button properties |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
159 var action = buttonConfig.onclick; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
160 var tooltip = buttonConfig.tooltip; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
161 var icon = imagePath + buttonConfig.icon; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
162 // construct the button html |
996 | 163 var $button = $('<div class="'+cssPrefix+'keep"><a href=""><img class="'+cssPrefix+'button" src="' + icon + '"/></a></div>'); |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
164 if (!show) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
165 $button.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
166 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
167 $div.append($button); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
168 // add attributes and bindings |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
169 $button.attr('title', tooltip); |
996 | 170 $button.addClass(cssPrefix+'arrow-' + buttonName); |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
171 // 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
|
172 // scroll arrows) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
173 $div.on('click.digilib', function(evt) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
174 // 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
|
175 console.debug('click action=', action, ' evt=', evt); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
176 $elem.digilib.apply($elem, action); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
177 return false; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
178 }); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
179 return $button; |
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 /** |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
183 * create arrows for moving the zoomed area. |
983 | 184 */ |
185 var setupZoomArrows = function(data) { | |
186 var $elem = data.$elem; | |
187 var settings = data.settings; | |
996 | 188 var cssPrefix = settings.cssPrefix; |
983 | 189 var show = settings.showZoomArrows; |
190 console.log('zoom arrows:', show); | |
191 if (!show) | |
192 return; | |
193 var mode = settings.interactionMode; | |
194 var arrowNames = settings.buttonSettings[mode].arrowSet; | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
195 if (arrowNames == null) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
196 console.error("No buttons for scroll arrows!"); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
197 settings.showZoomArrows = false; |
983 | 198 return; |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
199 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
200 // wrap scaler img in table |
996 | 201 data.$scaler.wrap('<table class="'+cssPrefix+'scalertable"><tbody><tr class="'+cssPrefix+'midrow"><td/></tr></tbody></table>'); |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
202 // middle row with img has three elements |
996 | 203 data.$scaler.parent().before('<td class="'+cssPrefix+'arrow '+cssPrefix+'left" valign="middle"/>') |
204 .after('<td class="'+cssPrefix+'arrow '+cssPrefix+'right" valign="middle"/>'); | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
205 // first and last row has only one |
996 | 206 var $table = $elem.find('table.'+cssPrefix+'scalertable'); |
207 $table.find('tr.'+cssPrefix+'midrow') | |
208 .before('<tr class="'+cssPrefix+'firstrow"><td colspan="3" class="'+cssPrefix+'arrow '+cssPrefix+'up" align="center"/></tr>') | |
209 .after('<tr class="'+cssPrefix+'lasttrow"><td colspan="3" class="'+cssPrefix+'arrow '+cssPrefix+'down" align="center"/></tr>'); | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
210 // add arrow buttons |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
211 var ar = {}; |
996 | 212 ar.$up = createButton(data, $table.find('td.'+cssPrefix+'up'), 'up', digilib.fn.canMove(data, 0, -1)); |
213 ar.$down = createButton(data, $table.find('td.'+cssPrefix+'down'), 'down', digilib.fn.canMove(data, 0, 1)); | |
214 ar.$left = createButton(data, $table.find('td.'+cssPrefix+'left'), 'left', digilib.fn.canMove(data, -1, 0)); | |
215 ar.$right = createButton(data, $table.find('td.'+cssPrefix+'right'), 'right', digilib.fn.canMove(data, 1, 0)); | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
216 data.arrows = ar; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
217 |
983 | 218 }; |
219 | |
220 /** | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
221 * show or hide arrows, called after scaler img is loaded. |
983 | 222 * |
223 */ | |
224 var renderZoomArrows = function(data) { | |
225 var settings = data.settings; | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
226 var arrows = data.arrows; |
983 | 227 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
|
228 arrows.$up.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
229 arrows.$down.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
230 arrows.$left.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
231 arrows.$right.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
232 data.currentInsets['arrows'] = {'x' : 0, 'y' : 0}; |
983 | 233 return; |
234 } | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
235 if (digilib.fn.canMove(data, 0, -1)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
236 arrows.$up.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
237 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
238 arrows.$up.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
239 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
240 if (digilib.fn.canMove(data, 0, 1)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
241 arrows.$down.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
242 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
243 arrows.$down.hide(); |
983 | 244 } |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
245 if (digilib.fn.canMove(data, -1, 0)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
246 arrows.$left.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
247 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
248 arrows.$left.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
249 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
250 if (digilib.fn.canMove(data, 1, 0)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
251 arrows.$right.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
252 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
253 arrows.$right.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
254 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
255 // adjust insets |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
256 data.currentInsets['arrows'] = getInsets(data); |
983 | 257 }; |
258 | |
259 // plugin object with name and init | |
260 // shared objects filled by digilib on registration | |
261 var plugin = { | |
262 name : 'arrows', | |
263 install : install, | |
264 init : init, | |
265 buttons : {}, | |
266 actions : {}, | |
267 fn : {}, | |
268 plugins : {} | |
269 }; | |
270 | |
271 if ($.fn.digilib == null) { | |
272 $.error("jquery.digilib.arrows must be loaded after jquery.digilib!"); | |
273 } else { | |
274 $.fn.digilib('plugin', plugin); | |
275 } | |
276 })(jQuery); |