[ 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 AJAXBASE */ 16 17 /** 18 * Provides an in browser PDF editor. 19 * 20 * @module moodle-assignfeedback_editpdf-editor 21 */ 22 23 /** 24 * Class representing a users list of quick comments. 25 * 26 * @namespace M.assignfeedback_editpdf 27 * @class quickcommentlist 28 */ 29 var QUICKCOMMENTLIST = function(editor) { 30 31 /** 32 * Reference to M.assignfeedback_editpdf.editor. 33 * @property editor 34 * @type M.assignfeedback_editpdf.editor 35 * @public 36 */ 37 this.editor = editor; 38 39 /** 40 * Array of Comments 41 * @property shapes 42 * @type M.assignfeedback_editpdf.quickcomment[] 43 * @public 44 */ 45 this.comments = []; 46 47 /** 48 * Add a comment to the users quicklist. 49 * 50 * @protected 51 * @method add 52 */ 53 this.add = function(comment) { 54 var ajaxurl = AJAXBASE, 55 config; 56 57 // Do not save empty comments. 58 if (comment.rawtext === '') { 59 return; 60 } 61 62 config = { 63 method: 'post', 64 context: this, 65 sync: false, 66 data: { 67 'sesskey': M.cfg.sesskey, 68 'action': 'addtoquicklist', 69 'userid': this.editor.get('userid'), 70 'commenttext': comment.rawtext, 71 'width': comment.width, 72 'colour': comment.colour, 73 'attemptnumber': this.editor.get('attemptnumber'), 74 'assignmentid': this.editor.get('assignmentid') 75 }, 76 on: { 77 success: function(tid, response) { 78 var jsondata, quickcomment; 79 try { 80 jsondata = Y.JSON.parse(response.responseText); 81 if (jsondata.error) { 82 return new M.core.ajaxException(jsondata); 83 } else { 84 quickcomment = new M.assignfeedback_editpdf.quickcomment(jsondata.id, 85 jsondata.rawtext, 86 jsondata.width, 87 jsondata.colour); 88 this.comments.push(quickcomment); 89 } 90 } catch (e) { 91 return new M.core.exception(e); 92 } 93 }, 94 failure: function(tid, response) { 95 return M.core.exception(response.responseText); 96 } 97 } 98 }; 99 100 Y.io(ajaxurl, config); 101 }; 102 103 /** 104 * Remove a comment from the users quicklist. 105 * 106 * @public 107 * @method remove 108 */ 109 this.remove = function(comment) { 110 var ajaxurl = AJAXBASE, 111 config; 112 113 // Should not happen. 114 if (!comment) { 115 return; 116 } 117 118 config = { 119 method: 'post', 120 context: this, 121 sync: false, 122 data: { 123 'sesskey': M.cfg.sesskey, 124 'action': 'removefromquicklist', 125 'userid': this.editor.get('userid'), 126 'commentid': comment.id, 127 'attemptnumber': this.editor.get('attemptnumber'), 128 'assignmentid': this.editor.get('assignmentid') 129 }, 130 on: { 131 success: function() { 132 var i; 133 134 // Find and remove the comment from the quicklist. 135 i = this.comments.indexOf(comment); 136 if (i >= 0) { 137 this.comments.splice(i, 1); 138 } 139 }, 140 failure: function(tid, response) { 141 return M.core.exception(response.responseText); 142 } 143 } 144 }; 145 146 Y.io(ajaxurl, config); 147 }; 148 149 /** 150 * Load the users quick comments list. 151 * 152 * @protected 153 * @method load_quicklist 154 */ 155 this.load = function() { 156 var ajaxurl = AJAXBASE, 157 config; 158 159 config = { 160 method: 'get', 161 context: this, 162 sync: false, 163 data: { 164 'sesskey': M.cfg.sesskey, 165 'action': 'loadquicklist', 166 'userid': this.editor.get('userid'), 167 'attemptnumber': this.editor.get('attemptnumber'), 168 'assignmentid': this.editor.get('assignmentid') 169 }, 170 on: { 171 success: function(tid, response) { 172 var jsondata; 173 try { 174 jsondata = Y.JSON.parse(response.responseText); 175 if (jsondata.error) { 176 return new M.core.ajaxException(jsondata); 177 } else { 178 Y.each(jsondata, function(comment) { 179 var quickcomment = new M.assignfeedback_editpdf.quickcomment(comment.id, 180 comment.rawtext, 181 comment.width, 182 comment.colour); 183 this.comments.push(quickcomment); 184 }, this); 185 } 186 } catch (e) { 187 return new M.core.exception(e); 188 } 189 }, 190 failure: function(tid, response) { 191 return M.core.exception(response.responseText); 192 } 193 } 194 }; 195 196 Y.io(ajaxurl, config); 197 }; 198 }; 199 200 M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; 201 M.assignfeedback_editpdf.quickcommentlist = QUICKCOMMENTLIST;
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 |