Mercurial > hg > digilib-old
annotate webapp/src/main/webapp/jquery/jquery.digilib.arrows.js @ 1131:c1e7821d3c68
fix bug in path of arrow-images and problem with nested options.
author | robcast |
---|---|
date | Tue, 13 Nov 2012 17:35:32 +0100 |
parents | e1b29f51d224 |
children |
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, |
1075
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
17 // by what fraction should the arrows move the zoomed area? |
983 | 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) |
1131
c1e7821d3c68
fix bug in path of arrow-images and problem with nested options.
robcast
parents:
1087
diff
changeset
|
23 'imagePath' : 'img/fullscreen/32/', |
1087 | 24 'arrowSetSize' : 16, |
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/', |
1087 | 29 'arrowSetSize' : 8, |
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; | |
1075
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
69 // rotate and mirror change direction of cooordinate system |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
70 var trafo = data.imgTrafo; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
71 var tdx = (trafo.m00 > 0) ? dx : -dx; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
72 var tdy = (trafo.m11 > 0) ? dy : -dy; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
73 if (Math.abs(trafo.m00) < Math.abs(trafo.m01)) { |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
74 tdx = (trafo.m01 > 0) ? -dy : dy; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
75 tdy = (trafo.m10 > 0) ? -dx : dx; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
76 } |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
77 var deltaX = tdx * factor * za.width; |
1e4f4964e9c2
CLOSED - # 25: scroll arrows have wrong direction with mirror and rot
robcast
parents:
1000
diff
changeset
|
78 var deltaY = tdy * factor * za.height; |
983 | 79 var delta = geom.position(deltaX, deltaY); |
80 za.addPosition(delta); | |
81 za = FULL_AREA.fit(za); | |
82 digilib.fn.setZoomArea(data, za); | |
83 digilib.fn.redisplay(data); | |
84 } | |
85 | |
86 }; | |
87 | |
88 // plugin installation called by digilib on plugin object. | |
89 var install = function(plugin) { | |
90 digilib = plugin; | |
91 console.debug('installing arrows plugin. digilib:', digilib); | |
92 // import geometry classes | |
93 geom = digilib.fn.geometry; | |
94 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
|
95 // add defaults, actions |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
96 $.extend(true, digilib.defaults, defaults); // make deep copy |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
97 $.extend(digilib.buttons, buttons); |
983 | 98 $.extend(digilib.actions, actions); |
994
8be56a27db58
fixed problem when using arrows.js without buttons.js.
robcast
parents:
990
diff
changeset
|
99 // update buttons reference in defaults |
8be56a27db58
fixed problem when using arrows.js without buttons.js.
robcast
parents:
990
diff
changeset
|
100 digilib.defaults.buttons = digilib.buttons; |
983 | 101 }; |
102 | |
103 // plugin initialization | |
104 var init = function(data) { | |
105 console.debug('initialising arrows plugin. data:', data); | |
106 var $data = $(data); | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
107 // adjust insets |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
108 data.currentInsets['arrows'] = getInsets(data); |
983 | 109 // install event handler |
110 $data.bind('setup', handleSetup); | |
111 $data.bind('update', handleUpdate); | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
112 // $data.bind('redisplay', handleRedisplay); |
983 | 113 }; |
114 | |
115 var handleSetup = function(evt) { | |
116 console.debug("arrows: handleSetup"); | |
117 var data = this; | |
118 setupZoomArrows(data); | |
119 }; | |
120 | |
121 var handleUpdate = function(evt) { | |
122 console.debug("arrows: handleUpdate"); | |
123 var data = this; | |
124 renderZoomArrows(data); | |
125 }; | |
126 | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
127 |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
128 /** |
990 | 129 * 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
|
130 */ |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
131 var getInsets = function(data) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
132 var settings = data.settings; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
133 var insets = { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
134 'x' : 0, |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
135 'y' : 0 |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
136 }; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
137 if (settings.showZoomArrows) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
138 var mode = settings.interactionMode; |
990 | 139 var bw = settings.buttonSettings[mode].arrowSetSize; |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
140 if (digilib.fn.canMove(data, 0, -1)) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
141 insets.y += bw; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
142 if (digilib.fn.canMove(data, 0, 1)) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
143 insets.y += bw; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
144 if (digilib.fn.canMove(data, -1, 0)) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
145 insets.x += bw; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
146 if (digilib.fn.canMove(data, 1, 0)) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
147 insets.x += bw; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
148 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
149 return insets; |
983 | 150 }; |
151 | |
152 /** | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
153 * creates HTML structure for a single button |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
154 */ |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
155 var createButton = function(data, $div, buttonName, show) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
156 var $elem = data.$elem; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
157 var settings = data.settings; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
158 var mode = settings.interactionMode; |
996 | 159 var cssPrefix = settings.cssPrefix; |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
160 var imagePath = settings.buttonSettings[mode].imagePath; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
161 // make relative imagePath absolute |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
162 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
|
163 imagePath = settings.digilibBaseUrl + '/jquery/' + imagePath; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
164 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
165 var buttonConfig = settings.buttons[buttonName]; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
166 // button properties |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
167 var action = buttonConfig.onclick; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
168 var tooltip = buttonConfig.tooltip; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
169 var icon = imagePath + buttonConfig.icon; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
170 // construct the button html |
996 | 171 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
|
172 if (!show) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
173 $button.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
174 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
175 $div.append($button); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
176 // add attributes and bindings |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
177 $button.attr('title', tooltip); |
996 | 178 $button.addClass(cssPrefix+'arrow-' + buttonName); |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
179 // 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
|
180 // scroll arrows) |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
181 $div.on('click.digilib', function(evt) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
182 // 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
|
183 console.debug('click action=', action, ' evt=', evt); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
184 $elem.digilib.apply($elem, action); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
185 return false; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
186 }); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
187 return $button; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
188 }; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
189 |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
190 /** |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
191 * create arrows for moving the zoomed area. |
983 | 192 */ |
193 var setupZoomArrows = function(data) { | |
194 var $elem = data.$elem; | |
195 var settings = data.settings; | |
996 | 196 var cssPrefix = settings.cssPrefix; |
983 | 197 var show = settings.showZoomArrows; |
198 console.log('zoom arrows:', show); | |
199 if (!show) | |
200 return; | |
201 var mode = settings.interactionMode; | |
202 var arrowNames = settings.buttonSettings[mode].arrowSet; | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
203 if (arrowNames == null) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
204 console.error("No buttons for scroll arrows!"); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
205 settings.showZoomArrows = false; |
983 | 206 return; |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
207 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
208 // wrap scaler img in table |
996 | 209 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
|
210 // middle row with img has three elements |
996 | 211 data.$scaler.parent().before('<td class="'+cssPrefix+'arrow '+cssPrefix+'left" valign="middle"/>') |
212 .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
|
213 // first and last row has only one |
996 | 214 var $table = $elem.find('table.'+cssPrefix+'scalertable'); |
215 $table.find('tr.'+cssPrefix+'midrow') | |
216 .before('<tr class="'+cssPrefix+'firstrow"><td colspan="3" class="'+cssPrefix+'arrow '+cssPrefix+'up" align="center"/></tr>') | |
217 .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
|
218 // add arrow buttons |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
219 var ar = {}; |
996 | 220 ar.$up = createButton(data, $table.find('td.'+cssPrefix+'up'), 'up', digilib.fn.canMove(data, 0, -1)); |
221 ar.$down = createButton(data, $table.find('td.'+cssPrefix+'down'), 'down', digilib.fn.canMove(data, 0, 1)); | |
222 ar.$left = createButton(data, $table.find('td.'+cssPrefix+'left'), 'left', digilib.fn.canMove(data, -1, 0)); | |
223 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
|
224 data.arrows = ar; |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
225 |
983 | 226 }; |
227 | |
228 /** | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
229 * show or hide arrows, called after scaler img is loaded. |
983 | 230 * |
231 */ | |
232 var renderZoomArrows = function(data) { | |
233 var settings = data.settings; | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
234 var arrows = data.arrows; |
983 | 235 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
|
236 arrows.$up.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
237 arrows.$down.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
238 arrows.$left.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
239 arrows.$right.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
240 data.currentInsets['arrows'] = {'x' : 0, 'y' : 0}; |
983 | 241 return; |
242 } | |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
243 if (digilib.fn.canMove(data, 0, -1)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
244 arrows.$up.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
245 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
246 arrows.$up.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
247 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
248 if (digilib.fn.canMove(data, 0, 1)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
249 arrows.$down.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
250 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
251 arrows.$down.hide(); |
983 | 252 } |
989
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
253 if (digilib.fn.canMove(data, -1, 0)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
254 arrows.$left.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
255 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
256 arrows.$left.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
257 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
258 if (digilib.fn.canMove(data, 1, 0)) { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
259 arrows.$right.show(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
260 } else { |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
261 arrows.$right.hide(); |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
262 } |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
263 // adjust insets |
f4757bf6ab65
new arrows plugin for scroll arrows next to the image.
robcast
parents:
983
diff
changeset
|
264 data.currentInsets['arrows'] = getInsets(data); |
983 | 265 }; |
266 | |
267 // plugin object with name and init | |
268 // shared objects filled by digilib on registration | |
269 var plugin = { | |
270 name : 'arrows', | |
271 install : install, | |
272 init : init, | |
273 buttons : {}, | |
274 actions : {}, | |
275 fn : {}, | |
276 plugins : {} | |
277 }; | |
278 | |
279 if ($.fn.digilib == null) { | |
280 $.error("jquery.digilib.arrows must be loaded after jquery.digilib!"); | |
281 } else { | |
282 $.fn.digilib('plugin', plugin); | |
283 } | |
284 })(jQuery); |