annotate client/digitallibrary/jquery/jquery.digilib.js @ 626:f2ab7d4eedc2 jquery

Merge with HEAD
author robcast
date Mon, 17 Jan 2011 22:10:12 +0100
parents 5f3564a21a9c 7d13b7e5140e
children c2566e470569
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
1 /*
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
2 * digilib jQuery plugin
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
3 *
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
4 */
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
5
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
6 (function($) {
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
7 var actions = {
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
8 reference : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
9 onclick : "javascript:getRefWin()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
10 tooltip : "get a reference URL",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
11 img : "reference.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
12 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
13 zoomin : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
14 onclick : "javascript:dl.zoomBy(1.4)",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
15 tooltip : "zoom in",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
16 img : "zoom-in.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
17 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
18 zoomout : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
19 onclick : "javascript:zoomBy(0.7)",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
20 tooltip : "zoom out",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
21 img : "zoom-out.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
22 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
23 zoomarea : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
24 onclick : "javascript:zoomArea()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
25 tooltip : "zoom area",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
26 img : "zoom-area.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
27 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
28 zoomfull : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
29 onclick : "javascript:zoomFullpage()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
30 tooltip : "view the whole image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
31 img : "zoom-full.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
32 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
33 pagewidth : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
34 onclick : "javascript:zoomFullpage('width')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
35 tooltip : "page width",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
36 img : "pagewidth.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
37 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
38 back : {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
39 onclick : ["gotoPage", "-1"],
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
40 tooltip : "goto previous image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
41 img : "back.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
42 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
43 fwd : {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
44 onclick : ["gotoPage", "+1"],
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
45 tooltip : "goto next image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
46 img : "fwd.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
47 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
48 page : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
49 onclick : "javascript:gotoPageWin()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
50 tooltip : "specify image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
51 img : "page.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
52 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
53 bird : {
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
54 onclick : "toggleBirdDiv",
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
55 tooltip : "show bird's eye view",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
56 img : "birds-eye.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
57 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
58 help : {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
59 onclick : "toggleAboutDiv",
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
60 tooltip : "about Digilib",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
61 img : "help.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
62 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
63 reset : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
64 onclick : "javascript:resetImage()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
65 tooltip : "reset image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
66 img : "reset.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
67 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
68 mark : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
69 onclick : "javascript:setMark()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
70 tooltip : "set a mark",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
71 img : "mark.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
72 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
73 delmark : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
74 onclick : "javascript:removeMark()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
75 tooltip : "delete the last mark",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
76 img : "delmark.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
77 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
78 hmir : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
79 onclick : "javascript:mirror('h')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
80 tooltip : "mirror horizontally",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
81 img : "mirror-horizontal.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
82 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
83 vmir : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
84 onclick : "javascript:mirror('v')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
85 tooltip : "mirror vertically",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
86 img : "mirror-vertical.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
87 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
88 rot : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
89 onclick : "javascript:setParamWin('rot', 'Rotate (0..360) clockwise')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
90 tooltip : "rotate image",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
91 img : "rotate.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
92 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
93 brgt : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
94 onclick : "javascript:setParamWin('brgt', 'Brightness (-255..255)')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
95 tooltip : "set brightness",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
96 img : "brightness.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
97 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
98 cont : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
99 onclick : "javascript:setParamWin('cont', 'Contrast (0..8)')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
100 tooltip : "set contrast",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
101 img : "contrast.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
102 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
103 rgb : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
104 onclick : "javascript:setParamWin('rgb', '...')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
105 tooltip : "set rgb values",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
106 img : "rgb.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
107 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
108 quality : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
109 onclick : "javascript:setQualityWin('Quality (0..2)')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
110 tooltip : "set image quality",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
111 img : "quality.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
112 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
113 size : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
114 onclick : "javascript:toggleSizeMenu()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
115 tooltip : "set page size",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
116 img : "size.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
117 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
118 calibrationx : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
119 onclick : "javascript:calibrate('x')",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
120 tooltip : "calibrate screen x-ratio",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
121 img : "calibration-x.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
122 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
123 scale : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
124 onclick : "javascript:toggleScaleMenu()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
125 tooltip : "change image scale",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
126 img : "original-size.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
127 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
128 options : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
129 onclick : "javascript:toggleOptionDiv()",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
130 tooltip : "hide options",
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
131 img : "options.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
132 },
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
133 SEP : {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
134 img : "sep.png"
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
135 }
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
136 };
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
137
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
138 var defaults = {
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
139 // the root digilib element, for easy retrieval
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
140 'digilibRoot' : null,
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
141 // version of this script
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
142 'version' : 'jquery.digilib.js 1.0',
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
143 // logo url
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
144 'logoUrl' : '../img/digilib-logo-text1.png',
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
145 // repository url
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
146 'reposUrl' : 'http://digilib.berlios.de',
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
147 // base URL to Scaler servlet
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
148 'scalerBaseUrl' : 'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler',
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
149 // list of Scaler parameters
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
150 'scalerParamNames' : ['fn','pn','dw','dh','ww','wh','wx','wy','ws','mo',
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
151 'rot','cont','brgt','rgbm','rgba','ddpi','ddpix','ddpiy'],
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
152 // mode of operation.
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
153 // fullscreen: takes parameters from page URL, keeps state in page URL
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
154 // embedded: takes parameters from Javascript options, keeps state inside object
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
155 'interactionMode' : 'fullscreen',
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
156 // actions
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
157 'actions' : actions,
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
158 // path to button images (must end with a slash)
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
159 'buttonsImagePath' : '../greyskin/',
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
160 // actions groups
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
161 'actionsStandard' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","bird","SEP","help","reset","options"],
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
162 'actionsSpecial' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","SEP","options"],
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
163 'actionsCustom' : [],
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
164 // is birdView shown?
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
165 'isBirdDivVisible' : false,
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
166 // dimensions of bird's eye window
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
167 'birdMaxX' : 200,
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
168 'birdMaxY' : 200,
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
169 // is the "about" window shown?
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
170 'isAboutDivVisible' : false
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
171
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
172 };
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
173
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
174 // parameters from the query string
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
175 var queryParams = {};
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
176
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
177 // affine geometry classes
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
178 var geom = dlGeometry();
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
179
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
180 var methods = {
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
181 // digilib initialization
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
182 init : function(options) {
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
183 // settings for this digilib instance are merged from defaults and options
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
184 var settings = $.extend({}, defaults, options);
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
185 var isFullscreen = settings.interactionMode === 'fullscreen';
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
186 if (isFullscreen) {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
187 queryParams = parseQueryParams();
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
188 };
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
189 return this.each(function() {
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
190 var $elem = $(this);
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
191 var data = $elem.data('digilib');
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
192 var elemSettings;
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
193 // if the plugin hasn't been initialized yet
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
194 if (!data) {
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
195 // merge query parameters
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
196 if (isFullscreen) {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
197 elemSettings = $.extend({}, settings, queryParams);
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
198 } else {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
199 elemSettings = $.extend({}, settings, parseImgParams($elem));
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
200 };
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
201 // store $(this) element in the settings
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
202 elemSettings.digilibRoot = $elem;
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
203 // store in data element
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
204 $elem.data('digilib', {
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
205 target : $elem,
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
206 settings : elemSettings
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
207 });
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
208 }
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
209 // create HTML structure
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
210 setupScalerDiv($elem, elemSettings);
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
211 setupButtons($elem, elemSettings, 'actionsStandard');
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
212 // bird's eye view creation - could be deferred?
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
213 setupBirdviewDiv($elem, elemSettings);
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
214 // about window creation - could be deferred? restrict to only one item?
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
215 setupAboutDiv($elem, elemSettings);
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
216 });
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
217 },
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
218
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
219 // clean up digilib
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
220 destroy : function() {
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
221 return this.each(function(){
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
222 var $this = $(this);
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
223 var data = $this.data('digilib');
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
224 // Namespacing FTW
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
225 $(window).unbind('.digilib'); // unbinds all digilibs(?)
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
226 data.digilib.remove();
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
227 $this.removeData('digilib');
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
228 });
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
229 },
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
230
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
231 // event handler: toggles the visibility of the 'about' window
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
232 toggleAboutDiv : function () {
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
233 var $elem = $(this); // the clicked button
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
234 var settings = $elem.data('digilib').settings;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
235 var $root = settings.digilibRoot;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
236 var $about = $root.find('div.about');
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
237 settings.isAboutDivVisible = !settings.isAboutDivVisible;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
238 if (settings.isAboutDivVisible) {
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
239 $about.fadeIn();
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
240 } else {
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
241 $about.fadeOut();
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
242 };
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
243 return false;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
244 },
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
245
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
246 // event handler: toggles the visibility of the bird's eye window
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
247 toggleBirdDiv : function () {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
248 // TODO: red frame functionality
617
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
249 var $elem = $(this); // the clicked button
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
250 var settings = $elem.data('digilib').settings;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
251 var $root = settings.digilibRoot;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
252 var $bird = $root.find('div.birdview');
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
253 settings.isBirdDivVisible = !settings.isBirdDivVisible;
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
254 if (settings.isBirdDivVisible) {
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
255 $bird.fadeIn();
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
256 } else {
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
257 $bird.fadeOut();
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
258 };
cd846b5c8be8 toggle view event handlers for bird's eye and 'about windows
hertzhaft
parents: 616
diff changeset
259 return false;
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
260 },
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
261
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
262 // goto given page nr (+/-: relative)
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
263 gotoPage : function(pageNr, keepMarks) {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
264 var $elem = $(this); // the clicked button
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
265 var settings = $elem.data('digilib').settings;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
266 var oldpn = settings.pn;
624
7d13b7e5140e small retouches
hertzhaft
parents: 623
diff changeset
267 var pn = setNumValue(settings, "pn", pageNr);
7d13b7e5140e small retouches
hertzhaft
parents: 623
diff changeset
268 if (pn == null) return false; // nothing happened
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
269 if (pn < 1) {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
270 alert("no such page (page number too low)");
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
271 settings.pn = oldpn;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
272 return false;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
273 };
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
274 if (settings.pt) {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
275 if (pn > settings.pt) {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
276 alert("no such page (page number too high)");
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
277 settings.pn = oldpn;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
278 return false;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
279 }
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
280 };
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
281 // TODO: keepMarks
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
282 var $root = settings.digilibRoot;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
283 var $img = $root.find('img.pic');
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
284 display($img, settings);
624
7d13b7e5140e small retouches
hertzhaft
parents: 623
diff changeset
285 return false;
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
286 }
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
287 };
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
288
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
289 // sets a key to a value (relative values with +/- if relative=true)
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
290 var setNumValue = function(settings, key, value) {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
291 // TODO: type and error checking
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
292 if (settings[key] == null) return null;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
293 var sign = value.substring(0,1);
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
294 if (sign === '+' || sign === '-') {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
295 settings[key] = parseFloat(settings[key]) + parseFloat(value);
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
296 } else {
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
297 settings[key] = value;
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
298 }
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
299 return settings[key];
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
300 };
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
301
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
302 // returns parameters from page url
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
303 var parseQueryParams = function() {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
304 return parseQueryString(location.search.slice(1));
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
305 };
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
306
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
307 // returns parameters taken from embedded img-element
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
308 var parseImgParams = function($elem) {
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
309 var src = $elem.find('img').first().attr('src');
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
310 if (!src) {
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
311 return null;
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
312 }
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
313 var pos = src.indexOf('?');
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
314 var query = (pos < 0) ? '' : src.substring(pos + 1);
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
315 var scalerUrl = src.substring(0, pos);
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
316 var hash = parseQueryString(query);
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
317 hash.scalerBaseUrl = scalerUrl;
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
318 // console.log(hash);
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
319 return hash;
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
320 };
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
321
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
322 // parses query parameter string into parameter object
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
323 var parseQueryString = function(query) {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
324 var pairs = query.split("&");
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
325 var hash = {};
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
326 for (var i = 0; i < pairs.length; i++) {
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
327 var pair = pairs[i].split("=");
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
328 if (pair.length === 2) {
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
329 hash[pair[0]] = pair[1];
607
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
330 };
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
331 };
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
332 return hash;
f5d5cae64828 parameter parsing
hertzhaft
parents: 605
diff changeset
333 };
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
334
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
335 // returns a query string from key names from a parameter hash
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
336 var makeParamString = function (settings, keys) {
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
337 var paramString = '';
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
338 var latter = false;
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
339 for (i = 0; i < keys.length; ++i) {
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
340 var key = keys[i];
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
341 if (settings[key]) {
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
342 // first param gets no '&'
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
343 paramString += latter ? '&' : '';
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
344 latter = true;
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
345 // add parm=val
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
346 paramString += key + '=' + settings[key];
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
347 };
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
348 }
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
349 return paramString;
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
350 };
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
351
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
352 // returns URL and query string for Scaler
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
353 var getScalerString = function (settings) {
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
354 var keys = settings.scalerParamNames;
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
355 var queryString = makeParamString(settings, keys);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
356 var url = settings.scalerBaseUrl + '?' + queryString;
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
357 return url;
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
358 };
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
359
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
360 // returns maximum size for scaler img in fullscreen mode
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
361 var getFullscreenImgSize = function($elem) {
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
362 var winH = $(window).height();
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
363 var winW = $(window).width();
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
364 // TODO: account for borders?
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
365 return geom.size(winW, winH);
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
366 };
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
367
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
368 // (re)load the img from a new scaler URL
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
369 var display = function ($img, settings) {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
370 // TODO: update location.href (browser URL) in fullscreen mode
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
371 var scalerUrl = getScalerString(settings);
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
372 $img.attr('src', scalerUrl);
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
373 // TODO: update bird view?
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
374 };
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
375
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
376 // creates HTML structure for digilib in elem
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
377 var setupScalerDiv = function ($elem, settings) {
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
378 var $img;
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
379 if (settings.interactionMode === 'fullscreen') {
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
380 // fullscreen
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
381 var imgSize = getFullscreenImgSize($elem);
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
382 settings.dw = imgSize.width;
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
383 settings.dh = imgSize.height;
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
384 $img = $('<img/>');
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
385 display($img, settings);
609
435f81210a33 start work on scaler call
robcast
parents: 608
diff changeset
386 } else {
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
387 // embedded mode -- try to keep img tag
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
388 $img = $elem.find('img');
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
389 if ($img.length > 0) {
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
390 console.debug("img detach:",$img);
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
391 $img.detach();
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
392 } else {
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
393 $img = $('<img/>');
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
394 display($img, settings);
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
395 }
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
396 }
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
397 // create new html
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
398 $elem.empty(); // TODO: should we keep stuff for customization?
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
399 var $scaler = $('<div class="scaler"/>');
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
400 $elem.append($scaler);
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
401 $scaler.append($img);
622
cc3d81f02d4e factored out display function
hertzhaft
parents: 621
diff changeset
402 $img.addClass('pic');
623
7ba95f12d172 first attempt at switching images by page number
hertzhaft
parents: 622
diff changeset
403 $img.load(scalerImgLoadedFn(settings));
608
774a3f60efd5 start work on scaler call
robcast
parents: 607
diff changeset
404 };
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
405
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
406 // creates HTML structure for buttons in elem
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
407 var setupButtons = function ($elem, settings, actionGroup) {
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
408 if (settings.interactionMode === 'fullscreen') {
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
409 // fullscreen -- create new
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
410 var $buttonsDiv = $('<div class="buttons"></div>');
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
411 $elem.append($buttonsDiv);
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
412 var actionNames = settings[actionGroup];
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
413 for (var i = 0; i < actionNames.length; i++) {
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
414 var actionName = actionNames[i];
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
415 var actionSettings = settings.actions[actionName];
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
416 // construct the button html
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
417 var $button = $('<div class="button"></div>');
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
418 var $a = $('<a/>');
614
0bd19b6cede4 highlight hovered buttons
hertzhaft
parents: 613
diff changeset
419 var $img = $('<img class="button"/>');
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
420 $buttonsDiv.append($button);
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
421 $button.append($a);
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
422 $a.append($img);
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
423 // add attributes and bindings
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
424 $button.attr('title', actionSettings.tooltip);
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
425 $button.addClass('button-' + actionName);
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
426 // let the clicked <a> element know about the digilib context
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
427 $a.data('digilib', { 'action' : actionName, 'settings' : settings } );
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
428 $a.bind('click', function() {
619
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
429 var $elem = $(this);
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
430 // get the context data
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
431 var data = $elem.data('digilib');
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
432 // find the action for the clicked element
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
433 var method = data.settings.actions[data.action].onclick;
619
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
434 if ($.isArray(method)) {
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
435 $elem.digilib.apply(this, method);
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
436 } else {
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
437 $elem.digilib(method);
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
438 };
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
439 console.log(method);
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
440 });
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
441 // binding mit closure
619
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
442 //(function(){ var action = actionSettings.onclick;
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
443 // $a.bind('click', function(){ console.log( action )} );
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
444 //})();
618
09167ef1512e some refactoring, onclick handlers now work with arguments
hertzhaft
parents: 617
diff changeset
445 $img.attr('src', settings.buttonsImagePath + actionSettings.img);
611
1b6202aba26e work on button creation
robcast
parents: 610
diff changeset
446 };
1b6202aba26e work on button creation
robcast
parents: 610
diff changeset
447 }
612
fb94f1b74d59 bind data and actions to buttons
hertzhaft
parents: 611
diff changeset
448 return $buttonsDiv;
610
cd9f657d49fa code for generating the buttons
hertzhaft
parents: 609
diff changeset
449 };
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
450
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
451 // creates HTML structure for the bird's eye view in elem
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
452 var setupBirdviewDiv = function ($elem, settings) {
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
453 // use only the relevant parameters
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
454 var keys = ['fn','pn','dw','dh'];
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
455 var birdDimensions = {
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
456 'dw' : settings.birdMaxX,
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
457 'dh' : settings.birdMaxY
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
458 };
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
459 var birdSettings = $.extend({}, settings, birdDimensions);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
460 var birdUrl = settings.scalerBaseUrl + '?' + makeParamString(birdSettings, keys);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
461 // the bird's eye div
625
5f3564a21a9c small merge and fix
robcast
parents: 619 620
diff changeset
462 var $birdviewDiv = $('<div class="birdview" style="display:none"/>');
615
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
463 // the detail indicator frame
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
464 var $birdzoomDiv = $('<div class="birdzoom"/>');
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
465 // the small image
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
466 var $birdImg = $('<img class="birdimg"/>');
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
467 $elem.append($birdviewDiv);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
468 $birdviewDiv.append($birdzoomDiv);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
469 $birdviewDiv.append($birdImg);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
470 $birdImg.attr('src', birdUrl);
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
471 };
ec131e9699a6 setup bird's eye view div
hertzhaft
parents: 614
diff changeset
472
625
5f3564a21a9c small merge and fix
robcast
parents: 619 620
diff changeset
473 // creates HTML structure for the about view in elem
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
474 var setupAboutDiv = function ($elem, settings) {
625
5f3564a21a9c small merge and fix
robcast
parents: 619 620
diff changeset
475 var $aboutDiv = $('<div class="about" style="display:none"/>');
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
476 var $header = $('<p>Digilib Graphic Viewer</p>');
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
477 var $link = $('<a/>');
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
478 var $logo = $('<img class="logo" title="digilib"/>');
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
479 var $content = $('<p/>');
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
480 $elem.append($aboutDiv);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
481 $aboutDiv.append($header);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
482 $aboutDiv.append($link);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
483 $aboutDiv.append($content);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
484 $link.append($logo);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
485 $logo.attr('src', settings.logoUrl);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
486 $link.attr('href', settings.reposUrl);
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
487 $content.text('Version: ' + settings.version);
619
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
488 // let the element know about the digilib context
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
489 $aboutDiv.data('digilib', { 'settings' : settings } );
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
490 $aboutDiv.bind('click', function() {
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
491 console.log($(this));
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
492 $(this).digilib('toggleAboutDiv');
a473998de5f8 'about' window has its own event handler
hertzhaft
parents: 618
diff changeset
493 });
616
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
494 };
55e06ebb879f setup the 'about' window
hertzhaft
parents: 615
diff changeset
495
613
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
496 // returns function for load event of scaler img
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
497 var scalerImgLoadedFn = function(settings) {
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
498 return function() {
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
499 console.debug("img loaded! settings=", settings);
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
500 };
53ee659e2d00 keeping img tag for embedded mode seems to work now
robcast
parents: 612
diff changeset
501 };
605
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
502 // hook plugin into jquery
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
503 $.fn.digilib = function(method) {
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
504 if (methods[method]) {
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
505 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
506 } else if (typeof(method) === 'object' || !method) {
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
507 return methods.init.apply(this, arguments);
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
508 } else {
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
509 $.error( 'Method ' + method + ' does not exist on jQuery.digilib' );
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
510 }
aee94e4a8c48 next version zero of jquery.digilib
robcast
parents: 604
diff changeset
511 };
604
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
512
3a2942d2d5cd version zero of jquery.digilib
robcast
parents:
diff changeset
513 })(jQuery);