annotate webapp/src/main/webapp/jquery/jquery.digilib.annotator.js @ 1118:f0474c1faaff

trying new annotator authentication.
author robcast
date Tue, 06 Nov 2012 18:24:39 +0100
parents 08206603c7dc
children 036efe7361c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
1 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
2 digilib plugin for annotations.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
3
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
4 currently only point-like annotations (like marks).
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
5
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
6 Annotations are stored on a Annotator http://annotateit.org compatible server.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
7
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
8 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
9
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
10 (function($) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
11
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
12 // affine geometry
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
13 var geom = null;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
14 // plugin object with digilib data
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
15 var digilib = null;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
16
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
17 var buttons = {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
18 annotations : {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
19 onclick : "toggleAnnotations",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
20 tooltip : "show or hide annotations",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
21 icon : "annotations.png"
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
22 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
23 annotationuser : {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
24 onclick : "setAnnotationUser",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
25 tooltip : "set user account for annotations",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
26 icon : "annotation-user.png"
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
27 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
28 annotationmark : {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
29 onclick : "setAnnotationMark",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
30 tooltip : "create an annotation for a point",
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
31 icon : "annotation-mark.png"
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
32 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
33 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
34
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
35 var defaults = {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
36 // are annotations active?
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
37 'isAnnotationsVisible' : true,
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
38 // buttonset of this plugin
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
39 'annotationSet' : ['annotations', 'annotationuser', 'annotationmark', 'lessoptions'],
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
40 // URL of annotation server
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
41 'annotationServerUrl' : 'http://virtuoso.mpiwg-berlin.mpg.de:8080/AnnotationManager/annotator',
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
42 // URL of authentication token server
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
43 'annotationTokenUrl' : 'http://localhost:8080/test/annotator/token',
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
44 // annotation user name
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
45 'annotationUser' : 'anonymous',
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
46 // function to translate user name from annotation server format
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
47 'annotationServerUserString' : function() {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
48 if (this.user && this.user.name) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
49 return this.user.name;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
50 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
51 return this.user;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
52 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
53
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
54 // Annotator plugin settings (some values provided in handleSetup)
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
55 'annotatorPlugins' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
56 //'Tags' : {},
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
57 'Auth' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
58 //token : data.annotationToken
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
59 //tokenUrl: data.settings.annotationTokenUrl
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
60 autoFetch: true,
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
61 requestMethod: 'POST',
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
62 requestData: {
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
63 //'user': data.settings.annotationUser,
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
64 //'password': data.annotationPassword
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
65 }
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
66 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
67 'Permissions' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
68 //user: data.settings.annotationUser,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
69 userString : function(user) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
70 if (user && user.name) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
71 return user.name;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
72 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
73 return user;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
74 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
75 userId: function (user) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
76 if (user && user.id) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
77 return user.id;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
78 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
79 return user;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
80 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
81 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
82 'Store' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
83 //prefix : data.settings.annotationServerUrl,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
84 annotationData: {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
85 //'uri': getAnnotationPageUrl()
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
86 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
87 loadFromSearch: {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
88 'limit': 20,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
89 //'uri': getAnnotationPageUrl()
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
90 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
91 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
92 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
93
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
94 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
95
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
96 var actions = {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
97 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
98 * show/hide annotations
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
99 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
100 toggleAnnotations : function (data) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
101 var show = !data.settings.isAnnotationsVisible;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
102 data.settings.isAnnotationsVisible = show;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
103 digilib.fn.highlightButtons(data, 'annotations', show);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
104 renderAnnotations(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
105 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
106
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
107 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
108 * set user account for annotations
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
109 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
110 setAnnotationUser : function (data, user, password) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
111 var settings = data.settings;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
112 if (user == null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
113 // user name entered in JS-prompt
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
114 user = window.prompt("User name:", settings.annotationUser);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
115 if (user != null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
116 // password entered in JS-prompt
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
117 password = window.prompt("Password:", '');
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
118 settings.annotationUser = user;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
119 data.dlOpts.annotationUser = user;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
120 digilib.fn.storeOptions(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
121 loadAnnotationToken(data, password);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
122 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
123 } else {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
124 settings.annotationUser = user;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
125 data.dlOpts.annotationUser = user;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
126 digilib.fn.storeOptions(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
127 loadAnnotationToken(data, password);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
128 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
129 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
130
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
131 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
132 * set a mark-annotation by clicking (or giving a position and a text)
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
133 *
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
134 * @param data
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
135 * @param mpos
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
136 * @param text
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
137 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
138 setAnnotationMark : function (data, mpos, text) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
139 if (mpos == null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
140 // interactive
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
141 setAnnotationMark(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
142 } else {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
143 // use position and text (and user-id)
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
144 console.error("Currently only interactive annotations!");
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
145 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
146 },
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
147 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
148
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
149 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
150 * returns an annotatable url to this digilib image
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
151 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
152 var getAnnotationPageUrl = function(data) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
153 var url = data.settings.digilibBaseUrl + '/jquery/digilib.html?';
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
154 url += digilib.fn.getParamString(data.settings, ['fn', 'pn'], digilib.defaults);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
155 return url;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
156 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
157
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
158 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
159 * add a mark-annotation where clicked.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
160 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
161 var setAnnotationMark = function(data) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
162 var $scaler = data.$scaler;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
163 // unbind other handler TODO: do we need to do this?
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
164 $scaler.off(".dlZoomDrag");
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
165 // start event capturing
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
166 $scaler.one('mousedown.dlSetAnnotationMark', function(evt) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
167 // event handler adding a new mark
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
168 console.log("setAnnotationMark at=", evt);
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
169 var annotator = data.annotator;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
170 var mpos = geom.position(evt);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
171 var pos = data.imgTrafo.invtransform(mpos);
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
172 // mark selected areas
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
173 annotator.selectedAreas = [geom.rectangle(pos)];
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
174 // create and edit new annotation
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
175 var annotation = annotator.createAnnotation();
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
176 annotator.showEditor(annotation, mpos.getAsCss());
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
177 return false;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
178 });
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
179 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
180
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
181 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
182 * place annotations on the image
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
183 */
1114
1525c820ee27 annotator annotations even show up now.
casties
parents: 1113
diff changeset
184 var renderAnnotations = function (data) {
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
185 console.debug("renderAnnotations!");
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
186 if (data.annotations == null || data.annotator == null || data.$img == null || data.imgTrafo == null)
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
187 return;
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
188 var annotations = data.annotations;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
189 var cssPrefix = data.settings.cssPrefix;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
190 var $elem = data.$elem;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
191 // try to show annotation user state
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
192 $elem.find('div#'+cssPrefix+'button-annotationuser').attr('title', 'annotation user: '+data.settings.annotationUser);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
193 // clear annotations
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
194 $elem.find('div.' + cssPrefix + 'annotationmark').remove();
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
195 if (!data.settings.isAnnotationsVisible) return;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
196 for (var i = 0; i < annotations.length; i++) {
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
197 renderAnnotation(data, annotations[i]);
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
198 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
199 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
200
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
201 /**
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
202 * place single annotation on the image
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
203 */
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
204 var renderAnnotation = function (data, annot) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
205 console.debug("renderAnnotation: annotation=", annot);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
206 if (annot == null || annot.annotation == null || annot.annotation.areas == null
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
207 || data.$img == null || data.imgTrafo == null)
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
208 return;
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
209 if (!data.settings.isAnnotationsVisible) return;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
210 var cssPrefix = data.settings.cssPrefix;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
211 var $elem = data.$elem;
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
212 var annotator = data.annotator;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
213 var annotation = annot.annotation;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
214 var idx = annot.idx ? annot.idx : '?';
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
215 var pos = geom.position(annotation.areas[0]);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
216 if (data.zoomArea.containsPosition(pos)) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
217 var mpos = data.imgTrafo.transform(pos);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
218 console.debug("renderannotations: pos=", mpos);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
219 // create annotation
1114
1525c820ee27 annotator annotations even show up now.
casties
parents: 1113
diff changeset
220 var html = '<div class="'+cssPrefix+'annotationmark '+cssPrefix+'overlay annotator-hl">'+idx+'</div>';
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
221 var $annotation = $(html);
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
222 // save annotation in data for Annotator
1114
1525c820ee27 annotator annotations even show up now.
casties
parents: 1113
diff changeset
223 $annotation.data('annotation', annotation);
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
224 // save reference to div
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
225 annot.$div = $annotation;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
226 $elem.append($annotation);
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
227 // hook up Annotator events
1114
1525c820ee27 annotator annotations even show up now.
casties
parents: 1113
diff changeset
228 $annotation.on("mouseover", annotator.onHighlightMouseover);
1525c820ee27 annotator annotations even show up now.
casties
parents: 1113
diff changeset
229 $annotation.on("mouseout", annotator.startViewerHideTimer);
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
230 mpos.adjustDiv($annotation);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
231 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
232 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
233
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
234 /**
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
235 * returns setupAnnotation function using the given data.
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
236 */
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
237 var getSetupAnnotation = function(data) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
238 return function (annotation) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
239 // create annotation wrapper
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
240 var ann = {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
241 'annotation' : annotation,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
242 'idx' : data.annotations.length+1
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
243 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
244 // add to list
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
245 data.annotations.push(ann);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
246 // render this annotation
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
247 renderAnnotation(data, ann);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
248 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
249 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
250
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
251 /**
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
252 * returns annotationDeleted function using the given data.
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
253 */
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
254 var getAnnotationDeleted = function(data) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
255 return function (annotation) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
256 // remove annotation mark
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
257 var annots = data.annotations;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
258 for (var i = 0; i < annots.length; ++i) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
259 var annot = annots[i];
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
260 if (annot.annotation === annotation) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
261 // this is the right wrapper
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
262 if (annot.$div != null) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
263 // remove from screen
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
264 annot.$div.remove();
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
265 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
266 // remove from list
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
267 delete annots[i];
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
268 break;
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
269 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
270 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
271 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
272 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
273
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
274 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
275 * Get an authentication token from the token server.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
276 *
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
277 * Stores the token and loads annotations on success.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
278 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
279 var loadAnnotationToken = function(data, password) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
280 var settings = data.settings;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
281 var url = settings.annotationTokenUrl;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
282 var params = {'user': settings.annotationUser};
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
283 if (password != null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
284 params.password = password;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
285 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
286 // TODO: better error handling
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
287 $.post(url, params)
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
288 .done(function (authToken, authStatus) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
289 console.debug("got auth token data=", authToken);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
290 data.annotationToken = authToken;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
291 data.dlOpts.annotationToken = authToken;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
292 digilib.fn.storeOptions(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
293 //loadAnnotations(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
294 })
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
295 .fail(function (xhr, status) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
296 console.error("got auth token error:", xhr);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
297 data.annotationToken = null;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
298 data.settings.annotationUser = "anonymous";
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
299 //loadAnnotations(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
300 });
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
301 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
302
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
303 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
304 * install additional buttons
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
305 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
306 var installButtons = function(data) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
307 var settings = data.settings;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
308 var mode = settings.interactionMode;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
309 var buttonSettings = settings.buttonSettings[mode];
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
310 // configure buttons through digilib "annotationSet" option
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
311 var buttonSet = settings.annotationSet || annotationSet;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
312 // set annotationSet to [] or '' for no buttons (when showing annotations only)
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
313 if (buttonSet.length && buttonSet.length > 0) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
314 buttonSettings.annotationSet = buttonSet;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
315 buttonSettings.buttonSets.push('annotationSet');
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
316 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
317 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
318
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
319 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
320 * plugin installation. called by digilib on plugin object.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
321 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
322 var install = function(plugin) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
323 digilib = plugin;
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
324 console.debug('installing annotator plugin. digilib:', digilib);
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
325 // import geometry classes
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
326 geom = digilib.fn.geometry;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
327 FULL_AREA = geom.rectangle(0, 0, 1, 1);
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
328 // add defaults, actions, buttons
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
329 $.extend(digilib.defaults, defaults);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
330 $.extend(digilib.actions, actions);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
331 $.extend(digilib.buttons, buttons);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
332 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
333
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
334 /** plugin initialization */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
335 var init = function(data) {
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
336 console.debug('initialising annotator plugin. data:', data);
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
337 var $data = $(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
338 // set up
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
339 data.annotations = [];
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
340 if (digilib.plugins.buttons != null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
341 installButtons(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
342 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
343 if (data.dlOpts.annotationUser != null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
344 // get annotation user from cookie
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
345 data.settings.annotationUser = data.dlOpts.annotationUser;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
346 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
347 if (data.dlOpts.annotationToken != null) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
348 // get annotation token from cookie
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
349 data.annotationToken = data.dlOpts.annotationToken;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
350 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
351 // install event handler
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
352 $data.bind('setup', handleSetup);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
353 $data.bind('update', handleUpdate);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
354 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
355
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
356 /**
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
357 * setup creates Annotator object.
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
358 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
359 var handleSetup = function(evt) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
360 console.debug("annotations: handleSetup");
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
361 var data = this;
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
362 /* if (data.annotationToken == null) {
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
363 loadAnnotationToken(data);
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
364 } */
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
365 // set up annotator (after html has been set up)
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
366 var uri = getAnnotationPageUrl(data);
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
367 var annotator = new Annotator(data.$elem.get(0));
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
368 // set plugin parameters
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
369 var pluginParams = {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
370 'Auth' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
371 'token' : data.annotationToken,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
372 'tokenUrl' : data.settings.annotationTokenUrl,
1118
f0474c1faaff trying new annotator authentication.
robcast
parents: 1116
diff changeset
373 'autoFetch' : true
1116
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
374 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
375 'Permissions' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
376 'user' : data.settings.annotationUser
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
377 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
378 'Store' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
379 'prefix' : data.settings.annotationServerUrl,
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
380 'annotationData' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
381 'uri': uri
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
382 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
383 'loadFromSearch' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
384 'uri': uri
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
385 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
386 },
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
387 'DigilibIntegrator' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
388 'hooks' : {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
389 'setupAnnotation' : getSetupAnnotation(data),
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
390 'annotationDeleted' : getAnnotationDeleted(data)
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
391 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
392 }
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
393 };
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
394 // merge with settings
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
395 $.extend(true, pluginParams, data.settings.annotatorPlugins);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
396 // add plugins
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
397 $.each(pluginParams, function (name, params) {
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
398 console.debug("plugin:", name, params);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
399 annotator.addPlugin(name, params);
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
400 });
08206603c7dc annotations use new Annotator-digilibintegration plugin.
robcast
parents: 1115
diff changeset
401 // save annotator reference
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
402 data.annotator = annotator;
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
403 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
404
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
405 /**
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
406 * update renders all annotations.
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
407 */
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
408 var handleUpdate = function(evt) {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
409 console.debug("annotations: handleUpdate");
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
410 var data = this;
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
411 renderAnnotations(data);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
412 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
413
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
414 // plugin object with name and init
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
415 // shared objects filled by digilib on registration
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
416 var plugin = {
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
417 name : 'annotator',
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
418 install : install,
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
419 init : init,
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
420 buttons : {},
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
421 actions : {},
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
422 fn : {},
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
423 plugins : {}
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
424 };
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
425
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
426 if ($.fn.digilib == null) {
1115
526dafa4690d using annotator in digilib works now. code still ugly.
robcast
parents: 1114
diff changeset
427 $.error("jquery.digilib.annotator must be loaded after jquery.digilib!");
1113
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
428 } else {
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
429 $.fn.digilib('plugin', plugin);
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
430 }
7affda55c10e using annotator in digilib works somewhat now.
robcast
parents:
diff changeset
431 })(jQuery);