[ Index ] |
PHP Cross Reference of moodle-2.8 |
[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 16 /** 17 * Provides an in browser PDF editor. 18 * 19 * @module moodle-assignfeedback_editpdf-editor 20 */ 21 22 /** 23 * Class representing a stamp. 24 * 25 * @namespace M.assignfeedback_editpdf 26 * @class annotationstamp 27 * @extends M.assignfeedback_editpdf.annotation 28 */ 29 ANNOTATIONSTAMP = function(config) { 30 ANNOTATIONSTAMP.superclass.constructor.apply(this, [config]); 31 }; 32 33 ANNOTATIONSTAMP.NAME = "annotationstamp"; 34 ANNOTATIONSTAMP.ATTRS = {}; 35 36 Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, { 37 /** 38 * Draw a stamp annotation 39 * @protected 40 * @method draw 41 * @return M.assignfeedback_editpdf.drawable 42 */ 43 draw : function() { 44 var drawable = new M.assignfeedback_editpdf.drawable(this.editor), 45 drawingregion = Y.one(SELECTOR.DRAWINGREGION), 46 node, 47 position; 48 49 position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y)); 50 node = Y.Node.create('<div/>'); 51 node.setStyles({ 52 'position': 'absolute', 53 'display': 'inline-block', 54 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')', 55 'width': (this.endx - this.x), 56 'height': (this.endy - this.y), 57 'backgroundSize': '100% 100%', 58 'zIndex': 50 59 }); 60 61 drawingregion.append(node); 62 node.setX(position.x); 63 node.setY(position.y); 64 65 // Pass throught the event handlers on the div. 66 node.on('gesturemovestart', this.editor.edit_start, null, this.editor); 67 node.on('gesturemove', this.editor.edit_move, null, this.editor); 68 node.on('gesturemoveend', this.editor.edit_end, null, this.editor); 69 70 drawable.nodes.push(node); 71 72 this.drawable = drawable; 73 return ANNOTATIONSTAMP.superclass.draw.apply(this); 74 }, 75 76 /** 77 * Draw the in progress edit. 78 * 79 * @public 80 * @method draw_current_edit 81 * @param M.assignfeedback_editpdf.edit edit 82 */ 83 draw_current_edit : function(edit) { 84 var bounds = new M.assignfeedback_editpdf.rect(), 85 drawable = new M.assignfeedback_editpdf.drawable(this.editor), 86 drawingregion = Y.one(SELECTOR.DRAWINGREGION), 87 node, 88 position; 89 90 bounds.bound([edit.start, edit.end]); 91 position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(bounds.x, bounds.y)); 92 93 node = Y.Node.create('<div/>'); 94 node.setStyles({ 95 'position': 'absolute', 96 'display': 'inline-block', 97 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')', 98 'width': bounds.width, 99 'height': bounds.height, 100 'backgroundSize': '100% 100%', 101 'zIndex': 50 102 }); 103 104 drawingregion.append(node); 105 node.setX(position.x); 106 node.setY(position.y); 107 108 drawable.nodes.push(node); 109 110 return drawable; 111 }, 112 113 /** 114 * Promote the current edit to a real annotation. 115 * 116 * @public 117 * @method init_from_edit 118 * @param M.assignfeedback_editpdf.edit edit 119 * @return bool if width/height is more than min. required. 120 */ 121 init_from_edit : function(edit) { 122 var bounds = new M.assignfeedback_editpdf.rect(); 123 bounds.bound([edit.start, edit.end]); 124 125 if (bounds.width < 40) { 126 bounds.width = 40; 127 } 128 if (bounds.height < 40) { 129 bounds.height = 40; 130 } 131 this.gradeid = this.editor.get('gradeid'); 132 this.pageno = this.editor.currentpage; 133 this.x = bounds.x; 134 this.y = bounds.y; 135 this.endx = bounds.x + bounds.width; 136 this.endy = bounds.y + bounds.height; 137 this.colour = edit.annotationcolour; 138 this.path = edit.stamp; 139 140 // Min width and height is always more than 40px. 141 return true; 142 }, 143 144 /** 145 * Move an annotation to a new location. 146 * @public 147 * @param int newx 148 * @param int newy 149 * @method move_annotation 150 */ 151 move : function(newx, newy) { 152 var diffx = newx - this.x, 153 diffy = newy - this.y; 154 155 this.x += diffx; 156 this.y += diffy; 157 this.endx += diffx; 158 this.endy += diffy; 159 160 if (this.drawable) { 161 this.drawable.erase(); 162 } 163 this.editor.drawables.push(this.draw()); 164 } 165 166 }); 167 168 M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; 169 M.assignfeedback_editpdf.annotationstamp = ANNOTATIONSTAMP;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |