Merge branch 'MDL-53822-master' of git://github.com/damyon/moodle

This commit is contained in:
David Monllao 2016-05-12 08:44:19 +08:00
commit 8ae171ed1c
10 changed files with 129 additions and 20 deletions

View file

@ -48,6 +48,7 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
'comment' => 'z', 'comment' => 'z',
'commentcolour' => 'x', 'commentcolour' => 'x',
'select' => 'c', 'select' => 'c',
'drag' => 'd',
'pen' => 'y', 'pen' => 'y',
'line' => 'u', 'line' => 'u',
'rectangle' => 'i', 'rectangle' => 'i',
@ -168,6 +169,7 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
$toolbar1 = html_writer::div($toolbar1, 'toolbar', array('role'=>'toolbar')); $toolbar1 = html_writer::div($toolbar1, 'toolbar', array('role'=>'toolbar'));
// Select Tool. // Select Tool.
$toolbar2 .= $this->render_toolbar_button('drag', 'drag', $this->get_shortcut('drag'));
$toolbar2 .= $this->render_toolbar_button('select', 'select', $this->get_shortcut('select')); $toolbar2 .= $this->render_toolbar_button('select', 'select', $this->get_shortcut('select'));
$toolbar2 = html_writer::div($toolbar2, 'toolbar', array('role'=>'toolbar')); $toolbar2 = html_writer::div($toolbar2, 'toolbar', array('role'=>'toolbar'));

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="-0.1 -0.1 16 16"
preserveAspectRatio="xMinYMid meet"
overflow="visible"
id="svg2"
version="1.1"
inkscape:version="0.91 r"
sodipodi:docname="drag.svg">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="971"
id="namedview6"
showgrid="true"
inkscape:zoom="20.85965"
inkscape:cx="5.2992298"
inkscape:cy="10.570585"
inkscape:window-x="0"
inkscape:window-y="31"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<path
style="fill:#999999;fill-opacity:1"
d="M 4.6842425,14.805742 C 3.8240932,13.534706 3.1416707,12.149287 2.4463204,10.782766 1.9591547,9.6846878 1.4518904,8.5567031 1.3208867,7.3520332 1.3993702,6.6731869 2.216905,6.1664787 2.8701071,6.3903275 3.6134351,6.4294647 3.9825459,7.0921787 4.2785963,7.6787182 4.3710479,6.0289778 4.4178644,4.376668 4.5265291,2.7282346 4.6236395,2.1028138 4.6050223,1.2982208 5.1834853,0.90090281 5.789478,0.70075799 6.5333865,0.78864747 7.0808467,1.1128358 7.6517943,1.6925727 7.4267719,2.558639 7.4997375,3.2940078 l 0.051498,1.3351186 c 0.5369532,0.028609 1.1474423,0.069439 1.4753552,0.5690113 0.4315323,0.7415379 1.4579453,0.2069096 1.9466193,0.8668554 0.419059,0.6604803 1.26597,0.3846686 1.850644,0.772358 0.674988,0.309933 0.813687,1.1505478 0.943377,1.8070205 0.124658,1.1540316 -0.03264,2.3150924 0.0092,3.4726674 -0.02263,0.949145 -0.180946,2.153104 -1.186694,2.548039 -1.304727,0.357832 -2.680781,0.287396 -4.0218842,0.325397 -1.2583238,-0.02696 -2.5320056,0.0592 -3.778731,-0.137814 l -0.1049048,-0.04692 2e-7,0 z"
id="path4186"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccccccccccc" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -18,6 +18,12 @@
.assignfeedback_editpdf_widget .moodle-dialogue-bd .drawingregion { .assignfeedback_editpdf_widget .moodle-dialogue-bd .drawingregion {
position: inherit; position: inherit;
} }
.assignfeedback_editpdf_widget .drawingregion[data-currenttool=drag] .drawingcanvas {
cursor: move;
}
.assignfeedback_editpdf_widget .drawingregion[data-currenttool=select] .drawingcanvas {
cursor: pointer;
}
.assignfeedback_editpdf_widget .drawingregion { .assignfeedback_editpdf_widget .drawingregion {
border: 1px solid #ccc; border: 1px solid #ccc;
left: 1em; left: 1em;

View file

@ -74,6 +74,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
'oval': '.ovalbutton', 'oval': '.ovalbutton',
'stamp': '.stampbutton', 'stamp': '.stampbutton',
'select': '.selectbutton', 'select': '.selectbutton',
'drag': '.dragbutton',
'highlight': '.highlightbutton' 'highlight': '.highlightbutton'
}, },
STROKEWEIGHT = 4; STROKEWEIGHT = 4;
@ -360,7 +361,7 @@ var EDIT = function() {
* @type String * @type String
* @public * @public
*/ */
this.tool = "comment"; this.tool = "drag";
/** /**
* The currently comment colour * The currently comment colour
@ -3294,7 +3295,7 @@ EDITOR.prototype = {
* @method refresh_button_state * @method refresh_button_state
*/ */
refresh_button_state : function() { refresh_button_state : function() {
var button, currenttoolnode, imgurl; var button, currenttoolnode, imgurl, drawingregion;
// Initalise the colour buttons. // Initalise the colour buttons.
button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON); button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
@ -3315,6 +3316,8 @@ EDITOR.prototype = {
currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]); currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]);
currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'true'); currenttoolnode.setAttribute('aria-pressed', 'true');
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setAttribute('data-currenttool', this.currentedit.tool);
button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON); button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp), button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp),
@ -3728,7 +3731,8 @@ EDITOR.prototype = {
currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'false'); currenttoolnode.setAttribute('aria-pressed', 'false');
this.currentedit.tool = tool; this.currentedit.tool = tool;
if (tool !== "comment" && tool !== "select" && tool !== "stamp") {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool; this.lastannotationtool = tool;
} }
this.refresh_button_state(); this.refresh_button_state();
@ -3890,9 +3894,12 @@ EDITOR.prototype = {
e.preventDefault(); e.preventDefault();
var bounds = this.get_canvas_bounds(), var bounds = this.get_canvas_bounds(),
canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS), canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION),
clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'), clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'),
e.clientY + canvas.get('docScrollY')), e.clientY + canvas.get('docScrollY')),
point = this.get_canvas_coordinates(clientpoint); point = this.get_canvas_coordinates(clientpoint),
diffX,
diffY;
// Ignore events out of the canvas area. // Ignore events out of the canvas area.
if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) { if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) {
@ -3908,6 +3915,13 @@ EDITOR.prototype = {
this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x, this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x,
this.currentedit.annotationstart.y + point.y - this.currentedit.start.y); this.currentedit.annotationstart.y + point.y - this.currentedit.start.y);
} }
} else if (this.currentedit.tool === 'drag') {
diffX = point.x - this.currentedit.start.x;
diffY = point.y - this.currentedit.start.y;
drawingregion.getDOMNode().scrollLeft -= diffX;
drawingregion.getDOMNode().scrollTop -= diffY;
} else { } else {
if (this.currentedit.start) { if (this.currentedit.start) {
this.currentedit.end = point; this.currentedit.end = point;

View file

@ -74,6 +74,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
'oval': '.ovalbutton', 'oval': '.ovalbutton',
'stamp': '.stampbutton', 'stamp': '.stampbutton',
'select': '.selectbutton', 'select': '.selectbutton',
'drag': '.dragbutton',
'highlight': '.highlightbutton' 'highlight': '.highlightbutton'
}, },
STROKEWEIGHT = 4; STROKEWEIGHT = 4;
@ -360,7 +361,7 @@ var EDIT = function() {
* @type String * @type String
* @public * @public
*/ */
this.tool = "comment"; this.tool = "drag";
/** /**
* The currently comment colour * The currently comment colour
@ -3294,7 +3295,7 @@ EDITOR.prototype = {
* @method refresh_button_state * @method refresh_button_state
*/ */
refresh_button_state : function() { refresh_button_state : function() {
var button, currenttoolnode, imgurl; var button, currenttoolnode, imgurl, drawingregion;
// Initalise the colour buttons. // Initalise the colour buttons.
button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON); button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
@ -3315,6 +3316,8 @@ EDITOR.prototype = {
currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]); currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]);
currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'true'); currenttoolnode.setAttribute('aria-pressed', 'true');
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setAttribute('data-currenttool', this.currentedit.tool);
button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON); button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp), button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp),
@ -3728,7 +3731,8 @@ EDITOR.prototype = {
currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'false'); currenttoolnode.setAttribute('aria-pressed', 'false');
this.currentedit.tool = tool; this.currentedit.tool = tool;
if (tool !== "comment" && tool !== "select" && tool !== "stamp") {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool; this.lastannotationtool = tool;
} }
this.refresh_button_state(); this.refresh_button_state();
@ -3890,9 +3894,12 @@ EDITOR.prototype = {
e.preventDefault(); e.preventDefault();
var bounds = this.get_canvas_bounds(), var bounds = this.get_canvas_bounds(),
canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS), canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION),
clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'), clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'),
e.clientY + canvas.get('docScrollY')), e.clientY + canvas.get('docScrollY')),
point = this.get_canvas_coordinates(clientpoint); point = this.get_canvas_coordinates(clientpoint),
diffX,
diffY;
// Ignore events out of the canvas area. // Ignore events out of the canvas area.
if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) { if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) {
@ -3908,6 +3915,13 @@ EDITOR.prototype = {
this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x, this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x,
this.currentedit.annotationstart.y + point.y - this.currentedit.start.y); this.currentedit.annotationstart.y + point.y - this.currentedit.start.y);
} }
} else if (this.currentedit.tool === 'drag') {
diffX = point.x - this.currentedit.start.x;
diffY = point.y - this.currentedit.start.y;
drawingregion.getDOMNode().scrollLeft -= diffX;
drawingregion.getDOMNode().scrollTop -= diffY;
} else { } else {
if (this.currentedit.start) { if (this.currentedit.start) {
this.currentedit.end = point; this.currentedit.end = point;

View file

@ -65,7 +65,7 @@ var EDIT = function() {
* @type String * @type String
* @public * @public
*/ */
this.tool = "comment"; this.tool = "drag";
/** /**
* The currently comment colour * The currently comment colour

View file

@ -238,7 +238,7 @@ EDITOR.prototype = {
* @method refresh_button_state * @method refresh_button_state
*/ */
refresh_button_state : function() { refresh_button_state : function() {
var button, currenttoolnode, imgurl; var button, currenttoolnode, imgurl, drawingregion;
// Initalise the colour buttons. // Initalise the colour buttons.
button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON); button = this.get_dialogue_element(SELECTOR.COMMENTCOLOURBUTTON);
@ -259,6 +259,8 @@ EDITOR.prototype = {
currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]); currenttoolnode = this.get_dialogue_element(TOOLSELECTOR[this.currentedit.tool]);
currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.addClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'true'); currenttoolnode.setAttribute('aria-pressed', 'true');
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
drawingregion.setAttribute('data-currenttool', this.currentedit.tool);
button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON); button = this.get_dialogue_element(SELECTOR.STAMPSBUTTON);
button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp), button.one('img').setAttrs({'src': this.get_stamp_image_url(this.currentedit.stamp),
@ -672,7 +674,8 @@ EDITOR.prototype = {
currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton'); currenttoolnode.removeClass('assignfeedback_editpdf_selectedbutton');
currenttoolnode.setAttribute('aria-pressed', 'false'); currenttoolnode.setAttribute('aria-pressed', 'false');
this.currentedit.tool = tool; this.currentedit.tool = tool;
if (tool !== "comment" && tool !== "select" && tool !== "stamp") {
if (tool !== "comment" && tool !== "select" && tool !== "drag" && tool !== "stamp") {
this.lastannotationtool = tool; this.lastannotationtool = tool;
} }
this.refresh_button_state(); this.refresh_button_state();
@ -834,9 +837,12 @@ EDITOR.prototype = {
e.preventDefault(); e.preventDefault();
var bounds = this.get_canvas_bounds(), var bounds = this.get_canvas_bounds(),
canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS), canvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION),
clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'), clientpoint = new M.assignfeedback_editpdf.point(e.clientX + canvas.get('docScrollX'),
e.clientY + canvas.get('docScrollY')), e.clientY + canvas.get('docScrollY')),
point = this.get_canvas_coordinates(clientpoint); point = this.get_canvas_coordinates(clientpoint),
diffX,
diffY;
// Ignore events out of the canvas area. // Ignore events out of the canvas area.
if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) { if (point.x < 0 || point.x > bounds.width || point.y < 0 || point.y > bounds.height) {
@ -852,6 +858,13 @@ EDITOR.prototype = {
this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x, this.currentannotation.move( this.currentedit.annotationstart.x + point.x - this.currentedit.start.x,
this.currentedit.annotationstart.y + point.y - this.currentedit.start.y); this.currentedit.annotationstart.y + point.y - this.currentedit.start.y);
} }
} else if (this.currentedit.tool === 'drag') {
diffX = point.x - this.currentedit.start.x;
diffY = point.y - this.currentedit.start.y;
drawingregion.getDOMNode().scrollLeft -= diffX;
drawingregion.getDOMNode().scrollTop -= diffY;
} else { } else {
if (this.currentedit.start) { if (this.currentedit.start) {
this.currentedit.end = point; this.currentedit.end = point;

View file

@ -72,6 +72,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
'oval': '.ovalbutton', 'oval': '.ovalbutton',
'stamp': '.stampbutton', 'stamp': '.stampbutton',
'select': '.selectbutton', 'select': '.selectbutton',
'drag': '.dragbutton',
'highlight': '.highlightbutton' 'highlight': '.highlightbutton'
}, },
STROKEWEIGHT = 4; STROKEWEIGHT = 4;