1 /** 2 * Copyright (C) 2012-2013 KO GmbH <copyright@kogmbh.com> 3 * 4 * @licstart 5 * This file is part of WebODF. 6 * 7 * WebODF is free software: you can redistribute it and/or modify it 8 * under the terms of the GNU Affero General Public License (GNU AGPL) 9 * as published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * WebODF is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Affero General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License 18 * along with WebODF. If not, see <http://www.gnu.org/licenses/>. 19 * @licend 20 * 21 * @source: http://www.webodf.org/ 22 * @source: https://github.com/kogmbh/WebODF/ 23 */ 24 25 /*global ops*/ 26 27 /** 28 * @constructor 29 * @implements ops.Operation 30 */ 31 ops.OpAddCursor = function OpAddCursor() { 32 "use strict"; 33 34 var memberid, timestamp; 35 36 /** 37 * @param {!ops.OpAddCursor.InitSpec} data 38 */ 39 this.init = function (data) { 40 memberid = data.memberid; 41 timestamp = data.timestamp; 42 }; 43 44 this.isEdit = false; 45 this.group = undefined; 46 47 /** 48 * @param {!ops.Document} document 49 */ 50 this.execute = function (document) { 51 var odtDocument = /**@type{ops.OdtDocument}*/(document), 52 cursor = odtDocument.getCursor(memberid); 53 54 // there should be none 55 if (cursor) { 56 return false; 57 } 58 59 cursor = new ops.OdtCursor(memberid, odtDocument); 60 odtDocument.addCursor(cursor); 61 odtDocument.emit(ops.Document.signalCursorAdded, cursor); 62 return true; 63 }; 64 65 /** 66 * @return {!ops.OpAddCursor.Spec} 67 */ 68 this.spec = function () { 69 return { 70 optype: "AddCursor", 71 memberid: memberid, 72 timestamp: timestamp 73 }; 74 }; 75 }; 76 /**@typedef{{ 77 optype:string, 78 memberid:string, 79 timestamp:number 80 }}*/ 81 ops.OpAddCursor.Spec; 82 /**@typedef{{ 83 memberid:string, 84 timestamp:(number|undefined) 85 }}*/ 86 ops.OpAddCursor.InitSpec; 87