comparison webapp/src/main/webapp/jquery/jquery.digilib.annotator.js @ 1114:1525c820ee27

annotator annotations even show up now.
author casties
date Fri, 02 Nov 2012 10:51:57 +0100
parents 7affda55c10e
children 526dafa4690d
comparison
equal deleted inserted replaced
1113:7affda55c10e 1114:1525c820ee27
175 }; 175 };
176 176
177 /** 177 /**
178 * place annotations on the image 178 * place annotations on the image
179 */ 179 */
180 var renderAnnotations = function(data) { 180 var renderAnnotations = function (data) {
181 console.debug("renderAnnotations: annotator=", annotator); 181 console.debug("renderAnnotations: annotator=", annotator);
182 if (annotator == null || data.$img == null || data.imgTrafo == null) 182 if (annotator == null || data.$img == null || data.imgTrafo == null)
183 return; 183 return;
184 var annotations = annotator.plugins['Store'].annotations; 184 var annotations = annotator.plugins['Store'].annotations;
185 var cssPrefix = data.settings.cssPrefix; 185 var cssPrefix = data.settings.cssPrefix;
189 // clear annotations 189 // clear annotations
190 $elem.find('div.' + cssPrefix + 'annotationmark').remove(); 190 $elem.find('div.' + cssPrefix + 'annotationmark').remove();
191 if (!data.settings.isAnnotationsVisible) return; 191 if (!data.settings.isAnnotationsVisible) return;
192 for (var i = 0; i < annotations.length; i++) { 192 for (var i = 0; i < annotations.length; i++) {
193 var annotation = annotations[i]; 193 var annotation = annotations[i];
194 renderAnnotation(data, annotation); 194 renderAnnotation(data, annotation, i+1);
195 } 195 }
196 }; 196 };
197 197
198 /** 198 /**
199 * place annotation on the image 199 * place annotation on the image
200 */ 200 */
201 var renderAnnotation = function(data, annotation) { 201 var renderAnnotation = function (data, annotation, idx) {
202 console.debug("renderAnnotation: annotation=", annotation); 202 console.debug("renderAnnotation: annotation=", annotation);
203 if (annotation == null || data.$img == null || data.imgTrafo == null) 203 if (annotation == null || data.$img == null || data.imgTrafo == null)
204 return; 204 return;
205 var cssPrefix = data.settings.cssPrefix; 205 var cssPrefix = data.settings.cssPrefix;
206 var $elem = data.$elem; 206 var $elem = data.$elem;
207 if (idx == null) idx = '?';
207 // try to show annotation user state 208 // try to show annotation user state
208 $elem.find('div#'+cssPrefix+'button-annotationuser').attr('title', 'annotation user: '+data.settings.annotationUser); 209 $elem.find('div#'+cssPrefix+'button-annotationuser').attr('title', 'annotation user: '+data.settings.annotationUser);
209 if (!data.settings.isAnnotationsVisible) return; 210 if (!data.settings.isAnnotationsVisible) return;
210 var pos = geom.position(annotation.areas[0]); 211 var pos = geom.position(annotation.areas[0]);
211 if (data.zoomArea.containsPosition(pos)) { 212 if (data.zoomArea.containsPosition(pos)) {
212 var mpos = data.imgTrafo.transform(pos); 213 var mpos = data.imgTrafo.transform(pos);
213 console.debug("renderannotations: pos=", mpos); 214 console.debug("renderannotations: pos=", mpos);
214 // create annotation 215 // create annotation
215 var html = '<div class="' + cssPrefix + 'annotationmark ' + cssPrefix + 'overlay">?</div>'; 216 var html = '<div class="'+cssPrefix+'annotationmark '+cssPrefix+'overlay annotator-hl">'+idx+'</div>';
217 var $annotation = $(html);
218 $annotation.data('annotation', annotation);
216 // set text as tooltip 219 // set text as tooltip
217 var $annotation = $(html); 220 //$annotation.attr('title', "Annotation: " + annotation.text);
218 $annotation.attr('title', "Annotation: " + annotation.text);
219 $elem.append($annotation); 221 $elem.append($annotation);
222 $annotation.on("mouseover", annotator.onHighlightMouseover);
223 $annotation.on("mouseout", annotator.startViewerHideTimer);
220 mpos.adjustDiv($annotation); 224 mpos.adjustDiv($annotation);
221 } 225 }
222 }; 226 };
223 227
224 /** 228 /**