Mercurial > hg > digilib
annotate client/digitallibrary/greyskin/dllib.js @ 513:9fa19391ef38 Root_jquery
fixes for zoom when birds-eye view open
fixes for IE (works mostly in IE7 and IE8)
author | robcast |
---|---|
date | Fri, 04 Sep 2009 12:27:02 +0200 |
parents | 0cb53ae1c4e8 |
children | e04c954edea0 |
rev | line source |
---|---|
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
1 /* Copyright (C) 2003,2004 IT-Group MPIWG, WTWG Uni Bern and others |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
2 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
3 This program is free software; you can redistribute it and/or |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
4 modify it under the terms of the GNU General Public License |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
5 as published by the Free Software Foundation; either version 2 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
6 of the License, or (at your option) any later version. |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
7 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
8 This program is distributed in the hope that it will be useful, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
9 but WITHOUT ANY WARRANTY; without even the implied warranty of |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
11 GNU General Public License for more details. |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
12 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
14 along with this program; if not, write to the Free Software |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
16 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
17 Authors: |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
18 Christian Luginbuehl, 01.05.2003 (first version) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
19 DW 24.03.2004 (Changed for digiLib in Zope) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
20 Robert Casties, 8.11.2005 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
21 Martin Raspe <hertzhaft@biblhertz.it>, 12.12.2005 |
513 | 22 Robert Casties, 4.9.2009 |
23 | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
24 ! Requires baselib.js ! |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
25 */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
26 digilibVersion = "Digilib NG"; |
513 | 27 dllibVersion = "2.041"; |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
28 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
29 function identify() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
30 // used for identifying a digilib instance |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
31 // Relato uses that function - lugi |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
32 return digilibVersion; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
33 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
34 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
35 function createMarkDiv(index) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
36 var div = document.createElement("div"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
37 div.className = "mark"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
38 div.id = "mark" + index; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
39 div.innerHTML = index + 1; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
40 document.body.appendChild(div); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
41 return div; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
42 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
43 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
44 function bestPicSize(elem, inset) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
45 // returns a Size with the best image size for the given element |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
46 if (! defined(inset)) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
47 inset = 25; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
48 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
49 var ws = getWinSize(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
50 var es = getElementPosition(elem); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
51 if (es) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
52 ws.width = ws.width - es.x - inset; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
53 ws.height = ws.height - es.y - inset; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
54 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
55 return ws; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
56 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
57 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
58 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
59 /**************************************************** |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
60 * digilib specific classes (must be defined first) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
61 ****************************************************/ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
62 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
63 /* |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
64 * Marks class |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
65 */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
66 function Marks() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
67 return this; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
68 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
69 // Marks inherits from Array |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
70 Marks.prototype = new Array(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
71 Marks.prototype.parse = function(query) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
72 this.length = 0; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
73 if (query.indexOf(";") >= 0) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
74 var pa = query.split(";"); // old format with ";" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
75 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
76 var pa = query.split(","); // new format |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
77 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
78 for (var i = 0; i < pa.length ; i++) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
79 var pos = pa[i].split("/"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
80 if (pos.length > 1) this.push(new Position(pos[0], pos[1])); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
81 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
82 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
83 Marks.prototype.getAll = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
84 var ma = new Array(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
85 for (var i = 0; i < this.length; i++) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
86 ma.push(cropFloat(this[i].x) + "/" + cropFloat(this[i].y)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
87 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
88 return ma.join(","); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
89 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
90 Marks.prototype.addEvent = function(evt, digilib) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
91 // add a mark from a screen event |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
92 if (!digilib) digilib = dl; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
93 var pos = digilib.trafo.invtransform(evtPosition(evt)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
94 this.push(pos); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
95 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
96 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
97 /* |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
98 * DLParameters -- digilib parameter class |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
99 */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
100 function DLParameters() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
101 // flags for parameter sets |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
102 this.PARAM_FILE = 1; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
103 this.PARAM_MODE = 2; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
104 this.PARAM_DIM = 4; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
105 this.PARAM_IMAGE = 8; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
106 this.PARAM_DPI = 16; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
107 this.PARAM_SIZE = 32; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
108 this.PARAM_MARK = 64; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
109 this.PARAM_PAGES = 128; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
110 this.PARAM_CLIENT = 256; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
111 /* request parameters */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
112 with (this) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
113 // file |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
114 define('fn', '', PARAM_FILE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
115 define('pn', '1', PARAM_FILE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
116 // mode |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
117 define('mo', '', PARAM_MODE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
118 // relative dimensions of zoomed image |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
119 define('wx', '0.0', PARAM_DIM); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
120 define('wy', '0.0', PARAM_DIM); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
121 define('ww', '1.0', PARAM_DIM); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
122 define('wh', '1.0', PARAM_DIM); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
123 // image manipulation |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
124 define('brgt', '0.0', PARAM_IMAGE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
125 define('cont', '0.0', PARAM_IMAGE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
126 define('rot', '0.0', PARAM_IMAGE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
127 define('rgba', '', PARAM_IMAGE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
128 define('rgbm', '', PARAM_IMAGE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
129 // resolution |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
130 define('ddpi', '', PARAM_DPI); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
131 define('ddpix', '', PARAM_DPI); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
132 define('ddpiy', '', PARAM_DPI); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
133 // marks |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
134 define('mk', '', PARAM_MARK); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
135 // pages total |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
136 define('pt', '0', PARAM_PAGES); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
137 // size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
138 define('ws', '1.0', PARAM_SIZE); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
139 // client side options |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
140 define('clop', '', PARAM_CLIENT); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
141 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
142 return this; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
143 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
144 DLParameters.prototype = new Parameters(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
145 // move the inherited getAll because we need it later |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
146 DLParameters.prototype._getAll = Parameters.prototype.getAll; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
147 DLParameters.prototype.getAll = function(paDetail, moDetail, digilib) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
148 if (!digilib) digilib = dl; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
149 // get Flags and Marks first |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
150 var mo = digilib.flags.getAll(moDetail); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
151 this.set("mo", mo); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
152 var clop = digilib.opts.getAll(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
153 this.set("clop", clop); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
154 var mk = digilib.marks.getAll(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
155 this.set("mk", mk); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
156 var ret = this._getAll(paDetail); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
157 return ret; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
158 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
159 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
160 /* |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
161 * DLModes -- digilib flags class |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
162 */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
163 function DLFlags() { |
513 | 164 // flags for mode sets |
165 this.MODE_QUAL = 1; | |
166 this.MODE_SIZE = 2; | |
167 this.MODE_MIR = 4; | |
168 this.MODE_OTHER = 128; | |
169 this.MODE_ALL = 255; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
170 /* mode flags */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
171 with (this) { |
513 | 172 define('q0', MODE_QUAL); |
173 define('q1', MODE_QUAL); | |
174 define('q2', MODE_QUAL); | |
175 define('fit', MODE_SIZE); | |
176 define('clip', MODE_SIZE); | |
177 define('osize', MODE_SIZE); | |
178 define('vmir', MODE_MIR); | |
179 define('hmir', MODE_MIR); | |
180 } | |
181 return this; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
182 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
183 // inherits from Flags |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
184 DLFlags.prototype = new Flags(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
185 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
186 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
187 /* |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
188 * Digilib -- digilib base class |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
189 */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
190 function Digilib() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
191 if (!baseLibVersion) alert("ERROR: baselib.js not loaded!"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
192 /* constants */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
193 this.MAX_AREA = new Rectangle(0.0, 0.0, 1.0, 1.0); |
513 | 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; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
207 /* variables */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
208 this.fitOnlyWidth = false; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
209 this.fitOnlyHeight = false; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
210 this.trafo = null; |
513 | 211 // page elements |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
212 this.scalerDiv = null; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
213 this.scalerImg = null; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
214 this.buttons1Div = null; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
215 this.buttons2Div = null; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
216 /* parse parameters */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
217 this.params = new DLParameters(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
218 // put the query parameters (sans "?") in the parameters array |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
219 this.params.parse(location.search.slice(1)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
220 // treat special parameters |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
221 this.area = this.parseArea(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
222 this.marks = new Marks(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
223 this.marks.parse(this.params.get("mk")); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
224 this.flags = new DLFlags(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
225 this.flags.parse(this.params.get("mo")); |
513 | 226 this.opts = new Flags(); |
227 this.opts.parse(this.params.get("clop")); | |
228 return this; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
229 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
230 Digilib.prototype.setDLParam = function(e, s, relative) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
231 // sets parameter based on HTML event |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
232 var nam; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
233 var val; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
234 if (s.type && (s.type == "select-one")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
235 nam = s.name; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
236 val = s.options[s.selectedIndex].value; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
237 } else if (s.name && s.value) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
238 nam = s.name; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
239 val = s.value; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
240 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
241 if (nam && val) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
242 dl.params.set(nam, val, relative); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
243 display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
244 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
245 alert("ERROR: unable to process event!"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
246 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
247 return true; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
248 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
249 Digilib.prototype.parseArea = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
250 // returns area Rectangle from current parameters |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
251 return new Rectangle( |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
252 this.params.get("wx"), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
253 this.params.get("wy"), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
254 this.params.get("ww"), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
255 this.params.get("wh")); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
256 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
257 Digilib.prototype.setParamFromArea = function(rect) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
258 // sets digilib wx etc. from rect |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
259 this.params.set("wx", cropFloat(rect.x)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
260 this.params.set("wy", cropFloat(rect.y)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
261 this.params.set("ww", cropFloat(rect.width)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
262 this.params.set("wh", cropFloat(rect.height)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
263 return true; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
264 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
265 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
266 Digilib.prototype.parseTrafo = function(elem) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
267 // returns Transform from current dlArea and picsize |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
268 var picsize = getElementRect(elem); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
269 var trafo = new Transform(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
270 // subtract area offset and size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
271 trafo.concat(trafo.getTranslation(new Position(-this.area.x, -this.area.y))); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
272 trafo.concat(trafo.getScale(new Size(1/this.area.width, 1/this.area.height))); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
273 // scale to screen size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
274 trafo.concat(trafo.getScale(picsize)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
275 trafo.concat(trafo.getTranslation(picsize)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
276 // FIX ME: Robert, kannst Du mal nachsehen, ob das folgende tut, was es soll? |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
277 // oder gibt es dafuer neuen Code? -- ROC: Bisher funktioniert es nicht! |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
278 // rotate |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
279 //var rot = getRotation(- dl.params.get("rot"), new Position(0.5*picsize.width, 0.5*picsize.height)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
280 //trafo.concat(rot); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
281 // mirror |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
282 //if (hasFlag("hmir")) trafo.m00 = - trafo.m00; // ?? |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
283 //if (hasFlag("vmir")) trafo.m11 = - trafo.m11; // ?? |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
284 return trafo; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
285 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
286 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
287 Digilib.prototype.onLoad = function() { |
513 | 288 // initialize digilib; called by body.onload |
289 this.scalerDiv = getElement("scaler", true); | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
290 this.scalerImg = getElement("pic", true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
291 this.buttons1Div = getElement("buttons", true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
292 this.buttons2Div = getElement("options", true); |
513 | 293 /* |
294 * if (this.scalerImg == null && this.scalerDiv) { // in N4 pic is in the | |
295 * scaler layer this.scalerImg = this.scalerDiv.document.images[0]; } | |
296 */ | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
297 if ((!this.scalerImg)||(!this.scalerDiv)) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
298 alert("Sorry, digilib doesn't work here!"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
299 return false; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
300 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
301 // fix fixed menus |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
302 var ms1 = getElementSize(this.buttons1Div); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
303 var ms2 = getElementSize(this.buttons2Div); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
304 var maxh = (ms1.height > ms2.height) ? ms1.height : ms2.height; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
305 var wins = getWinSize(); |
513 | 306 if ((wins.height <= maxh) || (browserType.isIE && (browserType.versIE < 7))) { |
307 // unlock fixed menus to absolute if window is too small or IE | |
308 this.buttons1Div.style.position = "absolute"; | |
309 this.buttons2Div.style.position = "absolute"; | |
310 } | |
311 this.setScalerImage(); // setzt auch onImgLoad | |
312 this.setBirdImage(); // laedt das Bird's Eye Bild | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
313 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
314 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
315 Digilib.prototype.setScalerImage = function() { |
513 | 316 // set the scaler image source (needs the browser size) |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
317 var picsize = bestPicSize(this.scalerDiv); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
318 var menusize = getElementSize(this.buttons1Div); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
319 // subtract menu width |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
320 picsize.width -= menusize.width; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
321 picsize.height -= this.INSET; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
322 // compose Scaler URL |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
323 var src = "../servlet/Scaler?" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
324 + this.params.getAll(this.params.PARAM_ALL & ~(this.params.PARAM_MARK | this.params.PARAM_PAGES)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
325 if (this.opts.get('fitwidth')) { |
513 | 326 src += "&dw=" + picsize.width; |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
327 } else if (this.opts.get('fitheight')) { |
513 | 328 src += "&dh=" + picsize.height; |
329 } else { | |
330 src += "&dw=" + picsize.width + "&dh=" + picsize.height; | |
331 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
332 // debug(src); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
333 this.scalerImg.onload = onImgLoad; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
334 this.scalerImg.src = src; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
335 |
513 | 336 var digilib = this; |
337 // this is a local callback function that can use the current scope | |
338 | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
339 function onImgLoad() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
340 if (! digilib) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
341 return; |
513 | 342 // make sure the image is loaded so we know its size |
343 /* this test seems to have problems sometimes :-( | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
344 if (defined(digilib.scalerImg.complete) && !digilib.scalerImg.complete) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
345 alert("ERROR: the image seems not to be complete in onImgLoad!?"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
346 } */ |
513 | 347 digilib.trafo = digilib.parseTrafo(digilib.scalerImg); |
348 // display marks | |
349 digilib.renderMarks(); | |
350 digilib.showBirdDiv(isBirdDivVisible); | |
351 digilib.showArrows(); // show arrow overlays for zoom navigation | |
352 //digilib.moveCenter(true); // click to move point to center | |
353 // new Slider("sizes", 1, 5, 2); | |
354 focus(); | |
355 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
356 } |
513 | 357 |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
358 Digilib.prototype.renderMarks = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
359 // make sure the image is loaded so we know its size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
360 if (!this.trafo) { |
513 | 361 alert("ERROR: trafo missing, cannot render marks!"); |
362 return; | |
363 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
364 // debugProps(dlArea, "dlArea"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
365 for (var i = 0; i < this.marks.length; i++) { |
513 | 366 var div = getElement("mark" + i, true) || createMarkDiv(i); |
367 var mark = this.marks[i]; | |
368 // debugProps(mark, "mark"); | |
369 if (this.area.containsPosition(mark)) { | |
370 var mpos = this.trafo.transform(mark); | |
371 // debugProps(mark, "mpos"); | |
372 // better not hide the marked spot (MR) | |
373 // suboptimal to place -5 pixels and not half size of mark-image | |
374 // mpos.x = mpos.x -5; | |
375 // mpos.y = mpos.y -5; | |
376 moveElement(div, mpos); | |
377 showElement(div, true); | |
378 } else { | |
379 // hide the other marks | |
380 showElement(div, false); | |
381 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
382 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
383 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
384 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
385 Digilib.prototype.display = function(detail, moDetail) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
386 // redisplay the page |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
387 var queryString = this.params.getAll(detail, moDetail); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
388 location.href |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
389 = location.protocol + "//" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
390 + location.host |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
391 + location.pathname |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
392 + "?" + queryString; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
393 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
394 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
395 /* ********************************************** |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
396 * interactive digilib functions |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
397 * ******************************************** */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
398 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
399 Digilib.prototype.setMark = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
400 // add a mark where clicked |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
401 window.focus(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
402 this.moveCenter(false); |
510 | 403 |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
404 // start event capturing |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
405 registerEvent("mousedown", this.scalerDiv, markEvent); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
406 |
510 | 407 // our own reference to this for the local function |
408 var digilib = this; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
409 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
410 function markEvent(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
411 // event handler adding a new mark |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
412 unregisterEvent("mousedown", digilib.scalerDiv, markEvent); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
413 digilib.marks.addEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
414 digilib.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
415 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
416 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
417 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
418 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
419 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
420 Digilib.prototype.removeMark = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
421 // remove the last mark |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
422 this.marks.pop(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
423 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
424 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
425 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
426 Digilib.prototype.zoomArea = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
427 var pt1, pt2; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
428 var zoomdiv = getElement("zoom"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
429 var overlay = getElement("overlay"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
430 // use overlay div to avoid <img> mousemove problems |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
431 var picRect = getElementRect(this.scalerImg); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
432 // FIX ME: is there a way to query the border width from CSS info? |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
433 // rect.x -= 2; // account for overlay borders |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
434 // rect.y -= 2; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
435 moveElement(overlay, picRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
436 showElement(overlay, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
437 // start event capturing |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
438 registerEvent("mousedown", overlay, zoomStart); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
439 registerEvent("mousedown", this.scalerImg, zoomStart); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
440 window.focus(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
441 |
510 | 442 // our own reference to "this" for the local functions |
443 var digilib = this; | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
444 |
510 | 445 // mousedown handler: start moving |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
446 function zoomStart(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
447 pt1 = evtPosition(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
448 unregisterEvent("mousedown", overlay, zoomStart); |
510 | 449 unregisterEvent("mousedown", digilib.scalerImg, zoomStart); |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
450 // setup and show zoom div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
451 moveElement(zoomdiv, Rectangle(pt1.x, pt1.y, 0, 0)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
452 showElement(zoomdiv, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
453 // register events |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
454 registerEvent("mousemove", document, zoomMove); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
455 registerEvent("mouseup", document, zoomEnd); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
456 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
457 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
458 |
510 | 459 // mouseup handler: end moving |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
460 function zoomEnd(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
461 pt2 = evtPosition(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
462 // assume a click if the area is too small (up to 3 x 3 pixel) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
463 var clickRect = new Rectangle(pt1, pt2); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
464 clickRect.normalize(); |
513 | 465 if (clickRect.getArea() <= digilib.MIN_AREA_SIZE) { |
466 return stopEvent(evt); | |
467 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
468 // hide zoom div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
469 showElement(zoomdiv, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
470 showElement(overlay, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
471 // unregister events |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
472 unregisterEvent("mousemove", document, zoomMove); |
510 | 473 unregisterEvent("mouseup", document, zoomEnd); |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
474 // clip and transform |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
475 clickRect.clipTo(picRect); |
510 | 476 var area = digilib.trafo.invtransform(clickRect); |
477 digilib.setParamFromArea(area); | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
478 // zoomed is always fit |
510 | 479 digilib.params.set("ws", 1); |
480 digilib.display(); | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
481 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
482 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
483 |
510 | 484 // mouse move handler |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
485 function zoomMove(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
486 pt2 = evtPosition(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
487 var rect = new Rectangle(pt1, pt2); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
488 rect.normalize(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
489 rect.clipTo(picRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
490 // update zoom div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
491 moveElement(zoomdiv, rect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
492 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
493 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
494 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
495 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
496 Digilib.prototype.zoomBy = function(factor) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
497 // zooms by the given factor |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
498 var newarea = this.area.copy(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
499 newarea.width /= factor; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
500 newarea.height /= factor; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
501 newarea.x -= 0.5 * (newarea.width - this.area.width); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
502 newarea.y -= 0.5 * (newarea.height - this.area.height); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
503 newarea = this.MAX_AREA.fit(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
504 this.setParamFromArea(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
505 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
506 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
507 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
508 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
509 Digilib.prototype.zoomFullpage = function(fit) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
510 // zooms out to show the whole image |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
511 this.params.set("wx", 0.0); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
512 this.params.set("wy", 0.0); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
513 this.params.set("ww", 1.0); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
514 this.params.set("wh", 1.0); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
515 if (fit == "width") { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
516 this.opts.set('fitwidth'); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
517 } else if (fit == "height") { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
518 this.opts.set('fitheight'); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
519 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
520 this.opts.reset('fitwidth'); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
521 this.opts.reset('fitheight'); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
522 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
523 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
524 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
525 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
526 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
527 Digilib.prototype.moveCenter = function(on) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
528 // move visible area so that it's centered around the clicked point |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
529 if (this.isFullArea()) return; // nothing to do |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
530 // starting event capture |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
531 if (on) registerEvent("mousedown", this.scalerImg, moveCenterEvent); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
532 else unregisterEvent("mousedown", this.scalerImg, moveCenterEvent); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
533 window.focus(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
534 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
535 // our own reference to this for the local function |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
536 var digilib = this; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
537 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
538 function moveCenterEvent(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
539 // move to handler |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
540 var pt = digilib.trafo.invtransform(evtPosition(evt)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
541 var newarea = digilib.area.copy(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
542 newarea.setCenter(pt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
543 newarea.stayInside(this.MAX_AREA); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
544 // newarea = dlMaxArea.fit(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
545 // debugProps(newarea, "newarea"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
546 // debugProps(dlArea, "dlArea"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
547 if (newarea.equals(digilib.area)) return; // keep event handler |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
548 unregisterEvent("mousedown", digilib.scalerImg, moveCenterEvent); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
549 // set parameters |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
550 digilib.setParamFromArea(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
551 digilib.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
552 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
553 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
554 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
555 Digilib.prototype.isFullArea = function(area) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
556 if (!area) area = this.area; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
557 return (area.width == 1.0) && (area.height == 1.0); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
558 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
559 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
560 Digilib.prototype.canMove = function(movx, movy) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
561 if (this.isFullArea()) return false; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
562 var x2 = this.area.x + this.area.width; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
563 var y2 = this.area.y + this.area.height; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
564 // debugProps(dlArea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
565 return ((movx < 0) && (this.area.x > 0)) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
566 || ((movx > 0) && (x2 < 1.0)) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
567 || ((movy < 0) && (this.area.y > 0)) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
568 || ((movy > 0) && (y2 < 1.0)) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
569 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
570 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
571 Digilib.prototype.moveBy = function(movx, movy) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
572 // move visible area by movx and movy (in units of ww, wh) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
573 if (!this.canMove(movx, movy)) return; // nothing to do |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
574 var newarea = this.area.copy(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
575 newarea.x += parseFloat(movx)*this.area.width; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
576 newarea.y += parseFloat(movy)*this.area.height; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
577 newarea = this.MAX_AREA.fit(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
578 // set parameters |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
579 this.setParamFromArea(newarea); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
580 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
581 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
582 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
583 Digilib.prototype.getRef = function(baseUrl) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
584 // returns a reference to the current digilib set |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
585 if (!baseUrl) baseUrl |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
586 = location.protocol |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
587 + "//" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
588 + location.host |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
589 + location.pathname; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
590 var hyperlinkRef = baseUrl; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
591 with (this.params) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
592 // all without ddpi, pt |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
593 var ps = getAll(PARAM_ALL & ~(PARAM_DPI | PARAM_PAGES | PARAM_CLIENT)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
594 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
595 if (ps.length > 0) hyperlinkRef += "?" + ps; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
596 return hyperlinkRef; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
597 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
598 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
599 Digilib.prototype.getRefWin = function(type, msg) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
600 // shows an alert with a reference to the current digilib set |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
601 if (! msg) msg = "URL reference to the current view"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
602 prompt(msg, this.getRef()); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
603 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
604 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
605 Digilib.prototype.getQuality = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
606 // returns the current q setting |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
607 for (var i = 0; i < 3; i++) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
608 if (this.flags.get("q"+i)) return i; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
609 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
610 return 1 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
611 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
612 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
613 Digilib.prototype.setQuality = function(qual) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
614 // set the image quality |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
615 if ((qual < 0)||(qual > 2)) return alert("Quality setting not supported"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
616 for (var i = 0; i < 3; i++) this.flags.reset("q" + i); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
617 this.flags.set("q" + qual); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
618 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
619 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
620 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
621 Digilib.prototype.setQualityWin = function(msg) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
622 // dialog for setting quality |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
623 if (! msg) msg = "Quality (0..2)"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
624 var q = this.getQuality(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
625 var newq = window.prompt(msg, q); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
626 if (newq) this.setQuality(newq); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
627 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
628 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
629 Digilib.prototype.mirror = function(dir) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
630 // mirror the image horizontally or vertically |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
631 if (dir == "h") { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
632 this.flags.toggle("hmir"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
633 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
634 this.flags.toggle("vmir"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
635 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
636 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
637 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
638 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
639 Digilib.prototype.gotoPage = function(gopage, keep) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
640 // goto given page nr (+/-: relative) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
641 var oldpn = parseInt(this.params.get("pn")); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
642 // set with relative=true uses the sign |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
643 this.params.set("pn", gopage, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
644 // now check the outcome |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
645 var pn = parseInt(this.params.get("pn")); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
646 if (pn < 1) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
647 alert("No such page! (Page number too low)"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
648 this.params.set("pn", oldpn); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
649 return; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
650 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
651 if (this.params.isSet("pt")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
652 pt = parseInt(this.params.get("pt")) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
653 if (pn > pt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
654 alert("No such page! (Page number too high)"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
655 this.params.set("pn", oldpn); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
656 return; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
657 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
658 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
659 if (keep) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
660 this.display(this.params.PARAM_ALL & ~this.params.PARAM_MARK); // all, no mark |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
661 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
662 this.display(this.params.PARAM_FILE | this.params.PARAM_MODE | this.params.PARAM_PAGES, this.params.MODE_QUAL | this.params.MODE_OTHER); // fn, pn, ws, mo + pt |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
663 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
664 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
665 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
666 Digilib.prototype.gotoPageWin = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
667 // dialog to ask for new page nr |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
668 var pn = this.params.get("pn"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
669 var gopage = window.prompt("Go to page", pn); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
670 if (gopage) this.gotoPage(gopage); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
671 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
672 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
673 Digilib.prototype.setParamWin = function(param, text, relative) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
674 // dialog to ask for new parameter value |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
675 var val = this.params.get(param); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
676 var newval = window.prompt(text, val); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
677 if (newval) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
678 this.params.set(param, newval, relative); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
679 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
680 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
681 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
682 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
683 Digilib.prototype.showOptions = function(show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
684 // show or hide option div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
685 var elem = getElement("dloptions"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
686 showElement(elem, show); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
687 // FIX ME: get rid of the dotted line around the buttons when focused |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
688 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
689 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
690 Digilib.prototype.showAboutDiv = function(show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
691 // show or hide "about" div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
692 var elem = getElement("about"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
693 if (elem == null) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
694 if (show) alert("About Digilib - dialog missing in HTML code!" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
695 + "\nDigilib Version: " + digilibVersion |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
696 + "\JSP Version: " + jspVersion |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
697 + "\ndlLib Version: " + dllibVersion |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
698 + "\nbaseLib Version: " + baseLibVersion); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
699 return; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
700 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
701 if (show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
702 getElement("digilib-version").innerHTML = "Digilib Version: " + digilibVersion; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
703 getElement("jsp-version").innerHTML = "JSP Version: " + jspVersion; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
704 getElement("baselib-version").innerHTML = "baseLib Version: " + baseLibVersion; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
705 getElement("dllib-version").innerHTML = "dlLib Version: " + dllibVersion; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
706 var aboutRect = getElementRect(elem); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
707 aboutRect.setCenter(getWinRect().getCenter()); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
708 moveElement(elem, aboutRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
709 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
710 showElement(elem, show); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
711 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
712 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
713 Digilib.prototype.setBirdImage = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
714 var img = getElement("bird-image"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
715 var src = "../servlet/Scaler?" |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
716 + this.params.getAll(this.params.PARAM_FILE) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
717 + "&dw=" + this.BIRD_MAXX |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
718 + "&dh=" + this.BIRD_MAXY; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
719 img.src = src; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
720 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
721 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
722 Digilib.prototype.showBirdDiv = function(show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
723 // show or hide "bird's eye" div |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
724 var startPos; // anchor for dragging |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
725 var newRect; // position after drag |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
726 var birdImg = getElement("bird-image"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
727 var birdArea = getElement("bird-area"); |
513 | 728 var overlay = getElement("bird-overlay"); |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
729 showElement(birdImg, show); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
730 // dont show selector if area has full size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
731 if (!show || this.isFullArea()) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
732 // hide area |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
733 showElement(birdArea, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
734 showElement(overlay, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
735 return; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
736 }; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
737 var birdImgRect = getElementRect(birdImg); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
738 var area = this.area; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
739 if (this.flags.get("osize") || this.flags.get("clip")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
740 // in original-size and pixel-by-pixel mode the area size is not valid |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
741 var birdAreaRect = new Rectangle( |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
742 birdImgRect.x + birdImgRect.width * area.x, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
743 birdImgRect.y + birdImgRect.height * area.y, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
744 5, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
745 5); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
746 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
747 // scale area down to img size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
748 var birdAreaRect = new Rectangle( |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
749 // what about borders ?? |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
750 birdImgRect.x + birdImgRect.width * area.x, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
751 birdImgRect.y + birdImgRect.height * area.y, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
752 birdImgRect.width * area.width, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
753 birdImgRect.height * area.height); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
754 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
755 moveElement(birdArea, birdAreaRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
756 showElement(birdArea, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
757 moveElement(overlay, birdImgRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
758 showElement(overlay, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
759 registerEvent("mousedown", overlay, birdAreaStartDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
760 registerEvent("mousedown", birdImg, birdAreaStartDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
761 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
762 // our own reference to this for local functions |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
763 var digilib = this; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
764 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
765 function birdAreaStartDrag(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
766 // mousedown handler: start drag |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
767 startPos = evtPosition(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
768 unregisterEvent("mousedown", overlay, birdAreaStartDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
769 unregisterEvent("mousedown", birdImg, birdAreaStartDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
770 registerEvent("mousemove", document, birdAreaMove); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
771 registerEvent("mouseup", document, birdAreaEndDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
772 // debugProps(getElementRect(bird)) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
773 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
774 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
775 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
776 function birdAreaMove(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
777 // mousemove handler: drag |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
778 var pos = evtPosition(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
779 var dx = pos.x - startPos.x; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
780 var dy = pos.y - startPos.y; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
781 // move birdArea div, keeping size |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
782 newRect = new Rectangle( |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
783 birdAreaRect.x + dx, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
784 birdAreaRect.y + dy, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
785 birdAreaRect.width, |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
786 birdAreaRect.height); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
787 // stay within image |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
788 newRect.stayInside(birdImgRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
789 moveElement(birdArea, newRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
790 showElement(birdArea, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
791 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
792 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
793 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
794 function birdAreaEndDrag(evt) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
795 // mouseup handler: reload page |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
796 unregisterEvent("mousemove", document, birdAreaMove); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
797 unregisterEvent("mouseup", document, birdAreaEndDrag); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
798 showElement(overlay, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
799 if (newRect == null) { // no movement happened |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
800 startPos = birdAreaRect.getCenter(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
801 birdAreaMove(evt); // set center to click position |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
802 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
803 digilib.params.set("wx", cropFloat((newRect.x - birdImgRect.x) / birdImgRect.width)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
804 digilib.params.set("wy", cropFloat((newRect.y - birdImgRect.y) / birdImgRect.height)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
805 // zoomed is always fit |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
806 digilib.params.set("ws", 1); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
807 digilib.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
808 return stopEvent(evt); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
809 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
810 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
811 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
812 Digilib.prototype.showArrow = function(name, rect, show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
813 var arrow = getElement(name); |
513 | 814 moveElement(arrow, rect); |
815 showElement(arrow, show); | |
816 } | |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
817 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
818 Digilib.prototype.showArrows = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
819 // show the 4 arrow bars on top of scaler img according to current dlArea |
513 | 820 var r = getElementRect(this.scalerImg); |
481
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
821 this.showArrow('up', |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
822 new Rectangle(r.x, r.y, r.width, this.ARROW_WIDTH), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
823 this.canMove(0, -1) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
824 ); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
825 this.showArrow('down', |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
826 new Rectangle(r.x, r.y + r.height - this.ARROW_WIDTH, r.width, this.ARROW_WIDTH), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
827 this.canMove(0, 1) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
828 ); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
829 this.showArrow('left', |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
830 new Rectangle(r.x, r.y, this.ARROW_WIDTH, r.height), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
831 this.canMove(-1, 0) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
832 ); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
833 this.showArrow('right', |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
834 new Rectangle(r.x + r.width - this.ARROW_WIDTH, r.y, this.ARROW_WIDTH, r.height), |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
835 this.canMove(1, 0) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
836 ); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
837 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
838 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
839 Digilib.prototype.calibrate = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
840 // calibrate screen resolution |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
841 var calDiv = getElement("calibration"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
842 var calRect = getElementRect(calDiv); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
843 moveCenter(false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
844 var wins = getWinSize(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
845 calRect.setCenter(new Position(wins.width / 2, wins.height / 2)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
846 moveElement(calDiv, calRect); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
847 showElement(calDiv, true); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
848 var cm = window.prompt("The length of the scale on your screen in centimeter:"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
849 if (cm) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
850 var dpi = calRect.width / parseFloat(cm) * 2.54; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
851 this.params.set("ddpi", cropFloat(dpi)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
852 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
853 showElement(calDiv, false); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
854 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
855 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
856 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
857 Digilib.prototype.setScale = function(scale) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
858 // sets original-size, pixel-by-pixel or fit-to-screen scale type |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
859 if (scale == "pixel") { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
860 // pixel by pixel |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
861 this.flags.set("clip"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
862 this.flags.reset("osize"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
863 this.flags.reset("fit"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
864 } else if (scale == "original") { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
865 // original size -- needs calibrated screen |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
866 if (!this.params.isSet("ddpi")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
867 var dpi = cookie.get("ddpi"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
868 if (dpi == null) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
869 alert("Your screen has not yet been calibrated - using default value of 72 dpi"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
870 dpi = 72; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
871 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
872 this.params.set("ddpi", dpi); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
873 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
874 this.flags.set("osize"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
875 this.flags.reset("clip"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
876 this.flags.reset("fit"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
877 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
878 // scale to screen size (default) |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
879 this.flags.reset("clip"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
880 this.flags.reset("osize"); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
881 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
882 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
883 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
884 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
885 Digilib.prototype.getScale = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
886 // returns scale type |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
887 if (this.flags.get("clip")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
888 return "pixel"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
889 } else if (this.flags.get("osize")) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
890 return "original"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
891 } else { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
892 return "fit"; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
893 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
894 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
895 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
896 Digilib.prototype.pageWidth = function() { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
897 this.zoomFullpage('width'); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
898 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
899 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
900 Digilib.prototype.setSize = function(factor) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
901 this.params.set("ws", factor); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
902 this.display(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
903 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
904 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
905 Digilib.prototype.showMenu = function(menuId, buttonId, show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
906 var menu = getElement(menuId); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
907 if (show) { |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
908 // align right side of menu with button |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
909 var buttonPos = getElementPosition(getElement(buttonId)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
910 var menusize = getElementSize(menu); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
911 moveElement(menu, new Position(buttonPos.x - menusize.width - 3, buttonPos.y)); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
912 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
913 showElement(menu, show); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
914 } |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
915 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
916 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
917 /******************************** |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
918 * global variables |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
919 ********************************/ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
920 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
921 var dl = new Digilib(); |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
922 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
923 /* old parameter function compatibility stuff */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
924 function newParameter(a,b,c) {return dl.params.define(a,b,c)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
925 function resetParameter(a) {return dl.params.reset(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
926 function deleteParameter(a) {return dl.params.remove(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
927 function getParameter(a) {return dl.params.get(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
928 function setParameter(a,b,c) {return dl.params.set(a,b,c)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
929 function hasParameter(a) {return dl.params.isSet(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
930 function getAllParameters(a) {return dl.params.getAll(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
931 getQueryString = getAllParameters; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
932 function parseParameters(a) {return dl.params.parse(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
933 function getAllMarks() {return dl.marks.getAll()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
934 getMarksQueryString = getAllMarks; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
935 function addMark(evt) {return dl.marks.addEvent(evt)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
936 function deleteMark() {return dl.marks.pop()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
937 function deleteAllMarks() {return dl.marks = new Marks()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
938 function hasFlag(mode) {return dl.flags.get(mode)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
939 function addFlag(mode) {return dl.flags.set(mode)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
940 function removeFlag(mode) {return dl.flags.reset(mode)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
941 function toggleFlag(mode) {return dl.flags.toggle(mode)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
942 function getAllFlags() {return dl.flags.getAll()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
943 /* old digilib function compatibility */ |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
944 function setDLParam(e, s, relative) {dl.setDLParam(e, s, relative)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
945 function display(detail, moDetail) {dl.display(detail, moDetail)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
946 function setMark(reload) {dl.setMark(reload)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
947 function removeMark(reload) {dl.removeMark(reload)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
948 function zoomArea() {dl.zoomArea()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
949 function zoomBy(factor) {dl.zoomBy(factor)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
950 function zoomFullpage(a) {dl.zoomFullpage(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
951 function moveCenter(on) {dl.moveCenter(on)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
952 function isFullArea(area) {dl.isFullArea(area)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
953 function canMove(movx, movy) {dl.canMove(movx, movy)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
954 function moveBy(movx, movy) {dl.moveBy(movx, movy)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
955 function getRef(baseURL) {dl.getRef(baseURL)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
956 function getRefWin(type, msg) {dl.getRefWin(type, msg)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
957 function getQuality() {dl.getQuality()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
958 function setQuality(qual) {dl.setQuality(qual)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
959 function setQualityWin(msg) {dl.setQualityWin(msg)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
960 function mirror(dir) {dl.mirror(dir)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
961 function gotoPage(gopage, keep) {dl.gotoPage(gopage, keep)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
962 function gotoPageWin() {dl.gotoPageWin()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
963 function setParamWin(param, text, relative) {dl.setParamWin(param, text, relative)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
964 function showOptions(show) {dl.showOptions(show)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
965 function showBirdDiv(show) {dl.showBirdDiv(show)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
966 function showAboutDiv(show) {dl.showAboutDiv(show)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
967 function calibrate(direction) {dl.calibrate(direction)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
968 function setScale(a) {dl.setScale(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
969 function getScale(a) {dl.getScale(a)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
970 function originalSize(on) {dl.originalSize(on)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
971 function pixelByPixel(on) {dl.pixelByPixel(on)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
972 function pageWidth() {dl.pageWidth()}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
973 function setSize(factor) {dl.setSize(factor)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
974 function showMenu(a,b,c) {dl.showMenu(a,b,c)}; |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
975 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
976 |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
977 // :tabSize=4:indentSize=4:noTabs=true: |
7ef10557a819
Fixed a bug when the clicked zoom area was too small
hertzhaft
parents:
479
diff
changeset
|
978 |