Gitlab CSE Unil

Commit d921fd04 authored by M. Chardon's avatar M. Chardon
Browse files

deselection de lelement si clique à côte

parent 7dde37e2
...@@ -1019,6 +1019,10 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1019,6 +1019,10 @@ Y.extend(ANNOTATION, Y.Base, {
}); });
this.drawable.shapes.push(shape); this.drawable.shapes.push(shape);
shape.editor = this.editor;
//shape.on('clickoutside', this.remove_selection, this);
shape.on('clickoutside', Y.rbind(this.editor.redraw_annotation, this.editor));
// Add a delete X to the annotation. // Add a delete X to the annotation.
var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'), var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'),
deletelink = Y.Node.create('<a href="#" role="button"></a>'); deletelink = Y.Node.create('<a href="#" role="button"></a>');
...@@ -1045,6 +1049,12 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1045,6 +1049,12 @@ Y.extend(ANNOTATION, Y.Base, {
} }
return this.drawable; return this.drawable;
}, },
remove_selection: function (e) {
Y.log('remove_selection');
if (this.drawable) {
this.drawable.erase();
}
},
/** /**
* Draw an annotation * Draw an annotation
* @public * @public
...@@ -5907,7 +5917,7 @@ EDITOR.prototype = { ...@@ -5907,7 +5917,7 @@ EDITOR.prototype = {
toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid); toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid);
toolnode.setAttribute('aria-pressed', 'false'); toolnode.setAttribute('aria-pressed', 'false');
}, this); }, this);
// Setup the tool buttons. // Setup the tool buttons.
Y.each(TOOLSELECTOR, function (selector, tool) { Y.each(TOOLSELECTOR, function (selector, tool) {
toolnode = this.get_dialogue_element(selector); toolnode = this.get_dialogue_element(selector);
...@@ -5974,15 +5984,7 @@ EDITOR.prototype = { ...@@ -5974,15 +5984,7 @@ EDITOR.prototype = {
} }
if (tool !== "select") { if (tool !== "select") {
this.currentannotation = null; this.redraw_annotation();
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
} }
if (!has_parent) { if (!has_parent) {
this.currentedit.parent_annot_element = null; this.currentedit.parent_annot_element = null;
...@@ -5990,6 +5992,17 @@ EDITOR.prototype = { ...@@ -5990,6 +5992,17 @@ EDITOR.prototype = {
this.refresh_button_state(); this.refresh_button_state();
}, },
redraw_annotation: function (e) {
this.currentannotation = null;
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
},
/** /**
* JSON encode the current page data - stripping out drawable references which cannot be encoded. * JSON encode the current page data - stripping out drawable references which cannot be encoded.
* @protected * @protected
......
...@@ -1019,6 +1019,10 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1019,6 +1019,10 @@ Y.extend(ANNOTATION, Y.Base, {
}); });
this.drawable.shapes.push(shape); this.drawable.shapes.push(shape);
shape.editor = this.editor;
//shape.on('clickoutside', this.remove_selection, this);
shape.on('clickoutside', Y.rbind(this.editor.redraw_annotation, this.editor));
// Add a delete X to the annotation. // Add a delete X to the annotation.
var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'), var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'),
deletelink = Y.Node.create('<a href="#" role="button"></a>'); deletelink = Y.Node.create('<a href="#" role="button"></a>');
...@@ -1045,6 +1049,11 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1045,6 +1049,11 @@ Y.extend(ANNOTATION, Y.Base, {
} }
return this.drawable; return this.drawable;
}, },
remove_selection: function (e) {
if (this.drawable) {
this.drawable.erase();
}
},
/** /**
* Draw an annotation * Draw an annotation
* @public * @public
...@@ -5900,7 +5909,7 @@ EDITOR.prototype = { ...@@ -5900,7 +5909,7 @@ EDITOR.prototype = {
toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid); toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid);
toolnode.setAttribute('aria-pressed', 'false'); toolnode.setAttribute('aria-pressed', 'false');
}, this); }, this);
// Setup the tool buttons. // Setup the tool buttons.
Y.each(TOOLSELECTOR, function (selector, tool) { Y.each(TOOLSELECTOR, function (selector, tool) {
toolnode = this.get_dialogue_element(selector); toolnode = this.get_dialogue_element(selector);
...@@ -5966,15 +5975,7 @@ EDITOR.prototype = { ...@@ -5966,15 +5975,7 @@ EDITOR.prototype = {
} }
if (tool !== "select") { if (tool !== "select") {
this.currentannotation = null; this.redraw_annotation();
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
} }
if (!has_parent) { if (!has_parent) {
this.currentedit.parent_annot_element = null; this.currentedit.parent_annot_element = null;
...@@ -5982,6 +5983,17 @@ EDITOR.prototype = { ...@@ -5982,6 +5983,17 @@ EDITOR.prototype = {
this.refresh_button_state(); this.refresh_button_state();
}, },
redraw_annotation: function (e) {
this.currentannotation = null;
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
},
/** /**
* JSON encode the current page data - stripping out drawable references which cannot be encoded. * JSON encode the current page data - stripping out drawable references which cannot be encoded.
* @protected * @protected
......
...@@ -478,6 +478,9 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -478,6 +478,9 @@ Y.extend(ANNOTATION, Y.Base, {
}); });
this.drawable.shapes.push(shape); this.drawable.shapes.push(shape);
shape.editor = this.editor;
shape.on('clickoutside', Y.rbind(this.editor.redraw_annotation, this.editor));
// Add a delete X to the annotation. // Add a delete X to the annotation.
var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'), var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'),
deletelink = Y.Node.create('<a href="#" role="button"></a>'); deletelink = Y.Node.create('<a href="#" role="button"></a>');
......
...@@ -589,7 +589,7 @@ EDITOR.prototype = { ...@@ -589,7 +589,7 @@ EDITOR.prototype = {
toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid); toolnode.on('key', this.handle_tool_button, 'down:13', this, toollib, toolid);
toolnode.setAttribute('aria-pressed', 'false'); toolnode.setAttribute('aria-pressed', 'false');
}, this); }, this);
// Setup the tool buttons. // Setup the tool buttons.
Y.each(TOOLSELECTOR, function (selector, tool) { Y.each(TOOLSELECTOR, function (selector, tool) {
toolnode = this.get_dialogue_element(selector); toolnode = this.get_dialogue_element(selector);
...@@ -656,15 +656,7 @@ EDITOR.prototype = { ...@@ -656,15 +656,7 @@ EDITOR.prototype = {
} }
if (tool !== "select") { if (tool !== "select") {
this.currentannotation = null; this.redraw_annotation();
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
} }
if (!has_parent) { if (!has_parent) {
this.currentedit.parent_annot_element = null; this.currentedit.parent_annot_element = null;
...@@ -672,6 +664,17 @@ EDITOR.prototype = { ...@@ -672,6 +664,17 @@ EDITOR.prototype = {
this.refresh_button_state(); this.refresh_button_state();
}, },
redraw_annotation: function (e) {
this.currentannotation = null;
var annotations = this.pages[this.currentpage].annotations;
Y.each(annotations, function (annotation) {
if (annotation && annotation.drawable) {
// Redraw the annotation to remove the highlight.
annotation.drawable.erase();
annotation.draw();
}
});
},
/** /**
* JSON encode the current page data - stripping out drawable references which cannot be encoded. * JSON encode the current page data - stripping out drawable references which cannot be encoded.
* @protected * @protected
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment