image_annotation/commit

index fields on image id in global annotorious admin object ...

authorJacco van Ossenbruggen
Sun Sep 21 09:08:37 2014 +0200
committerJacco van Ossenbruggen
Sun Sep 21 09:08:37 2014 +0200
commit2183fb477edff99d810fa5d30dc5ef83cdb98495
tree8507a0facdb79b341aa5c253fd7ce998a30d5e64
parent7145cfca25097557302f3ed8f6ab6c5a60444b65
Diff style: patch stat
diff --git a/web/js/annotation.js b/web/js/annotation.js
index 8c39338..21d3d69 100644
--- a/web/js/annotation.js
+++ b/web/js/annotation.js
@@ -53,12 +53,15 @@ YUI.add('annotation', function(Y) {
 	    if (typeof(anno) != "undefined") {
 		this._anno = anno; // hack
 		var fieldsId = this.get('fieldsId');
+		var imageId  = this.get('imageId');
 		if (! anno.fields) anno.fields = {};
-		fields = anno.fields[fieldsId];
-		if (fields) 
+		if (! anno.fields[imageId]) anno.fields[imageId] = {};
+		var fields = anno.fields[imageId][fieldsId];
+		if (fields) {
 		    fields.push(this);
-		else
-		    anno.fields[fieldsId] = [this];
+		} else {
+		    anno.fields[imageId][fieldsId] = [this];
+		}
 	    }
 	    // handler to call when item selected from autocompletion suggestions:
 	    this.on("select", this.onItemSelect, this, null);
diff --git a/web/js/deniche-plugin.js b/web/js/deniche-plugin.js
index b5c416b..f871a24 100644
--- a/web/js/deniche-plugin.js
+++ b/web/js/deniche-plugin.js
@@ -45,8 +45,7 @@ annotorious.plugin.DenichePlugin = function(config) {
 	this._saveButtons = {};	 // we have multiple buttons if we have multiple images per page
 	this._cancelButtons = {};
 	// console.log(config);
-	if (config.yui_sandbox) 
-		this.Y = config.yui_sandbox;
+	if (config.yui_sandbox) this.Y = config.yui_sandbox;
 }
 
 annotorious.plugin.DenichePlugin.states = { EMPTY:'empty', SOME:'some' };
@@ -56,14 +55,15 @@ annotorious.plugin.DenichePlugin.prototype.onInitAnnotator = function(annotator)
     // move the cpack editor into the annotorious editor:
     var el =  annotator.element;
     var fieldsId = el.getElementsByTagName('img')[0].getAttribute('fields');
+    var imageId  = el.getElementsByTagName('img')[0].getAttribute('id');
     var fieldsEl = document.getElementById(fieldsId);
     annotator.editor.addField(fieldsEl);
-    
+
     // install all handlers on events created by annotorious:
     this.installHandlers();
 
     if (this._anno.fields) {
-	fields = this._anno.fields[fieldsId];
+	fields = this._anno.fields[imageId][fieldsId];
 	for(i in fields) {
 	    f = fields[i];
 	    if (f.get('lazy')) f.getTags();
@@ -90,11 +90,11 @@ annotorious.plugin.DenichePlugin.prototype.toggleButtons = function(state, field
 
 annotorious.plugin.DenichePlugin.prototype.filterTags = function(targetId, fieldsId) {
 	var oSelf = this;
-	var editor = oSelf.Y.one('.annotorious-editor');
+	var editor = this.Y.one('.annotorious-editor');
 	editor.on("key", oSelf.onFragmentCancel, "esc", oSelf);
 	var selector = '#'+ fieldsId + ' li.tagitem';
 	if (!fieldsId) selector = 'li.tagitem';
-	oSelf.Y.all(selector).each(function(tagNode) {
+	this.Y.all(selector).each(function(tagNode) {
 		if (targetId == tagNode.getAttribute('targetId')) {
 			editor.detach("key", oSelf.onFragmentCancel, "esc");
 			tagNode.show();