// This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . /* global SELECTOR, COMMENTCOLOUR, COMMENTTEXTCOLOUR */ /** * Provides an in browser PDF editor. * * @module moodle-assignfeedback_editpdf-editor */ /** * Class representing a list of comments. * * @namespace M.assignfeedback_editpdf * @class comment * @param M.assignfeedback_editpdf.editor editor * @param Int gradeid * @param Int pageno * @param Int x * @param Int y * @param Int width * @param String colour * @param String rawtext */ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) { /** * Reference to M.assignfeedback_editpdf.editor. * @property editor * @type M.assignfeedback_editpdf.editor * @public */ this.editor = editor; /** * Grade id * @property gradeid * @type Int * @public */ this.gradeid = gradeid || 0; /** * X position * @property x * @type Int * @public */ this.x = parseInt(x, 10) || 0; /** * Y position * @property y * @type Int * @public */ this.y = parseInt(y, 10) || 0; /** * Comment width * @property width * @type Int * @public */ this.width = parseInt(width, 10) || 0; /** * Comment rawtext * @property rawtext * @type String * @public */ this.rawtext = rawtext || ''; /** * Comment page number * @property pageno * @type Int * @public */ this.pageno = pageno || 0; /** * Comment background colour. * @property colour * @type String * @public */ this.colour = colour || 'yellow'; /** * Reference to M.assignfeedback_editpdf.drawable * @property drawable * @type M.assignfeedback_editpdf.drawable * @public */ this.drawable = false; /** * Boolean used by a timeout to delete empty comments after a short delay. * @property deleteme * @type Boolean * @public */ this.deleteme = false; /** * Reference to the link that opens the menu. * @property menulink * @type Y.Node * @public */ this.menulink = null; /** * Reference to the dialogue that is the context menu. * @property menu * @type M.assignfeedback_editpdf.dropdown * @public */ this.menu = null; /** * Clean a comment record, returning an oject with only fields that are valid. * @public * @method clean * @return {} */ this.clean = function() { return { gradeid: this.gradeid, x: parseInt(this.x, 10), y: parseInt(this.y, 10), width: parseInt(this.width, 10), rawtext: this.rawtext, pageno: this.currentpage, colour: this.colour }; }; /** * Draw a comment. * @public * @method draw_comment * @param boolean focus - Set the keyboard focus to the new comment if true * @return M.assignfeedback_editpdf.drawable */ this.draw = function(focus) { var drawable = new M.assignfeedback_editpdf.drawable(this.editor), node, drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION), container, menu, position, scrollheight; // Lets add a contenteditable div. node = Y.Node.create('