MDL-42351 EditPDF: Fix jiggling of relatively positioned elements

When calling setX/setY with YUI - YUI takes into account the position style
of the element. If none is set it assumes position relative. Position relative
is bad because relatively positioned elements still take up space in the page,
and all the elements after that node are positioned, taking into account the size
of that node. So when a node is resized or deleted, all nodes after that one in
the list of drawables are affected.

The magic fix - is just to set position: absolute on the drawables before calling setX/setY.
This commit is contained in:
Damyon Wiese 2013-10-29 22:18:19 +08:00
parent d147e833c0
commit d79d1bd8fa
5 changed files with 14 additions and 5 deletions

View File

@ -1410,6 +1410,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y)); position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y));
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')',
'width': (this.endx - this.x), 'width': (this.endx - this.x),
@ -1452,6 +1453,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')',
'width': bounds.width, 'width': bounds.width,
@ -2308,6 +2310,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
}); });
drawingregion.append(container); drawingregion.append(container);
container.setStyle('position', 'absolute');
container.setX(position.x); container.setX(position.x);
container.setY(position.y); container.setY(position.y);
drawable.nodes.push(container); drawable.nodes.push(container);

View File

@ -1410,6 +1410,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y)); position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y));
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')',
'width': (this.endx - this.x), 'width': (this.endx - this.x),
@ -1452,6 +1453,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')',
'width': bounds.width, 'width': bounds.width,
@ -2308,6 +2310,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
}); });
drawingregion.append(container); drawingregion.append(container);
container.setStyle('position', 'absolute');
container.setX(position.x); container.setX(position.x);
container.setY(position.y); container.setY(position.y);
drawable.nodes.push(container); drawable.nodes.push(container);

View File

@ -44,6 +44,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y)); position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y));
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')',
'width': (this.endx - this.x), 'width': (this.endx - this.x),
@ -86,6 +87,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
node = Y.Node.create('<div/>'); node = Y.Node.create('<div/>');
node.setStyles({ node.setStyles({
'position': 'absolute',
'display': 'inline-block', 'display': 'inline-block',
'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')', 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')',
'width': bounds.width, 'width': bounds.width,

View File

@ -189,6 +189,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
}); });
drawingregion.append(container); drawingregion.append(container);
container.setStyle('position', 'absolute');
container.setX(position.x); container.setX(position.x);
container.setY(position.y); container.setY(position.y);
drawable.nodes.push(container); drawable.nodes.push(container);