1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Provides an in browser PDF editor.
|
|
|
18 |
*
|
|
|
19 |
* @module moodle-assignfeedback_editpdf-editor
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Class representing a oval.
|
|
|
24 |
*
|
|
|
25 |
* @namespace M.assignfeedback_editpdf
|
|
|
26 |
* @class annotationoval
|
|
|
27 |
* @extends M.assignfeedback_editpdf.annotation
|
|
|
28 |
*/
|
|
|
29 |
var ANNOTATIONOVAL = function(config) {
|
|
|
30 |
ANNOTATIONOVAL.superclass.constructor.apply(this, [config]);
|
|
|
31 |
};
|
|
|
32 |
|
|
|
33 |
ANNOTATIONOVAL.NAME = "annotationoval";
|
|
|
34 |
ANNOTATIONOVAL.ATTRS = {};
|
|
|
35 |
|
|
|
36 |
Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, {
|
|
|
37 |
/**
|
|
|
38 |
* Draw a oval annotation
|
|
|
39 |
* @protected
|
|
|
40 |
* @method draw
|
|
|
41 |
* @return M.assignfeedback_editpdf.drawable
|
|
|
42 |
*/
|
|
|
43 |
draw: function() {
|
|
|
44 |
var drawable,
|
|
|
45 |
bounds,
|
|
|
46 |
shape;
|
|
|
47 |
|
|
|
48 |
drawable = new M.assignfeedback_editpdf.drawable(this.editor);
|
|
|
49 |
|
|
|
50 |
bounds = new M.assignfeedback_editpdf.rect();
|
|
|
51 |
bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y),
|
|
|
52 |
new M.assignfeedback_editpdf.point(this.endx, this.endy)]);
|
|
|
53 |
|
|
|
54 |
shape = this.editor.graphic.addShape({
|
|
|
55 |
type: Y.Ellipse,
|
|
|
56 |
width: bounds.width,
|
|
|
57 |
height: bounds.height,
|
|
|
58 |
stroke: {
|
|
|
59 |
weight: STROKEWEIGHT,
|
|
|
60 |
color: ANNOTATIONCOLOUR[this.colour]
|
|
|
61 |
},
|
|
|
62 |
x: bounds.x,
|
|
|
63 |
y: bounds.y
|
|
|
64 |
});
|
|
|
65 |
drawable.shapes.push(shape);
|
|
|
66 |
this.drawable = drawable;
|
|
|
67 |
|
|
|
68 |
return ANNOTATIONOVAL.superclass.draw.apply(this);
|
|
|
69 |
},
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Draw the in progress edit.
|
|
|
73 |
*
|
|
|
74 |
* @public
|
|
|
75 |
* @method draw_current_edit
|
|
|
76 |
* @param M.assignfeedback_editpdf.edit edit
|
|
|
77 |
*/
|
|
|
78 |
draw_current_edit: function(edit) {
|
|
|
79 |
var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
|
|
|
80 |
shape,
|
|
|
81 |
bounds;
|
|
|
82 |
|
|
|
83 |
bounds = new M.assignfeedback_editpdf.rect();
|
|
|
84 |
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
|
|
85 |
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
|
|
86 |
|
|
|
87 |
// Set min. width and height of oval.
|
|
|
88 |
if (!bounds.has_min_width()) {
|
|
|
89 |
bounds.set_min_width();
|
|
|
90 |
}
|
|
|
91 |
if (!bounds.has_min_height()) {
|
|
|
92 |
bounds.set_min_height();
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
shape = this.editor.graphic.addShape({
|
|
|
96 |
type: Y.Ellipse,
|
|
|
97 |
width: bounds.width,
|
|
|
98 |
height: bounds.height,
|
|
|
99 |
stroke: {
|
|
|
100 |
weight: STROKEWEIGHT,
|
|
|
101 |
color: ANNOTATIONCOLOUR[edit.annotationcolour]
|
|
|
102 |
},
|
|
|
103 |
x: bounds.x,
|
|
|
104 |
y: bounds.y
|
|
|
105 |
});
|
|
|
106 |
|
|
|
107 |
drawable.shapes.push(shape);
|
|
|
108 |
|
|
|
109 |
return drawable;
|
|
|
110 |
}
|
|
|
111 |
});
|
|
|
112 |
|
|
|
113 |
M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
|
|
|
114 |
M.assignfeedback_editpdf.annotationoval = ANNOTATIONOVAL;
|