[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 /* global ANNOTATIONCOLOUR */ 16 17 /** 18 * Provides an in browser PDF editor. 19 * 20 * @module moodle-assignfeedback_editpdf-editor 21 */ 22 23 /** 24 * Class representing a highlight. 25 * 26 * @namespace M.assignfeedback_editpdf 27 * @class annotationhighlight 28 * @extends M.assignfeedback_editpdf.annotation 29 * @module moodle-assignfeedback_editpdf-editor 30 */ 31 var ANNOTATIONHIGHLIGHT = function(config) { 32 ANNOTATIONHIGHLIGHT.superclass.constructor.apply(this, [config]); 33 }; 34 35 ANNOTATIONHIGHLIGHT.NAME = "annotationhighlight"; 36 ANNOTATIONHIGHLIGHT.ATTRS = {}; 37 38 Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, { 39 /** 40 * Draw a highlight annotation 41 * @protected 42 * @method draw 43 * @return M.assignfeedback_editpdf.drawable 44 */ 45 draw: function() { 46 var drawable, 47 shape, 48 bounds, 49 highlightcolour; 50 51 drawable = new M.assignfeedback_editpdf.drawable(this.editor); 52 bounds = new M.assignfeedback_editpdf.rect(); 53 bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y), 54 new M.assignfeedback_editpdf.point(this.endx, this.endy)]); 55 56 highlightcolour = ANNOTATIONCOLOUR[this.colour]; 57 58 // Add an alpha channel to the rgb colour. 59 60 highlightcolour = highlightcolour.replace('rgb', 'rgba'); 61 highlightcolour = highlightcolour.replace(')', ',0.5)'); 62 63 shape = this.editor.graphic.addShape({ 64 type: Y.Rect, 65 width: bounds.width, 66 height: bounds.height, 67 stroke: false, 68 fill: { 69 color: highlightcolour 70 }, 71 x: bounds.x, 72 y: bounds.y 73 }); 74 75 drawable.shapes.push(shape); 76 this.drawable = drawable; 77 78 return ANNOTATIONHIGHLIGHT.superclass.draw.apply(this); 79 }, 80 81 /** 82 * Draw the in progress edit. 83 * 84 * @public 85 * @method draw_current_edit 86 * @param M.assignfeedback_editpdf.edit edit 87 */ 88 draw_current_edit: function(edit) { 89 var drawable = new M.assignfeedback_editpdf.drawable(this.editor), 90 shape, 91 bounds, 92 highlightcolour; 93 94 bounds = new M.assignfeedback_editpdf.rect(); 95 bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y), 96 new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]); 97 98 // Set min. width of highlight. 99 if (!bounds.has_min_width()) { 100 bounds.set_min_width(); 101 } 102 103 highlightcolour = ANNOTATIONCOLOUR[edit.annotationcolour]; 104 // Add an alpha channel to the rgb colour. 105 106 highlightcolour = highlightcolour.replace('rgb', 'rgba'); 107 highlightcolour = highlightcolour.replace(')', ',0.5)'); 108 109 // We will draw a box with the current background colour. 110 shape = this.editor.graphic.addShape({ 111 type: Y.Rect, 112 width: bounds.width, 113 height: 16, 114 stroke: false, 115 fill: { 116 color: highlightcolour 117 }, 118 x: bounds.x, 119 y: edit.start.y 120 }); 121 122 drawable.shapes.push(shape); 123 124 return drawable; 125 }, 126 127 /** 128 * Promote the current edit to a real annotation. 129 * 130 * @public 131 * @method init_from_edit 132 * @param M.assignfeedback_editpdf.edit edit 133 * @return bool true if highlight bound is more than min width/height, else false. 134 */ 135 init_from_edit: function(edit) { 136 var bounds = new M.assignfeedback_editpdf.rect(); 137 bounds.bound([edit.start, edit.end]); 138 139 this.gradeid = this.editor.get('gradeid'); 140 this.pageno = this.editor.currentpage; 141 this.x = bounds.x; 142 this.y = edit.start.y; 143 this.endx = bounds.x + bounds.width; 144 this.endy = edit.start.y + 16; 145 this.colour = edit.annotationcolour; 146 this.page = ''; 147 148 return (bounds.has_min_width()); 149 } 150 151 }); 152 153 M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; 154 M.assignfeedback_editpdf.annotationhighlight = ANNOTATIONHIGHLIGHT;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |