mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
Merge branch 'wip-mdl-42799' of https://github.com/rajeshtaneja/moodle
Conflicts: mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js
This commit is contained in:
commit
1d2a7ef54f
@ -64,6 +64,10 @@ class pdf extends \FPDI {
|
||||
const GSPATH_NOTESTFILE = 'notestfile';
|
||||
/** Any other error */
|
||||
const GSPATH_ERROR = 'error';
|
||||
/** Min. width an annotation should have */
|
||||
const MIN_ANNOTATION_WIDTH = 5;
|
||||
/** Min. height an annotation should have */
|
||||
const MIN_ANNOTATION_HEIGHT = 5;
|
||||
|
||||
/**
|
||||
* Combine the given PDF files into a single PDF. Optionally add a coversheet and coversheet fields.
|
||||
@ -300,6 +304,15 @@ class pdf extends \FPDI {
|
||||
$ry = abs($sy - $ey) / 2;
|
||||
$sx = min($sx, $ex) + $rx;
|
||||
$sy = min($sy, $ey) + $ry;
|
||||
|
||||
// $rx and $ry should be >= min width and height
|
||||
if ($rx < self::MIN_ANNOTATION_WIDTH) {
|
||||
$rx = self::MIN_ANNOTATION_WIDTH;
|
||||
}
|
||||
if ($ry < self::MIN_ANNOTATION_HEIGHT) {
|
||||
$ry = self::MIN_ANNOTATION_HEIGHT;
|
||||
}
|
||||
|
||||
$this->Ellipse($sx, $sy, $rx, $ry);
|
||||
break;
|
||||
case 'rectangle':
|
||||
@ -307,6 +320,14 @@ class pdf extends \FPDI {
|
||||
$h = abs($sy - $ey);
|
||||
$sx = min($sx, $ex);
|
||||
$sy = min($sy, $ey);
|
||||
|
||||
// Width or height should be >= min width and height
|
||||
if ($w < self::MIN_ANNOTATION_WIDTH) {
|
||||
$w = self::MIN_ANNOTATION_WIDTH;
|
||||
}
|
||||
if ($h < self::MIN_ANNOTATION_HEIGHT) {
|
||||
$h = self::MIN_ANNOTATION_HEIGHT;
|
||||
}
|
||||
$this->Rect($sx, $sy, $w, $h);
|
||||
break;
|
||||
case 'highlight':
|
||||
@ -316,6 +337,12 @@ class pdf extends \FPDI {
|
||||
$sy = min($sy, $ey) + ($h * 0.5);
|
||||
$this->SetAlpha(0.5, 'Normal', 0.5, 'Normal');
|
||||
$this->SetLineWidth(8.0 * $this->scale);
|
||||
|
||||
// width should be >= min width
|
||||
if ($w < self::MIN_ANNOTATION_WIDTH) {
|
||||
$w = self::MIN_ANNOTATION_WIDTH;
|
||||
}
|
||||
|
||||
$this->Rect($sx, $sy, $w, $h);
|
||||
$this->SetAlpha(1.0, 'Normal', 1.0, 'Normal');
|
||||
break;
|
||||
@ -326,7 +353,10 @@ class pdf extends \FPDI {
|
||||
foreach ($points as $point) {
|
||||
$scalepath[] = intval($point) * $this->scale;
|
||||
}
|
||||
$this->PolyLine($scalepath, 'S');
|
||||
|
||||
if (!empty($scalepath)) {
|
||||
$this->PolyLine($scalepath, 'S');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'stamp':
|
||||
@ -335,6 +365,8 @@ class pdf extends \FPDI {
|
||||
$h = abs($sy - $ey);
|
||||
$sx = min($sx, $ex);
|
||||
$sy = min($sy, $ey);
|
||||
|
||||
// Stamp is always more than 40px, so no need to check width/height.
|
||||
$this->Image($imgfile, $sx, $sy, $w, $h);
|
||||
break;
|
||||
default: // Line.
|
||||
|
@ -250,6 +250,44 @@ RECT = function(x, y, width, height) {
|
||||
// Allow chaining.
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min width.
|
||||
* @method has_min_width
|
||||
* @return bool true if width is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_width = function() {
|
||||
return (this.width >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min height.
|
||||
* @method has_min_height
|
||||
* @return bool true if height is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_height = function() {
|
||||
return (this.height >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. width of annotation bound.
|
||||
* @method set_min_width
|
||||
* @public
|
||||
*/
|
||||
this.set_min_width = function() {
|
||||
this.width = 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. height of annotation bound.
|
||||
* @method set_min_height
|
||||
* @public
|
||||
*/
|
||||
this.set_min_height = function() {
|
||||
this.height = 5;
|
||||
};
|
||||
};
|
||||
|
||||
M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
|
||||
@ -745,6 +783,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -758,6 +797,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
}
|
||||
|
||||
});
|
||||
@ -860,6 +900,7 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if line bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
this.gradeid = this.editor.get('gradeid');
|
||||
@ -870,6 +911,8 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.end.y;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
|
||||
return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0));
|
||||
}
|
||||
|
||||
});
|
||||
@ -956,6 +999,14 @@ Y.extend(ANNOTATIONRECTANGLE, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of rectangle.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Rect,
|
||||
width: bounds.width,
|
||||
@ -1056,6 +1107,14 @@ Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of oval.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Ellipse,
|
||||
width: bounds.width,
|
||||
@ -1200,6 +1259,7 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if pen bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect(),
|
||||
@ -1221,6 +1281,8 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = pathlist.join(':');
|
||||
|
||||
return (bounds.has_min_width() || bounds.has_min_height());
|
||||
}
|
||||
|
||||
|
||||
@ -1318,6 +1380,11 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width of highlight.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
|
||||
highlightcolour = ANNOTATIONCOLOUR[edit.annotationcolour];
|
||||
// Add an alpha channel to the rgb colour.
|
||||
|
||||
@ -1348,6 +1415,7 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if highlight bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -1361,6 +1429,8 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.start.y + 16;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.page = '';
|
||||
|
||||
return (bounds.has_min_width());
|
||||
}
|
||||
|
||||
});
|
||||
@ -1480,6 +1550,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -1499,6 +1570,9 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = edit.stamp;
|
||||
|
||||
// Min width and height is always more than 40px.
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2539,6 +2613,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if comment bound is more than min width/height, else false.
|
||||
*/
|
||||
this.init_from_edit = function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -2558,6 +2633,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
this.width = bounds.width;
|
||||
this.colour = edit.commentcolour;
|
||||
this.rawtext = '';
|
||||
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
};
|
||||
|
||||
};
|
||||
@ -3615,10 +3692,11 @@ EDITOR.prototype = {
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
comment = new M.assignfeedback_editpdf.comment(this);
|
||||
comment.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
if (comment.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
}
|
||||
} else {
|
||||
annotation = this.create_annotation(this.currentedit.tool, {});
|
||||
if (annotation) {
|
||||
@ -3626,13 +3704,13 @@ EDITOR.prototype = {
|
||||
this.currentdrawable.erase();
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
annotation.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
if (annotation.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save the changes.
|
||||
this.save_current_page();
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -250,6 +250,44 @@ RECT = function(x, y, width, height) {
|
||||
// Allow chaining.
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min width.
|
||||
* @method has_min_width
|
||||
* @return bool true if width is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_width = function() {
|
||||
return (this.width >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min height.
|
||||
* @method has_min_height
|
||||
* @return bool true if height is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_height = function() {
|
||||
return (this.height >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. width of annotation bound.
|
||||
* @method set_min_width
|
||||
* @public
|
||||
*/
|
||||
this.set_min_width = function() {
|
||||
this.width = 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. height of annotation bound.
|
||||
* @method set_min_height
|
||||
* @public
|
||||
*/
|
||||
this.set_min_height = function() {
|
||||
this.height = 5;
|
||||
};
|
||||
};
|
||||
|
||||
M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
|
||||
@ -745,6 +783,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -758,6 +797,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
}
|
||||
|
||||
});
|
||||
@ -860,6 +900,7 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if line bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
this.gradeid = this.editor.get('gradeid');
|
||||
@ -870,6 +911,8 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.end.y;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
|
||||
return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0));
|
||||
}
|
||||
|
||||
});
|
||||
@ -956,6 +999,14 @@ Y.extend(ANNOTATIONRECTANGLE, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of rectangle.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Rect,
|
||||
width: bounds.width,
|
||||
@ -1056,6 +1107,14 @@ Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of oval.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Ellipse,
|
||||
width: bounds.width,
|
||||
@ -1200,6 +1259,7 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if pen bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect(),
|
||||
@ -1221,6 +1281,8 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = pathlist.join(':');
|
||||
|
||||
return (bounds.has_min_width() || bounds.has_min_height());
|
||||
}
|
||||
|
||||
|
||||
@ -1318,6 +1380,11 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width of highlight.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
|
||||
highlightcolour = ANNOTATIONCOLOUR[edit.annotationcolour];
|
||||
// Add an alpha channel to the rgb colour.
|
||||
|
||||
@ -1348,6 +1415,7 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if highlight bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -1361,6 +1429,8 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.start.y + 16;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.page = '';
|
||||
|
||||
return (bounds.has_min_width());
|
||||
}
|
||||
|
||||
});
|
||||
@ -1480,6 +1550,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -1499,6 +1570,9 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = edit.stamp;
|
||||
|
||||
// Min width and height is always more than 40px.
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2539,6 +2613,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if comment bound is more than min width/height, else false.
|
||||
*/
|
||||
this.init_from_edit = function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -2558,6 +2633,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
this.width = bounds.width;
|
||||
this.colour = edit.commentcolour;
|
||||
this.rawtext = '';
|
||||
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
};
|
||||
|
||||
};
|
||||
@ -3615,10 +3692,11 @@ EDITOR.prototype = {
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
comment = new M.assignfeedback_editpdf.comment(this);
|
||||
comment.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
if (comment.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
}
|
||||
} else {
|
||||
annotation = this.create_annotation(this.currentedit.tool, {});
|
||||
if (annotation) {
|
||||
@ -3626,13 +3704,13 @@ EDITOR.prototype = {
|
||||
this.currentdrawable.erase();
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
annotation.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
if (annotation.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save the changes.
|
||||
this.save_current_page();
|
||||
|
||||
|
@ -308,6 +308,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -321,6 +322,7 @@ Y.extend(ANNOTATION, Y.Base, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -88,6 +88,11 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width of highlight.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
|
||||
highlightcolour = ANNOTATIONCOLOUR[edit.annotationcolour];
|
||||
// Add an alpha channel to the rgb colour.
|
||||
|
||||
@ -118,6 +123,7 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if highlight bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -131,6 +137,8 @@ Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.start.y + 16;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.page = '';
|
||||
|
||||
return (bounds.has_min_width());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -94,6 +94,7 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if line bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
this.gradeid = this.editor.get('gradeid');
|
||||
@ -104,6 +105,8 @@ Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = edit.end.y;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = '';
|
||||
|
||||
return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -78,6 +78,14 @@ Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of oval.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Ellipse,
|
||||
width: bounds.width,
|
||||
|
@ -122,6 +122,7 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if pen bound is more than min width/height, else false.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect(),
|
||||
@ -143,6 +144,8 @@ Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = pathlist.join(':');
|
||||
|
||||
return (bounds.has_min_width() || bounds.has_min_height());
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,6 +78,14 @@ Y.extend(ANNOTATIONRECTANGLE, M.assignfeedback_editpdf.annotation, {
|
||||
bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
|
||||
new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
|
||||
|
||||
// Set min. width and height of rectangle.
|
||||
if (!bounds.has_min_width()) {
|
||||
bounds.set_min_width();
|
||||
}
|
||||
if (!bounds.has_min_height()) {
|
||||
bounds.set_min_height();
|
||||
}
|
||||
|
||||
shape = this.editor.graphic.addShape({
|
||||
type: Y.Rect,
|
||||
width: bounds.width,
|
||||
|
@ -111,6 +111,7 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool if width/height is more than min. required.
|
||||
*/
|
||||
init_from_edit : function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -130,6 +131,9 @@ Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, {
|
||||
this.endy = bounds.y + bounds.height;
|
||||
this.colour = edit.annotationcolour;
|
||||
this.path = edit.stamp;
|
||||
|
||||
// Min width and height is always more than 40px.
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -411,6 +411,7 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
* @public
|
||||
* @method init_from_edit
|
||||
* @param M.assignfeedback_editpdf.edit edit
|
||||
* @return bool true if comment bound is more than min width/height, else false.
|
||||
*/
|
||||
this.init_from_edit = function(edit) {
|
||||
var bounds = new M.assignfeedback_editpdf.rect();
|
||||
@ -430,6 +431,8 @@ COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
|
||||
this.width = bounds.width;
|
||||
this.colour = edit.commentcolour;
|
||||
this.rawtext = '';
|
||||
|
||||
return (bounds.has_min_width() && bounds.has_min_height());
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -785,10 +785,11 @@ EDITOR.prototype = {
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
comment = new M.assignfeedback_editpdf.comment(this);
|
||||
comment.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
if (comment.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].comments.push(comment);
|
||||
this.drawables.push(comment.draw(true));
|
||||
this.editingcomment = true;
|
||||
}
|
||||
} else {
|
||||
annotation = this.create_annotation(this.currentedit.tool, {});
|
||||
if (annotation) {
|
||||
@ -796,13 +797,13 @@ EDITOR.prototype = {
|
||||
this.currentdrawable.erase();
|
||||
}
|
||||
this.currentdrawable = false;
|
||||
annotation.init_from_edit(this.currentedit);
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
if (annotation.init_from_edit(this.currentedit)) {
|
||||
this.pages[this.currentpage].annotations.push(annotation);
|
||||
this.drawables.push(annotation.draw());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save the changes.
|
||||
this.save_current_page();
|
||||
|
||||
|
@ -99,6 +99,44 @@ RECT = function(x, y, width, height) {
|
||||
// Allow chaining.
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min width.
|
||||
* @method has_min_width
|
||||
* @return bool true if width is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_width = function() {
|
||||
return (this.width >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if rect has min height.
|
||||
* @method has_min_height
|
||||
* @return bool true if height is more than 5px.
|
||||
* @public
|
||||
*/
|
||||
this.has_min_height = function() {
|
||||
return (this.height >= 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. width of annotation bound.
|
||||
* @method set_min_width
|
||||
* @public
|
||||
*/
|
||||
this.set_min_width = function() {
|
||||
this.width = 5;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set min. height of annotation bound.
|
||||
* @method set_min_height
|
||||
* @public
|
||||
*/
|
||||
this.set_min_height = function() {
|
||||
this.height = 5;
|
||||
};
|
||||
};
|
||||
|
||||
M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user