Skip to content

Commit

Permalink
MDL-55245 assignfeedback_editpdf: Enable text in comments to be selected
Browse files Browse the repository at this point in the history
Only move comment boxes if 'select' tool is selected, enabling users to
drag-select text within comments using the 'comment' tool.
  • Loading branch information
tonyjbutler committed Jul 22, 2016
1 parent 90a8bdb commit b37b6cd
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2630,43 +2630,49 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
});

node.on('gesturemovestart', function(e) {
node.setData('dragging', true);
node.setData('offsetx', e.clientX - node.getX());
node.setData('offsety', e.clientY - node.getY());
if (editor.currentedit.tool === 'select') {
node.setData('dragging', true);
node.setData('offsetx', e.clientX - node.getX());
node.setData('offsety', e.clientY - node.getY());
}
});
node.on('gesturemoveend', function() {
node.setData('dragging', false);
this.editor.save_current_page();
if (editor.currentedit.tool === 'select') {
node.setData('dragging', false);
this.editor.save_current_page();
}
}, null, this);
node.on('gesturemove', function(e) {
var x = e.clientX - node.getData('offsetx'),
y = e.clientY - node.getData('offsety'),
nodewidth,
nodeheight,
newlocation,
windowlocation,
bounds;

nodewidth = parseInt(node.getStyle('width'), 10);
nodeheight = parseInt(node.getStyle('height'), 10);

newlocation = this.editor.get_canvas_coordinates(new M.assignfeedback_editpdf.point(x, y));
bounds = this.editor.get_canvas_bounds(true);
bounds.x = 0;
bounds.y = 0;

bounds.width -= nodewidth + 42;
bounds.height -= nodeheight + 8;
// Clip to the window size - the comment size.
newlocation.clip(bounds);

this.x = newlocation.x;
this.y = newlocation.y;

windowlocation = this.editor.get_window_coordinates(newlocation);
node.ancestor().setX(windowlocation.x);
node.ancestor().setY(windowlocation.y);
this.drawable.store_position(node.ancestor(), windowlocation.x, windowlocation.y);
if (editor.currentedit.tool === 'select') {
var x = e.clientX - node.getData('offsetx'),
y = e.clientY - node.getData('offsety'),
nodewidth,
nodeheight,
newlocation,
windowlocation,
bounds;

nodewidth = parseInt(node.getStyle('width'), 10);
nodeheight = parseInt(node.getStyle('height'), 10);

newlocation = this.editor.get_canvas_coordinates(new M.assignfeedback_editpdf.point(x, y));
bounds = this.editor.get_canvas_bounds(true);
bounds.x = 0;
bounds.y = 0;

bounds.width -= nodewidth + 42;
bounds.height -= nodeheight + 8;
// Clip to the window size - the comment size.
newlocation.clip(bounds);

this.x = newlocation.x;
this.y = newlocation.y;

windowlocation = this.editor.get_window_coordinates(newlocation);
node.ancestor().setX(windowlocation.x);
node.ancestor().setY(windowlocation.y);
this.drawable.store_position(node.ancestor(), windowlocation.x, windowlocation.y);
}
}, null, this);

this.menu = new M.assignfeedback_editpdf.commentmenu({
Expand Down
Loading

0 comments on commit b37b6cd

Please sign in to comment.