Mercurial > hg > digilib-old
comparison client/digitallibrary/greyskin/dllib.js @ 452:6edd60cfa47f
ongoing experimental intermediary release
- more cleanup on object stuff
- new mark image
- menu is now fixed and tries to work in IE
author | robcast |
---|---|
date | Tue, 24 Jan 2006 21:17:44 +0100 |
parents | a6c83fa262b2 |
children | 9c16290e6f44 |
comparison
equal
deleted
inserted
replaced
451:a6c83fa262b2 | 452:6edd60cfa47f |
---|---|
24 | 24 |
25 */ | 25 */ |
26 digilibVersion = "Digilib NG"; | 26 digilibVersion = "Digilib NG"; |
27 dllibVersion = "2.040"; | 27 dllibVersion = "2.040"; |
28 | 28 |
29 MAX_AREA = new Rectangle(0.0, 0.0, 1.0, 1.0); | |
30 | |
31 // default inset (for scalerImg relativ to scalerDiv | |
32 INSET = 40; // because of scrollbars of main window and scaler [Firefox bug?] | |
33 | |
34 // mouse drag area that counts as one click | |
35 MIN_AREA_SIZE = 3 * 3 + 1; | |
36 | |
37 // standard zoom factor | |
38 ZOOMFACTOR = Math.sqrt(2); | |
39 | |
40 // bird's eye view dimensions | |
41 BIRD_MAXX = 100; | |
42 BIRD_MAXY = 100; | |
43 | |
44 // with of arrow bars | |
45 ARROW_WIDTH = 32; | |
46 | |
47 // with of calibration bar | |
48 CALIBRATION_WIDTH = 64; | |
49 | |
50 function identify() { | 29 function identify() { |
51 // used for identifying a digilib instance | 30 // used for identifying a digilib instance |
52 // Relato uses that function - lugi | 31 // Relato uses that function - lugi |
53 return digilibVersion; | 32 return digilibVersion; |
54 } | 33 } |
126 this.PARAM_IMAGE = 8; | 105 this.PARAM_IMAGE = 8; |
127 this.PARAM_DPI = 16; | 106 this.PARAM_DPI = 16; |
128 this.PARAM_SIZE = 32; | 107 this.PARAM_SIZE = 32; |
129 this.PARAM_MARK = 64; | 108 this.PARAM_MARK = 64; |
130 this.PARAM_PAGES = 128; | 109 this.PARAM_PAGES = 128; |
131 this.PARAM_ALL = 255; | 110 this.PARAM_CLIENT = 256; |
132 /* request parameters */ | 111 /* request parameters */ |
133 with (this) { | 112 with (this) { |
134 // file | 113 // file |
135 define('fn', '', PARAM_FILE); | 114 define('fn', '', PARAM_FILE); |
136 define('pn', '1', PARAM_FILE); | 115 define('pn', '1', PARAM_FILE); |
155 define('mk', '', PARAM_MARK); | 134 define('mk', '', PARAM_MARK); |
156 // pages total | 135 // pages total |
157 define('pt', '0', PARAM_PAGES); | 136 define('pt', '0', PARAM_PAGES); |
158 // size | 137 // size |
159 define('ws', '1.0', PARAM_SIZE); | 138 define('ws', '1.0', PARAM_SIZE); |
139 // client side options | |
140 define('clop', '', PARAM_CLIENT); | |
160 } | 141 } |
161 return this; | 142 return this; |
162 } | 143 } |
163 DLParameters.prototype = new Parameters(); | 144 DLParameters.prototype = new Parameters(); |
164 // move the inherited getAll because we need it later | 145 // move the inherited getAll because we need it later |
165 DLParameters.prototype._getAll = Parameters.prototype.getAll; | 146 DLParameters.prototype._getAll = Parameters.prototype.getAll; |
166 DLParameters.prototype.getAll = function(paDetail, moDetail, digilib) { | 147 DLParameters.prototype.getAll = function(paDetail, moDetail, digilib) { |
148 if (!digilib) digilib = dl; | |
167 // get Flags and Marks first | 149 // get Flags and Marks first |
168 if (!digilib) digilib = dl; | |
169 var mo = digilib.flags.getAll(moDetail); | 150 var mo = digilib.flags.getAll(moDetail); |
170 this.set("mo", mo); | 151 this.set("mo", mo); |
152 var clop = digilib.opts.getAll(); | |
153 this.set("clop", clop); | |
171 var mk = digilib.marks.getAll(); | 154 var mk = digilib.marks.getAll(); |
172 this.set("mk", mk); | 155 this.set("mk", mk); |
173 var ret = this._getAll(paDetail); | 156 var ret = this._getAll(paDetail); |
174 return ret; | 157 return ret; |
175 } | 158 } |
204 /* | 187 /* |
205 * Digilib -- digilib base class | 188 * Digilib -- digilib base class |
206 */ | 189 */ |
207 function Digilib() { | 190 function Digilib() { |
208 if (!baseLibVersion) alert("ERROR: baselib.js not loaded!"); | 191 if (!baseLibVersion) alert("ERROR: baselib.js not loaded!"); |
192 /* constants */ | |
193 this.MAX_AREA = new Rectangle(0.0, 0.0, 1.0, 1.0); | |
194 // default inset (for scalerImg relativ to scalerDiv | |
195 this.INSET = 40; // because of scrollbars of main window and scaler [Firefox bug?] | |
196 // mouse drag area that counts as one click | |
197 this.MIN_AREA_SIZE = 3 * 3 + 1; | |
198 // standard zoom factor | |
199 this.ZOOMFACTOR = Math.sqrt(2); | |
200 // bird's eye view dimensions | |
201 this.BIRD_MAXX = 100; | |
202 this.BIRD_MAXY = 100; | |
203 // witdh of arrow bars | |
204 this.ARROW_WIDTH = 32; | |
205 // width of calibration bar | |
206 this.CALIBRATION_WIDTH = 64; | |
207 /* variables */ | |
208 this.fitOnlyWidth = false; | |
209 this.fitOnlyHeight = false; | |
209 this.trafo = null; | 210 this.trafo = null; |
210 // page elements | 211 // page elements |
211 this.scalerDiv = null; | 212 this.scalerDiv = null; |
212 this.scalerImg = null; | 213 this.scalerImg = null; |
214 this.buttons1Div = null; | |
215 this.buttons2Div = null; | |
213 /* parse parameters */ | 216 /* parse parameters */ |
214 // put the query parameters (sans "?") in the parameters array | 217 // put the query parameters (sans "?") in the parameters array |
215 this.params = new DLParameters(); | 218 this.params = new DLParameters(); |
216 this.params.parse(location.search.slice(1)); | 219 this.params.parse(location.search.slice(1)); |
217 // treat special parameters | 220 // treat special parameters |
218 this.area = this.parseArea(); | 221 this.area = this.parseArea(); |
219 this.marks = new Marks(); | 222 this.marks = new Marks(); |
220 this.marks.parse(this.params.get("mk")); | 223 this.marks.parse(this.params.get("mk")); |
221 this.flags = new DLFlags(); | 224 this.flags = new DLFlags(); |
222 this.flags.parse(this.params.get("mo")); | 225 this.flags.parse(this.params.get("mo")); |
223 | 226 this.opts = new Flags(); |
227 this.opts.parse(this.params.get("clop")); | |
224 return this; | 228 return this; |
229 } | |
230 Digilib.prototype.setDLParam = function(e, s, relative) { | |
231 // sets parameter based on HTML event | |
232 var nam; | |
233 var val; | |
234 if (s.type && (s.type == "select-one")) { | |
235 nam = s.name; | |
236 val = s.options[s.selectedIndex].value; | |
237 } else if (s.name && s.value) { | |
238 nam = s.name; | |
239 val = s.value; | |
240 } | |
241 if (nam && val) { | |
242 dl.params.set(nam, val, relative); | |
243 display(); | |
244 } else { | |
245 alert("ERROR: unable to process event!"); | |
246 } | |
247 return true; | |
225 } | 248 } |
226 Digilib.prototype.parseArea = function() { | 249 Digilib.prototype.parseArea = function() { |
227 // returns area Rectangle from current parameters | 250 // returns area Rectangle from current parameters |
228 return new Rectangle( | 251 return new Rectangle( |
229 this.params.get("wx"), | 252 this.params.get("wx"), |
237 this.params.set("wy", cropFloat(rect.y)); | 260 this.params.set("wy", cropFloat(rect.y)); |
238 this.params.set("ww", cropFloat(rect.width)); | 261 this.params.set("ww", cropFloat(rect.width)); |
239 this.params.set("wh", cropFloat(rect.height)); | 262 this.params.set("wh", cropFloat(rect.height)); |
240 return true; | 263 return true; |
241 } | 264 } |
265 | |
242 Digilib.prototype.parseTrafo = function(elem) { | 266 Digilib.prototype.parseTrafo = function(elem) { |
243 // returns Transform from current dlArea and picsize | 267 // returns Transform from current dlArea and picsize |
244 var picsize = getElementRect(elem); | 268 var picsize = getElementRect(elem); |
245 var trafo = new Transform(); | 269 var trafo = new Transform(); |
246 // subtract area offset and size | 270 // subtract area offset and size |
257 // mirror | 281 // mirror |
258 //if (hasFlag("hmir")) trafo.m00 = - trafo.m00; // ?? | 282 //if (hasFlag("hmir")) trafo.m00 = - trafo.m00; // ?? |
259 //if (hasFlag("vmir")) trafo.m11 = - trafo.m11; // ?? | 283 //if (hasFlag("vmir")) trafo.m11 = - trafo.m11; // ?? |
260 return trafo; | 284 return trafo; |
261 } | 285 } |
262 Digilib.prototype.setDLParam = function(e, s, relative) { | 286 |
263 // sets parameter based on HTML event | |
264 var nam; | |
265 var val; | |
266 if (s.type && (s.type == "select-one")) { | |
267 nam = s.name; | |
268 val = s.options[s.selectedIndex].value; | |
269 } else if (s.name && s.value) { | |
270 nam = s.name; | |
271 val = s.value; | |
272 } | |
273 if (nam && val) { | |
274 dl.params.set(nam, val, relative); | |
275 display(); | |
276 } else { | |
277 alert("ERROR: unable to process event!"); | |
278 } | |
279 return true; | |
280 } | |
281 Digilib.prototype.onLoad = function() { | 287 Digilib.prototype.onLoad = function() { |
282 // initialize digilib; called by body.onload | 288 // initialize digilib; called by body.onload |
283 this.scalerDiv = getElement("scaler", true); | 289 this.scalerDiv = getElement("scaler", true); |
284 this.scalerImg = getElement("pic", true); | 290 this.scalerImg = getElement("pic", true); |
285 if (this.scalerImg == null && this.scalerDiv) { | 291 this.buttons1Div = getElement("buttons", true); |
292 this.buttons2Div = getElement("options", true); | |
293 /* if (this.scalerImg == null && this.scalerDiv) { | |
286 // in N4 pic is in the scaler layer | 294 // in N4 pic is in the scaler layer |
287 this.scalerImg = this.scalerDiv.document.images[0]; | 295 this.scalerImg = this.scalerDiv.document.images[0]; |
288 } | 296 } */ |
289 if ((!this.scalerImg)||(!this.scalerDiv)) { | 297 if ((!this.scalerImg)||(!this.scalerDiv)) { |
290 alert("Sorry, digilib doesn't work here!"); | 298 alert("Sorry, digilib doesn't work here!"); |
291 return false; | 299 return false; |
292 } | 300 } |
301 // fix fixed menus | |
302 var ms1 = getElementSize(this.buttons1Div); | |
303 var ms2 = getElementSize(this.buttons2Div); | |
304 var maxh = (ms1.height > ms2.height) ? ms1.height : ms2.height; | |
305 var wins = getWinSize(); | |
306 if ((wins.height <= maxh) || browserType.isIE) { | |
307 // unlock fixed menus to absolute | |
308 this.buttons1Div.style.position = "absolute"; | |
309 this.buttons2Div.style.position = "absolute"; | |
310 } | |
293 this.setScalerImage(); // setzt auch onImgLoad | 311 this.setScalerImage(); // setzt auch onImgLoad |
294 this.loadBirdImage(); // l?dt das Bird's Eye Bild | 312 this.setBirdImage(); // l?dt das Bird's Eye Bild |
295 } | 313 } |
296 Digilib.prototype.setScalerImage = function(detail) { | 314 |
315 Digilib.prototype.setScalerImage = function() { | |
297 // set the scaler image source (needs the browser size) | 316 // set the scaler image source (needs the browser size) |
298 var picsize = bestPicSize(this.scalerDiv, 50); | 317 var picsize = bestPicSize(this.scalerDiv); |
318 var menusize = getElementSize(this.buttons1Div); | |
319 // subtract menu width | |
320 picsize.width -= menusize.width; | |
321 picsize.height -= this.INSET; | |
322 // compose Scaler URL | |
299 var src = "../servlet/Scaler?" | 323 var src = "../servlet/Scaler?" |
300 + this.params.getAll(this.params.PARAM_ALL & ~(this.params.PARAM_MARK | this.params.PARAM_PAGES)) | 324 + this.params.getAll(this.params.PARAM_ALL & ~(this.params.PARAM_MARK | this.params.PARAM_PAGES)); |
301 + "&dw=" + picsize.width | 325 if (this.opts.get('fitwidth')) { |
302 + "&dh=" + picsize.height; | 326 src += "&dw=" + picsize.width; |
327 } else if (this.opts.get('fitheight')) { | |
328 src += "&dh=" + picsize.height; | |
329 } else { | |
330 src += "&dw=" + picsize.width + "&dh=" + picsize.height; | |
331 } | |
303 // debug(src); | 332 // debug(src); |
304 this.scalerImg.onload = onImgLoad; | 333 this.scalerImg.onload = onImgLoad; |
305 this.scalerImg.src = src; | 334 this.scalerImg.src = src; |
306 | 335 |
307 var digilib = this; | 336 var digilib = this; |
308 // this is a local callback function that can use the current scope | 337 // this is a local callback function that can use the current scope |
338 | |
309 function onImgLoad() { | 339 function onImgLoad() { |
310 // make sure the image is loaded so we know its size | 340 // make sure the image is loaded so we know its size |
311 if (defined(digilib.scalerImg.complete) && !digilib.scalerImg.complete && !digilib.browserType.isN4 ) { | 341 /* this test seems to have problems sometimes :-( |
312 alert("ERROR: the image seems not to be complete!?"); | 342 if (defined(digilib.scalerImg.complete) && !digilib.scalerImg.complete) { |
313 } | 343 alert("ERROR: the image seems not to be complete in onImgLoad!?"); |
344 } */ | |
314 digilib.trafo = digilib.parseTrafo(digilib.scalerImg); | 345 digilib.trafo = digilib.parseTrafo(digilib.scalerImg); |
315 // display marks | 346 // display marks |
316 digilib.renderMarks(); | 347 digilib.renderMarks(); |
317 digilib.showBirdDiv(isBirdDivVisible); | 348 digilib.showBirdDiv(isBirdDivVisible); |
318 digilib.showArrows(); // show arrow overlays for zoom navigation | 349 digilib.showArrows(); // show arrow overlays for zoom navigation |
319 digilib.moveCenter(true); // click to move point to center | 350 digilib.moveCenter(true); // click to move point to center |
320 // new Slider("sizes", 1, 5, 2); | 351 // new Slider("sizes", 1, 5, 2); |
321 focus(); | 352 focus(); |
322 } | 353 } |
323 } | 354 } |
355 Digilib.prototype.renderMarks = function() { | |
356 // make sure the image is loaded so we know its size | |
357 if (!this.trafo) { | |
358 alert("ERROR: trafo missing, cannot render marks!"); | |
359 return; | |
360 } | |
361 // debugProps(dlArea, "dlArea"); | |
362 for (var i = 0; i < this.marks.length; i++) { | |
363 var div = getElement("mark" + i, true) || createMarkDiv(i); | |
364 var mark = this.marks[i]; | |
365 // debugProps(mark, "mark"); | |
366 if (this.area.containsPosition(mark)) { | |
367 var mpos = this.trafo.transform(mark); | |
368 // debugProps(mark, "mpos"); | |
369 // better not hide the marked spot (MR) | |
370 // suboptimal to place -5 pixels and not half size of mark-image | |
371 // mpos.x = mpos.x -5; | |
372 // mpos.y = mpos.y -5; | |
373 moveElement(div, mpos); | |
374 showElement(div, true); | |
375 } else { | |
376 // hide the other marks | |
377 showElement(div, false); | |
378 } | |
379 } | |
380 } | |
381 | |
324 Digilib.prototype.display = function(detail, moDetail) { | 382 Digilib.prototype.display = function(detail, moDetail) { |
325 // redisplay the page | 383 // redisplay the page |
326 var queryString = this.params.getAll(detail, moDetail); | 384 var queryString = this.params.getAll(detail, moDetail); |
327 location.href | 385 location.href |
328 = location.protocol + "//" | 386 = location.protocol + "//" |
329 + location.host | 387 + location.host |
330 + location.pathname | 388 + location.pathname |
331 + "?" + queryString; | 389 + "?" + queryString; |
332 } | 390 } |
333 Digilib.prototype.renderMarks = function() { | |
334 // make sure the image is loaded so we know its size | |
335 if (!this.trafo) { | |
336 alert("ERROR: cannot render marks!"); | |
337 return; | |
338 } | |
339 // debugProps(dlArea, "dlArea"); | |
340 for (var i = 0; i < this.marks.length; i++) { | |
341 var div = getElement("mark" + i, true) || createMarkDiv(i); | |
342 var mark = this.marks[i]; | |
343 // debugProps(mark, "mark"); | |
344 if (this.area.containsPosition(mark)) { | |
345 var mpos = this.trafo.transform(mark); | |
346 // debugProps(mark, "mpos"); | |
347 // suboptimal to place -5 pixels and not half size of mark-image | |
348 // better not hide the marked spot (MR) | |
349 // mpos.x = mpos.x -5; | |
350 // mpos.y = mpos.y -5; | |
351 moveElement(div, mpos); | |
352 showElement(div, true); | |
353 } else { | |
354 // hide the other marks | |
355 showElement(div, false); | |
356 } | |
357 } | |
358 } | |
359 | 391 |
360 /* ********************************************** | 392 /* ********************************************** |
361 * interactive digilib functions | 393 * interactive digilib functions |
362 * ******************************************** */ | 394 * ******************************************** */ |
363 | 395 |
364 Digilib.prototype.setMark = function(reload) { | 396 Digilib.prototype.setMark = function() { |
365 // add a mark where clicked | 397 // add a mark where clicked |
366 window.focus(); | 398 window.focus(); |
367 this.moveCenter(false); | 399 this.moveCenter(false); |
368 // start event capturing | 400 // start event capturing |
369 registerEvent("mousedown", this.scalerDiv, markEvent); | 401 registerEvent("mousedown", this.scalerDiv, markEvent); |
373 | 405 |
374 function markEvent(evt) { | 406 function markEvent(evt) { |
375 // event handler adding a new mark | 407 // event handler adding a new mark |
376 unregisterEvent("mousedown", digilib.scalerDiv, markEvent); | 408 unregisterEvent("mousedown", digilib.scalerDiv, markEvent); |
377 digilib.marks.addEvent(evt); | 409 digilib.marks.addEvent(evt); |
378 if ( defined(reload) && !reload ) { | |
379 // don't redisplay | |
380 digilib.renderMarks(); | |
381 return stopEvent(evt); | |
382 } | |
383 digilib.display(); | 410 digilib.display(); |
384 return stopEvent(evt); | 411 return stopEvent(evt); |
385 } | 412 } |
386 | 413 |
387 } | 414 } |
388 | 415 |
389 Digilib.prototype.removeMark = function(reload) { | 416 Digilib.prototype.removeMark = function() { |
390 // remove the last mark | 417 // remove the last mark |
391 this.marks.pop(); | 418 this.marks.pop(); |
392 if (defined(reload)&&(!reload)) { | |
393 // don't redisplay | |
394 this.renderMarks(); | |
395 return; | |
396 } | |
397 this.display(); | 419 this.display(); |
398 } | 420 } |
399 | 421 |
400 Digilib.prototype.zoomArea = function() { | 422 Digilib.prototype.zoomArea = function() { |
401 var pt1, pt2; | 423 var pt1, pt2; |
414 window.focus(); | 436 window.focus(); |
415 | 437 |
416 // our own reference to this for the local function | 438 // our own reference to this for the local function |
417 var digilib = this; | 439 var digilib = this; |
418 | 440 |
419 // mousedown handler: start moving | 441 // mousedown handler: start moving |
420 function zoomStart(evt) { | 442 function zoomStart(evt) { |
421 pt1 = evtPosition(evt); | 443 pt1 = evtPosition(evt); |
422 unregisterEvent("mousedown", overlay, zoomStart); | 444 unregisterEvent("mousedown", overlay, zoomStart); |
423 unregisterEvent("mousedown", digilib.scalerImg, zoomStart); | 445 unregisterEvent("mousedown", digilib.scalerImg, zoomStart); |
424 // setup and show zoom div | 446 // setup and show zoom div |
428 registerEvent("mousemove", document, zoomMove); | 450 registerEvent("mousemove", document, zoomMove); |
429 registerEvent("mouseup", document, zoomEnd); | 451 registerEvent("mouseup", document, zoomEnd); |
430 return stopEvent(evt); | 452 return stopEvent(evt); |
431 } | 453 } |
432 | 454 |
433 // mouseup handler: end moving | 455 // mouseup handler: end moving |
434 function zoomEnd(evt) { | 456 function zoomEnd(evt) { |
435 pt2 = evtPosition(evt); | 457 pt2 = evtPosition(evt); |
436 // assume a click if the area is too small (up to 3 x 3 pixel) | 458 // assume a click if the area is too small (up to 3 x 3 pixel) |
437 var clickRect = new Rectangle(pt1, pt2); | 459 var clickRect = new Rectangle(pt1, pt2); |
438 clickRect.normalize(); | 460 clickRect.normalize(); |
439 if (clickRect.getArea() <= MIN_AREA_SIZE) return stopEvent(evt); | 461 if (clickRect.getArea() <= this.MIN_AREA_SIZE) return stopEvent(evt); |
440 // hide zoom div | 462 // hide zoom div |
441 showElement(zoomdiv, false); | 463 showElement(zoomdiv, false); |
442 showElement(overlay, false); | 464 showElement(overlay, false); |
443 // unregister events | 465 // unregister events |
444 unregisterEvent("mousemove", document, zoomMove); | 466 unregisterEvent("mousemove", document, zoomMove); |
451 digilib.params.set("ws", 1); | 473 digilib.params.set("ws", 1); |
452 digilib.display(); | 474 digilib.display(); |
453 return stopEvent(evt); | 475 return stopEvent(evt); |
454 } | 476 } |
455 | 477 |
456 // mouse move handler | 478 // mouse move handler |
457 function zoomMove(evt) { | 479 function zoomMove(evt) { |
458 pt2 = evtPosition(evt); | 480 pt2 = evtPosition(evt); |
459 var rect = new Rectangle(pt1, pt2); | 481 var rect = new Rectangle(pt1, pt2); |
460 rect.normalize(); | 482 rect.normalize(); |
461 rect.clipTo(picRect); | 483 rect.clipTo(picRect); |
470 var newarea = this.area.copy(); | 492 var newarea = this.area.copy(); |
471 newarea.width /= factor; | 493 newarea.width /= factor; |
472 newarea.height /= factor; | 494 newarea.height /= factor; |
473 newarea.x -= 0.5 * (newarea.width - this.area.width); | 495 newarea.x -= 0.5 * (newarea.width - this.area.width); |
474 newarea.y -= 0.5 * (newarea.height - this.area.height); | 496 newarea.y -= 0.5 * (newarea.height - this.area.height); |
475 newarea = MAX_AREA.fit(newarea); | 497 newarea = this.MAX_AREA.fit(newarea); |
476 this.setParamFromArea(newarea); | 498 this.setParamFromArea(newarea); |
477 this.display(); | 499 this.display(); |
478 } | 500 } |
479 | 501 |
480 | 502 |
481 Digilib.prototype.zoomFullpage = function() { | 503 Digilib.prototype.zoomFullpage = function(fit) { |
482 // zooms out to show the whole image | 504 // zooms out to show the whole image |
483 this.params.set("wx", 0.0); | 505 this.params.set("wx", 0.0); |
484 this.params.set("wy", 0.0); | 506 this.params.set("wy", 0.0); |
485 this.params.set("ww", 1.0); | 507 this.params.set("ww", 1.0); |
486 this.params.set("wh", 1.0); | 508 this.params.set("wh", 1.0); |
509 if (fit == "width") { | |
510 this.opts.set('fitwidth'); | |
511 } else if (fit == "height") { | |
512 this.opts.set('fitheight'); | |
513 } else { | |
514 this.opts.reset('fitwidth'); | |
515 this.opts.reset('fitheight'); | |
516 } | |
487 this.display(); | 517 this.display(); |
488 } | 518 } |
489 | 519 |
490 | 520 |
491 Digilib.prototype.moveCenter = function(on) { | 521 Digilib.prototype.moveCenter = function(on) { |
502 function moveCenterEvent(evt) { | 532 function moveCenterEvent(evt) { |
503 // move to handler | 533 // move to handler |
504 var pt = digilib.trafo.invtransform(evtPosition(evt)); | 534 var pt = digilib.trafo.invtransform(evtPosition(evt)); |
505 var newarea = digilib.area.copy(); | 535 var newarea = digilib.area.copy(); |
506 newarea.setCenter(pt); | 536 newarea.setCenter(pt); |
507 newarea.stayInside(MAX_AREA); | 537 newarea.stayInside(this.MAX_AREA); |
508 // newarea = dlMaxArea.fit(newarea); | 538 // newarea = dlMaxArea.fit(newarea); |
509 // debugProps(newarea, "newarea"); | 539 // debugProps(newarea, "newarea"); |
510 // debugProps(dlArea, "dlArea"); | 540 // debugProps(dlArea, "dlArea"); |
511 if (newarea.equals(digilib.area)) return; // keep event handler | 541 if (newarea.equals(digilib.area)) return; // keep event handler |
512 unregisterEvent("mousedown", digilib.scalerImg, moveCenterEvent); | 542 unregisterEvent("mousedown", digilib.scalerImg, moveCenterEvent); |
517 } | 547 } |
518 | 548 |
519 Digilib.prototype.isFullArea = function(area) { | 549 Digilib.prototype.isFullArea = function(area) { |
520 if (!area) area = this.area; | 550 if (!area) area = this.area; |
521 // pixel by pixel is not always full area | 551 // pixel by pixel is not always full area |
522 return (area.width == 1.0) && (area.height == 1.0) && ! hasFlag("clip"); | 552 return (area.width == 1.0) && (area.height == 1.0) && ! this.flags.get("clip"); |
523 } | 553 } |
524 | 554 |
525 Digilib.prototype.canMove = function(movx, movy) { | 555 Digilib.prototype.canMove = function(movx, movy) { |
526 if (this.isFullArea()) return false; | 556 if (this.isFullArea()) return false; |
527 var x2 = this.area.x + this.area.width; | 557 var x2 = this.area.x + this.area.width; |
537 // move visible area by movx and movy (in units of ww, wh) | 567 // move visible area by movx and movy (in units of ww, wh) |
538 if (!this.canMove(movx, movy)) return; // nothing to do | 568 if (!this.canMove(movx, movy)) return; // nothing to do |
539 var newarea = this.area.copy(); | 569 var newarea = this.area.copy(); |
540 newarea.x += parseFloat(movx)*this.area.width; | 570 newarea.x += parseFloat(movx)*this.area.width; |
541 newarea.y += parseFloat(movy)*this.area.height; | 571 newarea.y += parseFloat(movy)*this.area.height; |
542 newarea = MAX_AREA.fit(newarea); | 572 newarea = this.MAX_AREA.fit(newarea); |
543 // set parameters | 573 // set parameters |
544 this.setParamFromArea(newarea); | 574 this.setParamFromArea(newarea); |
545 this.display(); | 575 this.display(); |
546 } | 576 } |
547 | 577 |
552 + "//" | 582 + "//" |
553 + location.host | 583 + location.host |
554 + location.pathname; | 584 + location.pathname; |
555 var hyperlinkRef = baseUrl; | 585 var hyperlinkRef = baseUrl; |
556 with (this.params) { | 586 with (this.params) { |
557 var ps = getAll(PARAM_ALL & ~(PARAM_DPI | PARAM_PAGES)); // all without ddpi, pt | 587 // all without ddpi, pt |
588 var ps = getAll(PARAM_ALL & ~(PARAM_DPI | PARAM_PAGES | PARAM_CLIENT)); | |
558 } | 589 } |
559 if (ps.length > 0) hyperlinkRef += "?" + ps; | 590 if (ps.length > 0) hyperlinkRef += "?" + ps; |
560 return hyperlinkRef; | 591 return hyperlinkRef; |
561 } | 592 } |
562 | 593 |
672 moveElement(elem, aboutRect); | 703 moveElement(elem, aboutRect); |
673 } | 704 } |
674 showElement(elem, show); | 705 showElement(elem, show); |
675 } | 706 } |
676 | 707 |
677 Digilib.prototype.loadBirdImage = function() { | 708 Digilib.prototype.setBirdImage = function() { |
678 var img = getElement("bird-image"); | 709 var img = getElement("bird-image"); |
679 var src = "../servlet/Scaler?" | 710 var src = "../servlet/Scaler?" |
680 + this.params.getAll(this.params.PARAM_FILE) | 711 + this.params.getAll(this.params.PARAM_FILE) |
681 + "&dw=" + BIRD_MAXX | 712 + "&dw=" + this.BIRD_MAXX |
682 + "&dh=" + BIRD_MAXY; | 713 + "&dh=" + this.BIRD_MAXY; |
683 img.src = src; | 714 img.src = src; |
684 } | 715 } |
685 | 716 |
686 Digilib.prototype.showBirdDiv = function(show) { | 717 Digilib.prototype.showBirdDiv = function(show) { |
687 // show or hide "bird's eye" div | 718 // show or hide "bird's eye" div |
771 showElement(arrow, show); | 802 showElement(arrow, show); |
772 } | 803 } |
773 | 804 |
774 Digilib.prototype.showArrows = function() { | 805 Digilib.prototype.showArrows = function() { |
775 // show the 4 arrow bars on top of scaler img according to current dlArea | 806 // show the 4 arrow bars on top of scaler img according to current dlArea |
776 if (defined(this.scalerImg.complete) && !this.scalerImg.complete && !browserType.isN4 ) { | |
777 alert("ERROR: scaler img not complete in showArrows!"); | |
778 } | |
779 var r = getElementRect(this.scalerImg); | 807 var r = getElementRect(this.scalerImg); |
780 this.showArrow('up', | 808 this.showArrow('up', |
781 new Rectangle(r.x, r.y, r.width, ARROW_WIDTH), | 809 new Rectangle(r.x, r.y, r.width, this.ARROW_WIDTH), |
782 this.canMove(0, -1) | 810 this.canMove(0, -1) |
783 ); | 811 ); |
784 this.showArrow('down', | 812 this.showArrow('down', |
785 new Rectangle(r.x, r.y + r.height - ARROW_WIDTH, r.width, ARROW_WIDTH), | 813 new Rectangle(r.x, r.y + r.height - this.ARROW_WIDTH, r.width, this.ARROW_WIDTH), |
786 this.canMove(0, 1) | 814 this.canMove(0, 1) |
787 ); | 815 ); |
788 this.showArrow('left', | 816 this.showArrow('left', |
789 new Rectangle(r.x, r.y, ARROW_WIDTH, r.height), | 817 new Rectangle(r.x, r.y, this.ARROW_WIDTH, r.height), |
790 this.canMove(-1, 0) | 818 this.canMove(-1, 0) |
791 ); | 819 ); |
792 this.showArrow('right', | 820 this.showArrow('right', |
793 new Rectangle(r.x + r.width - ARROW_WIDTH, r.y, ARROW_WIDTH, r.height), | 821 new Rectangle(r.x + r.width - this.ARROW_WIDTH, r.y, this.ARROW_WIDTH, r.height), |
794 this.canMove(1, 0) | 822 this.canMove(1, 0) |
795 ); | 823 ); |
796 } | 824 } |
797 | 825 |
798 Digilib.prototype.calibrate = function(direction) { | 826 Digilib.prototype.calibrate = function(direction) { |
882 } | 910 } |
883 else this.flags.reset("clip"); | 911 else this.flags.reset("clip"); |
884 } | 912 } |
885 | 913 |
886 Digilib.prototype.pageWidth = function() { | 914 Digilib.prototype.pageWidth = function() { |
887 var divSize = getElementSize(this.scalerDiv); | 915 this.zoomFullpage('width'); |
888 divSize.width -= INSET; // allow for scrollbars [Firefox bug?] | |
889 var imgSize = getElementSize(this.scalerImg); | |
890 if (imgSize.width < divSize.width) { | |
891 this.params.set("ws", cropFloat(divSize.width / imgSize.width)); | |
892 this.display(this.params.PARAM_ALL & ~this.params.PARAM_DIM); // no zoom | |
893 }; | |
894 // TODO: how to calculate correct width if zoom is on? (plus size?) | |
895 } | 916 } |
896 | 917 |
897 Digilib.prototype.resize = function(factor) { | 918 Digilib.prototype.resize = function(factor) { |
898 this.params.set("ws", factor); | 919 this.params.set("ws", factor); |
899 this.showSizeMenu(false); | 920 this.showSizeMenu(false); |