From 3deb4739275eb1fa55e38d9380794ca6f68435c6 Mon Sep 17 00:00:00 2001 From: Tobias Hintze Date: Fri, 9 Aug 2013 21:18:48 +0200 Subject: [PATCH] webodf update --- css/editor.css | 18 +- js/editor/Editor.js | 50 +- js/editor/EditorSession.js | 24 +- js/editor/{UserList.js => MemberList.js} | 51 +- js/editor/PullBoxSessionList.js | 159 ---- js/editor/SessionList.js | 50 - js/editor/boot_editor.js | 41 +- js/editor/resources/fonts/fonts.css | 0 js/editor/server/ServerFactory.js | 5 +- js/editor/server/nowjs/serverFactory.js | 6 +- js/editor/server/pullbox/serverFactory.js | 6 +- js/editor/server/pullbox/sessionList.js | 10 +- js/webodf-debug.js | 528 ++++++----- js/webodf.js | 1002 +++++++++++---------- 14 files changed, 972 insertions(+), 978 deletions(-) rename js/editor/{UserList.js => MemberList.js} (75%) delete mode 100644 js/editor/PullBoxSessionList.js delete mode 100644 js/editor/SessionList.js create mode 100644 js/editor/resources/fonts/fonts.css diff --git a/css/editor.css b/css/editor.css index 93045d02..0fb5f2fd 100644 --- a/css/editor.css +++ b/css/editor.css @@ -58,8 +58,9 @@ html, body, #mainContainer { -webkit-transform-origin: top center; -moz-transform-origin: top center; -o-transform-origin: top center; - overflow: hidden; + + border: 1px solid #ccc; } #collaboration { @@ -87,7 +88,7 @@ html, body, #mainContainer { } -#people { +#members { width: 70px; padding: 2px; text-align: center; @@ -120,14 +121,14 @@ html, body, #mainContainer { box-shadow: 0px 0px 15px red; } -#people > #nameInfo { +#members > #nameInfo { padding-top: 3px; padding-bottom: 3px; width: 100%; background-color: #eef; } -#peopleList .userListButton { +#memberList .memberListButton { margin-top: 5px; padding-top: 3px; margin-left: auto; @@ -141,7 +142,7 @@ html, body, #mainContainer { cursor: pointer; } -#peopleList .userListLabel { +#memberList .memberListLabel { color: white; border-radius: 5px; padding: 2px; @@ -149,11 +150,11 @@ html, body, #mainContainer { word-wrap: break-word; text-align: center justify; } -div.userListLabel[fullname]:before { +div.memberListLabel[fullname]:before { content: attr(fullname) ""; } -#peopleList img { +#memberList img { box-shadow: 0px 0px 5px rgb(90, 90, 90) inset; background-color: rgb(200, 200, 200); border-radius: 5px; @@ -164,7 +165,7 @@ div.userListLabel[fullname]:before { margin: auto; } -#peopleList img:hover { +#memberList img:hover { opacity: 0.9; } @@ -314,3 +315,4 @@ cursor div:after { top: 100%; left: 43%; } + diff --git a/js/editor/Editor.js b/js/editor/Editor.js index 583d11aa..9334e652 100644 --- a/js/editor/Editor.js +++ b/js/editor/Editor.js @@ -36,14 +36,14 @@ define("webodf/editor/Editor", [ "dojo/i18n!webodf/editor/nls/myResources", "webodf/editor/EditorSession", - "webodf/editor/UserList", + "webodf/editor/MemberList", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "webodf/editor/widgets"], function (myResources, EditorSession, - UserList, + MemberList, BorderContainer, ContentPane, loadWidgets) { @@ -52,7 +52,7 @@ define("webodf/editor/Editor", [ /** * @constructor * @param {{networked:boolean=, - * memberid:string=, + * memberid:!string, * loadCallback:function()=, * saveCallback:function()=, * cursorAddedCallback:function(!string)=, @@ -65,14 +65,13 @@ define("webodf/editor/Editor", [ var self = this, // Private - userid, memberid = args.memberid, session, editorSession, - userList, + memberList, networked = args.networked === true, opRouter, - userModel, + memberModel, loadOdtFile = args.loadCallback, saveOdtFile = args.saveCallback, cursorAddedHandler = args.cursorAddedCallback, @@ -99,17 +98,17 @@ define("webodf/editor/Editor", [ */ function initGuiAndDoc(initialDocumentUrl, editorReadyCallback) { var odfElement, mainContainer, - editorPane, peoplePane, + editorPane, memberListPane, inviteButton, viewOptions = { editInfoMarkersInitiallyVisible: networked, caretAvatarsInitiallyVisible: networked, caretBlinksOnRangeSelect: true }, - peopleListDiv = document.getElementById('peopleList'); + memberListDiv = document.getElementById('memberList'); if (networked) { - runtime.assert(peopleListDiv, "missing peopleList div in HTML"); + runtime.assert(memberListDiv, "missing memberList div in HTML"); } runtime.loadClass('odf.OdfCanvas'); @@ -158,19 +157,14 @@ define("webodf/editor/Editor", [ // Allow annotations odfCanvas.enableAnnotations(true); - if (!memberid) { - // legacy - memberid should be passed in the constructor - memberid = (userid || 'undefined') + "___" + Date.now(); - } - session = new ops.Session(odfCanvas); editorSession = new EditorSession(session, memberid, { viewOptions: viewOptions }); editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager()); - if (peopleListDiv) { - userList = new UserList(editorSession, peopleListDiv); + if (memberListDiv) { + memberList = new MemberList(editorSession, memberListDiv); } if (registerCallbackForShutdown) { @@ -192,12 +186,12 @@ define("webodf/editor/Editor", [ }, 'editor'); mainContainer.addChild(editorPane); - if (networked && peopleListDiv) { - peoplePane = new ContentPane({ + if (networked && memberListDiv) { + memberListPane = new ContentPane({ region: 'right', - title: translator("people") - }, 'people'); - mainContainer.addChild(peoplePane); + title: translator("members") + }, 'members'); + mainContainer.addChild(memberListPane); } mainContainer.startup(); @@ -205,7 +199,7 @@ define("webodf/editor/Editor", [ if (window.inviteButtonProxy) { inviteButton = document.getElementById('inviteButton'); if (inviteButton) { - inviteButton.innerText = translator("invitePeople"); + inviteButton.innerText = translator("inviteMembers"); inviteButton.style.display = "block"; inviteButton.onclick = window.inviteButtonProxy.clicked; } @@ -269,12 +263,12 @@ define("webodf/editor/Editor", [ */ self.loadSession = function (sessionId, editorReadyCallback) { initGuiAndDoc(server.getGenesisUrl(sessionId), function () { - // get router and user model + // get router and member model opRouter = opRouter || serverFactory.createOperationRouter(sessionId, memberid, server); session.setOperationRouter(opRouter); - userModel = userModel || serverFactory.createUserModel(server); - session.setUserModel(userModel); + memberModel = memberModel || serverFactory.createMemberModel(sessionId, server); + session.setMemberModel(memberModel); opRouter.requestReplay(function done() { var odtDocument = session.getOdtDocument(); @@ -295,9 +289,9 @@ define("webodf/editor/Editor", [ }); }; - // access to user model - self.getUserModel = function () { - return userModel; + // access to member model + self.getMemberModel = function () { + return memberModel; }; } return Editor; diff --git a/js/editor/EditorSession.js b/js/editor/EditorSession.js index cab8eaea..3da4bb27 100644 --- a/js/editor/EditorSession.js +++ b/js/editor/EditorSession.js @@ -70,8 +70,8 @@ define("webodf/editor/EditorSession", [ formatting = odtDocument.getFormatting(), styleHelper = new gui.StyleHelper(formatting), eventNotifier = new core.EventNotifier([ - EditorSession.signalUserAdded, - EditorSession.signalUserRemoved, + EditorSession.signalMemberAdded, + EditorSession.signalMemberRemoved, EditorSession.signalCursorMoved, EditorSession.signalParagraphChanged, EditorSession.signalStyleCreated, @@ -164,7 +164,7 @@ define("webodf/editor/EditorSession", [ ncName = createNCName(name); // create default paragraph style - // memberid is used to avoid id conflicts with ids created by other users + // memberid is used to avoid id conflicts with ids created by other members result = ncName + "_" + ncMemberId; // then loop until result is really unique while (formatting.hasParagraphStyle(result)) { @@ -196,12 +196,12 @@ define("webodf/editor/EditorSession", [ // Custom signals, that make sense in the Editor context. We do not want to expose webodf's ops signals to random bits of the editor UI. odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, function (cursor) { - self.emit(EditorSession.signalUserAdded, cursor.getMemberId()); + self.emit(EditorSession.signalMemberAdded, cursor.getMemberId()); trackCursor(cursor); }); odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, function (memberId) { - self.emit(EditorSession.signalUserRemoved, memberId); + self.emit(EditorSession.signalMemberRemoved, memberId); }); odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, function (cursor) { @@ -251,12 +251,12 @@ define("webodf/editor/EditorSession", [ eventNotifier.subscribe(eventid, cb); }; - this.getUserDetailsAndUpdates = function (memberId, subscriber) { - return session.getUserModel().getUserDetailsAndUpdates(memberId, subscriber); + this.getMemberDetailsAndUpdates = function (memberId, subscriber) { + return session.getMemberModel().getMemberDetailsAndUpdates(memberId, subscriber); }; - this.unsubscribeUserDetailsUpdates = function (memberId, subscriber) { - return session.getUserModel().unsubscribeUserDetailsUpdates(memberId, subscriber); + this.unsubscribeMemberDetailsUpdates = function (memberId, subscriber) { + return session.getMemberModel().unsubscribeMemberDetailsUpdates(memberId, subscriber); }; this.getCursorPosition = function () { @@ -458,7 +458,7 @@ define("webodf/editor/EditorSession", [ this.deleteStyle = function (styleName) { var op; - op = new ops.OpDeleteParagraphStyle(); + op = new ops.OpRemoveParagraphStyle(); op.init({ memberid: memberid, styleName: styleName @@ -541,8 +541,8 @@ define("webodf/editor/EditorSession", [ init(); }; - /**@const*/EditorSession.signalUserAdded = "userAdded"; - /**@const*/EditorSession.signalUserRemoved = "userRemoved"; + /**@const*/EditorSession.signalMemberAdded = "memberAdded"; + /**@const*/EditorSession.signalMemberRemoved = "memberRemoved"; /**@const*/EditorSession.signalCursorMoved = "cursorMoved"; /**@const*/EditorSession.signalParagraphChanged = "paragraphChanged"; /**@const*/EditorSession.signalStyleCreated = "styleCreated"; diff --git a/js/editor/UserList.js b/js/editor/MemberList.js similarity index 75% rename from js/editor/UserList.js rename to js/editor/MemberList.js index 7b5c820d..cc18a5ad 100644 --- a/js/editor/UserList.js +++ b/js/editor/MemberList.js @@ -33,32 +33,33 @@ * @source: http://gitorious.org/webodf/webodf/ */ /*global define,runtime */ -define("webodf/editor/UserList", + +define("webodf/editor/MemberList", ["webodf/editor/EditorSession"], function (EditorSession) { "use strict"; - return function UserList(editorSession, userListDiv) { + return function MemberList(editorSession, memberListDiv) { var self = this; - editorSession.subscribe(EditorSession.signalUserAdded, function (memberId) { - self.addUser(memberId); + editorSession.subscribe(EditorSession.signalMemberAdded, function (memberId) { + self.addMember(memberId); }); - editorSession.subscribe(EditorSession.signalUserRemoved, function (memberId) { - self.removeUser(memberId); + editorSession.subscribe(EditorSession.signalMemberRemoved, function (memberId) { + self.removeMember(memberId); }); /** * @param {!string} memberId */ - function updateAvatarButton(memberId, userDetails) { - var node = userListDiv.firstChild; - if (userDetails === null) { - // 'null' here means finally unknown user + function updateAvatarButton(memberId, memberDetails) { + var node = memberListDiv.firstChild; + if (memberDetails === null) { + // 'null' here means finally unknown member // (and not that the data is still loading) - userDetails = { + memberDetails = { memberid: memberId, fullname: "Unknown", color: "black", imageurl: "avatar-joe.png" }; @@ -69,11 +70,11 @@ define("webodf/editor/UserList", while (node) { if (node.localName === "img") { // update avatar image - node.src = userDetails.imageurl; + node.src = memberDetails.imageurl; // update border color - node.style.borderColor = userDetails.color; + node.style.borderColor = memberDetails.color; } else if (node.localName === "div") { - node.setAttribute('fullname', userDetails.fullname); + node.setAttribute('fullname', memberDetails.fullname); } node = node.nextSibling; } @@ -87,15 +88,15 @@ define("webodf/editor/UserList", * @param {!string} memberId */ function createAvatarButton(memberId) { - runtime.assert(userListDiv, "userListDiv unavailable"); - var doc = userListDiv.ownerDocument, + runtime.assert(memberListDiv, "memberListDiv unavailable"); + var doc = memberListDiv.ownerDocument, htmlns = doc.documentElement.namespaceURI, avatarDiv = doc.createElementNS(htmlns, "div"), imageElement = doc.createElement("img"), fullnameNode = doc.createElement("div"); - avatarDiv.className = "userListButton"; - fullnameNode.className = "userListLabel"; + avatarDiv.className = "memberListButton"; + fullnameNode.className = "memberListLabel"; avatarDiv.appendChild(imageElement); avatarDiv.appendChild(fullnameNode); avatarDiv.memberId = memberId; // TODO: namespace? @@ -112,7 +113,7 @@ define("webodf/editor/UserList", caret.toggleHandleVisibility(); } }; - userListDiv.appendChild(avatarDiv); + memberListDiv.appendChild(avatarDiv); // preset bogus data // TODO: indicate loading state @@ -124,10 +125,10 @@ define("webodf/editor/UserList", * @param {!string} memberId */ function removeAvatarButton(memberId) { - var node = userListDiv.firstChild; + var node = memberListDiv.firstChild; while (node) { if (node.memberId === memberId) { - userListDiv.removeChild(node); + memberListDiv.removeChild(node); return; } node = node.nextSibling; @@ -137,16 +138,16 @@ define("webodf/editor/UserList", /** * @param {!string} memberId */ - this.addUser = function (memberId) { + this.addMember = function (memberId) { createAvatarButton(memberId); - editorSession.getUserDetailsAndUpdates(memberId, updateAvatarButton); + editorSession.getMemberDetailsAndUpdates(memberId, updateAvatarButton); }; /** * @param {!string} memberId */ - this.removeUser = function (memberId) { - editorSession.unsubscribeUserDetailsUpdates(memberId, updateAvatarButton); + this.removeMember = function (memberId) { + editorSession.unsubscribeMemberDetailsUpdates(memberId, updateAvatarButton); removeAvatarButton(memberId); }; }; diff --git a/js/editor/PullBoxSessionList.js b/js/editor/PullBoxSessionList.js deleted file mode 100644 index 21795b57..00000000 --- a/js/editor/PullBoxSessionList.js +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @license - * Copyright (C) 2013 KO GmbH - * - * @licstart - * The JavaScript code in this page is free software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * (GNU AGPL) as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. The code is distributed - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. - * - * As additional permission under GNU AGPL version 3 section 7, you - * may distribute non-source (e.g., minimized or compacted) forms of - * that code without the copy of the GNU GPL normally required by - * section 4, provided you include this license notice and a URL - * through which recipients can access the Corresponding Source. - * - * As a special exception to the AGPL, any HTML file which merely makes function - * calls to this code, and for that purpose includes it by reference shall be - * deemed a separate work for copyright law purposes. In addition, the copyright - * holders of this code give you permission to combine this code with free - * software libraries that are released under the GNU LGPL. You may copy and - * distribute such a system following the terms of the GNU AGPL for this code - * and the LGPL for the libraries. If you modify this code, you may extend this - * exception to your version of the code, but you are not obligated to do so. - * If you do not wish to do so, delete this exception statement from your - * version. - * - * This license applies to this entire compilation. - * @licend - * @source: http://www.webodf.org/ - * @source: http://gitorious.org/webodf/webodf/ - */ - -/*global ops, runtime */ - -function PullBoxSessionList(server) { - "use strict"; - - var cachedSessionData = {}, - subscribers = [], - /** HACK: allow to stop pulling, so that does not mess up the logs - * Remove before merging to master */ - pullingActive = true; - - function onSessionData(sessionData) { - var i, - isNew = ! cachedSessionData.hasOwnProperty(sessionData.id); - - // cache - cachedSessionData[sessionData.id] = sessionData; - runtime.log("get session data for:"+sessionData.title+", is new:"+isNew); - - for (i = 0; i < subscribers.length; i += 1) { - if (isNew) { - subscribers[i].onCreated(sessionData); - } else { - subscribers[i].onUpdated(sessionData); - } - } - } - - function onSessionRemoved(sessionId) { - var i; - - if (cachedSessionData.hasOwnProperty(sessionId)) { - delete cachedSessionData[sessionId]; - - for (i = 0; i < subscribers.length; i += 1) { - subscribers[i].onRemoved(sessionId); - } - } - } - - function pullSessionList() { - if (!pullingActive) { return; } - - server.call("session-list", function(responseData) { - var response = runtime.fromJson(responseData), - sessionList, i, - unupdatedSessions = {}; - - runtime.log("session-list reply: " + responseData); - - if (response.hasOwnProperty("session_list")) { - // collect known sessions - for (i in cachedSessionData) { - if (cachedSessionData.hasOwnProperty(i)) { - unupdatedSessions[i] = ""; // some dummy value, unused - } - } - - // add/update with all delivered sessions - sessionList = response.session_list; - for (i = 0; i < sessionList.length; i++) { - if (unupdatedSessions.hasOwnProperty(sessionList[i].id)) { - delete unupdatedSessions[sessionList[i].id]; - } - onSessionData(sessionList[i]); - } - - // remove unupdated sessions - for (i in unupdatedSessions) { - if (unupdatedSessions.hasOwnProperty(i)) { - onSessionRemoved(i); - } - } - - // next update in 5 secs - runtime.getWindow().setTimeout(pullSessionList, 5000); - } else { - runtime.log("Meh, sessionlist data broken: " + responseData); - } - }); - } - - this.getSessions = function (subscriber) { - var i, - sessionList = []; - - if (subscriber) { - subscribers.push(subscriber); - } - - for (i in cachedSessionData) { - if (cachedSessionData.hasOwnProperty(i)) { - sessionList.push(cachedSessionData[i]); - } - } - - return sessionList; - }; - - this.unsubscribe = function (subscriber) { - var i; - - for (i=0; i - * - * @licstart - * The JavaScript code in this page is free software: you can redistribute it - * and/or modify it under the terms of the GNU Affero General Public License - * (GNU AGPL) as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. The code is distributed - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. - * - * As additional permission under GNU AGPL version 3 section 7, you - * may distribute non-source (e.g., minimized or compacted) forms of - * that code without the copy of the GNU GPL normally required by - * section 4, provided you include this license notice and a URL - * through which recipients can access the Corresponding Source. - * - * As a special exception to the AGPL, any HTML file which merely makes function - * calls to this code, and for that purpose includes it by reference shall be - * deemed a separate work for copyright law purposes. In addition, the copyright - * holders of this code give you permission to combine this code with free - * software libraries that are released under the GNU LGPL. You may copy and - * distribute such a system following the terms of the GNU AGPL for this code - * and the LGPL for the libraries. If you modify this code, you may extend this - * exception to your version of the code, but you are not obligated to do so. - * If you do not wish to do so, delete this exception statement from your - * version. - * - * This license applies to this entire compilation. - * @licend - * @source: http://www.webodf.org/ - * @source: http://gitorious.org/webodf/webodf/ - */ - -/*global ops, runtime */ - -/** - * A model which provides information about sessions. - * @interface - */ -SessionList = function SessionList() {"use strict"; }; - -/** - * @param {{onCreated:function(!Object), - * onUpdated:function(!Object), - * onRemoved:function(!string) }} subscriber - * @return {undefined} - */ -SessionList.prototype.getSessions = function (subscriber) {"use strict"; }; diff --git a/js/editor/boot_editor.js b/js/editor/boot_editor.js index 3895ecbc..b64de8f1 100644 --- a/js/editor/boot_editor.js +++ b/js/editor/boot_editor.js @@ -248,26 +248,22 @@ var webodfEditor = (function () { * and start the editor on the network. * * @param {!string} sessionId - * @param {!string} userid + * @param {!string} memberId * @param {?string} token * @param {?Object} editorOptions * @param {?function(!Object)} editorReadyCallback */ - function createNetworkedEditor(sessionId, userid, token, editorOptions, editorReadyCallback) { + function createNetworkedEditor(sessionId, memberId, token, editorOptions, editorReadyCallback) { runtime.assert(sessionId, "sessionId needs to be specified"); + runtime.assert(memberId, "memberId needs to be specified"); runtime.assert(editorInstance === null, "cannot boot with instanciated editor"); editorOptions = editorOptions || {}; - editorOptions.memberid = userid + "___" + Date.now(); + editorOptions.memberid = memberId; editorOptions.networked = true; editorOptions.networkSecurityToken = token; - // if pre-authentication has happened: - if (token) { - server.setToken(token); - } - require({ }, ["webodf/editor/Editor"], function (Editor) { // TODO: the networkSecurityToken needs to be retrieved via now.login @@ -280,7 +276,7 @@ var webodfEditor = (function () { editorReadyCallback(editorInstance); }); } - ); + ); } @@ -365,7 +361,8 @@ var webodfEditor = (function () { * */ function boot(args) { - var editorOptions = {}, loginProcedure = startLoginProcess; + var editorOptions = {}, + loginProcedure = startLoginProcess; runtime.assert(!booting, "editor creation already in progress"); args = args || {}; @@ -399,13 +396,25 @@ var webodfEditor = (function () { // start the editor with network function handleNetworkedSituation() { - loginProcedure(function (sessionId, userid, token) { - createNetworkedEditor(sessionId, userid, token, editorOptions, function (ed) { - if (args.callback) { - args.callback(ed); - } + var joinSession = server.joinSession; + + if (args.joinSession) { + joinSession = args.joinSession; + } + + loginProcedure(function (sessionId, userId, token) { + // if pre-authentication has happened: + if (token) { + server.setToken(token); } - ); + + joinSession(userId, sessionId, function(memberId) { + createNetworkedEditor(sessionId, memberId, token, editorOptions, function (ed) { + if (args.callback) { + args.callback(ed); + } + }); + }); }); } diff --git a/js/editor/resources/fonts/fonts.css b/js/editor/resources/fonts/fonts.css new file mode 100644 index 00000000..e69de29b diff --git a/js/editor/server/ServerFactory.js b/js/editor/server/ServerFactory.js index 4673a0e4..c21d134e 100644 --- a/js/editor/server/ServerFactory.js +++ b/js/editor/server/ServerFactory.js @@ -54,10 +54,11 @@ ServerFactory.prototype.createServer = function () {"use strict"; }; ServerFactory.prototype.createOperationRouter = function (sessionId, memberId, server) {"use strict"; }; /** + * @param {!string} sessionId * @param {!ops.Server} server - * @return {!ops.UserModel} + * @return {!ops.MemberModel} */ -ServerFactory.prototype.createUserModel = function (server) {"use strict"; }; +ServerFactory.prototype.createMemberModel = function (sessionId, server) {"use strict"; }; /** * @param {!ops.Server} server diff --git a/js/editor/server/nowjs/serverFactory.js b/js/editor/server/nowjs/serverFactory.js index dee230e4..c745ded3 100644 --- a/js/editor/server/nowjs/serverFactory.js +++ b/js/editor/server/nowjs/serverFactory.js @@ -41,7 +41,7 @@ define("webodf/editor/server/nowjs/serverFactory", [ "use strict"; runtime.loadClass("ops.NowjsServer"); - runtime.loadClass("ops.NowjsUserModel"); + runtime.loadClass("ops.NowjsMemberModel"); runtime.loadClass("ops.NowjsOperationRouter"); /** @@ -55,8 +55,8 @@ define("webodf/editor/server/nowjs/serverFactory", [ this.createOperationRouter = function (sid, mid, server) { return new ops.NowjsOperationRouter(sid, mid, server); }; - this.createUserModel = function (server) { - return new ops.NowjsUserModel(server); + this.createMemberModel = function (sid, server) { + return new ops.NowjsMemberModel(server); }; this.createSessionList = function (server) { return new NowjsSessionList(server); diff --git a/js/editor/server/pullbox/serverFactory.js b/js/editor/server/pullbox/serverFactory.js index b39c88df..fbac3f7b 100644 --- a/js/editor/server/pullbox/serverFactory.js +++ b/js/editor/server/pullbox/serverFactory.js @@ -41,7 +41,7 @@ define("webodf/editor/server/pullbox/serverFactory", [ "use strict"; runtime.loadClass("ops.PullBoxServer"); - runtime.loadClass("ops.PullBoxUserModel"); + runtime.loadClass("ops.PullBoxMemberModel"); runtime.loadClass("ops.PullBoxOperationRouter"); /** @@ -55,8 +55,8 @@ define("webodf/editor/server/pullbox/serverFactory", [ this.createOperationRouter = function (sid, mid, server) { return new ops.PullBoxOperationRouter(sid, mid, server); }; - this.createUserModel = function (server) { - return new ops.PullBoxUserModel(server); + this.createMemberModel = function (sid, server) { + return new ops.PullBoxMemberModel(sid, server); }; this.createSessionList = function (server) { return new PullBoxSessionList(server); diff --git a/js/editor/server/pullbox/sessionList.js b/js/editor/server/pullbox/sessionList.js index 04f24cff..db521758 100644 --- a/js/editor/server/pullbox/sessionList.js +++ b/js/editor/server/pullbox/sessionList.js @@ -77,14 +77,16 @@ define("webodf/editor/server/pullbox/sessionList", [], function () { function pullSessionList() { if (!pullingActive) { return; } - server.call("session-list", function(responseData) { + server.call({ + command: "query_sessiondata_list" + }, function(responseData) { var response = runtime.fromJson(responseData), sessionList, i, unupdatedSessions = {}; - runtime.log("session-list reply: " + responseData); + runtime.log("query_sessiondata_list reply: " + responseData); - if (response.hasOwnProperty("session_list")) { + if (response.hasOwnProperty("sessiondata_list")) { // collect known sessions for (i in cachedSessionData) { if (cachedSessionData.hasOwnProperty(i)) { @@ -93,7 +95,7 @@ define("webodf/editor/server/pullbox/sessionList", [], function () { } // add/update with all delivered sessions - sessionList = response.session_list; + sessionList = response.sessiondata_list; for (i = 0; i < sessionList.length; i++) { if (unupdatedSessions.hasOwnProperty(sessionList[i].id)) { delete unupdatedSessions[sessionList[i].id]; diff --git a/js/webodf-debug.js b/js/webodf-debug.js index 35c957c9..7ab890d6 100644 --- a/js/webodf-debug.js +++ b/js/webodf-debug.js @@ -2994,6 +2994,7 @@ core.Utils = function Utils() { this.hashString = hashString }; core.DomUtils = function DomUtils() { + var self = this; function findStablePoint(container, offset) { if(offset < container.childNodes.length) { container = container.childNodes[offset]; @@ -3108,7 +3109,26 @@ core.DomUtils = function DomUtils() { var nodeLength = node.nodeType === Node.TEXT_NODE ? node.length : node.childNodes.length; return range.comparePoint(node, 0) <= 0 && range.comparePoint(node, nodeLength) >= 0 } - this.rangeIntersectsNode = rangeIntersectsNode + this.rangeIntersectsNode = rangeIntersectsNode; + function containsNode(parent, descendant) { + return parent === descendant || parent.contains(descendant) + } + this.containsNode = containsNode; + function containsNodeForBrokenWebKit(parent, descendant) { + return parent === descendant || Boolean(parent.compareDocumentPosition(descendant) & Node.DOCUMENT_POSITION_CONTAINED_BY) + } + function init() { + var window = runtime.getWindow(), appVersion, webKitOrSafari; + if(window === null) { + return + } + appVersion = window.navigator.appVersion.toLowerCase(); + webKitOrSafari = appVersion.indexOf("chrome") === -1 && (appVersion.indexOf("applewebkit") !== -1 || appVersion.indexOf("safari") !== -1); + if(webKitOrSafari) { + self.containsNode = containsNodeForBrokenWebKit + } + } + init() }; runtime.loadClass("core.DomUtils"); core.Cursor = function Cursor(document, memberId) { @@ -5724,7 +5744,7 @@ xmldom.XPath = function() { @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.AnnotationViewManager = function AnnotationViewManager(odfFragment, annotationsPane) { +gui.AnnotationViewManager = function AnnotationViewManager(odfCanvas, odfFragment, annotationsPane) { var annotations = [], doc = odfFragment.ownerDocument, odfUtils = new odf.OdfUtils, CONNECTOR_MARGIN = 30, NOTE_MARGIN = 20, window = runtime.getWindow(); runtime.assert(Boolean(window), "Expected to be run in an environment which has a global window, like a browser."); function wrapAnnotation(annotation) { @@ -5782,21 +5802,21 @@ gui.AnnotationViewManager = function AnnotationViewManager(odfFragment, annotati return Math.sqrt(xs + ys) } function renderAnnotation(annotation) { - var annotationNote = annotation.node.parentNode, connectorHorizontal = annotationNote.nextSibling, connectorAngular = connectorHorizontal.nextSibling, annotationWrapper = annotationNote.parentNode, connectorAngle = 0, previousAnnotation = annotations[annotations.indexOf(annotation) - 1], previousRect, creatorNode = annotation.node.getElementsByTagNameNS(odf.Namespaces.dcns, "creator")[0], creatorName; - annotationNote.style.left = annotationsPane.getBoundingClientRect().left - annotationWrapper.getBoundingClientRect().left + "px"; - annotationNote.style.width = annotationsPane.getBoundingClientRect().width + "px"; + var annotationNote = annotation.node.parentNode, connectorHorizontal = annotationNote.nextSibling, connectorAngular = connectorHorizontal.nextSibling, annotationWrapper = annotationNote.parentNode, connectorAngle = 0, previousAnnotation = annotations[annotations.indexOf(annotation) - 1], previousRect, creatorNode = annotation.node.getElementsByTagNameNS(odf.Namespaces.dcns, "creator")[0], creatorName, zoomLevel = odfCanvas.getZoomLevel(); + annotationNote.style.left = (annotationsPane.getBoundingClientRect().left - annotationWrapper.getBoundingClientRect().left) / zoomLevel + "px"; + annotationNote.style.width = annotationsPane.getBoundingClientRect().width / zoomLevel + "px"; connectorHorizontal.style.width = parseFloat(annotationNote.style.left) - CONNECTOR_MARGIN + "px"; if(previousAnnotation) { previousRect = previousAnnotation.node.parentNode.getBoundingClientRect(); - if(annotationWrapper.getBoundingClientRect().top - previousRect.bottom <= NOTE_MARGIN) { - annotationNote.style.top = Math.abs(annotationWrapper.getBoundingClientRect().top - previousRect.bottom) + NOTE_MARGIN + "px" + if((annotationWrapper.getBoundingClientRect().top - previousRect.bottom) / zoomLevel <= NOTE_MARGIN) { + annotationNote.style.top = Math.abs(annotationWrapper.getBoundingClientRect().top - previousRect.bottom) / zoomLevel + NOTE_MARGIN + "px" }else { annotationNote.style.top = "0px" } } - connectorAngular.style.left = connectorHorizontal.getBoundingClientRect().width + "px"; - connectorAngular.style.width = lineDistance({x:connectorAngular.getBoundingClientRect().left, y:connectorAngular.getBoundingClientRect().top}, {x:annotationNote.getBoundingClientRect().left, y:annotationNote.getBoundingClientRect().top}) + "px"; - connectorAngle = Math.asin((annotationNote.getBoundingClientRect().top - connectorAngular.getBoundingClientRect().top) / parseFloat(connectorAngular.style.width)); + connectorAngular.style.left = connectorHorizontal.getBoundingClientRect().width / zoomLevel + "px"; + connectorAngular.style.width = lineDistance({x:connectorAngular.getBoundingClientRect().left / zoomLevel, y:connectorAngular.getBoundingClientRect().top / zoomLevel}, {x:annotationNote.getBoundingClientRect().left / zoomLevel, y:annotationNote.getBoundingClientRect().top / zoomLevel}) + "px"; + connectorAngle = Math.asin((annotationNote.getBoundingClientRect().top - connectorAngular.getBoundingClientRect().top) / (zoomLevel * parseFloat(connectorAngular.style.width))); connectorAngular.style.transform = "rotate(" + connectorAngle + "rad)"; connectorAngular.style.MozTransform = "rotate(" + connectorAngle + "rad)"; connectorAngular.style.WebkitTransform = "rotate(" + connectorAngle + "rad)"; @@ -8618,18 +8638,14 @@ odf.OdfCanvas = function() { } } if(url) { - if(/^(?:http|https|ftp):\/\//.test(url)) { - callback(url) - }else { - try { - part = container.getPart(url); - part.onchange = function(part) { - callback(part.url) - }; - part.load() - }catch(e) { - runtime.log("slight problem: " + e) - } + try { + part = container.getPart(url); + part.onchange = function(part) { + callback(part.url) + }; + part.load() + }catch(e) { + runtime.log("slight problem: " + e) } }else { url = getUrlFromBinaryDataElement(image); @@ -8917,7 +8933,7 @@ odf.OdfCanvas = function() { } odf.OdfCanvas = function OdfCanvas(element) { runtime.assert(element !== null && element !== undefined, "odf.OdfCanvas constructor needs DOM element"); - var doc = element.ownerDocument, odfcontainer, formatting = new odf.Formatting, selectionWatcher = new SelectionWatcher(element), pageSwitcher, fontcss, stylesxmlcss, positioncss, editable = false, zoomLevel = 1, eventHandlers = {}, editparagraph, loadingQueue = new LoadingQueue; + var self = this, doc = element.ownerDocument, odfcontainer, formatting = new odf.Formatting, selectionWatcher = new SelectionWatcher(element), pageSwitcher, fontcss, stylesxmlcss, positioncss, editable = false, zoomLevel = 1, eventHandlers = {}, editparagraph, loadingQueue = new LoadingQueue; addWebODFStyleSheet(doc); pageSwitcher = new PageSwitcher(addStyleSheet(doc)); fontcss = addStyleSheet(doc); @@ -9029,7 +9045,7 @@ odf.OdfCanvas = function() { if(annotationManager) { annotationManager.forgetAnnotations() } - annotationManager = new gui.AnnotationViewManager(odfnode.body, annotationsPane); + annotationManager = new gui.AnnotationViewManager(self, odfnode.body, annotationsPane); modifyAnnotations(odfnode.body) }else { if(annotationsPane.parentNode) { @@ -9331,6 +9347,8 @@ ops.Server.prototype.networkStatus = function() { }; ops.Server.prototype.login = function(login, password, successCb, failCb) { }; +ops.Server.prototype.joinSession = function(userId, sessionId, successCb, failCb) { +}; ops.Server.prototype.getGenesisUrl = function(sessionId) { }; /* @@ -9368,16 +9386,10 @@ ops.Server.prototype.getGenesisUrl = function(sessionId) { @source: http://gitorious.org/webodf/webodf/ */ ops.NowjsServer = function NowjsServer() { - var self = this, nowObject; + var nowObject; this.getNowObject = function() { return nowObject }; - function createOperationRouter(sid, mid) { - return new ops.NowjsOperationRouter(sid, mid, self) - } - function createUserModel() { - return new ops.NowjsUserModel(self) - } this.getGenesisUrl = function(sessionId) { return"/session/" + sessionId + "/genesis" }; @@ -9421,8 +9433,12 @@ ops.NowjsServer = function NowjsServer() { nowObject.login(login, password, successCb, failCb) } }; - this.createOperationRouter = createOperationRouter; - this.createUserModel = createUserModel + this.joinSession = function(userId, sessionId, successCb, failCb) { + nowObject.joinSession(userId, sessionId, function(memberId) { + nowObject.memberid = memberId; + successCb(memberId) + }, failCb) + } }; /* @@ -9523,6 +9539,19 @@ ops.PullBoxServer = function PullBoxServer(args) { failCb(responseData) } }) + }; + this.joinSession = function(userId, sessionId, successCb, failCb) { + call({command:"join_session", args:{user_id:userId, es_id:sessionId}}, function(responseData) { + var response = (runtime.fromJson(responseData)); + runtime.log("join_session reply: " + responseData); + if(response.hasOwnProperty("success") && response.success) { + successCb(response.member_id) + }else { + if(failCb) { + failCb() + } + } + }) } }; /* @@ -10635,7 +10664,7 @@ ops.OpSetParagraphStyle = function OpSetParagraphStyle() { }; this.transform = function(otherOp, hasPriority) { var otherOpspec = otherOp.spec(), otherOpType = otherOpspec.optype; - if(otherOpType === "DeleteParagraphStyle") { + if(otherOpType === "RemoveParagraphStyle") { if(otherOpspec.styleName === styleName) { styleName = "" } @@ -10759,7 +10788,7 @@ ops.OpUpdateParagraphStyle = function OpUpdateParagraphStyle() { } } }else { - if(otherOpType === "DeleteParagraphStyle") { + if(otherOpType === "RemoveParagraphStyle") { if(otherOpspec.styleName === styleName) { return[] } @@ -10866,7 +10895,7 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { }; this.transform = function(otherOp, hasPriority) { var otherSpec = otherOp.spec(); - if((otherSpec.optype === "UpdateParagraphStyle" || otherSpec.optype === "DeleteParagraphStyle") && otherSpec.styleName === styleName) { + if((otherSpec.optype === "UpdateParagraphStyle" || otherSpec.optype === "RemoveParagraphStyle") && otherSpec.styleName === styleName) { return null } return[self] @@ -10949,8 +10978,8 @@ ops.OpAddParagraphStyle = function OpAddParagraphStyle() { @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpDeleteParagraphStyle = function OpDeleteParagraphStyle() { - var self = this, optype = "DeleteParagraphStyle", memberid, timestamp, styleName; +ops.OpRemoveParagraphStyle = function OpRemoveParagraphStyle() { + var self = this, optype = "RemoveParagraphStyle", memberid, timestamp, styleName; this.init = function(data) { memberid = data.memberid; timestamp = data.timestamp; @@ -11137,7 +11166,7 @@ runtime.loadClass("ops.OpSplitParagraph"); runtime.loadClass("ops.OpSetParagraphStyle"); runtime.loadClass("ops.OpUpdateParagraphStyle"); runtime.loadClass("ops.OpAddParagraphStyle"); -runtime.loadClass("ops.OpDeleteParagraphStyle"); +runtime.loadClass("ops.OpRemoveParagraphStyle"); runtime.loadClass("ops.OpAddAnnotation"); ops.OperationFactory = function OperationFactory() { var specs; @@ -11158,7 +11187,7 @@ ops.OperationFactory = function OperationFactory() { } } function init() { - specs = {AddCursor:constructor(ops.OpAddCursor), ApplyDirectStyling:constructor(ops.OpApplyDirectStyling), InsertTable:constructor(ops.OpInsertTable), InsertText:constructor(ops.OpInsertText), RemoveText:constructor(ops.OpRemoveText), SplitParagraph:constructor(ops.OpSplitParagraph), SetParagraphStyle:constructor(ops.OpSetParagraphStyle), UpdateParagraphStyle:constructor(ops.OpUpdateParagraphStyle), AddParagraphStyle:constructor(ops.OpAddParagraphStyle), DeleteParagraphStyle:constructor(ops.OpDeleteParagraphStyle), + specs = {AddCursor:constructor(ops.OpAddCursor), ApplyDirectStyling:constructor(ops.OpApplyDirectStyling), InsertTable:constructor(ops.OpInsertTable), InsertText:constructor(ops.OpInsertText), RemoveText:constructor(ops.OpRemoveText), SplitParagraph:constructor(ops.OpSplitParagraph), SetParagraphStyle:constructor(ops.OpSetParagraphStyle), UpdateParagraphStyle:constructor(ops.OpUpdateParagraphStyle), AddParagraphStyle:constructor(ops.OpAddParagraphStyle), RemoveParagraphStyle:constructor(ops.OpRemoveParagraphStyle), MoveCursor:constructor(ops.OpMoveCursor), RemoveCursor:constructor(ops.OpRemoveCursor), AddAnnotation:constructor(ops.OpAddAnnotation)} } init() @@ -11555,7 +11584,7 @@ runtime.loadClass("ops.OpSplitParagraph"); runtime.loadClass("ops.OpSetParagraphStyle"); runtime.loadClass("ops.OpAddParagraphStyle"); runtime.loadClass("ops.OpUpdateParagraphStyle"); -runtime.loadClass("ops.OpDeleteParagraphStyle"); +runtime.loadClass("ops.OpRemoveParagraphStyle"); ops.OperationTransformer = function OperationTransformer() { var operationFactory; function transformOpVsOp(opA, opB) { @@ -11731,17 +11760,6 @@ ops.EditInfo = function EditInfo(container, odtDocument) { return sortEdits() }; this.addEdit = function(memberid, timestamp) { - var id, userid = memberid.split("___")[0]; - if(!editHistory[memberid]) { - for(id in editHistory) { - if(editHistory.hasOwnProperty(id)) { - if(id.split("___")[0] === userid) { - delete editHistory[id]; - break - } - } - } - } editHistory[memberid] = {time:timestamp} }; this.clearEdits = function() { @@ -11890,7 +11908,7 @@ gui.Caret = function Caret(cursor, avatarInitiallyVisible, blinkOnRangeSelect) { caretOffsetTopLeft.y += caretElement.offsetTop; return{left:caretOffsetTopLeft.x - margin, top:caretOffsetTopLeft.y - margin, right:caretOffsetTopLeft.x + caretElement.scrollWidth - 1 + margin, bottom:caretOffsetTopLeft.y + caretElement.scrollHeight - 1 + margin} } - this.refreshCursor = function() { + this.refreshCursorBlinking = function() { if(blinkOnRangeSelect || cursor.getSelectedRange().collapsed) { shouldBlink = true; blink(true) @@ -12168,6 +12186,8 @@ gui.Clipboard = function Clipboard() { } init() }; +runtime.loadClass("core.DomUtils"); +runtime.loadClass("odf.OdfUtils"); runtime.loadClass("ops.OpAddCursor"); runtime.loadClass("ops.OpRemoveCursor"); runtime.loadClass("ops.OpMoveCursor"); @@ -12181,7 +12201,8 @@ runtime.loadClass("gui.KeyboardHandler"); runtime.loadClass("gui.StyleHelper"); gui.SessionController = function() { gui.SessionController = function SessionController(session, inputMemberId) { - var odtDocument = session.getOdtDocument(), odfUtils = new odf.OdfUtils, clipboard = new gui.Clipboard, clickHandler = new gui.ClickHandler, keyDownHandler = new gui.KeyboardHandler, keyPressHandler = new gui.KeyboardHandler, styleHelper = new gui.StyleHelper(odtDocument.getFormatting()), keyboardMovementsFilter = new core.PositionFilterChain, baseFilter = odtDocument.getPositionFilter(), undoManager = null; + var window = (runtime.getWindow()), odtDocument = session.getOdtDocument(), domUtils = new core.DomUtils, odfUtils = new odf.OdfUtils, clipboard = new gui.Clipboard, clickHandler = new gui.ClickHandler, keyDownHandler = new gui.KeyboardHandler, keyPressHandler = new gui.KeyboardHandler, styleHelper = new gui.StyleHelper(odtDocument.getFormatting()), keyboardMovementsFilter = new core.PositionFilterChain, baseFilter = odtDocument.getPositionFilter(), undoManager = null; + runtime.assert(window !== null, "Expected to be run in an environment which has a global window, like a browser."); keyboardMovementsFilter.addFilter("BaseFilter", baseFilter); keyboardMovementsFilter.addFilter("RootFilter", odtDocument.createRootFilter(inputMemberId)); function listenEvent(eventTarget, eventType, eventHandler, includeDirect) { @@ -12258,21 +12279,67 @@ gui.SessionController = function() { } return null } + function findClosestPosition(node) { + var canvasElement = odtDocument.getOdfCanvas().getElement(), newNode = odtDocument.getRootNode(), newOffset = 0, beforeCanvas, iterator; + beforeCanvas = canvasElement.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING; + if(!beforeCanvas) { + iterator = gui.SelectionMover.createPositionIterator(newNode); + iterator.moveToEnd(); + newNode = iterator.container(); + newOffset = iterator.unfilteredDomOffset() + } + return{node:newNode, offset:newOffset} + } + function getSelection(e) { + var canvasElement = odtDocument.getOdfCanvas().getElement(), selection = window.getSelection(), anchorNode, anchorOffset, focusNode, focusOffset, anchorNodeInsideCanvas, focusNodeInsideCanvas, caretPos, node; + if(selection.anchorNode === null && selection.focusNode === null) { + caretPos = caretPositionFromPoint(e.clientX, e.clientY); + if(!caretPos) { + return null + } + anchorNode = (caretPos.container); + anchorOffset = caretPos.offset; + focusNode = anchorNode; + focusOffset = anchorOffset + }else { + anchorNode = (selection.anchorNode); + anchorOffset = selection.anchorOffset; + focusNode = (selection.focusNode); + focusOffset = selection.focusOffset + } + runtime.assert(anchorNode !== null && focusNode !== null, "anchorNode is null or focusNode is null"); + anchorNodeInsideCanvas = domUtils.containsNode(canvasElement, anchorNode); + focusNodeInsideCanvas = domUtils.containsNode(canvasElement, focusNode); + if(!anchorNodeInsideCanvas && !focusNodeInsideCanvas) { + return null + } + if(!anchorNodeInsideCanvas) { + node = findClosestPosition(anchorNode); + anchorNode = node.node; + anchorOffset = node.offset + } + if(!focusNodeInsideCanvas) { + node = findClosestPosition(focusNode); + focusNode = node.node; + focusOffset = node.offset + } + canvasElement.focus(); + return{anchorNode:anchorNode, anchorOffset:anchorOffset, focusNode:focusNode, focusOffset:focusOffset} + } function selectRange(e) { runtime.setTimeout(function() { - var selection = runtime.getWindow().getSelection(), oldPosition = odtDocument.getCursorPosition(inputMemberId), range, caretPos, stepsToAnchor, stepsToFocus, op; - if(selection.anchorNode === null && selection.focusNode === null) { - caretPos = caretPositionFromPoint(e.clientX, e.clientY); - if(caretPos) { - range = odtDocument.getDOM().createRange(); - range.setStart(caretPos.container, caretPos.offset); - range.collapse(true); - selection.addRange(range) - } + var selection = getSelection(e), oldPosition, stepsToAnchor, stepsToFocus, op; + if(selection === null) { + return } stepsToAnchor = countStepsToNode(selection.anchorNode, selection.anchorOffset); - stepsToFocus = countStepsToNode(selection.focusNode, selection.focusOffset); + if(selection.focusNode === selection.anchorNode && selection.focusOffset === selection.anchorOffset) { + stepsToFocus = stepsToAnchor + }else { + stepsToFocus = countStepsToNode(selection.focusNode, selection.focusOffset) + } if(stepsToFocus !== null && stepsToFocus !== 0 || stepsToAnchor !== null && stepsToAnchor !== 0) { + oldPosition = odtDocument.getCursorPosition(inputMemberId); op = createOpMoveCursor(oldPosition + stepsToAnchor, stepsToFocus - stepsToAnchor); session.enqueue(op) } @@ -12282,18 +12349,22 @@ gui.SessionController = function() { selectRange(e) } function selectWord() { - var currentNode, i, c, op, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), cursorNode = odtDocument.getCursor(inputMemberId).getNode(), oldPosition = odtDocument.getCursorPosition(inputMemberId), alphaNumeric = /[A-Za-z0-9]/, stepsToStart = 0, stepsToEnd = 0; + var canvasElement = odtDocument.getOdfCanvas().getElement(), alphaNumeric = /[A-Za-z0-9]/, stepsToStart = 0, stepsToEnd = 0, iterator, cursorNode, oldPosition, currentNode, i, c, op; + if(!domUtils.containsNode(canvasElement, window.getSelection().focusNode)) { + return + } + iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()); + cursorNode = odtDocument.getCursor(inputMemberId).getNode(); iterator.setUnfilteredPosition(cursorNode, 0); if(iterator.previousPosition()) { currentNode = iterator.getCurrentNode(); if(currentNode.nodeType === Node.TEXT_NODE) { for(i = currentNode.data.length - 1;i >= 0;i -= 1) { c = currentNode.data[i]; - if(alphaNumeric.test(c)) { - stepsToStart -= 1 - }else { + if(!alphaNumeric.test(c)) { break } + stepsToStart -= 1 } } } @@ -12303,25 +12374,31 @@ gui.SessionController = function() { if(currentNode.nodeType === Node.TEXT_NODE) { for(i = 0;i < currentNode.data.length;i += 1) { c = currentNode.data[i]; - if(alphaNumeric.test(c)) { - stepsToEnd += 1 - }else { + if(!alphaNumeric.test(c)) { break } + stepsToEnd += 1 } } } if(stepsToStart !== 0 || stepsToEnd !== 0) { + oldPosition = odtDocument.getCursorPosition(inputMemberId); op = createOpMoveCursor(oldPosition + stepsToStart, Math.abs(stepsToStart) + Math.abs(stepsToEnd)); session.enqueue(op) } } function selectParagraph() { - var stepsToStart, stepsToEnd, op, iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()), paragraphNode = odtDocument.getParagraphElement(odtDocument.getCursor(inputMemberId).getNode()), oldPosition = odtDocument.getCursorPosition(inputMemberId); + var canvasElement = odtDocument.getOdfCanvas().getElement(), iterator, paragraphNode, oldPosition, stepsToStart, stepsToEnd, op; + if(!domUtils.containsNode(canvasElement, window.getSelection().focusNode)) { + return + } + paragraphNode = odtDocument.getParagraphElement(odtDocument.getCursor(inputMemberId).getNode()); stepsToStart = odtDocument.getDistanceFromCursor(inputMemberId, paragraphNode, 0); + iterator = gui.SelectionMover.createPositionIterator(odtDocument.getRootNode()); iterator.moveToEndOfNode(paragraphNode); stepsToEnd = odtDocument.getDistanceFromCursor(inputMemberId, paragraphNode, iterator.unfilteredDomOffset()); if(stepsToStart !== 0 || stepsToEnd !== 0) { + oldPosition = odtDocument.getCursorPosition(inputMemberId); op = createOpMoveCursor(oldPosition + stepsToStart, Math.abs(stepsToStart) + Math.abs(stepsToEnd)); session.enqueue(op) } @@ -12540,7 +12617,7 @@ gui.SessionController = function() { return true } function maintainCursorSelection() { - var cursor = odtDocument.getCursor(inputMemberId), selection = runtime.getWindow().getSelection(); + var cursor = odtDocument.getCursor(inputMemberId), selection = window.getSelection(); if(cursor) { selection.removeAllRanges(); selection.addRange(cursor.getSelectedRange().cloneRange()) @@ -12583,7 +12660,7 @@ gui.SessionController = function() { } } function handlePaste(e) { - var plainText, window = runtime.getWindow(); + var plainText; if(window.clipboardData && window.clipboardData.getData) { plainText = window.clipboardData.getData("Text") }else { @@ -12655,7 +12732,7 @@ gui.SessionController = function() { listenEvent(canvasElement, "copy", handleCopy); listenEvent(canvasElement, "beforepaste", handleBeforePaste, true); listenEvent(canvasElement, "paste", handlePaste); - listenEvent(canvasElement, "mouseup", clickHandler.handleMouseUp); + listenEvent(window, "mouseup", clickHandler.handleMouseUp); listenEvent(canvasElement, "contextmenu", handleContextMenu); odtDocument.subscribe(ops.OdtDocument.signalOperationExecuted, maintainCursorSelection); odtDocument.subscribe(ops.OdtDocument.signalOperationExecuted, updateUndoStack); @@ -12679,7 +12756,7 @@ gui.SessionController = function() { removeEvent(canvasElement, "copy", handleCopy); removeEvent(canvasElement, "paste", handlePaste); removeEvent(canvasElement, "beforepaste", handleBeforePaste); - removeEvent(canvasElement, "mouseup", clickHandler.handleMouseUp); + removeEvent(window, "mouseup", clickHandler.handleMouseUp); removeEvent(canvasElement, "contextmenu", handleContextMenu); op = new ops.OpRemoveCursor; op.init({memberid:inputMemberId}); @@ -12711,7 +12788,7 @@ gui.SessionController = function() { return undoManager }; function init() { - var isMacOS = runtime.getWindow().navigator.appVersion.toLowerCase().indexOf("mac") !== -1, modifier = gui.KeyboardHandler.Modifier, keyCode = gui.KeyboardHandler.KeyCode; + var isMacOS = window.navigator.appVersion.toLowerCase().indexOf("mac") !== -1, modifier = gui.KeyboardHandler.Modifier, keyCode = gui.KeyboardHandler.KeyCode; keyDownHandler.bind(keyCode.Tab, modifier.None, function() { insertText("\t"); return true @@ -12779,15 +12856,9 @@ gui.SessionController = function() { }; return gui.SessionController }(); -ops.UserModel = function UserModel() { -}; -ops.UserModel.prototype.getUserDetailsAndUpdates = function(memberId, subscriber) { -}; -ops.UserModel.prototype.unsubscribeUserDetailsUpdates = function(memberId, subscriber) { -}; /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -12819,19 +12890,88 @@ ops.UserModel.prototype.unsubscribeUserDetailsUpdates = function(memberId, subsc @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.TrivialUserModel = function TrivialUserModel() { - var users = {}; - users.bob = {memberid:"bob", fullname:"Bob Pigeon", color:"red", imageurl:"avatar-pigeon.png"}; - users.alice = {memberid:"alice", fullname:"Alice Bee", color:"green", imageurl:"avatar-flower.png"}; - users.you = {memberid:"you", fullname:"I, Robot", color:"blue", imageurl:"avatar-joe.png"}; - this.getUserDetailsAndUpdates = function(memberId, subscriber) { - var userid = memberId.split("___")[0]; - subscriber(memberId, users[userid] || null) +ops.MemberModel = function MemberModel() { +}; +ops.MemberModel.prototype.getMemberDetailsAndUpdates = function(memberId, subscriber) { +}; +ops.MemberModel.prototype.unsubscribeMemberDetailsUpdates = function(memberId, subscriber) { +}; +/* + + Copyright (C) 2012-2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +ops.TrivialMemberModel = function TrivialMemberModel() { + this.getMemberDetailsAndUpdates = function(memberId, subscriber) { + subscriber(memberId, null) }; - this.unsubscribeUserDetailsUpdates = function(memberId, subscriber) { + this.unsubscribeMemberDetailsUpdates = function(memberId, subscriber) { } }; -ops.NowjsUserModel = function NowjsUserModel(server) { +/* + + Copyright (C) 2012-2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +ops.NowjsMemberModel = function NowjsMemberModel(server) { var cachedUserData = {}, memberDataSubscribers = {}, nowObject = server.getNowObject(); function userIdFromMemberId(memberId) { return memberId.split("___")[0] @@ -12846,7 +12986,7 @@ ops.NowjsUserModel = function NowjsUserModel(server) { } } } - this.getUserDetailsAndUpdates = function(memberId, subscriber) { + this.getMemberDetailsAndUpdates = function(memberId, subscriber) { var userId = userIdFromMemberId(memberId), userData = cachedUserData[userId], subscribers = memberDataSubscribers[userId] || [], i; memberDataSubscribers[userId] = subscribers; runtime.assert(subscriber !== undefined, "missing callback"); @@ -12856,7 +12996,7 @@ ops.NowjsUserModel = function NowjsUserModel(server) { } } if(i < subscribers.length) { - runtime.log("double subscription request for " + memberId + " in NowjsUserModel::getUserDetailsAndUpdates") + runtime.log("double subscription request for " + memberId + " in NowjsMemberModel::getMemberDetailsAndUpdates") }else { subscribers.push({memberId:memberId, subscriber:subscriber}); if(subscribers.length === 1) { @@ -12867,7 +13007,7 @@ ops.NowjsUserModel = function NowjsUserModel(server) { subscriber(memberId, userData) } }; - this.unsubscribeUserDetailsUpdates = function(memberId, subscriber) { + this.unsubscribeMemberDetailsUpdates = function(memberId, subscriber) { var i, userId = userIdFromMemberId(memberId), subscribers = memberDataSubscribers[userId]; runtime.assert(subscriber !== undefined, "missing subscriber parameter or null"); runtime.assert(subscribers, "tried to unsubscribe when no one is subscribed ('" + memberId + "')"); @@ -12926,61 +13066,53 @@ ops.NowjsUserModel = function NowjsUserModel(server) { @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.PullBoxUserModel = function PullBoxUserModel(server) { - var cachedUserData = {}, memberDataSubscribers = {}, serverPullingActivated = false, pullingIntervall = 2E4; - function userIdFromMemberId(memberId) { - return memberId.split("___")[0] - } - function cacheUserDatum(userData) { +ops.PullBoxMemberModel = function PullBoxMemberModel(sessionId, server) { + var cachedMemberData = {}, memberDataSubscribers = {}, serverPullingActivated = false, pullingIntervall = 2E4; + function cacheMemberDatum(memberData) { var subscribers, i; - subscribers = memberDataSubscribers[userData.userid]; + subscribers = memberDataSubscribers[memberData.memberid]; if(subscribers) { - cachedUserData[userData.userid] = userData; + cachedMemberData[memberData.memberid] = memberData; for(i = 0;i < subscribers.length;i += 1) { - subscribers[i].subscriber(subscribers[i].memberId, userData) + subscribers[i](memberData.memberid, memberData) } } } - function pullUserData() { - var i, userIds = []; - for(i in memberDataSubscribers) { - if(memberDataSubscribers.hasOwnProperty(i)) { - userIds.push(i) - } - } - runtime.log("user-list request for : " + userIds.join(",")); - server.call({command:"user-list", args:{user_ids:userIds}}, function(responseData) { - var response = (runtime.fromJson(responseData)), userList, newUserData, oldUserData; - runtime.log("user-list reply: " + responseData); - if(response.hasOwnProperty("userdata_list")) { - userList = response.userdata_list; - for(i = 0;i < userList.length;i += 1) { - newUserData = {userid:userList[i].uid, fullname:userList[i].fullname, imageurl:"/user/" + userList[i].avatarId + "/avatar.png", color:userList[i].color}; - oldUserData = cachedUserData.hasOwnProperty(userList[i].uid) ? cachedUserData[userList[i].uid] : null; - if(!oldUserData || oldUserData.fullname !== newUserData.fullname || oldUserData.imageurl !== newUserData.imageurl || oldUserData.color !== newUserData.color) { - cacheUserDatum(newUserData) + function pullMemberData() { + var i, memberIds = Object.keys(memberDataSubscribers); + runtime.log("member-list request for : " + memberIds.join(",")); + server.call({command:"query_memberdata_list", args:{es_id:sessionId, member_ids:memberIds}}, function(responseData) { + var response = (runtime.fromJson(responseData)), memberDataList, newMemberData, oldMemberData; + runtime.log("member-list reply: " + responseData); + if(response.hasOwnProperty("memberdata_list")) { + memberDataList = response.memberdata_list; + for(i = 0;i < memberDataList.length;i += 1) { + newMemberData = {memberid:memberDataList[i].member_id, fullname:memberDataList[i].display_name, imageurl:memberDataList[i].avatar_url, color:memberDataList[i].color}; + oldMemberData = cachedMemberData.hasOwnProperty(newMemberData.memberid) ? cachedMemberData[newMemberData.memberid] : null; + if(!oldMemberData || oldMemberData.fullname !== newMemberData.fullname || oldMemberData.imageurl !== newMemberData.imageurl || oldMemberData.color !== newMemberData.color) { + cacheMemberDatum(newMemberData) } } }else { - runtime.log("Meh, userlist data broken: " + responseData) + runtime.log("Meh, memberdata list broken: " + responseData) } }) } - function periodicPullUserData() { + function periodicPullMemberData() { if(!serverPullingActivated) { return } - pullUserData(); - runtime.setTimeout(periodicPullUserData, pullingIntervall) + pullMemberData(); + runtime.setTimeout(periodicPullMemberData, pullingIntervall) } - function activatePeriodicUserDataPulling() { + function activatePeriodicMemberDataPulling() { if(serverPullingActivated) { return } serverPullingActivated = true; - runtime.setTimeout(periodicPullUserData, pullingIntervall) + runtime.setTimeout(periodicPullMemberData, pullingIntervall) } - function deactivatePeriodicUserDataPulling() { + function deactivatePeriodicMemberDataPulling() { var key; if(!serverPullingActivated) { return @@ -12992,35 +13124,35 @@ ops.PullBoxUserModel = function PullBoxUserModel(server) { } serverPullingActivated = false } - this.getUserDetailsAndUpdates = function(memberId, subscriber) { - var userId = userIdFromMemberId(memberId), userData = cachedUserData[userId], subscribers = memberDataSubscribers[userId] || [], i; - memberDataSubscribers[userId] = subscribers; + this.getMemberDetailsAndUpdates = function(memberId, subscriber) { + var memberData = cachedMemberData[memberId], subscribers = memberDataSubscribers[memberId] || [], i; + memberDataSubscribers[memberId] = subscribers; runtime.assert(subscriber !== undefined, "missing callback"); for(i = 0;i < subscribers.length;i += 1) { - if(subscribers[i].subscriber === subscriber && subscribers[i].memberId === memberId) { + if(subscribers[i] === subscriber) { break } } if(i < subscribers.length) { - runtime.log("double subscription request for " + memberId + " in PullBoxUserModel::getUserDetailsAndUpdates") + runtime.log("double subscription request for " + memberId + " in PullBoxMemberModel::getMemberDetailsAndUpdates") }else { - subscribers.push({memberId:memberId, subscriber:subscriber}); + subscribers.push(subscriber); if(subscribers.length === 1) { - pullUserData() + pullMemberData() } } - if(userData) { - subscriber(memberId, userData) + if(memberData) { + subscriber(memberId, memberData) } - activatePeriodicUserDataPulling() + activatePeriodicMemberDataPulling() }; - this.unsubscribeUserDetailsUpdates = function(memberId, subscriber) { - var i, userId = userIdFromMemberId(memberId), subscribers = memberDataSubscribers[userId]; + this.unsubscribeMemberDetailsUpdates = function(memberId, subscriber) { + var i, subscribers = memberDataSubscribers[memberId]; runtime.assert(subscriber !== undefined, "missing subscriber parameter or null"); runtime.assert(subscribers, "tried to unsubscribe when no one is subscribed ('" + memberId + "')"); if(subscribers) { for(i = 0;i < subscribers.length;i += 1) { - if(subscribers[i].subscriber === subscriber && subscribers[i].memberId === memberId) { + if(subscribers[i] === subscriber) { break } } @@ -13028,9 +13160,9 @@ ops.PullBoxUserModel = function PullBoxUserModel(server) { subscribers.splice(i, 1); if(subscribers.length === 0) { runtime.log("no more subscribers for: " + memberId); - delete memberDataSubscribers[userId]; - delete cachedUserData[userId]; - deactivatePeriodicUserDataPulling() + delete memberDataSubscribers[memberId]; + delete cachedMemberData[memberId]; + deactivatePeriodicMemberDataPulling() } } }; @@ -13193,14 +13325,7 @@ ops.NowjsOperationRouter = function NowjsOperationRouter(sessionId, memberid, se done_cb() } }) - }; - function init() { - nowObject.memberid = memberid; - nowObject.joinSession(sessionId, function(sessionJoinSuccess) { - runtime.assert(sessionJoinSuccess, "Trying to join a session which does not exists or where we are already in") - }) } - init() }; /* @@ -13336,10 +13461,10 @@ ops.PullBoxOperationRouter = function PullBoxOperationRouter(sessionId, memberId syncLock = true; syncedClientOpspecs = unsyncedClientOpspecQueue; unsyncedClientOpspecQueue = []; - server.call({command:"sync-ops", args:{es_id:sessionId, member_id:memberId, seq_head:String(lastServerSeq), client_ops:syncedClientOpspecs}}, function(responseData) { + server.call({command:"sync_ops", args:{es_id:sessionId, member_id:memberId, seq_head:String(lastServerSeq), client_ops:syncedClientOpspecs}}, function(responseData) { var shouldRetryInstantly = false, response = (runtime.fromJson(responseData)); runtime.log("sync-ops reply: " + responseData); - if(response.result === "newOps") { + if(response.result === "new_ops") { if(response.ops.length > 0) { if(unsyncedClientOpspecQueue.length === 0) { receiveOpSpecsFromNetwork(compressOpSpecs(response.ops)) @@ -13347,18 +13472,18 @@ ops.PullBoxOperationRouter = function PullBoxOperationRouter(sessionId, memberId runtime.log("meh, have new ops locally meanwhile, have to do transformations."); hasUnresolvableConflict = !handleOpsSyncConflict(compressOpSpecs(response.ops)) } - lastServerSeq = response.headSeq + lastServerSeq = response.head_seq } }else { if(response.result === "added") { runtime.log("All added to server"); - lastServerSeq = response.headSeq + lastServerSeq = response.head_seq }else { if(response.result === "conflict") { unsyncedClientOpspecQueue = syncedClientOpspecs.concat(unsyncedClientOpspecQueue); runtime.log("meh, server has new ops meanwhile, have to do transformations."); hasUnresolvableConflict = !handleOpsSyncConflict(compressOpSpecs(response.ops)); - lastServerSeq = response.headSeq; + lastServerSeq = response.head_seq; if(!hasUnresolvableConflict) { shouldRetryInstantly = true } @@ -13423,15 +13548,7 @@ ops.PullBoxOperationRouter = function PullBoxOperationRouter(sessionId, memberId playbackFunction(timedOp); unsyncedClientOpspecQueue.push(opspec); triggerPushingOps() - }; - function init() { - server.call({command:"join-session", args:{session_id:sessionId, member_id:memberId}}, function(responseData) { - var response = Boolean(runtime.fromJson(responseData)); - runtime.log("join-session reply: " + responseData); - runtime.assert(response, "Trying to join a session which does not exists or where we are already in") - }) } - init() }; gui.EditInfoHandle = function EditInfoHandle(parentElement) { var edits = [], handle, document = (parentElement.ownerDocument), htmlns = document.documentElement.namespaceURI, editinfons = "urn:webodf:names:editinfo"; @@ -13561,7 +13678,7 @@ gui.EditInfoMarker = function EditInfoMarker(editInfo, initialVisibility) { }; /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -13594,7 +13711,7 @@ gui.EditInfoMarker = function EditInfoMarker(editInfo, initialVisibility) { @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("gui.Caret"); -runtime.loadClass("ops.TrivialUserModel"); +runtime.loadClass("ops.TrivialMemberModel"); runtime.loadClass("ops.EditInfo"); runtime.loadClass("gui.EditInfoMarker"); gui.SessionViewOptions = function() { @@ -13604,7 +13721,7 @@ gui.SessionViewOptions = function() { }; gui.SessionView = function() { function configOption(userValue, defaultValue) { - return userValue !== undefined ? userValue : defaultValue + return userValue !== undefined ? Boolean(userValue) : defaultValue } function SessionView(viewOptions, session, caretManager) { var avatarInfoStyles, editInfons = "urn:webodf:names:editinfo", editInfoMap = {}, showEditInfoMarkers = configOption(viewOptions.editInfoMarkersInitiallyVisible, true), showCaretAvatars = configOption(viewOptions.caretAvatarsInitiallyVisible, true), blinkOnRangeSelect = configOption(viewOptions.caretBlinksOnRangeSelect, true); @@ -13708,26 +13825,26 @@ gui.SessionView = function() { this.getCaret = function(memberid) { return caretManager.getCaret(memberid) }; - function renderMemberData(memberId, userData) { + function renderMemberData(memberId, memberData) { var caret = caretManager.getCaret(memberId); - if(userData === undefined) { - runtime.log('UserModel sent undefined data for member "' + memberId + '".'); + if(memberData === undefined) { + runtime.log('MemberModel sent undefined data for member "' + memberId + '".'); return } - if(userData === null) { - userData = {memberid:memberId, fullname:"Unknown Identity", color:"black", imageurl:"avatar-joe.png"} + if(memberData === null) { + memberData = {memberid:memberId, fullname:"Unknown Identity", color:"black", imageurl:"avatar-joe.png"} } if(caret) { - caret.setAvatarImageUrl(userData.imageurl); - caret.setColor(userData.color) + caret.setAvatarImageUrl(memberData.imageurl); + caret.setColor(memberData.color) } - setAvatarInfoStyle(memberId, userData.fullname, userData.color) + setAvatarInfoStyle(memberId, memberData.fullname, memberData.color) } function onCursorAdded(cursor) { - var memberId = cursor.getMemberId(), userModel = session.getUserModel(); + var memberId = cursor.getMemberId(), memberModel = session.getMemberModel(); caretManager.registerCursor(cursor, showCaretAvatars, blinkOnRangeSelect); renderMemberData(memberId, null); - userModel.getUserDetailsAndUpdates(memberId, renderMemberData); + memberModel.getMemberDetailsAndUpdates(memberId, renderMemberData); runtime.log("+++ View here +++ eagerly created an Caret for '" + memberId + "'! +++") } function onCursorRemoved(memberid) { @@ -13739,7 +13856,7 @@ gui.SessionView = function() { } } if(!hasMemberEditInfo) { - session.getUserModel().unsubscribeUserDetailsUpdates(memberid, renderMemberData) + session.getMemberModel().unsubscribeMemberDetailsUpdates(memberid, renderMemberData) } } function init() { @@ -13762,7 +13879,7 @@ gui.SessionView = function() { }(); /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -13797,35 +13914,44 @@ gui.SessionView = function() { runtime.loadClass("gui.Caret"); gui.CaretManager = function CaretManager(sessionController) { var carets = {}; + function getCaret(memberId) { + return carets.hasOwnProperty(memberId) ? carets[memberId] : null + } function getCanvasElement() { return sessionController.getSession().getOdtDocument().getOdfCanvas().getElement() } function removeCaret(memberId) { if(memberId === sessionController.getInputMemberId()) { - getCanvasElement().removeAttribute("tabindex", 0) + getCanvasElement().removeAttribute("tabindex") } delete carets[memberId] } - function refreshCaret(cursor) { - var caret = carets[cursor.getMemberId()]; - if(caret) { - caret.refreshCursor() + function refreshLocalCaretBlinking(cursor) { + var caret, memberId = cursor.getMemberId(); + if(memberId === sessionController.getInputMemberId()) { + caret = getCaret(memberId); + if(caret) { + caret.refreshCursorBlinking() + } } } function ensureLocalCaretVisible(info) { - var caret = carets[info.memberId]; - if(info.memberId === sessionController.getInputMemberId() && caret) { - caret.ensureVisible() + var caret; + if(info.memberId === sessionController.getInputMemberId()) { + caret = getCaret(info.memberId); + if(caret) { + caret.ensureVisible() + } } } function focusLocalCaret() { - var caret = carets[sessionController.getInputMemberId()]; + var caret = getCaret(sessionController.getInputMemberId()); if(caret) { caret.setFocus() } } function blurLocalCaret() { - var caret = carets[sessionController.getInputMemberId()]; + var caret = getCaret(sessionController.getInputMemberId()); if(caret) { caret.removeFocus() } @@ -13841,9 +13967,7 @@ gui.CaretManager = function CaretManager(sessionController) { } return caret }; - this.getCaret = function(memberid) { - return carets[memberid] - }; + this.getCaret = getCaret; this.getCarets = function() { return Object.keys(carets).map(function(memberid) { return carets[memberid] @@ -13852,7 +13976,7 @@ gui.CaretManager = function CaretManager(sessionController) { function init() { var session = sessionController.getSession(), odtDocument = session.getOdtDocument(), canvasElement = getCanvasElement(); odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, ensureLocalCaretVisible); - odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, refreshCaret); + odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, refreshLocalCaretBlinking); odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, removeCaret); canvasElement.onfocus = focusLocalCaret; canvasElement.onblur = blurLocalCaret @@ -15038,14 +15162,14 @@ ops.OdtDocument.signalUndoStackChanged = "undo/changed"; @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -runtime.loadClass("ops.TrivialUserModel"); +runtime.loadClass("ops.TrivialMemberModel"); runtime.loadClass("ops.TrivialOperationRouter"); runtime.loadClass("ops.OperationFactory"); runtime.loadClass("ops.OdtDocument"); ops.Session = function Session(odfCanvas) { - var self = this, operationFactory = new ops.OperationFactory, odtDocument = new ops.OdtDocument(odfCanvas), userModel = new ops.TrivialUserModel, operationRouter = null; - this.setUserModel = function(uModel) { - userModel = uModel + var self = this, operationFactory = new ops.OperationFactory, odtDocument = new ops.OdtDocument(odfCanvas), memberModel = new ops.TrivialMemberModel, operationRouter = null; + this.setMemberModel = function(uModel) { + memberModel = uModel }; this.setOperationFactory = function(opFactory) { operationFactory = opFactory; @@ -15061,8 +15185,8 @@ ops.Session = function Session(odfCanvas) { }); opRouter.setOperationFactory(operationFactory) }; - this.getUserModel = function() { - return userModel + this.getMemberModel = function() { + return memberModel }; this.getOperationFactory = function() { return operationFactory diff --git a/js/webodf.js b/js/webodf.js index 9d103c10..f2cc9c3f 100644 --- a/js/webodf.js +++ b/js/webodf.js @@ -36,79 +36,79 @@ */ var core={},gui={},xmldom={},odf={},ops={}; // Input 1 -function Runtime(){}Runtime.ByteArray=function(l){};Runtime.prototype.getVariable=function(l){};Runtime.prototype.toJson=function(l){};Runtime.prototype.fromJson=function(l){};Runtime.ByteArray.prototype.slice=function(l,f){};Runtime.ByteArray.prototype.length=0;Runtime.prototype.byteArrayFromArray=function(l){};Runtime.prototype.byteArrayFromString=function(l,f){};Runtime.prototype.byteArrayToString=function(l,f){};Runtime.prototype.concatByteArrays=function(l,f){}; -Runtime.prototype.read=function(l,f,m,g){};Runtime.prototype.readFile=function(l,f,m){};Runtime.prototype.readFileSync=function(l,f){};Runtime.prototype.loadXML=function(l,f){};Runtime.prototype.writeFile=function(l,f,m){};Runtime.prototype.isFile=function(l,f){};Runtime.prototype.getFileSize=function(l,f){};Runtime.prototype.deleteFile=function(l,f){};Runtime.prototype.log=function(l,f){};Runtime.prototype.setTimeout=function(l,f){};Runtime.prototype.clearTimeout=function(l){}; -Runtime.prototype.libraryPaths=function(){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(l){};Runtime.prototype.getWindow=function(){};Runtime.prototype.assert=function(l,f,m){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(l,f){function m(b){var a="",e,d=b.length;for(e=0;ec?a+=String.fromCharCode(c):(e+=1,g=b[e],194<=c&&224>c?a+=String.fromCharCode((c&31)<<6|g&63):(e+=1,h=b[e],224<=c&&240>c?a+=String.fromCharCode((c&15)<<12|(g&63)<<6|h&63):(e+=1,s=b[e],240<=c&&245>c&&(c=(c&7)<<18|(g&63)<<12|(h&63)<<6|s&63,c-=65536,a+=String.fromCharCode((c>>10)+55296,(c&1023)+56320))))); -return a}var b;"utf8"===f?b=g(l):("binary"!==f&&this.log("Unsupported encoding: "+f),b=m(l));return b};Runtime.getVariable=function(l){try{return eval(l)}catch(f){}};Runtime.toJson=function(l){return JSON.stringify(l)};Runtime.fromJson=function(l){return JSON.parse(l)};Runtime.getFunctionName=function(l){return void 0===l.name?(l=/function\s+(\w+)/.exec(l))&&l[1]:l.name}; -function BrowserRuntime(l){function f(a,e){var d,c,b;void 0!==e?b=a:e=a;l?(c=l.ownerDocument,b&&(d=c.createElement("span"),d.className=b,d.appendChild(c.createTextNode(b)),l.appendChild(d),l.appendChild(c.createTextNode(" "))),d=c.createElement("span"),0h?(c[f]=h,f+=1):2048>h?(c[f]=192|h>>>6,c[f+1]=128|h&63,f+=2):(c[f]=224|h>>>12&15,c[f+1]=128|h>>>6&63,c[f+2]=128|h&63,f+=3)}else for("binary"!== -e&&g.log("unknown encoding: "+e),d=a.length,c=new g.ByteArray(d),b=0;bc.status||0===c.status?d(null):d("Status "+String(c.status)+": "+c.responseText|| -c.statusText):d("File "+a+" is empty."))};e=e.buffer&&!c.sendAsBinary?e.buffer:g.byteArrayToString(e,"binary");try{c.sendAsBinary?c.sendAsBinary(e):c.send(e)}catch(f){g.log("HUH? "+f+" "+e),d(f.message)}};this.deleteFile=function(a,e){delete b[a];var d=new XMLHttpRequest;d.open("DELETE",a,!0);d.onreadystatechange=function(){4===d.readyState&&(200>d.status&&300<=d.status?e(d.responseText):e(null))};d.send(null)};this.loadXML=function(a,e){var d=new XMLHttpRequest;d.open("GET",a,!0);d.overrideMimeType&& -d.overrideMimeType("text/xml");d.onreadystatechange=function(){4===d.readyState&&(0!==d.status||d.responseText?200===d.status||0===d.status?e(null,d.responseXML):e(d.responseText):e("File "+a+" is empty."))};try{d.send(null)}catch(c){e(c.message)}};this.isFile=function(a,e){g.getFileSize(a,function(a){e(-1!==a)})};this.getFileSize=function(a,e){var d=new XMLHttpRequest;d.open("HEAD",a,!0);d.onreadystatechange=function(){if(4===d.readyState){var c=d.getResponseHeader("Content-Length");c?e(parseInt(c, -10)):m(a,"binary",function(c,a){c?e(-1):e(a.length)})}};d.send(null)};this.log=f;this.assert=function(a,e,d){if(!a)throw f("alert","ASSERTION FAILED:\n"+e),d&&d(),e;};this.setTimeout=function(a,e){return setTimeout(function(){a()},e)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(a){return(new DOMParser).parseFromString(a, -"text/xml")};this.exit=function(a){f("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window}} -function NodeJSRuntime(){function l(a,d,c){a=g.resolve(b,a);"binary"!==d?m.readFile(a,d,c):m.readFile(a,null,c)}var f=this,m=require("fs"),g=require("path"),b="",k,a;this.ByteArray=function(a){return new Buffer(a)};this.byteArrayFromArray=function(a){var d=new Buffer(a.length),c,b=a.length;for(c=0;c").implementation} -function RhinoRuntime(){function l(a,e){var d;void 0!==e?d=a:e=a;"alert"===d&&print("\n!!!!! ALERT !!!!!");print(e);"alert"===d&&print("!!!!! ALERT !!!!!")}var f=this,m=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),g,b,k="";m.setValidating(!1);m.setNamespaceAware(!0);m.setExpandEntityReferences(!1);m.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,e){var d=new Packages.java.io.FileReader(e);return new Packages.org.xml.sax.InputSource(d)}});g=m.newDocumentBuilder(); -g.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,e){var d=[],c,b=a.length;for(c=0;cd?a+=String.fromCharCode(d):(g+=1,c=b[g],194<=d&&224>d?a+=String.fromCharCode((d&31)<<6|c&63):(g+=1,f=b[g],224<=d&&240>d?a+=String.fromCharCode((d&15)<<12|(c&63)<<6|f&63):(g+=1,s=b[g],240<=d&&245>d&&(d=(d&7)<<18|(c&63)<<12|(f&63)<<6|s&63,d-=65536,a+=String.fromCharCode((d>>10)+55296,(d&1023)+56320))))); +return a}var b;"utf8"===l?b=c(k):("binary"!==l&&this.log("Unsupported encoding: "+l),b=n(k));return b};Runtime.getVariable=function(k){try{return eval(k)}catch(l){}};Runtime.toJson=function(k){return JSON.stringify(k)};Runtime.fromJson=function(k){return JSON.parse(k)};Runtime.getFunctionName=function(k){return void 0===k.name?(k=/function\s+(\w+)/.exec(k))&&k[1]:k.name}; +function BrowserRuntime(k){function l(a,g){var e,d,b;void 0!==g?b=a:g=a;k?(d=k.ownerDocument,b&&(e=d.createElement("span"),e.className=b,e.appendChild(d.createTextNode(b)),k.appendChild(e),k.appendChild(d.createTextNode(" "))),e=d.createElement("span"),0f?(d[s]=f,s+=1):2048>f?(d[s]=192|f>>>6,d[s+1]=128|f&63,s+=2):(d[s]=224|f>>>12&15,d[s+1]=128|f>>>6&63,d[s+2]=128|f&63,s+=3)}else for("binary"!== +g&&c.log("unknown encoding: "+g),e=a.length,d=new c.ByteArray(e),b=0;bd.status||0===d.status?e(null):e("Status "+String(d.status)+": "+d.responseText|| +d.statusText):e("File "+a+" is empty."))};g=g.buffer&&!d.sendAsBinary?g.buffer:c.byteArrayToString(g,"binary");try{d.sendAsBinary?d.sendAsBinary(g):d.send(g)}catch(h){c.log("HUH? "+h+" "+g),e(h.message)}};this.deleteFile=function(a,g){delete b[a];var e=new XMLHttpRequest;e.open("DELETE",a,!0);e.onreadystatechange=function(){4===e.readyState&&(200>e.status&&300<=e.status?g(e.responseText):g(null))};e.send(null)};this.loadXML=function(a,g){var e=new XMLHttpRequest;e.open("GET",a,!0);e.overrideMimeType&& +e.overrideMimeType("text/xml");e.onreadystatechange=function(){4===e.readyState&&(0!==e.status||e.responseText?200===e.status||0===e.status?g(null,e.responseXML):g(e.responseText):g("File "+a+" is empty."))};try{e.send(null)}catch(d){g(d.message)}};this.isFile=function(a,g){c.getFileSize(a,function(a){g(-1!==a)})};this.getFileSize=function(a,g){var e=new XMLHttpRequest;e.open("HEAD",a,!0);e.onreadystatechange=function(){if(4===e.readyState){var d=e.getResponseHeader("Content-Length");d?g(parseInt(d, +10)):n(a,"binary",function(d,a){d?g(-1):g(a.length)})}};e.send(null)};this.log=l;this.assert=function(a,g,e){if(!a)throw l("alert","ASSERTION FAILED:\n"+g),e&&e(),g;};this.setTimeout=function(a,g){return setTimeout(function(){a()},g)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=function(a){return(new DOMParser).parseFromString(a, +"text/xml")};this.exit=function(a){l("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window}} +function NodeJSRuntime(){function k(a,e,d){a=c.resolve(b,a);"binary"!==e?n.readFile(a,e,d):n.readFile(a,null,d)}var l=this,n=require("fs"),c=require("path"),b="",h,a;this.ByteArray=function(a){return new Buffer(a)};this.byteArrayFromArray=function(a){var e=new Buffer(a.length),d,b=a.length;for(d=0;d").implementation} +function RhinoRuntime(){function k(a,g){var e;void 0!==g?e=a:g=a;"alert"===e&&print("\n!!!!! ALERT !!!!!");print(g);"alert"===e&&print("!!!!! ALERT !!!!!")}var l=this,n=Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,h="";n.setValidating(!1);n.setNamespaceAware(!0);n.setExpandEntityReferences(!1);n.setSchema(null);b=Packages.org.xml.sax.EntityResolver({resolveEntity:function(a,g){var e=new Packages.java.io.FileReader(g);return new Packages.org.xml.sax.InputSource(e)}});c=n.newDocumentBuilder(); +c.setEntityResolver(b);this.ByteArray=function(a){return[a]};this.byteArrayFromArray=function(a){return a};this.byteArrayFromString=function(a,g){var e=[],d,b=a.length;for(d=0;d>>18],h+=q[c>>>12&63],h+=q[c>>>6&63],h+=q[c&63];d===b+1?(c=a[d]<<4,h+=q[c>>>6],h+=q[c&63],h+="=="):d===b&&(c=a[d]<<10|a[d+1]<<2,h+=q[c>>>12],h+=q[c>>>6&63],h+=q[c&63],h+="=");return h}function m(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var c=[],h=a.length%4,d,b=a.length,e;for(d=0;d>16,e>>8&255,e&255);c.length-=[0,0,2,1][h];return c}function g(a){var c=[],h,d=a.length,b;for(h=0;hb?c.push(b):2048>b?c.push(192|b>>>6,128|b&63):c.push(224|b>>>12&15,128|b>>>6&63,128|b&63);return c}function b(a){var c=[],h,d=a.length,b,e,n;for(h=0;hb?c.push(b):(h+=1,e=a[h],224>b?c.push((b&31)<<6|e&63):(h+=1,n=a[h],c.push((b&15)<<12|(e&63)<<6|n&63)));return c}function k(a){return f(l(a))} -function a(a){return String.fromCharCode.apply(String,m(a))}function e(a){return b(l(a))}function d(a){a=b(a);for(var c="",h=0;hc?d+=String.fromCharCode(c):(n+=1,b=a.charCodeAt(n)&255,224>c?d+=String.fromCharCode((c&31)<<6|b&63):(n+=1,e=a.charCodeAt(n)&255,d+=String.fromCharCode((c&15)<<12|(b&63)<<6|e&63)));return d}function t(a,h){function d(){var p= -n+b;p>a.length&&(p=a.length);e+=c(a,n,p);n=p;p=n===a.length;h(e,p)&&!p&&runtime.setTimeout(d,0)}var b=1E5,e="",n=0;a.length>>18],f+=r[d>>>12&63],f+=r[d>>>6&63],f+=r[d&63];b===e+1?(d=a[b]<<4,f+=r[d>>>6],f+=r[d&63],f+="=="):b===e&&(d=a[b]<<10|a[b+1]<<2,f+=r[d>>>12],f+=r[d>>>6&63],f+=r[d&63],f+="=");return f}function n(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,"");var d=[],f=a.length%4,b,e=a.length,g;for(b=0;b>16,g>>8&255,g&255);d.length-=[0,0,2,1][f];return d}function c(a){var d=[],f,b=a.length,e;for(f=0;fe?d.push(e):2048>e?d.push(192|e>>>6,128|e&63):d.push(224|e>>>12&15,128|e>>>6&63,128|e&63);return d}function b(a){var d=[],f,b=a.length,e,g,m;for(f=0;fe?d.push(e):(f+=1,g=a[f],224>e?d.push((e&31)<<6|g&63):(f+=1,m=a[f],d.push((e&15)<<12|(g&63)<<6|m&63)));return d}function h(a){return l(k(a))} +function a(a){return String.fromCharCode.apply(String,n(a))}function g(a){return b(k(a))}function e(a){a=b(a);for(var d="",f=0;fd?b+=String.fromCharCode(d):(m+=1,e=a.charCodeAt(m)&255,224>d?b+=String.fromCharCode((d&31)<<6|e&63):(m+=1,g=a.charCodeAt(m)&255,b+=String.fromCharCode((d&15)<<12|(e&63)<<6|g&63)));return b}function t(a,f){function b(){var c= +m+e;c>a.length&&(c=a.length);g+=d(a,m,c);m=c;c=m===a.length;f(g,c)&&!c&&runtime.setTimeout(b,0)}var e=1E5,g="",m=0;a.length>>8):(fa(a&255),fa(a>>>8))},aa=function(){p=(p<<5^n[C+3-1]&255)&8191;y=w[32768+p];w[C&32767]=y;w[32768+p]=C},ga=function(a,c){z>16-c?(v|=a<>16-z,z+=c-16):(v|=a<a;a++)n[a]=n[a+32768];P-=32768;C-=32768;u-=32768;for(a=0;8192>a;a++)c=w[32768+a],w[32768+a]=32768<=c?c-32768:0;for(a=0;32768>a;a++)c=w[a],w[a]=32768<=c?c-32768:0;h+=32768}B||(a=Ba(n,C+J,h),0>=a?B=!0:J+=a)},Ca=function(a){var c=U,h=C,d,b=N,e=32506=ka&&(c>>=2);do if(d=a,n[d+b]===g&&n[d+b-1]===f&&n[d]===n[h]&&n[++d]===n[h+1]){h+= -2;d++;do++h;while(n[h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&n[++h]===n[++d]&&hb){P=a;b=d;if(258<=d)break;f=n[h+b-1];g=n[h+b]}a=w[a&32767]}while(a>e&&0!==--c);return b},va=function(a,c){r[Z++]=c;0===a?ca[c].fc++:(a--,ca[G[c]+256+1].fc++,W[(256>a?ea[a]:ea[256+(a>>7)])&255].fc++,q[X++]=a,qa|=x);x<<=1;0===(Z&7)&&(R[na++]=qa,qa=0,x=1);if(2b;b++)h+=W[b].fc* -(5+ra[b]);h>>=3;if(X>=1,h<<=1;while(0<--c);return h>>1},Ea=function(a,c){var h=[];h.length=16;var d=0,b;for(b=1;15>=b;b++)d=d+L[b-1]<<1,h[b]=d;for(d=0;d<=c;d++)b=a[d].dl,0!==b&&(a[d].fc=Da(h[b]++,b))},za=function(a){var c=a.dyn_tree,h=a.static_tree,d=a.elems,b,e=-1, -n=d;Y=0;la=573;for(b=0;bY;)b=K[++Y]=2>e?++e:0,c[b].fc=1,E[b]=0,ia--,null!==h&&(ma-=h[b].dl);a.max_code=e;for(b=Y>>1;1<=b;b--)ya(c,b);do b=K[1],K[1]=K[Y--],ya(c,1),h=K[1],K[--la]=b,K[--la]=h,c[n].fc=c[b].fc+c[h].fc,E[n]=E[b]>E[h]+1?E[b]:E[h]+1,c[b].dl=c[h].dl=n,K[1]=n++,ya(c,1);while(2<=Y);K[--la]=K[1];n=a.dyn_tree;b=a.extra_bits;var d=a.extra_base,h=a.max_code,p=a.max_length,f=a.static_tree,g,s,q,k,r=0;for(s=0;15>=s;s++)L[s]=0;n[K[la]].dl=0; -for(a=la+1;573>a;a++)g=K[a],s=n[n[g].dl].dl+1,s>p&&(s=p,r++),n[g].dl=s,g>h||(L[s]++,q=0,g>=d&&(q=b[g-d]),k=n[g].fc,ia+=k*(s+q),null!==f&&(ma+=k*(f[g].dl+q)));if(0!==r){do{for(s=p-1;0===L[s];)s--;L[s]--;L[s+1]+=2;L[p]--;r-=2}while(0h||(n[b].dl!==s&&(ia+=(s-n[b].dl)*n[b].fc,n[b].fc=s),g--)}Ea(c,e)},Fa=function(a,c){var h,d=-1,b,e=a[0].dl,n=0,p=7,f=4;0===e&&(p=138,f=3);a[c+1].dl=65535;for(h=0;h<=c;h++)b=e,e=a[h+1].dl,++n=n?S[17].fc++:S[18].fc++,n=0,d=b,0===e?(p=138,f=3):b===e?(p=6,f=3):(p=7,f=4))},Ga=function(){8h?ea[h]:ea[256+(h>>7)])&255,sa(p,c),f=ra[p],0!==f&&(h-=V[p],ga(h,f))),n>>=1;while(d=n?(sa(17,S),ga(n-3,3)):(sa(18,S),ga(n-11,7));n=0;d=b;0===e?(p=138,f=3):b===e?(p=6,f=3):(p=7,f=4)}},Ja=function(){var a;for(a=0;286>a;a++)ca[a].fc=0;for(a=0;30>a;a++)W[a].fc=0;for(a=0;19>a;a++)S[a].fc=0;ca[256].fc=1;qa=Z=X=na=ia=ma=0;x=1},wa=function(a){var h,c,d,b;b=C-u;R[na]=qa;za(Q);za(F);Fa(ca,Q.max_code);Fa(W,F.max_code);za(M);for(d=18;3<=d&&0=== -S[ua[d]].dl;d--);ia+=3*(d+1)+14;h=ia+3+7>>3;c=ma+3+7>>3;c<=h&&(h=c);if(b+4<=h&&0<=u)for(ga(0+a,3),Ga(),ja(b),ja(~b),d=0;da.len&&(p=a.len);for(f=0;ft-h&&(p=t-h);for(f=0;fq;q++)for(ha[q]=g,f=0;f<1<q;q++)for(V[q]=g,f=0;f<1<>=7;30>q;q++)for(V[q]=g<<7,f=0;f<1<=f;f++)L[f]=0;for(f=0;143>=f;)O[f++].dl=8,L[8]++;for(;255>=f;)O[f++].dl=9,L[9]++;for(;279>=f;)O[f++].dl=7,L[7]++;for(;287>=f;)O[f++].dl=8,L[8]++;Ea(O,287);for(f=0;30>f;f++)ba[f].dl=5,ba[f].fc=Da(f,5);Ja()}for(f=0;8192>f;f++)w[32768+f]=0;da=$[T].max_lazy;ka=$[T].good_length;U=$[T].max_chain;u=C=0;J=Ba(n, -0,65536);if(0>=J)B=!0,J=0;else{for(B=!1;262>J&&!B;)xa();for(f=p=0;2>f;f++)p=(p<<5^n[f]&255)&8191}a=null;h=t=0;3>=T?(N=2,A=0):(A=2,H=0);s=!1}d=!0;if(0===J)return s=!0,0}f=Ka(c,b,e);if(f===e)return e;if(s)return f;if(3>=T)for(;0!==J&&null===a;){aa();0!==y&&32506>=C-y&&(A=Ca(y),A>J&&(A=J));if(3<=A)if(q=va(C-P,A-3),J-=A,A<=da){A--;do C++,aa();while(0!==--A);C++}else C+=A,A=0,p=n[C]&255,p=(p<<5^n[C+1]&255)&8191;else q=va(0,n[C]&255),J--,C++;q&&(wa(0),u=C);for(;262>J&&!B;)xa()}else for(;0!==J&&null===a;){aa(); -N=A;D=P;A=2;0!==y&&(N=C-y)&&(A=Ca(y),A>J&&(A=J),3===A&&4096J&&!B;)xa()}0===J&&(0!==H&&va(0,n[C-1]&255),wa(1),s=!0);return f+Ka(c,f+b,e-f)};this.deflate=function(h,p){var g,s;oa=h;I=0;"undefined"===String(typeof p)&&(p=6);(g=p)?1>g?g=1:9g;g++)ca[g]=new l;W=[];W.length=61;for(g=0;61>g;g++)W[g]=new l;O=[];O.length=288;for(g=0;288>g;g++)O[g]=new l;ba=[];ba.length=30;for(g=0;30>g;g++)ba[g]=new l;S=[];S.length=39;for(g=0;39>g;g++)S[g]=new l;Q=new f;F=new f;M=new f;L=[];L.length=16;K=[];K.length=573;E=[];E.length=573;G=[];G.length=256;ea=[];ea.length=512;ha=[];ha.length=29;V=[];V.length=30;R=[];R.length=1024}var v=Array(1024),m=[],t=[];for(g=La(v, -0,v.length);0>>8):(la(a&255),la(a>>>8))},ca=function(){p=(p<<5^m[B+3-1]&255)&8191;x=w[32768+p];w[B&32767]=x;w[32768+p]=B},U=function(a,d){y>16-d?(u|=a<>16-y,y+=d-16):(u|=a<a;a++)m[a]=m[a+32768];O-=32768;B-=32768;v-=32768;for(a=0;8192>a;a++)d=w[32768+a],w[32768+a]=32768<=d?d-32768:0;for(a=0;32768>a;a++)d=w[a],w[a]=32768<=d?d-32768:0;f+=32768}z||(a=Ba(m,B+I,f),0>=a?z=!0:I+=a)},Ca=function(a){var d=X,f=B,b,e=N,g=32506=ma&&(d>>=2);do if(b=a,m[b+e]===s&&m[b+e-1]===p&&m[b]===m[f]&&m[++b]===m[f+1]){f+=2;b++;do++f;while(m[f]=== +m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&m[++f]===m[++b]&&fe){O=a;e=b;if(258<=b)break;p=m[f+e-1];s=m[f+e]}a=w[a&32767]}while(a>g&&0!==--d);return e},wa=function(a,d){q[Q++]=d;0===a?da[d].fc++:(a--,da[E[d]+256+1].fc++,ba[(256>a?fa[a]:fa[256+(a>>7)])&255].fc++,r[ja++]=a,ka|=qa);qa<<=1;0===(Q&7)&&(ia[aa++]=ka,ka=0,qa=1);if(2e;e++)f+=ba[e].fc*(5+oa[e]);f>>=3; +if(ja>=1,f<<=1;while(0<--d);return f>>1},Ea=function(a,d){var f=[];f.length=16;var b=0,e;for(e=1;15>=e;e++)b=b+R[e-1]<<1,f[e]=b;for(b=0;b<=d;b++)e=a[b].dl,0!==e&&(a[b].fc=Da(f[e]++,e))},Aa=function(a){var d=a.dyn_tree,f=a.static_tree,b=a.elems,e,g=-1,m=b;S=0;ga=573; +for(e=0;eS;)e=L[++S]=2>g?++g:0,d[e].fc=1,K[e]=0,W--,null!==f&&(C-=f[e].dl);a.max_code=g;for(e=S>>1;1<=e;e--)za(d,e);do e=L[1],L[1]=L[S--],za(d,1),f=L[1],L[--ga]=e,L[--ga]=f,d[m].fc=d[e].fc+d[f].fc,K[m]=K[e]>K[f]+1?K[e]:K[f]+1,d[e].dl=d[f].dl=m,L[1]=m++,za(d,1);while(2<=S);L[--ga]=L[1];m=a.dyn_tree;e=a.extra_bits;var b=a.extra_base,f=a.max_code,c=a.max_length,p=a.static_tree,s,h,r,q,l=0;for(h=0;15>=h;h++)R[h]=0;m[L[ga]].dl=0;for(a=ga+1;573>a;a++)s= +L[a],h=m[m[s].dl].dl+1,h>c&&(h=c,l++),m[s].dl=h,s>f||(R[h]++,r=0,s>=b&&(r=e[s-b]),q=m[s].fc,W+=q*(h+r),null!==p&&(C+=q*(p[s].dl+r)));if(0!==l){do{for(h=c-1;0===R[h];)h--;R[h]--;R[h+1]+=2;R[c]--;l-=2}while(0f||(m[e].dl!==h&&(W+=(h-m[e].dl)*m[e].fc,m[e].fc=h),s--)}Ea(d,g)},Fa=function(a,d){var f,b=-1,e,m=a[0].dl,g=0,c=7,p=4;0===m&&(c=138,p=3);a[d+1].dl=65535;for(f=0;f<=d;f++)e=m,m=a[f+1].dl,++g=g?T[17].fc++:T[18].fc++,g=0,b=e,0===m?(c=138,p=3):e===m?(c=6,p=3):(c=7,p=4))},Ga=function(){8f?fa[f]:fa[256+(f>>7)])&255,Y(c,d),p=oa[c],0!==p&&(f-=Z[c],U(f,p))),g>>=1;while(b=g?(Y(17,T),U(g-3,3)):(Y(18,T),U(g-11,7));g=0;b=e;0===m?(c=138,p=3):e===m?(c=6,p=3):(c=7,p=4)}},Ja=function(){var a;for(a=0;286>a;a++)da[a].fc=0;for(a=0;30>a;a++)ba[a].fc=0;for(a=0;19>a;a++)T[a].fc=0;da[256].fc=1;ka=Q=ja=aa=W=C=0;qa=1},xa=function(a){var d,f,b,e;e=B-v;ia[aa]=ka;Aa(P);Aa(F);Fa(da,P.max_code);Fa(ba,F.max_code);Aa(J);for(b=18;3<=b&&0===T[sa[b]].dl;b--);W+=3*(b+1)+14;d=W+3+7>>3;f=C+ +3+7>>3;f<=d&&(d=f);if(e+4<=d&&0<=v)for(U(0+a,3),Ga(),pa(e),pa(~e),b=0;ba.len&&(c=a.len);for(p=0;pt-f&&(c= +t-f);for(p=0;pr;r++)for(ha[r]=h,c=0;c<1<r;r++)for(Z[r]=h,c=0;c<1<>=7;30>r;r++)for(Z[r]=h<<7,c=0;c<1<=c;c++)R[c]=0;for(c=0;143>=c;)M[c++].dl=8,R[8]++;for(;255>=c;)M[c++].dl=9,R[9]++;for(;279>=c;)M[c++].dl=7,R[7]++;for(;287>=c;)M[c++].dl=8,R[8]++;Ea(M,287);for(c=0;30>c;c++)$[c].dl=5,$[c].fc=Da(c,5);Ja()}for(c=0;8192>c;c++)w[32768+c]=0;ea=ra[V].max_lazy;ma=ra[V].good_length;X=ra[V].max_chain;v=B=0;I=Ba(m,0,65536);if(0>=I)z=!0,I=0;else{for(z=!1;262>I&& +!z;)ya();for(c=p=0;2>c;c++)p=(p<<5^m[c]&255)&8191}a=null;f=t=0;3>=V?(N=2,A=0):(A=2,G=0);s=!1}e=!0;if(0===I)return s=!0,0}c=Ka(d,b,g);if(c===g)return g;if(s)return c;if(3>=V)for(;0!==I&&null===a;){ca();0!==x&&32506>=B-x&&(A=Ca(x),A>I&&(A=I));if(3<=A)if(r=wa(B-O,A-3),I-=A,A<=ea){A--;do B++,ca();while(0!==--A);B++}else B+=A,A=0,p=m[B]&255,p=(p<<5^m[B+1]&255)&8191;else r=wa(0,m[B]&255),I--,B++;r&&(xa(0),v=B);for(;262>I&&!z;)ya()}else for(;0!==I&&null===a;){ca();N=A;D=O;A=2;0!==x&&(N=B-x)&& +(A=Ca(x),A>I&&(A=I),3===A&&4096I&&!z;)ya()}0===I&&(0!==G&&wa(0,m[B-1]&255),xa(1),s=!0);return c+Ka(d,c+b,g-c)};this.deflate=function(f,c){var p,s;na=f;ua=0;"undefined"===String(typeof c)&&(c=6);(p=c)?1>p?p=1:9p;p++)da[p]=new k;ba=[];ba.length=61;for(p=0;61>p;p++)ba[p]=new k;M=[];M.length=288;for(p=0;288>p;p++)M[p]=new k;$=[];$.length=30;for(p=0;30>p;p++)$[p]=new k;T=[];T.length=39;for(p=0;39>p;p++)T[p]=new k;P=new l;F=new l;J=new l;R=[];R.length=16;L=[];L.length=573;K=[];K.length=573;E=[];E.length=256;fa=[];fa.length=512;ha=[];ha.length=29;Z=[];Z.length=30;ia=[];ia.length=1024}var u=Array(1024),t=[],x=[];for(p=La(u,0,u.length);0>8&255])};this.appendUInt32LE=function(g){f.appendArray([g&255,g>>8&255,g>>16&255,g>>24&255])};this.appendString=function(f){m=runtime.concatByteArrays(m, -runtime.byteArrayFromString(f,l))};this.getLength=function(){return m.length};this.getByteArray=function(){return m}}; +core.ByteArrayWriter=function(k){var l=this,n=new runtime.ByteArray(0);this.appendByteArrayWriter=function(c){n=runtime.concatByteArrays(n,c.getByteArray())};this.appendByteArray=function(c){n=runtime.concatByteArrays(n,c)};this.appendArray=function(c){n=runtime.concatByteArrays(n,runtime.byteArrayFromArray(c))};this.appendUInt16LE=function(c){l.appendArray([c&255,c>>8&255])};this.appendUInt32LE=function(c){l.appendArray([c&255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){n=runtime.concatByteArrays(n, +runtime.byteArrayFromString(c,k))};this.getLength=function(){return n.length};this.getByteArray=function(){return n}}; // Input 6 -core.RawInflate=function(){var l,f,m=null,g,b,k,a,e,d,c,t,h,s,n,q,r,w,v=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],z=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],p=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],y=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[16,17,18, -0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=function(){this.list=this.next=null},A=function(){this.n=this.b=this.e=0;this.t=null},N=function(a,c,h,d,b,e){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var n=Array(this.BMAX+1),f,p,g,s,q,k,r,v=Array(this.BMAX+1),m,l,t,w=new A,y=Array(this.BMAX);s=Array(this.N_MAX);var u,z=Array(this.BMAX+1),D,C,B;B=this.root=null;for(q=0;qq&&(e=q);for(D=1<(D-=n[k])){this.status=2;this.m=e;return}if(0>(D-=n[q]))this.status=2,this.m=e;else{n[q]+=D;z[1]=k=0;m=n;l=1;for(t=2;0<--q;)z[t++]=k+=m[l++];m=a;q=l=0;do 0!=(k=m[l++])&&(s[z[k]++]=q);while(++qu+v[1+s];){u+=v[1+s];s++;C=(C=g-u)>e?e:C;if((p=1<<(k=r-u))>a+1)for(p-=a+1,t=r;++kf&&u>u-v[s],y[s-1][k].e=w.e,y[s-1][k].b=w.b,y[s-1][k].n=w.n,y[s-1][k].t=w.t)}w.b=r-u;l>=c?w.e=99:m[l]m[l]?16:15,w.n=m[l++]): -(w.e=b[m[l]-h],w.n=d[m[l++]-h]);p=1<>u;k>=1)q^=k;for(q^=k;(q&(1<>=c;a-=c},J=function(a,d,b){var p,g,k;if(0==b)return 0;for(k=0;;){C(n);g=h.list[P(n)];for(p=g.e;16 -e;e++)m[D[e]]=0;n=7;e=new N(m,19,19,null,null,n);if(0!=e.status)return-1;h=e.root;n=e.m;g=r+v;for(b=f=0;be)m[b++]=f=e;else if(16==e){C(2);e=3+P(2);B(2);if(b+e>g)return-1;for(;0g)return-1;for(;0F;F++)Q[F]=8;for(;256>F;F++)Q[F]=9;for(;280>F;F++)Q[F]=7;for(;288>F;F++)Q[F]=8;b=7;F=new N(Q,288,257,z,u,b);if(0!=F.status){alert("HufBuild error: "+F.status);O=-1;break b}m=F.root;b=F.m;for(F=0;30>F;F++)Q[F]=5;U=5;F=new N(Q,30,0,p,y,U);if(1r&&(c=r);for(D=1<(D-=m[q])){this.status=2;this.m=c;return}if(0>(D-=m[r]))this.status=2,this.m=c;else{m[r]+=D;y[1]=q=0;u=m;t=1;for(w=2;0<--r;)y[w++]=q+=u[t++];u=a;r=t=0;do 0!=(q=u[t++])&&(h[y[q]++]=r);while(++rv+k[1+h];){v+=k[1+h];h++;B=(B=s-v)>c?c:B;if((p=1<<(q=l-v))>a+1)for(p-=a+1,w=l;++qg&&v>v-k[h],n[h-1][q].e=x.e,n[h-1][q].b=x.b,n[h-1][q].n=x.n,n[h-1][q].t=x.t)}x.b=l-v;t>=d?x.e=99:u[t]u[t]?16:15,x.n=u[t++]): +(x.e=e[u[t]-f],x.n=b[u[t++]-f]);p=1<>v;q>=1)r^=q;for(r^=q;(r&(1<>=d;a-=d},I=function(a,b,e){var c,p,h;if(0==e)return 0;for(h=0;;){B(m);p=f.list[O(m)];for(c=p.e;16 +c;c++)u[D[c]]=0;m=7;c=new N(u,19,19,null,null,m);if(0!=c.status)return-1;f=c.root;m=c.m;h=l+k;for(e=g=0;ec)u[e++]=g=c;else if(16==c){B(2);c=3+O(2);z(2);if(e+c>h)return-1;for(;0h)return-1;for(;0F;F++)P[F]=8;for(;256>F;F++)P[F]=9;for(;280>F;F++)P[F]=7;for(;288>F;F++)P[F]=8;b=7;F=new N(P,288,257,y,v,b);if(0!=F.status){alert("HufBuild error: "+F.status);M=-1;break b}n=F.root;b=F.m;for(F=0;30>F;F++)P[F]=5;X=5;F=new N(P,30,0,p,x,X);if(1l))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0f))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; +core.LoopWatchDog=function(k,l){var n=Date.now(),c=0;this.check=function(){var b;if(k&&(b=Date.now(),b-n>k))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}}; // Input 8 -core.Utils=function(){this.hashString=function(l){var f=0,m,g;m=0;for(g=l.length;m= -f.compareBoundaryPoints(f.START_TO_START,m)&&0<=f.compareBoundaryPoints(f.END_TO_END,m)};this.rangesIntersect=function(f,m){return 0>=f.compareBoundaryPoints(f.END_TO_START,m)&&0<=f.compareBoundaryPoints(f.START_TO_END,m)};this.getNodesInRange=function(f,m){var g=[],b,k=f.startContainer.ownerDocument.createTreeWalker(f.commonAncestorContainer,NodeFilter.SHOW_ALL,m,!1);for(b=k.currentNode=f.startContainer;b;){if(m(b)===NodeFilter.FILTER_ACCEPT)g.push(b);else if(m(b)===NodeFilter.FILTER_REJECT)break; -b=b.parentNode}g.reverse();for(b=k.nextNode();b;)g.push(b),b=k.nextNode();return g};this.normalizeTextNodes=function(f){f&&f.nextSibling&&(f=l(f,f.nextSibling));f&&f.previousSibling&&l(f.previousSibling,f)};this.rangeContainsNode=function(f,m){var g=m.ownerDocument.createRange(),b=m.nodeType===Node.TEXT_NODE?m.length:m.childNodes.length;g.setStart(f.startContainer,f.startOffset);g.setEnd(f.endContainer,f.endOffset);b=0===g.comparePoint(m,0)&&0===g.comparePoint(m,b);g.detach();return b};this.mergeIntoParent= -function(f){for(var m=f.parentNode;f.firstChild;)m.insertBefore(f.firstChild,f);m.removeChild(f);return m};this.getElementsByTagNameNS=function(f,m,g){return Array.prototype.slice.call(f.getElementsByTagNameNS(m,g))};this.rangeIntersectsNode=function(f,m){var g=m.nodeType===Node.TEXT_NODE?m.length:m.childNodes.length;return 0>=f.comparePoint(m,0)&&0<=f.comparePoint(m,g)}}; +core.DomUtils=function(){function k(c,b){if(c.nodeType===Node.TEXT_NODE)if(0===c.length)c.parentNode.removeChild(c);else if(b.nodeType===Node.TEXT_NODE)return b.insertData(0,c.data),c.parentNode.removeChild(c),b;return c}function l(c,b){return c===b||Boolean(c.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_CONTAINED_BY)}var n=this;this.splitBoundaries=function(c){var b=[],h;if(c.startContainer.nodeType===Node.TEXT_NODE||c.endContainer.nodeType===Node.TEXT_NODE){h=c.endContainer;var a=c.endOffset; +if(a=c.compareBoundaryPoints(c.START_TO_START,b)&&0<=c.compareBoundaryPoints(c.END_TO_END,b)};this.rangesIntersect=function(c,b){return 0>=c.compareBoundaryPoints(c.END_TO_START,b)&&0<=c.compareBoundaryPoints(c.START_TO_END,b)};this.getNodesInRange=function(c,b){var h=[],a,g=c.startContainer.ownerDocument.createTreeWalker(c.commonAncestorContainer,NodeFilter.SHOW_ALL,b,!1);for(a=g.currentNode=c.startContainer;a;){if(b(a)=== +NodeFilter.FILTER_ACCEPT)h.push(a);else if(b(a)===NodeFilter.FILTER_REJECT)break;a=a.parentNode}h.reverse();for(a=g.nextNode();a;)h.push(a),a=g.nextNode();return h};this.normalizeTextNodes=function(c){c&&c.nextSibling&&(c=k(c,c.nextSibling));c&&c.previousSibling&&k(c.previousSibling,c)};this.rangeContainsNode=function(c,b){var h=b.ownerDocument.createRange(),a=b.nodeType===Node.TEXT_NODE?b.length:b.childNodes.length;h.setStart(c.startContainer,c.startOffset);h.setEnd(c.endContainer,c.endOffset);a= +0===h.comparePoint(b,0)&&0===h.comparePoint(b,a);h.detach();return a};this.mergeIntoParent=function(c){for(var b=c.parentNode;c.firstChild;)b.insertBefore(c.firstChild,c);b.removeChild(c);return b};this.getElementsByTagNameNS=function(c,b,h){return Array.prototype.slice.call(c.getElementsByTagNameNS(b,h))};this.rangeIntersectsNode=function(c,b){var h=b.nodeType===Node.TEXT_NODE?b.length:b.childNodes.length;return 0>=c.comparePoint(b,0)&&0<=c.comparePoint(b,h)};this.containsNode=function(c,b){return c=== +b||c.contains(b)};(function(){var c=runtime.getWindow();null!==c&&(c=c.navigator.appVersion.toLowerCase(),c=-1===c.indexOf("chrome")&&(-1!==c.indexOf("applewebkit")||-1!==c.indexOf("safari")))&&(n.containsNode=l)})()}; // Input 10 runtime.loadClass("core.DomUtils"); -core.Cursor=function(l,f){function m(a){a.parentNode&&(e.push(a.previousSibling),e.push(a.nextSibling),a.parentNode.removeChild(a))}function g(a,c,d){if(c.nodeType===Node.TEXT_NODE){runtime.assert(Boolean(c),"putCursorIntoTextNode: invalid container");var b=c.parentNode;runtime.assert(Boolean(b),"putCursorIntoTextNode: container without parent");runtime.assert(0<=d&&d<=c.length,"putCursorIntoTextNode: offset is out of bounds");0===d?b.insertBefore(a,c):(d!==c.length&&c.splitText(d),b.insertBefore(a, -c.nextSibling))}else if(c.nodeType===Node.ELEMENT_NODE){runtime.assert(Boolean(c),"putCursorIntoContainer: invalid container");for(b=c.firstChild;null!==b&&01/f?"-0":String(f),l(c+" should be "+a+". Was "+e+".")):l(c+" should be "+a+" (of type "+typeof a+"). Was "+f+" (of type "+typeof f+").")}var a=0,e;e=function(a,c){var e=Object.keys(a),h=Object.keys(c);e.sort();h.sort();return f(e,h)&&Object.keys(a).every(function(h){var e= -a[h],f=c[h];return b(e,f)?!0:(l(e+" should be "+f+" for key "+h),!1)})};this.areNodesEqual=g;this.shouldBeNull=function(a,c){k(a,c,"null")};this.shouldBeNonNull=function(a,c){var b,h;try{h=eval(c)}catch(e){b=e}b?l(c+" should be non-null. Threw exception "+b):null!==h?runtime.log("pass",c+" is non-null."):l(c+" should be non-null. Was "+h)};this.shouldBe=k;this.countFailedTests=function(){return a}}; -core.UnitTester=function(){function l(f,b){return""+f+""}var f=0,m={};this.runTests=function(g,b,k){function a(h){if(0===h.length)m[e]=t,f+=d.countFailedTests(),b();else{s=h[0];var n=Runtime.getFunctionName(s);runtime.log("Running "+n);q=d.countFailedTests();c.setUp();s(function(){c.tearDown();t[n]=q===d.countFailedTests();a(h.slice(1))})}}var e=Runtime.getFunctionName(g),d=new core.UnitTestRunner,c=new g(d),t={},h,s,n,q,r="BrowserRuntime"=== -runtime.type();if(m.hasOwnProperty(e))runtime.log("Test "+e+" has already run.");else{r?runtime.log("Running "+l(e,'runSuite("'+e+'");')+": "+c.description()+""):runtime.log("Running "+e+": "+c.description);n=c.tests();for(h=0;hRunning "+l(g,'runTest("'+e+'","'+g+'")')+""):runtime.log("Running "+g),q=d.countFailedTests(),c.setUp(),s(),c.tearDown(),t[g]=q===d.countFailedTests()); -a(c.asyncTests())}};this.countFailedTests=function(){return f};this.results=function(){return m}}; +core.UnitTest.provideTestAreaDiv=function(){var k=runtime.getWindow().document,l=k.getElementById("testarea");runtime.assert(!l,'Unclean test environment, found a div with id "testarea".');l=k.createElement("div");l.setAttribute("id","testarea");k.body.appendChild(l);return l}; +core.UnitTest.cleanupTestAreaDiv=function(){var k=runtime.getWindow().document,l=k.getElementById("testarea");runtime.assert(!!l&&l.parentNode===k.body,'Test environment broken, found no div with id "testarea" below body.');k.body.removeChild(l)}; +core.UnitTestRunner=function(){function k(b){a+=1;runtime.log("fail",b)}function l(a,d){var b;try{if(a.length!==d.length)return k("array of length "+a.length+" should be "+d.length+" long"),!1;for(b=0;b1/g?"-0":String(g),k(d+" should be "+a+". Was "+c+".")):k(d+" should be "+a+" (of type "+typeof a+"). Was "+g+" (of type "+typeof g+").")}var a=0,g;g=function(a,d){var c=Object.keys(a),f=Object.keys(d);c.sort();f.sort();return l(c,f)&&Object.keys(a).every(function(f){var c= +a[f],g=d[f];return b(c,g)?!0:(k(c+" should be "+g+" for key "+f),!1)})};this.areNodesEqual=c;this.shouldBeNull=function(a,d){h(a,d,"null")};this.shouldBeNonNull=function(a,d){var b,f;try{f=eval(d)}catch(c){b=c}b?k(d+" should be non-null. Threw exception "+b):null!==f?runtime.log("pass",d+" is non-null."):k(d+" should be non-null. Was "+f)};this.shouldBe=h;this.countFailedTests=function(){return a}}; +core.UnitTester=function(){function k(c,b){return""+c+""}var l=0,n={};this.runTests=function(c,b,h){function a(f){if(0===f.length)n[g]=t,l+=e.countFailedTests(),b();else{s=f[0];var c=Runtime.getFunctionName(s);runtime.log("Running "+c);r=e.countFailedTests();d.setUp();s(function(){d.tearDown();t[c]=r===e.countFailedTests();a(f.slice(1))})}}var g=Runtime.getFunctionName(c),e=new core.UnitTestRunner,d=new c(e),t={},f,s,m,r,q="BrowserRuntime"=== +runtime.type();if(n.hasOwnProperty(g))runtime.log("Test "+g+" has already run.");else{q?runtime.log("Running "+k(g,'runSuite("'+g+'");')+": "+d.description()+""):runtime.log("Running "+g+": "+d.description);m=d.tests();for(f=0;fRunning "+k(c,'runTest("'+g+'","'+c+'")')+""):runtime.log("Running "+c),r=e.countFailedTests(),d.setUp(),s(),d.tearDown(),t[c]=r===e.countFailedTests()); +a(d.asyncTests())}};this.countFailedTests=function(){return l};this.results=function(){return n}}; // Input 13 -core.PositionIterator=function(l,f,m,g){function b(){this.acceptNode=function(a){return a.nodeType===Node.TEXT_NODE&&0===a.length?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}function k(a){this.acceptNode=function(c){return c.nodeType===Node.TEXT_NODE&&0===c.length?NodeFilter.FILTER_REJECT:a.acceptNode(c)}}function a(){var a=d.currentNode.nodeType;c=a===Node.TEXT_NODE?d.currentNode.length-1:a===Node.ELEMENT_NODE?1:0}var e=this,d,c,t;this.nextPosition=function(){if(d.currentNode===l)return!1; -if(0===c&&d.currentNode.nodeType===Node.ELEMENT_NODE)null===d.firstChild()&&(c=1);else if(d.currentNode.nodeType===Node.TEXT_NODE&&c+1 "+a.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"), -b===a.length&&(c=void 0,d.nextSibling()?c=0:d.parentNode()&&(c=1),runtime.assert(void 0!==c,"Error in setPosition: position not valid.")),!0;f=t(a);b "+a.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"), +b===a.length&&(d=void 0,e.nextSibling()?d=0:e.parentNode()&&(d=1),runtime.assert(void 0!==d,"Error in setPosition: position not valid.")),!0;c=t(a);b>>8^e;return b^-1}function g(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var c=a.getFullYear();return 1980>c?0:c-1980<< -25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function k(a,c){var b,h,d,e,f,n,k,r=this;this.load=function(c){if(void 0!==r.data)c(null,r.data);else{var b=f+34+h+d+256;b+k>q&&(b=q-k);runtime.read(a,k,b,function(b,h){if(b||null===h)c(b,h);else a:{var d=h,p=new core.ByteArray(d),g=p.readUInt32LE(),k;if(67324752!==g)c("File entry signature is wrong."+g.toString()+" "+d.length.toString(),null);else{p.pos+=22;g=p.readUInt16LE();k=p.readUInt16LE();p.pos+=g+k; -if(e){d=d.slice(p.pos,p.pos+f);if(f!==d.length){c("The amount of compressed bytes read was "+d.length.toString()+" instead of "+f.toString()+" for "+r.filename+" in "+a+".",null);break a}d=w(d,n)}else d=d.slice(p.pos,p.pos+n);n!==d.length?c("The amount of bytes read was "+d.length.toString()+" instead of "+n.toString()+" for "+r.filename+" in "+a+".",null):(r.data=d,c(null,d))}}})}};this.set=function(a,c,b,d){r.filename=a;r.data=c;r.compressed=b;r.date=d};this.error=null;c&&(b=c.readUInt32LE(),33639248!== -b?this.error="Central directory entry has wrong signature at position "+(c.pos-4).toString()+' for file "'+a+'": '+c.data.length.toString():(c.pos+=6,e=c.readUInt16LE(),this.date=g(c.readUInt32LE()),c.readUInt32LE(),f=c.readUInt32LE(),n=c.readUInt32LE(),h=c.readUInt16LE(),d=c.readUInt16LE(),b=c.readUInt16LE(),c.pos+=8,k=c.readUInt32LE(),this.filename=runtime.byteArrayToString(c.data.slice(c.pos,c.pos+h),"utf8"),c.pos+=h+d+b))}function a(a,c){if(22!==a.length)c("Central directory length should be 22.", -v);else{var b=new core.ByteArray(a),d;d=b.readUInt32LE();101010256!==d?c("Central directory signature is wrong: "+d.toString(),v):(d=b.readUInt16LE(),0!==d?c("Zip files with non-zero disk numbers are not supported.",v):(d=b.readUInt16LE(),0!==d?c("Zip files with non-zero disk numbers are not supported.",v):(d=b.readUInt16LE(),r=b.readUInt16LE(),d!==r?c("Number of entries is inconsistent.",v):(d=b.readUInt32LE(),b=b.readUInt16LE(),b=q-22-d,runtime.read(l,b,q-b,function(a,b){if(a||null===b)c(a,v);else a:{var d= -new core.ByteArray(b),h,e;n=[];for(h=0;hq?f("File '"+l+"' cannot be read.",v):runtime.read(l,q-22,22,function(c,b){c||null===f||null===b?f(c,v):a(b,f)})})}; +2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],b,c,f=a.length,e=0,e=0;b=-1;for(c=0;c>>8^e;return b^-1}function c(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15,a>>5&63,(a&31)<<1)}function b(a){var d=a.getFullYear();return 1980>d?0:d-1980<< +25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function h(a,d){var b,f,e,g,m,h,q,s=this;this.load=function(d){if(void 0!==s.data)d(null,s.data);else{var b=m+34+f+e+256;b+q>r&&(b=r-q);runtime.read(a,q,b,function(b,c){if(b||null===c)d(b,c);else a:{var f=c,e=new core.ByteArray(f),p=e.readUInt32LE(),r;if(67324752!==p)d("File entry signature is wrong."+p.toString()+" "+f.length.toString(),null);else{e.pos+=22;p=e.readUInt16LE();r=e.readUInt16LE();e.pos+=p+r; +if(g){f=f.slice(e.pos,e.pos+m);if(m!==f.length){d("The amount of compressed bytes read was "+f.length.toString()+" instead of "+m.toString()+" for "+s.filename+" in "+a+".",null);break a}f=w(f,h)}else f=f.slice(e.pos,e.pos+h);h!==f.length?d("The amount of bytes read was "+f.length.toString()+" instead of "+h.toString()+" for "+s.filename+" in "+a+".",null):(s.data=f,d(null,f))}}})}};this.set=function(a,d,b,f){s.filename=a;s.data=d;s.compressed=b;s.date=f};this.error=null;d&&(b=d.readUInt32LE(),33639248!== +b?this.error="Central directory entry has wrong signature at position "+(d.pos-4).toString()+' for file "'+a+'": '+d.data.length.toString():(d.pos+=6,g=d.readUInt16LE(),this.date=c(d.readUInt32LE()),d.readUInt32LE(),m=d.readUInt32LE(),h=d.readUInt32LE(),f=d.readUInt16LE(),e=d.readUInt16LE(),b=d.readUInt16LE(),d.pos+=8,q=d.readUInt32LE(),this.filename=runtime.byteArrayToString(d.data.slice(d.pos,d.pos+f),"utf8"),d.pos+=f+e+b))}function a(a,d){if(22!==a.length)d("Central directory length should be 22.", +u);else{var b=new core.ByteArray(a),f;f=b.readUInt32LE();101010256!==f?d("Central directory signature is wrong: "+f.toString(),u):(f=b.readUInt16LE(),0!==f?d("Zip files with non-zero disk numbers are not supported.",u):(f=b.readUInt16LE(),0!==f?d("Zip files with non-zero disk numbers are not supported.",u):(f=b.readUInt16LE(),q=b.readUInt16LE(),f!==q?d("Number of entries is inconsistent.",u):(f=b.readUInt32LE(),b=b.readUInt16LE(),b=r-22-f,runtime.read(k,b,r-b,function(a,b){if(a||null===b)d(a,u);else a:{var f= +new core.ByteArray(b),c,e;m=[];for(c=0;cr?l("File '"+k+"' cannot be read.",u):runtime.read(k,r-22,22,function(d,b){d||null===l||null===b?l(d,u):a(b,l)})})}; // Input 18 -core.CSSUnits=function(){var l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(f,m,g){return f*l[g]/l[m]};this.convertMeasure=function(f,m){var g,b;f&&m?(g=parseFloat(f),b=f.replace(g.toString(),""),g=this.convert(g,b,m)):g="";return g.toString()};this.getUnits=function(f){return f.substr(f.length-2,f.length)}}; +core.CSSUnits=function(){var k={"in":1,cm:2.54,mm:25.4,pt:72,pc:12};this.convert=function(l,n,c){return l*k[c]/k[n]};this.convertMeasure=function(k,n){var c,b;k&&n?(c=parseFloat(k),b=k.replace(c.toString(),""),c=this.convert(c,b,n)):c="";return c.toString()};this.getUnits=function(k){return k.substr(k.length-2,k.length)}}; // Input 19 xmldom.LSSerializerFilter=function(){}; // Input 20 -"function"!==typeof Object.create&&(Object.create=function(l){var f=function(){};f.prototype=l;return new f}); -xmldom.LSSerializer=function(){function l(b){var f=b||{},a=function(a){var c={},b;for(b in a)a.hasOwnProperty(b)&&(c[a[b]]=b);return c}(b),e=[f],d=[a],c=0;this.push=function(){c+=1;f=e[c]=Object.create(f);a=d[c]=Object.create(a)};this.pop=function(){e[c]=void 0;d[c]=void 0;c-=1;f=e[c];a=d[c]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(c){var b=c.namespaceURI,d=0,e;if(!b)return c.localName;if(e=a[b])return e+":"+c.localName;do{e||!c.prefix?(e="ns"+d,d+=1):e=c.prefix; -if(f[e]===b)break;if(!f[e]){f[e]=b;a[b]=e;break}e=null}while(null===e);return e+":"+c.localName}}function f(b){return b.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function m(b,k){var a="",e=g.filter?g.filter.acceptNode(k):NodeFilter.FILTER_ACCEPT,d;if(e===NodeFilter.FILTER_ACCEPT&&k.nodeType===Node.ELEMENT_NODE){b.push();d=b.getQName(k);var c,l=k.attributes,h,s,n,q="",r;c="<"+d;h=l.length;for(s=0;s")}if(e===NodeFilter.FILTER_ACCEPT||e===NodeFilter.FILTER_SKIP){for(e=k.firstChild;e;)a+=m(b,e),e=e.nextSibling;k.nodeValue&&(a+=f(k.nodeValue))}d&&(a+="",b.pop());return a}var g=this;this.filter=null;this.writeToString=function(b,f){if(!b)return"";var a=new l(f);return m(a,b)}}; +"function"!==typeof Object.create&&(Object.create=function(k){var l=function(){};l.prototype=k;return new l}); +xmldom.LSSerializer=function(){function k(b){var c=b||{},a=function(a){var d={},b;for(b in a)a.hasOwnProperty(b)&&(d[a[b]]=b);return d}(b),g=[c],e=[a],d=0;this.push=function(){d+=1;c=g[d]=Object.create(c);a=e[d]=Object.create(a)};this.pop=function(){g[d]=void 0;e[d]=void 0;d-=1;c=g[d];a=e[d]};this.getLocalNamespaceDefinitions=function(){return a};this.getQName=function(d){var b=d.namespaceURI,e=0,g;if(!b)return d.localName;if(g=a[b])return g+":"+d.localName;do{g||!d.prefix?(g="ns"+e,e+=1):g=d.prefix; +if(c[g]===b)break;if(!c[g]){c[g]=b;a[b]=g;break}g=null}while(null===g);return g+":"+d.localName}}function l(b){return b.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")}function n(b,h){var a="",g=c.filter?c.filter.acceptNode(h):NodeFilter.FILTER_ACCEPT,e;if(g===NodeFilter.FILTER_ACCEPT&&h.nodeType===Node.ELEMENT_NODE){b.push();e=b.getQName(h);var d,k=h.attributes,f,s,m,r="",q;d="<"+e;f=k.length;for(s=0;s")}if(g===NodeFilter.FILTER_ACCEPT||g===NodeFilter.FILTER_SKIP){for(g=h.firstChild;g;)a+=n(b,g),g=g.nextSibling;h.nodeValue&&(a+=l(h.nodeValue))}e&&(a+="",b.pop());return a}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var a=new k(c);return n(a,b)}}; // Input 21 -xmldom.RelaxNGParser=function(){function l(a,b){this.message=function(){b&&(a+=1===b.nodeType?" Element ":" Node ",a+=b.nodeName,b.nodeValue&&(a+=" with value '"+b.nodeValue+"'"),a+=".");return a}}function f(a){if(2>=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return f({name:a.name,e:[b].concat(a.e.slice(2))})}function m(a){a=a.split(":",2);var b="",d;1===a.length?a=["",a[0]]:b=a[0];for(d in e)e[d]===b&&(a[0]=d);return a}function g(a,b){for(var d=0,e,f,k=a.name;a.e&&d=a.e.length)return a;var b={name:a.name,e:a.e.slice(0,2)};return l({name:a.name,e:[b].concat(a.e.slice(2))})}function n(a){a=a.split(":",2);var b="",f;1===a.length?a=["",a[0]]:b=a[0];for(f in g)g[f]===b&&(a[0]=f);return a}function c(a,b){for(var f=0,e,g,h=a.name;a.e&&f=d.length)return b;0===h&&(h=0);for(var f=d.item(h);f.namespaceURI===c;){h+=1;if(h>=d.length)return b;f=d.item(h)}return f=e(a,b.attDeriv(a,d.item(h)),d,h+1)}function d(a,b,c){c.e[0].a?(a.push(c.e[0].text),b.push(c.e[0].a.ns)):d(a,b,c.e[0]);c.e[1].a?(a.push(c.e[1].text),b.push(c.e[1].a.ns)): -d(a,b,c.e[1])}var c="http://www.w3.org/2000/xmlns/",t,h,s,n,q,r,w,v,z,u,p={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return p},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return p},endTagDeriv:function(){return p}},y={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return p},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return y},endTagDeriv:function(){return p}}, -D={type:"text",nullable:!0,hash:"text",textDeriv:function(){return D},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return D},endTagDeriv:function(){return p}},H,A,N;t=g("choice",function(a,b){if(a===p)return b;if(b===p||a===b)return a},function(a,c){var d={},e;b(d,{p1:a,p2:c});c=a=void 0;for(e in d)d.hasOwnProperty(e)&&(void 0===a?a=d[e]:c=void 0===c?d[e]:t(c,d[e]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, -textDeriv:function(c,d){return t(a.textDeriv(c,d),b.textDeriv(c,d))},startTagOpenDeriv:m(function(c){return t(a.startTagOpenDeriv(c),b.startTagOpenDeriv(c))}),attDeriv:function(c,d){return t(a.attDeriv(c,d),b.attDeriv(c,d))},startTagCloseDeriv:l(function(){return t(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:l(function(){return t(a.endTagDeriv(),b.endTagDeriv())})}}(a,c)});h=function(a,b,c){return function(){var d={},e=0;return function(h,f){var g=b&&b(h,f),n,p;if(void 0!==g)return g; -g=h.hash||h.toString();n=f.hash||f.toString();g=c.length)return b;0===f&&(f=0);for(var e=c.item(f);e.namespaceURI===d;){f+=1;if(f>=c.length)return b;e=c.item(f)}return e=g(a,b.attDeriv(a,c.item(f)),c,f+1)}function e(a,b,d){d.e[0].a?(a.push(d.e[0].text),b.push(d.e[0].a.ns)):e(a,b,d.e[0]);d.e[1].a?(a.push(d.e[1].text),b.push(d.e[1].a.ns)): +e(a,b,d.e[1])}var d="http://www.w3.org/2000/xmlns/",t,f,s,m,r,q,w,u,y,v,p={type:"notAllowed",nullable:!1,hash:"notAllowed",textDeriv:function(){return p},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return p},endTagDeriv:function(){return p}},x={type:"empty",nullable:!0,hash:"empty",textDeriv:function(){return p},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return x},endTagDeriv:function(){return p}}, +D={type:"text",nullable:!0,hash:"text",textDeriv:function(){return D},startTagOpenDeriv:function(){return p},attDeriv:function(){return p},startTagCloseDeriv:function(){return D},endTagDeriv:function(){return p}},G,A,N;t=c("choice",function(a,b){if(a===p)return b;if(b===p||a===b)return a},function(a,d){var c={},f;b(c,{p1:a,p2:d});d=a=void 0;for(f in c)c.hasOwnProperty(f)&&(void 0===a?a=c[f]:d=void 0===d?c[f]:t(d,c[f]));return function(a,b){return{type:"choice",p1:a,p2:b,nullable:a.nullable||b.nullable, +textDeriv:function(d,c){return t(a.textDeriv(d,c),b.textDeriv(d,c))},startTagOpenDeriv:n(function(d){return t(a.startTagOpenDeriv(d),b.startTagOpenDeriv(d))}),attDeriv:function(d,c){return t(a.attDeriv(d,c),b.attDeriv(d,c))},startTagCloseDeriv:k(function(){return t(a.startTagCloseDeriv(),b.startTagCloseDeriv())}),endTagDeriv:k(function(){return t(a.endTagDeriv(),b.endTagDeriv())})}}(a,d)});f=function(a,b,d){return function(){var c={},f=0;return function(e,g){var m=b&&b(e,g),h,p;if(void 0!==m)return m; +m=e.hash||e.toString();h=g.hash||g.toString();mNode.ELEMENT_NODE;){if(c!==Node.COMMENT_NODE&&(c!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new l("Not allowed node of type "+ -c+".")];c=(d=b.nextSibling())?d.nodeType:0}if(!d)return[new l("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(k[d.namespaceURI]+":"+d.localName))return[new l("Found "+d.nodeName+" instead of "+a.names+".",d)];if(b.firstChild()){for(g=f(a.e[1],b,d);b.nextSibling();)if(c=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||c===Node.COMMENT_NODE))return[new l("Spurious content.",b.currentNode)];if(b.parentNode()!==d)return[new l("Implementation error.")]}else g= -f(a.e[1],b,d);b.nextSibling();return g}var g,b,k;b=function(a,e,d,c){var g=a.name,h=null;if("text"===g)a:{for(var k=(a=e.currentNode)?a.nodeType:0;a!==d&&3!==k;){if(1===k){h=[new l("Element not allowed here.",a)];break a}k=(a=e.nextSibling())?a.nodeType:0}e.nextSibling();h=null}else if("data"===g)h=null;else if("value"===g)c!==a.text&&(h=[new l("Wrong value, should be '"+a.text+"', not '"+c+"'",d)]);else if("list"===g)h=null;else if("attribute"===g)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ -a.e.length;g=a.localnames.length;for(h=0;hNode.ELEMENT_NODE;){if(d!==Node.COMMENT_NODE&&(d!==Node.TEXT_NODE||!/^\s+$/.test(b.currentNode.nodeValue)))return[new k("Not allowed node of type "+ +d+".")];d=(c=b.nextSibling())?c.nodeType:0}if(!c)return[new k("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(h[c.namespaceURI]+":"+c.localName))return[new k("Found "+c.nodeName+" instead of "+a.names+".",c)];if(b.firstChild()){for(n=l(a.e[1],b,c);b.nextSibling();)if(d=b.currentNode.nodeType,!(b.currentNode&&b.currentNode.nodeType===Node.TEXT_NODE&&/^\s+$/.test(b.currentNode.nodeValue)||d===Node.COMMENT_NODE))return[new k("Spurious content.",b.currentNode)];if(b.parentNode()!==c)return[new k("Implementation error.")]}else n= +l(a.e[1],b,c);b.nextSibling();return n}var c,b,h;b=function(a,c,e,d){var h=a.name,f=null;if("text"===h)a:{for(var s=(a=c.currentNode)?a.nodeType:0;a!==e&&3!==s;){if(1===s){f=[new k("Element not allowed here.",a)];break a}s=(a=c.nextSibling())?a.nodeType:0}c.nextSibling();f=null}else if("data"===h)f=null;else if("value"===h)d!==a.text&&(f=[new k("Wrong value, should be '"+a.text+"', not '"+d+"'",e)]);else if("list"===h)f=null;else if("attribute"===h)a:{if(2!==a.e.length)throw"Attribute with wrong # of elements: "+ +a.e.length;h=a.localnames.length;for(f=0;f=g&&c.push(f(a.substring(b,d)))):"["===a[d]&&(0>=g&&(b=d+1),g+=1),d+=1;return d};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};c=function(c,d,f){var k,m,l,v;for(k=0;k=g&&d.push(l(a.substring(b,c)))):"["===a[c]&&(0>=g&&(b=c+1),g+=1),c+=1;return c};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};d=function(d,e,h){var k,q,l,u;for(k=0;k=m.getBoundingClientRect().top-w.bottom? -h.style.top=Math.abs(m.getBoundingClientRect().top-w.bottom)+20+"px":h.style.top="0px");n.style.left=g.getBoundingClientRect().width+"px";var g=n.style,m=n.getBoundingClientRect().left,l=n.getBoundingClientRect().top,w=h.getBoundingClientRect().left,v=h.getBoundingClientRect().top,z=0,u=0,z=w-m,z=z*z,u=v-l,u=u*u,m=Math.sqrt(z+u);g.width=m+"px";l=Math.asin((h.getBoundingClientRect().top-n.getBoundingClientRect().top)/parseFloat(n.style.width));n.style.transform="rotate("+l+"rad)";n.style.MozTransform= -"rotate("+l+"rad)";n.style.WebkitTransform="rotate("+l+"rad)";n.style.msTransform="rotate("+l+"rad)";e&&(w=d.getComputedStyle(e,":before").content)&&"none"!==w&&(w=w.substring(1,w.length-1),e.firstChild?e.firstChild.nodeValue=w:e.appendChild(a.createTextNode(w)))}}var k=[],a=l.ownerDocument,e=new odf.OdfUtils,d=runtime.getWindow();runtime.assert(Boolean(d),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=b;this.addAnnotation=function(c){k.push({node:c.node, -end:c.end});g();var d=a.createElement("div"),e=a.createElement("div"),f=a.createElement("div"),n=a.createElement("div"),l=c.node;d.className="annotationWrapper";l.parentNode.insertBefore(d,l);e.className="annotationNote";e.appendChild(l);f.className="annotationConnector horizontal";n.className="annotationConnector angular";d.appendChild(e);d.appendChild(f);d.appendChild(n);c.end&&m(c);b()};this.forgetAnnotations=function(){for(;k.length;){var b=k[0],d=b.node,e=d.parentNode.parentNode;"div"===e.localName&& -(e.parentNode.insertBefore(d,e),e.parentNode.removeChild(e));for(var d=b.node.getAttributeNS(odf.Namespaces.officens,"name"),d=a.querySelectorAll('span.annotationHighlight[annotation="'+d+'"]'),f=e=void 0,g=void 0,m=void 0,e=0;e=(q.getBoundingClientRect().top- +y.bottom)/w?e.style.top=Math.abs(q.getBoundingClientRect().top-y.bottom)/w+20+"px":e.style.top="0px");l.style.left=h.getBoundingClientRect().width/w+"px";var h=l.style,q=l.getBoundingClientRect().left/w,u=l.getBoundingClientRect().top/w,y=e.getBoundingClientRect().left/w,v=e.getBoundingClientRect().top/w,p=0,x=0,p=y-q,p=p*p,x=v-u,x=x*x,q=Math.sqrt(p+x);h.width=q+"px";w=Math.asin((e.getBoundingClientRect().top-l.getBoundingClientRect().top)/(w*parseFloat(l.style.width)));l.style.transform="rotate("+ +w+"rad)";l.style.MozTransform="rotate("+w+"rad)";l.style.WebkitTransform="rotate("+w+"rad)";l.style.msTransform="rotate("+w+"rad)";c&&(w=d.getComputedStyle(c,":before").content)&&"none"!==w&&(w=w.substring(1,w.length-1),c.firstChild?c.firstChild.nodeValue=w:c.appendChild(g.createTextNode(w)))}}var a=[],g=l.ownerDocument,e=new odf.OdfUtils,d=runtime.getWindow();runtime.assert(Boolean(d),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=h;this.addAnnotation= +function(d){a.push({node:d.node,end:d.end});b();var e=g.createElement("div"),k=g.createElement("div"),m=g.createElement("div"),l=g.createElement("div"),q=d.node;e.className="annotationWrapper";q.parentNode.insertBefore(e,q);k.className="annotationNote";k.appendChild(q);m.className="annotationConnector horizontal";l.className="annotationConnector angular";e.appendChild(k);e.appendChild(m);e.appendChild(l);d.end&&c(d);h()};this.forgetAnnotations=function(){for(;a.length;){var b=a[0],d=b.node,c=d.parentNode.parentNode; +"div"===c.localName&&(c.parentNode.insertBefore(d,c),c.parentNode.removeChild(c));for(var d=b.node.getAttributeNS(odf.Namespaces.officens,"name"),d=g.querySelectorAll('span.annotationHighlight[annotation="'+d+'"]'),e=c=void 0,h=void 0,k=void 0,c=0;c=b.value||"%"===b.unit)?null:b;return b||q(a)};this.parseFoLineHeight=function(a){var b;b=(b=n(a))&&(0>b.value|| -"%"===b.unit)?null:b;return b||q(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,c=[];for(b.nodeType===Node.ELEMENT_NODE&&(c=u.getElementsByTagNameNS(b,w,"p").concat(u.getElementsByTagNameNS(b,w,"h")));b&&!l(b);)b=b.parentNode;b&&c.push(b);return c.filter(function(b){return u.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var c=a.startContainer.ownerDocument.createRange(),d;d=u.getNodesInRange(a,function(d){c.selectNodeContents(d);if(d.nodeType===Node.TEXT_NODE){if(b&& -u.rangesIntersect(a,c)||u.containsRange(a,c))return Boolean(f(d)&&(!m(d.textContent)||s(d,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(u.rangesIntersect(a,c)&&r(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});c.detach();return d};this.getTextElements=function(a,c){var d=a.startContainer.ownerDocument.createRange(),e;e=u.getNodesInRange(a,function(e){var h=e.nodeType;d.selectNodeContents(e);if(h===Node.TEXT_NODE){if(u.containsRange(a,d)&&(c||Boolean(f(e)&&(!m(e.textContent)|| -s(e,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(e)){if(u.containsRange(a,d))return NodeFilter.FILTER_ACCEPT}else if(r(e)||g(e))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});d.detach();return e};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),c;c=u.getNodesInRange(a,function(c){b.selectNodeContents(c);if(l(c)){if(u.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(r(c)||g(c))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT}); -b.detach();return c}}; +odf.OdfUtils=function(){function k(a){var b=a&&a.localName;return("p"===b||"h"===b)&&a.namespaceURI===w}function l(a){for(;a&&!k(a);)a=a.parentNode;return a}function n(a){return/^[ \t\r\n]+$/.test(a)}function c(a){var b=a&&a.localName;return/^(span|p|h|a|meta)$/.test(b)&&a.namespaceURI===w||"span"===b&&"annotationHighlight"===a.className?!0:!1}function b(a){var b=a&&a.localName,d,c=!1;b&&(d=a.namespaceURI,d===w?c="s"===b||"tab"===b||"line-break"===b:d===u&&(c="frame"===b&&"as-char"===a.getAttributeNS(w, +"anchor-type")));return c}function h(a){for(;null!==a.firstChild&&c(a);)a=a.firstChild;return a}function a(a){for(;null!==a.lastChild&&c(a);)a=a.lastChild;return a}function g(b){for(;!k(b)&&null===b.previousSibling;)b=b.parentNode;return k(b)?null:a(b.previousSibling)}function e(a){for(;!k(a)&&null===a.nextSibling;)a=a.parentNode;return k(a)?null:h(a.nextSibling)}function d(a){for(var d=!1;a;)if(a.nodeType===Node.TEXT_NODE)if(0===a.length)a=g(a);else return!n(a.data.substr(a.length-1,1));else b(a)? +(d=!0,a=null):a=g(a);return d}function t(a){var d=!1;for(a=a&&h(a);a;){if(a.nodeType===Node.TEXT_NODE&&0=b.value||"%"===b.unit)?null:b;return b||r(a)};this.parseFoLineHeight=function(a){var b;b=(b=m(a))&&(0>b.value|| +"%"===b.unit)?null:b;return b||r(a)};this.getImpactedParagraphs=function(a){var b=a.commonAncestorContainer,d=[];for(b.nodeType===Node.ELEMENT_NODE&&(d=v.getElementsByTagNameNS(b,w,"p").concat(v.getElementsByTagNameNS(b,w,"h")));b&&!k(b);)b=b.parentNode;b&&d.push(b);return d.filter(function(b){return v.rangeIntersectsNode(a,b)})};this.getTextNodes=function(a,b){var d=a.startContainer.ownerDocument.createRange(),c;c=v.getNodesInRange(a,function(c){d.selectNodeContents(c);if(c.nodeType===Node.TEXT_NODE){if(b&& +v.rangesIntersect(a,d)||v.containsRange(a,d))return Boolean(l(c)&&(!n(c.textContent)||s(c,0)))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}else if(v.rangesIntersect(a,d)&&q(c))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});d.detach();return c};this.getTextElements=function(a,d){var e=a.startContainer.ownerDocument.createRange(),f;f=v.getNodesInRange(a,function(f){var g=f.nodeType;e.selectNodeContents(f);if(g===Node.TEXT_NODE){if(v.containsRange(a,e)&&(d||Boolean(l(f)&&(!n(f.textContent)|| +s(f,0)))))return NodeFilter.FILTER_ACCEPT}else if(b(f)){if(v.containsRange(a,e))return NodeFilter.FILTER_ACCEPT}else if(q(f)||c(f))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT});e.detach();return f};this.getParagraphElements=function(a){var b=a.startContainer.ownerDocument.createRange(),d;d=v.getNodesInRange(a,function(d){b.selectNodeContents(d);if(k(d)){if(v.rangesIntersect(a,b))return NodeFilter.FILTER_ACCEPT}else if(q(d)||c(d))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_REJECT}); +b.detach();return d}}; // Input 30 /* @@ -564,7 +565,7 @@ b.detach();return c}}; @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.OdfUtils"); -odf.TextSerializer=function(){function l(g){var b="",k=f.filter?f.filter.acceptNode(g):NodeFilter.FILTER_ACCEPT,a=g.nodeType,e;if(k===NodeFilter.FILTER_ACCEPT||k===NodeFilter.FILTER_SKIP)for(e=g.firstChild;e;)b+=l(e),e=e.nextSibling;k===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&m.isParagraph(g)?b+="\n":a===Node.TEXT_NODE&&g.textContent&&(b+=g.textContent));return b}var f=this,m=new odf.OdfUtils;this.filter=null;this.writeToString=function(f){return f?l(f):""}}; +odf.TextSerializer=function(){function k(c){var b="",h=l.filter?l.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,a=c.nodeType,g;if(h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)for(g=c.firstChild;g;)b+=k(g),g=g.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(a===Node.ELEMENT_NODE&&n.isParagraph(c)?b+="\n":a===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var l=this,n=new odf.OdfUtils;this.filter=null;this.writeToString=function(c){return c?k(c):""}}; // Input 31 /* @@ -601,10 +602,10 @@ odf.TextSerializer=function(){function l(g){var b="",k=f.filter?f.filter.acceptN @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("core.LoopWatchDog");runtime.loadClass("odf.Namespaces"); -odf.TextStyleApplicator=function(l,f,m){function g(a){function b(a,c){return"object"===typeof a&&"object"===typeof c?Object.keys(a).every(function(d){return b(a[d],c[d])}):a===c}this.isStyleApplied=function(d){d=f.getAppliedStylesForElement(d);return b(a,d)}}function b(b){var g={};this.applyStyleToContainer=function(h){var k;k=h.getAttributeNS(a,"style-name");var n=h.ownerDocument;k=k||"";if(!g.hasOwnProperty(k)){var q=k,r=k,w;r?(w=f.getStyleElement(r,"text"),w.parentNode===m?n=w.cloneNode(!0):(n= -n.createElementNS(e,"style:style"),n.setAttributeNS(e,"style:parent-style-name",r),n.setAttributeNS(e,"style:family","text"),n.setAttributeNS(d,"scope","document-content"))):(n=n.createElementNS(e,"style:style"),n.setAttributeNS(e,"style:family","text"),n.setAttributeNS(d,"scope","document-content"));f.updateStyle(n,b,l);m.appendChild(n);g[q]=n}k=g[k].getAttributeNS(e,"name");h.setAttributeNS(a,"text:style-name",k)}}var k=new core.DomUtils,a=odf.Namespaces.textns,e=odf.Namespaces.stylens,d="urn:webodf:names:scope"; -this.applyStyle=function(c,d,e){var f={},n,m,l,w;runtime.assert(e&&e["style:text-properties"],"applyStyle without any text properties");f["style:text-properties"]=e["style:text-properties"];l=new b(f);w=new g(f);c.forEach(function(b){n=w.isStyleApplied(b);if(!1===n){var c=b.ownerDocument,e=b.parentNode,f,h=b,g=new core.LoopWatchDog(1E3);"span"===e.localName&&e.namespaceURI===a?(b.previousSibling&&!k.rangeContainsNode(d,b.previousSibling)?(c=e.cloneNode(!1),e.parentNode.insertBefore(c,e.nextSibling)): -c=e,f=!0):(c=c.createElementNS(a,"text:span"),e.insertBefore(c,b),f=!1);for(;h&&(h===b||k.rangeContainsNode(d,h));)g.check(),e=h.nextSibling,h.parentNode!==c&&c.appendChild(h),h=e;if(h&&f)for(b=c.cloneNode(!1),c.parentNode.insertBefore(b,c.nextSibling);h;)g.check(),e=h.nextSibling,b.appendChild(h),h=e;m=c;l.applyStyleToContainer(m)}})}}; +odf.TextStyleApplicator=function(k,l,n){function c(a){function b(a,d){return"object"===typeof a&&"object"===typeof d?Object.keys(a).every(function(c){return b(a[c],d[c])}):a===d}this.isStyleApplied=function(c){c=l.getAppliedStylesForElement(c);return b(a,c)}}function b(b){var c={};this.applyStyleToContainer=function(f){var h;h=f.getAttributeNS(a,"style-name");var m=f.ownerDocument;h=h||"";if(!c.hasOwnProperty(h)){var r=h,q=h,w;q?(w=l.getStyleElement(q,"text"),w.parentNode===n?m=w.cloneNode(!0):(m= +m.createElementNS(g,"style:style"),m.setAttributeNS(g,"style:parent-style-name",q),m.setAttributeNS(g,"style:family","text"),m.setAttributeNS(e,"scope","document-content"))):(m=m.createElementNS(g,"style:style"),m.setAttributeNS(g,"style:family","text"),m.setAttributeNS(e,"scope","document-content"));l.updateStyle(m,b,k);n.appendChild(m);c[r]=m}h=c[h].getAttributeNS(g,"name");f.setAttributeNS(a,"text:style-name",h)}}var h=new core.DomUtils,a=odf.Namespaces.textns,g=odf.Namespaces.stylens,e="urn:webodf:names:scope"; +this.applyStyle=function(d,e,f){var g={},m,k,l,n;runtime.assert(f&&f["style:text-properties"],"applyStyle without any text properties");g["style:text-properties"]=f["style:text-properties"];l=new b(g);n=new c(g);d.forEach(function(b){m=n.isStyleApplied(b);if(!1===m){var d=b.ownerDocument,c=b.parentNode,f,g=b,s=new core.LoopWatchDog(1E3);"span"===c.localName&&c.namespaceURI===a?(b.previousSibling&&!h.rangeContainsNode(e,b.previousSibling)?(d=c.cloneNode(!1),c.parentNode.insertBefore(d,c.nextSibling)): +d=c,f=!0):(d=d.createElementNS(a,"text:span"),c.insertBefore(d,b),f=!1);for(;g&&(g===b||h.rangeContainsNode(e,g));)s.check(),c=g.nextSibling,g.parentNode!==d&&d.appendChild(g),g=c;if(g&&f)for(b=d.cloneNode(!1),d.parentNode.insertBefore(b,d.nextSibling);g;)s.check(),c=g.nextSibling,b.appendChild(g),g=c;k=d;l.applyStyleToContainer(k)}})}}; // Input 32 /* @@ -641,47 +642,47 @@ c=e,f=!0):(c=c.createElementNS(a,"text:span"),e.insertBefore(c,b),f=!1);for(;h&& @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("odf.OdfUtils");runtime.loadClass("xmldom.XPath");runtime.loadClass("core.CSSUnits"); -odf.Style2CSS=function(){function l(a){var b={},c,d;if(!a)return b;for(a=a.firstChild;a;){if(d=a.namespaceURI!==q||"style"!==a.localName&&"default-style"!==a.localName?a.namespaceURI===w&&"list-style"===a.localName?"list":a.namespaceURI!==q||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(q,"family"))(c=a.getAttributeNS&&a.getAttributeNS(q,"name"))||(c=""),d=b[d]=b[d]||{},d[c]=a;a=a.nextSibling}return b}function f(a,b){if(!b||!a)return null;if(a[b])return a[b]; -var c,d;for(c in a)if(a.hasOwnProperty(c)&&(d=f(a[c].derivedStyles,b)))return d;return null}function m(a,b,c){var d=b[a],e,h;d&&(e=d.getAttributeNS(q,"parent-style-name"),h=null,e&&(h=f(c,e),!h&&b[e]&&(m(e,b,c),h=b[e],b[e]=null)),h?(h.derivedStyles||(h.derivedStyles={}),h.derivedStyles[a]=d):c[a]=d)}function g(a,b){for(var c in a)a.hasOwnProperty(c)&&(m(c,a,b),a[c]=null)}function b(a,b){var c=u[a],d;if(null===c)return null;d=b?"["+c+'|style-name="'+b+'"]':"["+c+"|style-name]";"presentation"===c&& -(c="draw",d=b?'[presentation|style-name="'+b+'"]':"[presentation|style-name]");return c+"|"+p[a].join(d+","+c+"|")+d}function k(a,c,d){var e=[],f,h;e.push(b(a,c));for(f in d.derivedStyles)if(d.derivedStyles.hasOwnProperty(f))for(h in c=k(a,f,d.derivedStyles[f]),c)c.hasOwnProperty(h)&&e.push(c[h]);return e}function a(a,b,c){if(!a)return null;for(a=a.firstChild;a;){if(a.namespaceURI===b&&a.localName===c)return b=a;a=a.nextSibling}return null}function e(a,b){var c="",d,e;for(d in b)b.hasOwnProperty(d)&& -(d=b[d],e=a.getAttributeNS(d[0],d[1]),d[2]&&e&&(c+=d[2]+":"+e+";"));return c}function d(b){return(b=a(b,q,"text-properties"))?T.parseFoFontSize(b.getAttributeNS(n,"font-size")):null}function c(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function t(a,b,c,d){b='text|list[text|style-name="'+b+'"]';var e=c.getAttributeNS(w,"level"), -f;c=T.getFirstNonWhitespaceChild(c);c=T.getFirstNonWhitespaceChild(c);var h;c&&(f=c.attributes,h=f["fo:text-indent"]?f["fo:text-indent"].value:void 0,f=f["fo:margin-left"]?f["fo:margin-left"].value:void 0);h||(h="-0.6cm");c="-"===h.charAt(0)?h.substring(1):"-"+h;for(e=e&&parseInt(e,10);1 text|list-item > text|list",e-=1;e=b+" > text|list-item > *:not(text|list):first-child";void 0!==f&&(f=e+"{margin-left:"+f+";}",a.insertRule(f,a.cssRules.length));d=b+" > text|list-item > *:not(text|list):first-child:before{"+ -d+";";d+="counter-increment:list;";d+="margin-left:"+h+";";d+="width:"+c+";";d+="display:inline-block}";try{a.insertRule(d,a.cssRules.length)}catch(g){throw g;}}function h(b,f,g,m){if("list"===f)for(var l=m.firstChild,p,r;l;){if(l.namespaceURI===w)if(p=l,"list-level-style-number"===l.localName){var u=p;r=u.getAttributeNS(q,"num-format");var E=u.getAttributeNS(q,"num-suffix"),G={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},u=u.getAttributeNS(q,"num-prefix")||"",u=G.hasOwnProperty(r)? -u+(" counter(list, "+G[r]+")"):r?u+("'"+r+"';"):u+" ''";E&&(u+=" '"+E+"'");r="content: "+u+";";t(b,g,p,r)}else"list-level-style-image"===l.localName?(r="content: none;",t(b,g,p,r)):"list-level-style-bullet"===l.localName&&(r="content: '"+p.getAttributeNS(w,"bullet-char")+"';",t(b,g,p,r));l=l.nextSibling}else if("page"===f)if(E=p=g="",l=m.getElementsByTagNameNS(q,"page-layout-properties")[0],p=l.parentNode.parentNode.parentNode.masterStyles,E="",g+=e(l,J),r=l.getElementsByTagNameNS(q,"background-image"), -0 text|list-item > text|list",e-=1;e=b+" > text|list-item > *:not(text|list):first-child";void 0!==f&&(f=e+"{margin-left:"+f+";}",a.insertRule(f,a.cssRules.length));c=b+" > text|list-item > *:not(text|list):first-child:before{"+ +c+";";c+="counter-increment:list;";c+="margin-left:"+g+";";c+="width:"+d+";";c+="display:inline-block}";try{a.insertRule(c,a.cssRules.length)}catch(h){throw h;}}function f(b,c,k,l){if("list"===c)for(var q=l.firstChild,p,n;q;){if(q.namespaceURI===w)if(p=q,"list-level-style-number"===q.localName){var v=p;n=v.getAttributeNS(r,"num-format");var K=v.getAttributeNS(r,"num-suffix"),E={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},v=v.getAttributeNS(r,"num-prefix")||"",v=E.hasOwnProperty(n)? +v+(" counter(list, "+E[n]+")"):n?v+("'"+n+"';"):v+" ''";K&&(v+=" '"+K+"'");n="content: "+v+";";t(b,k,p,n)}else"list-level-style-image"===q.localName?(n="content: none;",t(b,k,p,n)):"list-level-style-bullet"===q.localName&&(n="content: '"+p.getAttributeNS(w,"bullet-char")+"';",t(b,k,p,n));q=q.nextSibling}else if("page"===c)if(K=p=k="",q=l.getElementsByTagNameNS(r,"page-layout-properties")[0],p=q.parentNode.parentNode.parentNode.masterStyles,K="",k+=g(q,I),n=q.getElementsByTagNameNS(r,"background-image"), +0c)break;e=e.nextSibling}a.insertBefore(b,e)}}}function k(a){this.OdfContainer=a}function a(a, -b,c,d){var e=this;this.size=0;this.type=null;this.name=a;this.container=c;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);e.url=b;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}}var e=new odf.StyleInfo,d="urn:oasis:names:tc:opendocument:xmlns:office:1.0",c="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -t="urn:webodf:names:scope",h="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),s=(new Date).getTime()+"_webodf_",n=new core.Base64;k.prototype=new function(){};k.prototype.constructor=k;k.namespaceURI=d;k.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+n.toBase64(this.data):null};odf.OdfContainer=function r(f,h){function n(a){for(var b=a.firstChild,c;b;)c=b.nextSibling,b.nodeType===Node.ELEMENT_NODE? -n(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=c}function u(a,b){for(var c=a&&a.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&c.setAttributeNS(t,"scope",b),c=c.nextSibling}function p(a,b){var c=null,d,e,f;if(a)for(c=a.cloneNode(!0),d=c.firstChild;d;)e=d.nextSibling,d.nodeType===Node.ELEMENT_NODE&&(f=d.getAttributeNS(t,"scope"))&&f!==b&&c.removeChild(d),d=e;return c}function y(a){var b=M.rootElement.ownerDocument,c;if(a){n(a.documentElement);try{c=b.importNode(a.documentElement, -!0)}catch(d){}}return c}function D(a){M.state=a;if(M.onchange)M.onchange(M);if(M.onstatereadychange)M.onstatereadychange(M)}function H(a){Y=null;M.rootElement=a;a.fontFaceDecls=l(a,d,"font-face-decls");a.styles=l(a,d,"styles");a.automaticStyles=l(a,d,"automatic-styles");a.masterStyles=l(a,d,"master-styles");a.body=l(a,d,"body");a.meta=l(a,d,"meta")}function A(a){a=y(a);var c=M.rootElement;a&&"document-styles"===a.localName&&a.namespaceURI===d?(c.fontFaceDecls=l(a,d,"font-face-decls"),b(c,c.fontFaceDecls), -c.styles=l(a,d,"styles"),b(c,c.styles),c.automaticStyles=l(a,d,"automatic-styles"),u(c.automaticStyles,"document-styles"),b(c,c.automaticStyles),c.masterStyles=l(a,d,"master-styles"),b(c,c.masterStyles),e.prefixStyleNames(c.automaticStyles,s,c.masterStyles)):D(r.INVALID)}function N(a){a=y(a);var c,e,f;if(a&&"document-content"===a.localName&&a.namespaceURI===d){c=M.rootElement;e=l(a,d,"font-face-decls");if(c.fontFaceDecls&&e)for(f=e.firstChild;f;)c.fontFaceDecls.appendChild(f),f=e.firstChild;else e&& -(c.fontFaceDecls=e,b(c,e));e=l(a,d,"automatic-styles");u(e,"document-content");if(c.automaticStyles&&e)for(f=e.firstChild;f;)c.automaticStyles.appendChild(f),f=e.firstChild;else e&&(c.automaticStyles=e,b(c,e));c.body=l(a,d,"body");b(c,c.body)}else D(r.INVALID)}function C(a){a=y(a);var c;a&&("document-meta"===a.localName&&a.namespaceURI===d)&&(c=M.rootElement,c.meta=l(a,d,"meta"),b(c,c.meta))}function P(a){a=y(a);var c;a&&("document-settings"===a.localName&&a.namespaceURI===d)&&(c=M.rootElement,c.settings= -l(a,d,"settings"),b(c,c.settings))}function B(a){a=y(a);var b;if(a&&"manifest"===a.localName&&a.namespaceURI===c)for(b=M.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&("file-entry"===a.localName&&a.namespaceURI===c)&&(K[a.getAttributeNS(c,"full-path")]=a.getAttributeNS(c,"media-type")),a=a.nextSibling}function J(a){var b=a.shift(),c,d;b?(c=b[0],d=b[1],L.loadAsDOM(c,function(b,c){d(c);b||M.state===r.INVALID||J(a)})):D(r.DONE)}function U(a){var b="";odf.Namespaces.forEachPrefix(function(a, -c){b+=" xmlns:"+a+'="'+c+'"'});return''}function da(){var a=new xmldom.LSSerializer,b=U("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(M.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function T(a,b){var d=document.createElementNS(c,"manifest:file-entry");d.setAttributeNS(c,"manifest:full-path",a);d.setAttributeNS(c,"manifest:media-type",b);return d}function ka(){var a= -runtime.parseXML(''),b=l(a,c,"manifest"),d=new xmldom.LSSerializer,e;for(e in K)K.hasOwnProperty(e)&&b.appendChild(T(e,K[e]));d.filter=new odf.OdfNodeFilter;return'\n'+d.writeToString(a,odf.Namespaces.namespaceMap)}function ca(){var a=new xmldom.LSSerializer,b=U("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(M.rootElement.settings,odf.Namespaces.namespaceMap); -return b+""}function W(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,c=p(M.rootElement.automaticStyles,"document-styles"),d=M.rootElement.masterStyles&&M.rootElement.masterStyles.cloneNode(!0),f=U("document-styles");e.removePrefixFromStyleNames(c,s,d);b.filter=new m(d,c);f+=b.writeToString(M.rootElement.fontFaceDecls,a);f+=b.writeToString(M.rootElement.styles,a);f+=b.writeToString(c,a);f+=b.writeToString(d,a);return f+""}function O(){var a= -odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,c=p(M.rootElement.automaticStyles,"document-content"),d=U("document-content");b.filter=new g(M.rootElement.body,c);d+=b.writeToString(c,a);d+=b.writeToString(M.rootElement.body,a);return d+""}function ba(a,b){runtime.loadXML(a,function(a,c){if(a)b(a);else{var e=y(c);e&&"document"===e.localName&&e.namespaceURI===d?(H(e),D(r.DONE)):D(r.INVALID)}})}function S(){function a(b,c){var f;c||(c=b);f=document.createElementNS(d, -c);e[b]=f;e.appendChild(f)}var b=new core.Zip("",null),c=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),e=M.rootElement,f=document.createElementNS(d,"text");b.save("mimetype",c,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");e.body.appendChild(f);D(r.DONE);return b}function Q(){var a,b=new Date;a=runtime.byteArrayFromString(ca(),"utf8"); -L.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(da(),"utf8");L.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(W(),"utf8");L.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(O(),"utf8");L.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(ka(),"utf8");L.save("META-INF/manifest.xml",a,!0,b)}function F(a,b){Q();L.writeAs(a,function(a){b(a)})}var M=this,L,K={},Y;this.onstatereadychange=h;this.rootElement=this.state=this.onchange=null;this.setRootElement=H;this.getContentElement= -function(){var a;Y||(a=M.rootElement.body,Y=a.getElementsByTagNameNS(d,"text")[0]||a.getElementsByTagNameNS(d,"presentation")[0]||a.getElementsByTagNameNS(d,"spreadsheet")[0]);return Y};this.getDocumentType=function(){var a=M.getContentElement();return a&&a.localName};this.getPart=function(b){return new a(b,K[b],M,L)};this.getPartData=function(a,b){L.load(a,b)};this.createByteArray=function(a,b){Q();L.createByteArray(a,b)};this.saveAs=F;this.save=function(a){F(f,a)};this.getUrl=function(){return f}; -this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),c;a=new a;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}(k);L=f?new core.Zip(f,function(a,b){L=b;a?ba(f,function(b){a&&(L.error=a+"\n"+b,D(r.INVALID))}):J([["styles.xml",A],["content.xml",N],["meta.xml",C],["settings.xml",P],["META-INF/manifest.xml",B]])}):S()};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING= +odf.OdfContainer=function(){function k(a,b,d){for(a=a?a.firstChild:null;a;){if(a.localName===d&&a.namespaceURI===b)return a;a=a.nextSibling}return null}function l(a){var b,d=f.length;for(b=0;bd)break;e=e.nextSibling}a.insertBefore(b,e)}}}function h(a){this.OdfContainer=a}function a(a, +b,d,c){var e=this;this.size=0;this.type=null;this.name=a;this.container=d;this.onchange=this.onreadystatechange=this.document=this.mimetype=this.url=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.load=function(){null!==c&&(this.mimetype=b,c.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);e.url=b;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}}var g=new odf.StyleInfo,e="urn:oasis:names:tc:opendocument:xmlns:office:1.0",d="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", +t="urn:webodf:names:scope",f="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),s=(new Date).getTime()+"_webodf_",m=new core.Base64;h.prototype=new function(){};h.prototype.constructor=h;h.namespaceURI=e;h.localName="document";a.prototype.load=function(){};a.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data):null};odf.OdfContainer=function q(f,m){function l(a){for(var b=a.firstChild,d;b;)d=b.nextSibling,b.nodeType===Node.ELEMENT_NODE? +l(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=d}function v(a,b){for(var d=a&&a.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS(t,"scope",b),d=d.nextSibling}function p(a,b){var d=null,c,e,f;if(a)for(d=a.cloneNode(!0),c=d.firstChild;c;)e=c.nextSibling,c.nodeType===Node.ELEMENT_NODE&&(f=c.getAttributeNS(t,"scope"))&&f!==b&&d.removeChild(c),c=e;return d}function x(a){var b=J.rootElement.ownerDocument,d;if(a){l(a.documentElement);try{d=b.importNode(a.documentElement, +!0)}catch(c){}}return d}function D(a){J.state=a;if(J.onchange)J.onchange(J);if(J.onstatereadychange)J.onstatereadychange(J)}function G(a){S=null;J.rootElement=a;a.fontFaceDecls=k(a,e,"font-face-decls");a.styles=k(a,e,"styles");a.automaticStyles=k(a,e,"automatic-styles");a.masterStyles=k(a,e,"master-styles");a.body=k(a,e,"body");a.meta=k(a,e,"meta")}function A(a){a=x(a);var d=J.rootElement;a&&"document-styles"===a.localName&&a.namespaceURI===e?(d.fontFaceDecls=k(a,e,"font-face-decls"),b(d,d.fontFaceDecls), +d.styles=k(a,e,"styles"),b(d,d.styles),d.automaticStyles=k(a,e,"automatic-styles"),v(d.automaticStyles,"document-styles"),b(d,d.automaticStyles),d.masterStyles=k(a,e,"master-styles"),b(d,d.masterStyles),g.prefixStyleNames(d.automaticStyles,s,d.masterStyles)):D(q.INVALID)}function N(a){a=x(a);var d,c,f;if(a&&"document-content"===a.localName&&a.namespaceURI===e){d=J.rootElement;c=k(a,e,"font-face-decls");if(d.fontFaceDecls&&c)for(f=c.firstChild;f;)d.fontFaceDecls.appendChild(f),f=c.firstChild;else c&& +(d.fontFaceDecls=c,b(d,c));c=k(a,e,"automatic-styles");v(c,"document-content");if(d.automaticStyles&&c)for(f=c.firstChild;f;)d.automaticStyles.appendChild(f),f=c.firstChild;else c&&(d.automaticStyles=c,b(d,c));d.body=k(a,e,"body");b(d,d.body)}else D(q.INVALID)}function B(a){a=x(a);var d;a&&("document-meta"===a.localName&&a.namespaceURI===e)&&(d=J.rootElement,d.meta=k(a,e,"meta"),b(d,d.meta))}function O(a){a=x(a);var d;a&&("document-settings"===a.localName&&a.namespaceURI===e)&&(d=J.rootElement,d.settings= +k(a,e,"settings"),b(d,d.settings))}function z(a){a=x(a);var b;if(a&&"manifest"===a.localName&&a.namespaceURI===d)for(b=J.rootElement,b.manifest=a,a=b.manifest.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&("file-entry"===a.localName&&a.namespaceURI===d)&&(L[a.getAttributeNS(d,"full-path")]=a.getAttributeNS(d,"media-type")),a=a.nextSibling}function I(a){var b=a.shift(),d,c;b?(d=b[0],c=b[1],R.loadAsDOM(d,function(b,d){c(d);b||J.state===q.INVALID||I(a)})):D(q.DONE)}function X(a){var b="";odf.Namespaces.forEachPrefix(function(a, +d){b+=" xmlns:"+a+'="'+d+'"'});return''}function ea(){var a=new xmldom.LSSerializer,b=X("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(J.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function V(a,b){var c=document.createElementNS(d,"manifest:file-entry");c.setAttributeNS(d,"manifest:full-path",a);c.setAttributeNS(d,"manifest:media-type",b);return c}function ma(){var a= +runtime.parseXML(''),b=k(a,d,"manifest"),c=new xmldom.LSSerializer,e;for(e in L)L.hasOwnProperty(e)&&b.appendChild(V(e,L[e]));c.filter=new odf.OdfNodeFilter;return'\n'+c.writeToString(a,odf.Namespaces.namespaceMap)}function da(){var a=new xmldom.LSSerializer,b=X("document-settings");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(J.rootElement.settings,odf.Namespaces.namespaceMap); +return b+""}function ba(){var a=odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d=p(J.rootElement.automaticStyles,"document-styles"),c=J.rootElement.masterStyles&&J.rootElement.masterStyles.cloneNode(!0),e=X("document-styles");g.removePrefixFromStyleNames(d,s,c);b.filter=new n(c,d);e+=b.writeToString(J.rootElement.fontFaceDecls,a);e+=b.writeToString(J.rootElement.styles,a);e+=b.writeToString(d,a);e+=b.writeToString(c,a);return e+""}function M(){var a= +odf.Namespaces.namespaceMap,b=new xmldom.LSSerializer,d=p(J.rootElement.automaticStyles,"document-content"),e=X("document-content");b.filter=new c(J.rootElement.body,d);e+=b.writeToString(d,a);e+=b.writeToString(J.rootElement.body,a);return e+""}function $(a,b){runtime.loadXML(a,function(a,d){if(a)b(a);else{var c=x(d);c&&"document"===c.localName&&c.namespaceURI===e?(G(c),D(q.DONE)):D(q.INVALID)}})}function T(){function a(b,d){var f;d||(d=b);f=document.createElementNS(e,d); +c[b]=f;c.appendChild(f)}var b=new core.Zip("",null),d=runtime.byteArrayFromString("application/vnd.oasis.opendocument.text","utf8"),c=J.rootElement,f=document.createElementNS(e,"text");b.save("mimetype",d,!1,new Date);a("meta");a("settings");a("scripts");a("fontFaceDecls","font-face-decls");a("styles");a("automaticStyles","automatic-styles");a("masterStyles","master-styles");a("body");c.body.appendChild(f);D(q.DONE);return b}function P(){var a,b=new Date;a=runtime.byteArrayFromString(da(),"utf8"); +R.save("settings.xml",a,!0,b);a=runtime.byteArrayFromString(ea(),"utf8");R.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(ba(),"utf8");R.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(M(),"utf8");R.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(ma(),"utf8");R.save("META-INF/manifest.xml",a,!0,b)}function F(a,b){P();R.writeAs(a,function(a){b(a)})}var J=this,R,L={},S;this.onstatereadychange=m;this.rootElement=this.state=this.onchange=null;this.setRootElement=G;this.getContentElement= +function(){var a;S||(a=J.rootElement.body,S=a.getElementsByTagNameNS(e,"text")[0]||a.getElementsByTagNameNS(e,"presentation")[0]||a.getElementsByTagNameNS(e,"spreadsheet")[0]);return S};this.getDocumentType=function(){var a=J.getContentElement();return a&&a.localName};this.getPart=function(b){return new a(b,L[b],J,R)};this.getPartData=function(a,b){R.load(a,b)};this.createByteArray=function(a,b){P();R.createByteArray(a,b)};this.saveAs=F;this.save=function(a){F(f,a)};this.getUrl=function(){return f}; +this.state=q.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName),d;a=new a;for(d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return b}(h);R=f?new core.Zip(f,function(a,b){R=b;a?$(f,function(b){a&&(R.error=a+"\n"+b,D(q.INVALID))}):I([["styles.xml",A],["content.xml",N],["meta.xml",B],["settings.xml",O],["META-INF/manifest.xml",z]])}):T()};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING= 4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a,null)};return odf.OdfContainer}(); // Input 34 /* @@ -719,9 +720,9 @@ this.state=r.LOADING;this.rootElement=function(a){var b=document.createElementNS @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.Base64");runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.OdfContainer"); -odf.FontLoader=function(){function l(f,b,k,a,e){var d,c=0,t;for(t in f)if(f.hasOwnProperty(t)){if(c===k){d=t;break}c+=1}d?b.getPartData(f[d].href,function(c,s){if(c)runtime.log(c);else{var n="@font-face { font-family: '"+(f[d].family||d)+"'; src: url(data:application/x-font-ttf;charset=binary;base64,"+m.convertUTF8ArrayToBase64(s)+') format("truetype"); }';try{a.insertRule(n,a.cssRules.length)}catch(q){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(q)+"\nRule: "+n)}}l(f,b,k+1,a,e)}): -e&&e()}var f=new xmldom.XPath,m=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(g,b){for(var k=g.rootElement.fontFaceDecls;b.cssRules.length;)b.deleteRule(b.cssRules.length-1);if(k){var a={},e,d,c,m;if(k)for(k=f.getODFElementsWithXPath(k,"style:font-face[svg:font-face-src]",odf.Namespaces.resolvePrefix),e=0;e text|list-item > *:first-child:before {";if(ja=x.getAttributeNS(y,"style-name")){x=q[ja];B=P.getFirstNonWhitespaceChild(x);x=void 0;if("list-level-style-number"===B.localName){x=B.getAttributeNS(z,"num-format");ja=B.getAttributeNS(z, -"num-suffix");var F="",F={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},E=void 0,E=B.getAttributeNS(z,"num-prefix")||"",E=F.hasOwnProperty(x)?E+(" counter(list, "+F[x]+")"):x?E+("'"+x+"';"):E+" ''";ja&&(E+=" '"+ja+"'");x=F="content: "+E+";"}else"list-level-style-image"===B.localName?x="content: none;":"list-level-style-bullet"===B.localName&&(x="content: '"+B.getAttributeNS(y,"bullet-char")+"';");B=x}if(fa){for(x=l[fa];x;)fa=x,x=l[fa];aa+="counter-increment:"+fa+";"; -B?(B=B.replace("list",fa),aa+=B):aa+="content:counter("+fa+");"}else fa="",B?(B=B.replace("list",A),aa+=B):aa+="content: counter("+A+");",aa+="counter-increment:"+A+";",g.insertRule("text|list#"+A+" {counter-reset:"+A+"}",g.cssRules.length);aa+="}";l[A]=fa;aa&&g.insertRule(aa,g.cssRules.length)}n.insertBefore(J,n.firstChild);u();D(f);if(!d&&(f=[K],Z.hasOwnProperty("statereadychange")))for(g=Z.statereadychange,n=0;n text|list-item > *:first-child:before {";if(W=z.getAttributeNS(x,"style-name")){z=r[W];Y=O.getFirstNonWhitespaceChild(z);z=void 0;if("list-level-style-number"===Y.localName){z=Y.getAttributeNS(y,"num-format");W=Y.getAttributeNS(y, +"num-suffix");var ta="",ta={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"},F=void 0,F=Y.getAttributeNS(y,"num-prefix")||"",F=ta.hasOwnProperty(z)?F+(" counter(list, "+ta[z]+")"):z?F+("'"+z+"';"):F+" ''";W&&(F+=" '"+W+"'");z=ta="content: "+F+";"}else"list-level-style-image"===Y.localName?z="content: none;":"list-level-style-bullet"===Y.localName&&(z="content: '"+Y.getAttributeNS(x,"bullet-char")+"';");Y=z}if(E){for(z=n[E];z;)E=z,z=n[E];U+="counter-increment:"+E+";";Y? +(Y=Y.replace("list",E),U+=Y):U+="content:counter("+E+");"}else E="",Y?(Y=Y.replace("list",A),U+=Y):U+="content: counter("+A+");",U+="counter-increment:"+A+";",m.insertRule("text|list#"+A+" {counter-reset:"+A+"}",m.cssRules.length);U+="}";n[A]=E;U&&m.insertRule(U,m.cssRules.length)}k.insertBefore(I,k.firstChild);v();D(g);if(!c&&(g=[S],ja.hasOwnProperty("statereadychange")))for(m=ja.statereadychange,k=0;km?(runtime.log("connection to server timed out."),g("timeout")):(k+=100,runtime.getWindow().setTimeout(b,100)):(runtime.log("connection to collaboration server established."),g("ready"))}var k= -0;f||(f=runtime.getVariable("now"),void 0===f&&(f={networkStatus:"unavailable"}),b())};this.networkStatus=function(){return f?f.networkStatus:"unavailable"};this.login=function(m,g,b,k){f?f.login(m,g,b,k):k("Not connected to server")};this.createOperationRouter=function(f,g){return new ops.NowjsOperationRouter(f,g,l)};this.createUserModel=function(){return new ops.NowjsUserModel(l)}}; +ops.NowjsServer=function(){var k;this.getNowObject=function(){return k};this.getGenesisUrl=function(k){return"/session/"+k+"/genesis"};this.connect=function(l,n){function c(){"unavailable"===k.networkStatus?(runtime.log("connection to server unavailable."),n("unavailable")):"ready"!==k.networkStatus?b>l?(runtime.log("connection to server timed out."),n("timeout")):(b+=100,runtime.getWindow().setTimeout(c,100)):(runtime.log("connection to collaboration server established."),n("ready"))}var b=0;k|| +(k=runtime.getVariable("now"),void 0===k&&(k={networkStatus:"unavailable"}),c())};this.networkStatus=function(){return k?k.networkStatus:"unavailable"};this.login=function(l,n,c,b){k?k.login(l,n,c,b):b("Not connected to server")};this.joinSession=function(l,n,c,b){k.joinSession(l,n,function(b){k.memberid=b;c(b)},b)}}; // Input 40 /* @@ -944,9 +945,9 @@ ops.NowjsServer=function(){var l=this,f;this.getNowObject=function(){return f};t @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.Base64");runtime.loadClass("core.ByteArrayWriter"); -ops.PullBoxServer=function(l){function f(b,a){var e=new XMLHttpRequest,d=new core.ByteArrayWriter("utf8"),c=JSON.stringify(b);runtime.log("Sending message to server: "+c);d.appendString(c);d=d.getByteArray();e.open("POST",l.url,!0);e.onreadystatechange=function(){4===e.readyState&&((200>e.status||300<=e.status)&&0===e.status&&runtime.log("Status "+String(e.status)+": "+e.responseText||e.statusText),a(e.responseText))};d=d.buffer&&!e.sendAsBinary?d.buffer:runtime.byteArrayToString(d,"binary");try{e.sendAsBinary? -e.sendAsBinary(d):e.send(d)}catch(f){runtime.log("Problem with calling server: "+f+" "+d),a(f.message)}}var m=this,g,b=new core.Base64;l=l||{};l.url=l.url||"/WSER";this.getGenesisUrl=function(b){return"/session/"+b+"/genesis"};this.call=f;this.getToken=function(){return g};this.setToken=function(b){g=b};this.connect=function(b,a){a("ready")};this.networkStatus=function(){return"ready"};this.login=function(k,a,e,d){f({command:"login",args:{login:b.toBase64(k),password:b.toBase64(a)}},function(a){var b= -runtime.fromJson(a);runtime.log("Login reply: "+a);b.hasOwnProperty("token")?(g=b.token,runtime.log("Caching token: "+m.getToken()),e(b)):d(a)})}}; +ops.PullBoxServer=function(k){function l(b,a){var c=new XMLHttpRequest,e=new core.ByteArrayWriter("utf8"),d=JSON.stringify(b);runtime.log("Sending message to server: "+d);e.appendString(d);e=e.getByteArray();c.open("POST",k.url,!0);c.onreadystatechange=function(){4===c.readyState&&((200>c.status||300<=c.status)&&0===c.status&&runtime.log("Status "+String(c.status)+": "+c.responseText||c.statusText),a(c.responseText))};e=e.buffer&&!c.sendAsBinary?e.buffer:runtime.byteArrayToString(e,"binary");try{c.sendAsBinary? +c.sendAsBinary(e):c.send(e)}catch(l){runtime.log("Problem with calling server: "+l+" "+e),a(l.message)}}var n=this,c,b=new core.Base64;k=k||{};k.url=k.url||"/WSER";this.getGenesisUrl=function(b){return"/session/"+b+"/genesis"};this.call=l;this.getToken=function(){return c};this.setToken=function(b){c=b};this.connect=function(b,a){a("ready")};this.networkStatus=function(){return"ready"};this.login=function(h,a,g,e){l({command:"login",args:{login:b.toBase64(h),password:b.toBase64(a)}},function(a){var b= +runtime.fromJson(a);runtime.log("Login reply: "+a);b.hasOwnProperty("token")?(c=b.token,runtime.log("Caching token: "+n.getToken()),g(b)):e(a)})};this.joinSession=function(b,a,c,e){l({command:"join_session",args:{user_id:b,es_id:a}},function(a){var b=runtime.fromJson(a);runtime.log("join_session reply: "+a);b.hasOwnProperty("success")&&b.success?c(b.member_id):e&&e()})}}; // Input 41 /* @@ -982,7 +983,7 @@ runtime.fromJson(a);runtime.log("Login reply: "+a);b.hasOwnProperty("token")?(g= @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.Operation=function(){};ops.Operation.prototype.init=function(l){};ops.Operation.prototype.transform=function(l,f){};ops.Operation.prototype.execute=function(l){};ops.Operation.prototype.spec=function(){}; +ops.Operation=function(){};ops.Operation.prototype.init=function(k){};ops.Operation.prototype.transform=function(k,l){};ops.Operation.prototype.execute=function(k){};ops.Operation.prototype.spec=function(){}; // Input 42 /* @@ -1018,7 +1019,7 @@ ops.Operation=function(){};ops.Operation.prototype.init=function(l){};ops.Operat @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpAddCursor=function(){var l=this,f,m;this.init=function(g){f=g.memberid;m=g.timestamp};this.transform=function(f,b){return[l]};this.execute=function(g){var b=g.getCursor(f);if(b)return!1;b=new ops.OdtCursor(f,g);g.addCursor(b);g.emit(ops.OdtDocument.signalCursorAdded,b);return!0};this.spec=function(){return{optype:"AddCursor",memberid:f,timestamp:m}}}; +ops.OpAddCursor=function(){var k=this,l,n;this.init=function(c){l=c.memberid;n=c.timestamp};this.transform=function(c,b){return[k]};this.execute=function(c){var b=c.getCursor(l);if(b)return!1;b=new ops.OdtCursor(l,c);c.addCursor(b);c.emit(ops.OdtDocument.signalCursorAdded,b);return!0};this.spec=function(){return{optype:"AddCursor",memberid:l,timestamp:n}}}; // Input 43 /* @@ -1055,8 +1056,8 @@ ops.OpAddCursor=function(){var l=this,f,m;this.init=function(g){f=g.memberid;m=g @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("odf.OdfUtils"); -gui.StyleHelper=function(l){function f(b,f,a){var e=!0,d;b.collapsed?(d=b.startContainer,d.hasChildNodes()&&b.startOffsetg&&e.positiong&&e.positionc?-e.countBackwardSteps(-c,d):0;a.move(c);b&&(d=0b?-e.countBackwardSteps(-b, -d):0,a.move(d,!0));k.emit(ops.OdtDocument.signalCursorMoved,a);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:f,timestamp:m,position:g,length:b}}}; +ops.OpMoveCursor=function(){var k=this,l,n,c,b;this.init=function(h){l=h.memberid;n=h.timestamp;c=parseInt(h.position,10);b=void 0!==h.length?parseInt(h.length,10):0};this.merge=function(h){return"MoveCursor"===h.optype&&h.memberid===l?(c=h.position,b=h.length,n=h.timestamp,!0):!1};this.transform=function(h,a){var g=h.spec(),e=g.optype,d=c+b,n=[k];"RemoveText"===e?(e=g.position+g.length,e<=c?c-=g.length:g.positionc&&g.positionc&&g.positiond?-g.countBackwardSteps(-d,e):0;a.move(d);b&&(e=0b?-g.countBackwardSteps(-b, +e):0,a.move(e,!0));h.emit(ops.OdtDocument.signalCursorMoved,a);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:l,timestamp:n,position:c,length:b}}}; // Input 47 -ops.OpInsertTable=function(){function l(a,c){var d;if(1===t.length)d=t[0];else if(3===t.length)switch(a){case 0:d=t[0];break;case b-1:d=t[2];break;default:d=t[1]}else d=t[a];if(1===d.length)return d[0];if(3===d.length)switch(c){case 0:return d[0];case k-1:return d[2];default:return d[1]}return d[c]}var f=this,m,g,b,k,a,e,d,c,t;this.init=function(f){m=f.memberid;g=f.timestamp;a=parseInt(f.position,10);b=parseInt(f.initialRows,10);k=parseInt(f.initialColumns,10);e=f.tableName;d=f.tableStyleName;c=f.tableColumnStyleName; -t=f.tableCellStyleMatrix};this.transform=function(b,c){var d=b.spec(),e=d.optype,g=[f];if("InsertTable"===e)g=null;else if("SplitParagraph"===e)if(d.position=a.textNode.length?null:a.textNode.splitText(a.offset));for(a=a.textNode;a!==d;)if(a=a.parentNode,c=a.cloneNode(!1),h){for(l&&c.appendChild(l);h.nextSibling;)c.appendChild(h.nextSibling); -a.parentNode.insertBefore(c,a.nextSibling);h=a;l=c}else a.parentNode.insertBefore(c,a),h=c,l=a;b.isListItem(l)&&(l=l.childNodes[0]);k.fixCursorPositions(f);k.getOdfCanvas().refreshSize();k.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:e,memberId:f,timeStamp:m});k.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:f,timeStamp:m});k.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:f,timestamp:m,position:g}}}; +ops.OpSplitParagraph=function(){var k=this,l,n,c,b=new odf.OdfUtils;this.init=function(b){l=b.memberid;n=b.timestamp;c=parseInt(b.position,10)};this.transform=function(b,a){var g=b.spec(),e=g.optype,d=[k];if("SplitParagraph"===e)if(g.position=a.textNode.length?null:a.textNode.splitText(a.offset));for(a=a.textNode;a!==e;)if(a=a.parentNode,d=a.cloneNode(!1),f){for(k&&d.appendChild(k);f.nextSibling;)d.appendChild(f.nextSibling); +a.parentNode.insertBefore(d,a.nextSibling);f=a;k=d}else a.parentNode.insertBefore(d,a),f=d,k=a;b.isListItem(k)&&(k=k.childNodes[0]);h.fixCursorPositions(l);h.getOdfCanvas().refreshSize();h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:l,timeStamp:n});h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:l,timeStamp:n});h.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",memberid:l,timestamp:n,position:c}}}; // Input 51 /* @@ -1329,8 +1330,8 @@ a.parentNode.insertBefore(c,a.nextSibling);h=a;l=c}else a.parentNode.insertBefor @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpSetParagraphStyle=function(){var l=this,f,m,g,b;this.init=function(k){f=k.memberid;m=k.timestamp;g=k.position;b=k.styleName};this.transform=function(f,a){var e=f.spec();"DeleteParagraphStyle"===e.optype&&e.styleName===b&&(b="");return[l]};this.execute=function(k){var a;if(a=k.getPositionInTextNode(g))if(a=k.getParagraphElement(a.textNode))return""!==b?a.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):a.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", -"style-name"),k.getOdfCanvas().refreshSize(),k.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,timeStamp:m,memberId:f}),k.getOdfCanvas().rerenderAnnotations(),!0;return!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:f,timestamp:m,position:g,styleName:b}}}; +ops.OpSetParagraphStyle=function(){var k=this,l,n,c,b;this.init=function(h){l=h.memberid;n=h.timestamp;c=h.position;b=h.styleName};this.transform=function(c,a){var g=c.spec();"RemoveParagraphStyle"===g.optype&&g.styleName===b&&(b="");return[k]};this.execute=function(h){var a;if(a=h.getPositionInTextNode(c))if(a=h.getParagraphElement(a.textNode))return""!==b?a.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",b):a.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0", +"style-name"),h.getOdfCanvas().refreshSize(),h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,timeStamp:n,memberId:l}),h.getOdfCanvas().rerenderAnnotations(),!0;return!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:l,timestamp:n,position:c,styleName:b}}}; // Input 52 /* @@ -1366,12 +1367,12 @@ ops.OpSetParagraphStyle=function(){var l=this,f,m,g,b;this.init=function(k){f=k. @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.OpUpdateParagraphStyle=function(){function l(a,b){var d,e;for(d=0;da?-1:1;for(a=Math.abs(a);0n?l.previousPosition():l.nextPosition());)if(F.check(),k.acceptPosition(l)===u&&(q+=1,r=l.container(),z=g(r,l.unfilteredDomOffset(),Q),z.top!==O)){if(z.top!==S&&S!==O)break;S=z.top;z=Math.abs(ba-z.left);if(null===s||za?(c=k.previousPosition,d=-1):(c=k.nextPosition,d=1);for(e=g(k.container(),k.unfilteredDomOffset(),q);c.call(k);)if(b.acceptPosition(k)===u){if(r.getParagraphElement(k.getCurrentNode())!==l)break;h=g(k.container(),k.unfilteredDomOffset(),q);if(h.bottom!==e.bottom&&(e=h.top>=e.top&&h.bottome.bottom,!e))break;n+=d;e=h}q.detach();return n}function n(a,b){for(var c=0,d;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"),a=a.parentNode;for(d=b.firstChild;d!== -a;)c+=1,d=d.nextSibling;return c}function q(a,b,c){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var d=m(),e=d.container(),f=d.unfilteredDomOffset(),g=0,h=new core.LoopWatchDog(1E3);d.setUnfilteredPosition(a,b);a=d.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=d.unfilteredDomOffset();d.setUnfilteredPosition(e,f);var e=a,f=b,k=d.container(),l=d.unfilteredDomOffset();if(e===k)e=l- -f;else{var r=e.compareDocumentPosition(k);2===r?r=-1:4===r?r=1:10===r?(f=n(e,k),r=fe)for(;d.nextPosition()&&(h.check(),c.acceptPosition(d)===u&&(g+=1),d.container()!==a||d.unfilteredDomOffset()!==b););else if(0a?-1:1;for(a=Math.abs(a);0m?k.previousPosition():k.nextPosition());)if(F.check(),h.acceptPosition(k)===v&&(r+=1,q=k.container(),y=c(q,k.unfilteredDomOffset(),P),y.top!==M)){if(y.top!==T&&T!==M)break;T=y.top;y=Math.abs($-y.left);if(null===s||ya?(d=h.previousPosition,e=-1):(d=h.nextPosition,e=1);for(f=c(h.container(),h.unfilteredDomOffset(),r);d.call(h);)if(b.acceptPosition(h)===v){if(q.getParagraphElement(h.getCurrentNode())!==k)break;g=c(h.container(),h.unfilteredDomOffset(),r);if(g.bottom!==f.bottom&&(f=g.top>=f.top&&g.bottomf.bottom,!f))break;m+=e;f=g}r.detach();return m}function m(a,b){for(var d=0,c;a.parentNode!==b;)runtime.assert(null!==a.parentNode,"parent is null"),a=a.parentNode;for(c=b.firstChild;c!== +a;)d+=1,c=c.nextSibling;return d}function r(a,b,d){runtime.assert(null!==a,"SelectionMover.countStepsToPosition called with element===null");var c=n(),e=c.container(),f=c.unfilteredDomOffset(),g=0,h=new core.LoopWatchDog(1E3);c.setUnfilteredPosition(a,b);a=c.container();runtime.assert(Boolean(a),"SelectionMover.countStepsToPosition: positionIterator.container() returned null");b=c.unfilteredDomOffset();c.setUnfilteredPosition(e,f);var e=a,f=b,k=c.container(),l=c.unfilteredDomOffset();if(e===k)e=l- +f;else{var q=e.compareDocumentPosition(k);2===q?q=-1:4===q?q=1:10===q?(f=m(e,k),q=fe)for(;c.nextPosition()&&(h.check(),d.acceptPosition(c)===v&&(g+=1),c.container()!==a||c.unfilteredDomOffset()!==b););else if(0=b&&(e=-g.movePointBackward(-b,a));m.handleUpdate();return e};this.handleUpdate=function(){};this.getStepCounter=function(){return g.getStepCounter()};this.getMemberId=function(){return l};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; -this.getOdtDocument=function(){return f};b=new core.Cursor(f.getDOM(),l);g=new gui.SelectionMover(b,f.getRootNode())}; +ops.OdtCursor=function(k,l){var n=this,c,b;this.removeFromOdtDocument=function(){b.remove()};this.move=function(b,a){var g=0;0=b&&(g=-c.movePointBackward(-b,a));n.handleUpdate();return g};this.handleUpdate=function(){};this.getStepCounter=function(){return c.getStepCounter()};this.getMemberId=function(){return k};this.getNode=function(){return b.getNode()};this.getAnchorNode=function(){return b.getAnchorNode()};this.getSelectedRange=function(){return b.getSelectedRange()}; +this.getOdtDocument=function(){return l};b=new core.Cursor(l.getDOM(),k);c=new gui.SelectionMover(b,l.getRootNode())}; // Input 60 /* @@ -1615,22 +1616,21 @@ this.getOdtDocument=function(){return f};b=new core.Cursor(f.getDOM(),l);g=new g @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.EditInfo=function(l,f){function m(){var f=[],a;for(a in b)b.hasOwnProperty(a)&&f.push({memberid:a,time:b[a].time});f.sort(function(a,b){return a.time-b.time});return f}var g,b={};this.getNode=function(){return g};this.getOdtDocument=function(){return f};this.getEdits=function(){return b};this.getSortedEdits=function(){return m()};this.addEdit=function(f,a){var e,d=f.split("___")[0];if(!b[f])for(e in b)if(b.hasOwnProperty(e)&&e.split("___")[0]===d){delete b[e];break}b[f]={time:a}};this.clearEdits= -function(){b={}};g=f.getDOM().createElementNS("urn:webodf:names:editinfo","editinfo");l.insertBefore(g,l.firstChild)}; +ops.EditInfo=function(k,l){function n(){var c=[],a;for(a in b)b.hasOwnProperty(a)&&c.push({memberid:a,time:b[a].time});c.sort(function(a,b){return a.time-b.time});return c}var c,b={};this.getNode=function(){return c};this.getOdtDocument=function(){return l};this.getEdits=function(){return b};this.getSortedEdits=function(){return n()};this.addEdit=function(c,a){b[c]={time:a}};this.clearEdits=function(){b={}};c=l.getDOM().createElementNS("urn:webodf:names:editinfo","editinfo");k.insertBefore(c,k.firstChild)}; // Input 61 -gui.Avatar=function(l,f){var m=this,g,b,k;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){m.isVisible()?b.src=a:k=a};this.isVisible=function(){return"block"===g.style.display};this.show=function(){k&&(b.src=k,k=void 0);g.style.display="block"};this.hide=function(){g.style.display="none"};this.markAsFocussed=function(a){g.className=a?"active":""};(function(){var a=l.ownerDocument,e=a.documentElement.namespaceURI;g=a.createElementNS(e,"div");b=a.createElementNS(e,"img"); -b.width=64;b.height=64;g.appendChild(b);g.style.width="64px";g.style.height="70px";g.style.position="absolute";g.style.top="-80px";g.style.left="-34px";g.style.display=f?"block":"none";l.appendChild(g)})()}; +gui.Avatar=function(k,l){var n=this,c,b,h;this.setColor=function(a){b.style.borderColor=a};this.setImageUrl=function(a){n.isVisible()?b.src=a:h=a};this.isVisible=function(){return"block"===c.style.display};this.show=function(){h&&(b.src=h,h=void 0);c.style.display="block"};this.hide=function(){c.style.display="none"};this.markAsFocussed=function(a){c.className=a?"active":""};(function(){var a=k.ownerDocument,g=a.documentElement.namespaceURI;c=a.createElementNS(g,"div");b=a.createElementNS(g,"img"); +b.width=64;b.height=64;c.appendChild(b);c.style.width="64px";c.style.height="70px";c.style.position="absolute";c.style.top="-80px";c.style.left="-34px";c.style.display=l?"block":"none";k.appendChild(c)})()}; // Input 62 runtime.loadClass("gui.Avatar");runtime.loadClass("ops.OdtCursor"); -gui.Caret=function(l,f,m){function g(a){d&&e.parentNode&&(!c||a)&&(a&&void 0!==t&&runtime.clearTimeout(t),c=!0,k.style.opacity=a||"0"===k.style.opacity?"1":"0",t=runtime.setTimeout(function(){c=!1;g(!1)},500))}function b(a){var b;if("string"===typeof a){if(""===a)return 0;b=/^(\d+)(\.\d+)?px$/.exec(a);runtime.assert(null!==b,"size ["+a+"] does not have unit px.");return parseFloat(b[1])}return a}var k,a,e,d=!1,c=!1,t;this.refreshCursor=function(){m||l.getSelectedRange().collapsed?(d=!0,g(!0)):(d= -!1,k.style.opacity="0")};this.setFocus=function(){d=!0;a.markAsFocussed(!0);g(!0)};this.removeFocus=function(){d=!1;a.markAsFocussed(!1);k.style.opacity="0"};this.setAvatarImageUrl=function(b){a.setImageUrl(b)};this.setColor=function(b){k.style.borderColor=b;a.setColor(b)};this.getCursor=function(){return l};this.getFocusElement=function(){return k};this.toggleHandleVisibility=function(){a.isVisible()?a.hide():a.show()};this.showHandle=function(){a.show()};this.hideHandle=function(){a.hide()};this.ensureVisible= -function(){var a,c,d,e,f,g,m,t=l.getOdtDocument().getOdfCanvas().getElement().parentNode;f=m=k;d=runtime.getWindow();runtime.assert(null!==d,"Expected to be run in an environment which has a global window, like a browser.");do{f=f.parentElement;if(!f)break;g=d.getComputedStyle(f,null)}while("block"!==g.display);g=f;f=e=0;if(g&&t){c=!1;do{d=g.offsetParent;for(a=g.parentNode;a!==d;){if(a===t){a=g;var u=t,p=0;c=0;var y=void 0,D=runtime.getWindow();for(runtime.assert(null!==D,"Expected to be run in an environment which has a global window, like a browser.");a&& -a!==u;)y=D.getComputedStyle(a,null),p+=b(y.marginLeft)+b(y.borderLeftWidth)+b(y.paddingLeft),c+=b(y.marginTop)+b(y.borderTopWidth)+b(y.paddingTop),a=a.parentElement;a=p;e+=a;f+=c;c=!0;break}a=a.parentNode}if(c)break;e+=b(g.offsetLeft);f+=b(g.offsetTop);g=d}while(g&&g!==t);d=e;e=f}else e=d=0;d+=m.offsetLeft;e+=m.offsetTop;f=d-5;g=e-5;d=d+m.scrollWidth-1+5;m=e+m.scrollHeight-1+5;gt.scrollTop+t.clientHeight-1&&(t.scrollTop=m-t.clientHeight+1);ft.scrollLeft+t.clientWidth-1&&(t.scrollLeft=d-t.clientWidth+1)};(function(){var b=l.getOdtDocument().getDOM();k=b.createElementNS(b.documentElement.namespaceURI,"span");e=l.getNode();e.appendChild(k);a=new gui.Avatar(e,f)})()}; +gui.Caret=function(k,l,n){function c(a){e&&g.parentNode&&(!d||a)&&(a&&void 0!==t&&runtime.clearTimeout(t),d=!0,h.style.opacity=a||"0"===h.style.opacity?"1":"0",t=runtime.setTimeout(function(){d=!1;c(!1)},500))}function b(a){var b;if("string"===typeof a){if(""===a)return 0;b=/^(\d+)(\.\d+)?px$/.exec(a);runtime.assert(null!==b,"size ["+a+"] does not have unit px.");return parseFloat(b[1])}return a}var h,a,g,e=!1,d=!1,t;this.refreshCursorBlinking=function(){n||k.getSelectedRange().collapsed?(e=!0,c(!0)): +(e=!1,h.style.opacity="0")};this.setFocus=function(){e=!0;a.markAsFocussed(!0);c(!0)};this.removeFocus=function(){e=!1;a.markAsFocussed(!1);h.style.opacity="0"};this.setAvatarImageUrl=function(b){a.setImageUrl(b)};this.setColor=function(b){h.style.borderColor=b;a.setColor(b)};this.getCursor=function(){return k};this.getFocusElement=function(){return h};this.toggleHandleVisibility=function(){a.isVisible()?a.hide():a.show()};this.showHandle=function(){a.show()};this.hideHandle=function(){a.hide()}; +this.ensureVisible=function(){var a,c,d,e,g,l,n,t=k.getOdtDocument().getOdfCanvas().getElement().parentNode;g=n=h;d=runtime.getWindow();runtime.assert(null!==d,"Expected to be run in an environment which has a global window, like a browser.");do{g=g.parentElement;if(!g)break;l=d.getComputedStyle(g,null)}while("block"!==l.display);l=g;g=e=0;if(l&&t){c=!1;do{d=l.offsetParent;for(a=l.parentNode;a!==d;){if(a===t){a=l;var v=t,p=0;c=0;var x=void 0,D=runtime.getWindow();for(runtime.assert(null!==D,"Expected to be run in an environment which has a global window, like a browser.");a&& +a!==v;)x=D.getComputedStyle(a,null),p+=b(x.marginLeft)+b(x.borderLeftWidth)+b(x.paddingLeft),c+=b(x.marginTop)+b(x.borderTopWidth)+b(x.paddingTop),a=a.parentElement;a=p;e+=a;g+=c;c=!0;break}a=a.parentNode}if(c)break;e+=b(l.offsetLeft);g+=b(l.offsetTop);l=d}while(l&&l!==t);d=e;e=g}else e=d=0;d+=n.offsetLeft;e+=n.offsetTop;g=d-5;l=e-5;d=d+n.scrollWidth-1+5;n=e+n.scrollHeight-1+5;lt.scrollTop+t.clientHeight-1&&(t.scrollTop=n-t.clientHeight+1);gt.scrollLeft+t.clientWidth-1&&(t.scrollLeft=d-t.clientWidth+1)};(function(){var b=k.getOdtDocument().getDOM();h=b.createElementNS(b.documentElement.namespaceURI,"span");g=k.getNode();g.appendChild(h);a=new gui.Avatar(g,l)})()}; // Input 63 runtime.loadClass("core.EventNotifier"); -gui.ClickHandler=function(){function l(){m=0;g=null}var f,m=0,g=null,b=new core.EventNotifier([gui.ClickHandler.signalSingleClick,gui.ClickHandler.signalDoubleClick,gui.ClickHandler.signalTripleClick]);this.subscribe=function(f,a){b.subscribe(f,a)};this.handleMouseUp=function(k){var a=runtime.getWindow();g&&g.x===k.screenX&&g.y===k.screenY?(m+=1,1===m?b.emit(gui.ClickHandler.signalSingleClick,k):2===m?b.emit(gui.ClickHandler.signalDoubleClick,void 0):3===m&&(a.clearTimeout(f),b.emit(gui.ClickHandler.signalTripleClick, -void 0),l())):(b.emit(gui.ClickHandler.signalSingleClick,k),m=1,g={x:k.screenX,y:k.screenY},a.clearTimeout(f),f=a.setTimeout(l,400))}};gui.ClickHandler.signalSingleClick="click";gui.ClickHandler.signalDoubleClick="doubleClick";gui.ClickHandler.signalTripleClick="tripleClick";(function(){return gui.ClickHandler})(); +gui.ClickHandler=function(){function k(){n=0;c=null}var l,n=0,c=null,b=new core.EventNotifier([gui.ClickHandler.signalSingleClick,gui.ClickHandler.signalDoubleClick,gui.ClickHandler.signalTripleClick]);this.subscribe=function(c,a){b.subscribe(c,a)};this.handleMouseUp=function(h){var a=runtime.getWindow();c&&c.x===h.screenX&&c.y===h.screenY?(n+=1,1===n?b.emit(gui.ClickHandler.signalSingleClick,h):2===n?b.emit(gui.ClickHandler.signalDoubleClick,void 0):3===n&&(a.clearTimeout(l),b.emit(gui.ClickHandler.signalTripleClick, +void 0),k())):(b.emit(gui.ClickHandler.signalSingleClick,h),n=1,c={x:h.screenX,y:h.screenY},a.clearTimeout(l),l=a.setTimeout(k,400))}};gui.ClickHandler.signalSingleClick="click";gui.ClickHandler.signalDoubleClick="doubleClick";gui.ClickHandler.signalTripleClick="tripleClick";(function(){return gui.ClickHandler})(); // Input 64 /* @@ -1666,8 +1666,8 @@ void 0),l())):(b.emit(gui.ClickHandler.signalSingleClick,k),m=1,g={x:k.screenX,y @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.KeyboardHandler=function(){function l(b,g){g||(g=f.None);return b+":"+g}var f=gui.KeyboardHandler.Modifier,m=null,g={};this.setDefault=function(b){m=b};this.bind=function(b,f,a){b=l(b,f);runtime.assert(!1===g.hasOwnProperty(b),"tried to overwrite the callback handler of key combo: "+b);g[b]=a};this.unbind=function(b,f){var a=l(b,f);delete g[a]};this.reset=function(){m=null;g={}};this.handleEvent=function(b){var k=b.keyCode,a=f.None;b.metaKey&&(a|=f.Meta);b.ctrlKey&&(a|=f.Ctrl);b.altKey&&(a|=f.Alt); -b.shiftKey&&(a|=f.Shift);k=l(k,a);k=g[k];a=!1;k?a=k():null!==m&&(a=m(b));a&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,I:73,U:85,Z:90};(function(){return gui.KeyboardHandler})(); +gui.KeyboardHandler=function(){function k(b,c){c||(c=l.None);return b+":"+c}var l=gui.KeyboardHandler.Modifier,n=null,c={};this.setDefault=function(b){n=b};this.bind=function(b,h,a){b=k(b,h);runtime.assert(!1===c.hasOwnProperty(b),"tried to overwrite the callback handler of key combo: "+b);c[b]=a};this.unbind=function(b,h){var a=k(b,h);delete c[a]};this.reset=function(){n=null;c={}};this.handleEvent=function(b){var h=b.keyCode,a=l.None;b.metaKey&&(a|=l.Meta);b.ctrlKey&&(a|=l.Ctrl);b.altKey&&(a|=l.Alt); +b.shiftKey&&(a|=l.Shift);h=k(h,a);h=c[h];a=!1;h?a=h():null!==n&&(a=n(b));a&&(b.preventDefault?b.preventDefault():b.returnValue=!1)}};gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,I:73,U:85,Z:90};(function(){return gui.KeyboardHandler})(); // Input 65 /* @@ -1704,38 +1704,38 @@ b.shiftKey&&(a|=f.Shift);k=l(k,a);k=g[k];a=!1;k?a=k():null!==m&&(a=m(b));a&&(b.p @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("odf.Namespaces");runtime.loadClass("xmldom.LSSerializer");runtime.loadClass("odf.OdfNodeFilter");runtime.loadClass("odf.TextSerializer"); -gui.Clipboard=function(){var l,f,m;this.setDataFromRange=function(g,b){var k=!0,a,e=g.clipboardData;a=runtime.getWindow();var d=b.startContainer.ownerDocument;!e&&a&&(e=a.clipboardData);e?(d=d.createElement("span"),d.appendChild(b.cloneContents()),a=e.setData("text/plain",f.writeToString(d)),k=k&&a,a=e.setData("text/html",l.writeToString(d,odf.Namespaces.namespaceMap)),k=k&&a,g.preventDefault()):k=!1;return k};l=new xmldom.LSSerializer;f=new odf.TextSerializer;m=new odf.OdfNodeFilter;l.filter=m;f.filter= -m}; +gui.Clipboard=function(){var k,l,n;this.setDataFromRange=function(c,b){var h=!0,a,g=c.clipboardData;a=runtime.getWindow();var e=b.startContainer.ownerDocument;!g&&a&&(g=a.clipboardData);g?(e=e.createElement("span"),e.appendChild(b.cloneContents()),a=g.setData("text/plain",l.writeToString(e)),h=h&&a,a=g.setData("text/html",k.writeToString(e,odf.Namespaces.namespaceMap)),h=h&&a,c.preventDefault()):h=!1;return h};k=new xmldom.LSSerializer;l=new odf.TextSerializer;n=new odf.OdfNodeFilter;k.filter=n;l.filter= +n}; // Input 66 -runtime.loadClass("ops.OpAddCursor");runtime.loadClass("ops.OpRemoveCursor");runtime.loadClass("ops.OpMoveCursor");runtime.loadClass("ops.OpInsertText");runtime.loadClass("ops.OpRemoveText");runtime.loadClass("ops.OpSplitParagraph");runtime.loadClass("ops.OpSetParagraphStyle");runtime.loadClass("gui.ClickHandler");runtime.loadClass("gui.Clipboard");runtime.loadClass("gui.KeyboardHandler");runtime.loadClass("gui.StyleHelper"); -gui.SessionController=function(){gui.SessionController=function(l,f){function m(a,b,c,d){var e="on"+b,f=!1;a.attachEvent&&(f=a.attachEvent(e,c));!f&&a.addEventListener&&(a.addEventListener(b,c,!1),f=!0);f&&!d||!a.hasOwnProperty(e)||(a[e]=c)}function g(a,b,c){var d="on"+b;a.detachEvent&&a.detachEvent(d,c);a.removeEventListener&&a.removeEventListener(b,c,!1);a[d]===c&&(a[d]=null)}function b(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a,b){var c=new ops.OpMoveCursor;c.init({memberid:f, -position:a,length:b||0});return c}function a(a,b){var c=gui.SelectionMover.createPositionIterator(x.getRootNode()),d=x.getOdfCanvas().getElement(),e;e=a;if(!e)return null;for(;e!==d&&!("urn:webodf:names:cursor"===e.namespaceURI&&"cursor"===e.localName||"urn:webodf:names:editinfo"===e.namespaceURI&&"editinfo"===e.localName);)if(e=e.parentNode,!e)return null;e!==d&&a!==e&&(a=e.parentNode,b=Array.prototype.indexOf.call(a.childNodes,e));c.setUnfilteredPosition(a,b);return x.getDistanceFromCursor(f,c.container(), -c.unfilteredDomOffset())}function e(b){runtime.setTimeout(function(){var c=runtime.getWindow().getSelection(),d=x.getCursorPosition(f),e,g;if(null===c.anchorNode&&null===c.focusNode){e=b.clientX;g=b.clientY;var h=x.getDOM();h.caretRangeFromPoint?(e=h.caretRangeFromPoint(e,g),g={container:e.startContainer,offset:e.startOffset}):h.caretPositionFromPoint?(e=h.caretPositionFromPoint(e,g),g={container:e.offsetNode,offset:e.offset}):g=null;g&&(e=x.getDOM().createRange(),e.setStart(g.container,g.offset), -e.collapse(!0),c.addRange(e))}e=a(c.anchorNode,c.anchorOffset);c=a(c.focusNode,c.focusOffset);if(null!==c&&0!==c||null!==e&&0!==e)d=k(d+e,c-e),l.enqueue(d)},0)}function d(a){e(a)}function c(){var a,b,c,d=gui.SelectionMover.createPositionIterator(x.getRootNode()),e=x.getCursor(f).getNode(),g=x.getCursorPosition(f),h=/[A-Za-z0-9]/,m=0,n=0;d.setUnfilteredPosition(e,0);if(d.previousPosition()&&(a=d.getCurrentNode(),a.nodeType===Node.TEXT_NODE))for(b=a.data.length-1;0<=b;b-=1)if(c=a.data[b],h.test(c))m-= -1;else break;d.setUnfilteredPosition(e,0);if(d.nextPosition()&&(a=d.getCurrentNode(),a.nodeType===Node.TEXT_NODE))for(b=0;ba.length&&(a.position+=a.length,a.length=-a.length);return a}function O(a){var b=new ops.OpRemoveText;b.init({memberid:f,position:a.position,length:a.length});return b}function ba(){var a=W(x.getCursorSelection(f)),b=null;0===a.length?0a.length&&(a.position+=a.length,a.length=-a.length);return a}function $(a){var b=new ops.OpRemoveText;b.init({memberid:l,position:a.position,length:a.length});return b}function T(){var a= +M(C.getCursorSelection(l)),b=null;0===a.length?0 + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -1767,11 +1767,81 @@ ops.UserModel=function(){};ops.UserModel.prototype.getUserDetailsAndUpdates=func @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -ops.TrivialUserModel=function(){var l={bob:{memberid:"bob",fullname:"Bob Pigeon",color:"red",imageurl:"avatar-pigeon.png"},alice:{memberid:"alice",fullname:"Alice Bee",color:"green",imageurl:"avatar-flower.png"},you:{memberid:"you",fullname:"I, Robot",color:"blue",imageurl:"avatar-joe.png"}};this.getUserDetailsAndUpdates=function(f,m){var g=f.split("___")[0];m(f,l[g]||null)};this.unsubscribeUserDetailsUpdates=function(f,l){}}; +ops.MemberModel=function(){};ops.MemberModel.prototype.getMemberDetailsAndUpdates=function(k,l){};ops.MemberModel.prototype.unsubscribeMemberDetailsUpdates=function(k,l){}; +// Input 68 +/* + + Copyright (C) 2012-2013 KO GmbH + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +ops.TrivialMemberModel=function(){this.getMemberDetailsAndUpdates=function(k,l){l(k,null)};this.unsubscribeMemberDetailsUpdates=function(k,l){}}; // Input 69 -ops.NowjsUserModel=function(l){var f={},m={},g=l.getNowObject();this.getUserDetailsAndUpdates=function(b,k){var a=b.split("___")[0],e=f[a],d=m[a]||[],c;m[a]=d;runtime.assert(void 0!==k,"missing callback");for(c=0;c + + @licstart + The JavaScript code in this page is free software: you can redistribute it + and/or modify it under the terms of the GNU Affero General Public License + (GNU AGPL) as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. The code is distributed + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. + + As additional permission under GNU AGPL version 3 section 7, you + may distribute non-source (e.g., minimized or compacted) forms of + that code without the copy of the GNU GPL normally required by + section 4, provided you include this license notice and a URL + through which recipients can access the Corresponding Source. + + As a special exception to the AGPL, any HTML file which merely makes function + calls to this code, and for that purpose includes it by reference shall be + deemed a separate work for copyright law purposes. In addition, the copyright + holders of this code give you permission to combine this code with free + software libraries that are released under the GNU LGPL. You may copy and + distribute such a system following the terms of the GNU AGPL for this code + and the LGPL for the libraries. If you modify this code, you may extend this + exception to your version of the code, but you are not obligated to do so. + If you do not wish to do so, delete this exception statement from your + version. + + This license applies to this entire compilation. + @licend + @source: http://www.webodf.org/ + @source: http://gitorious.org/webodf/webodf/ +*/ +ops.NowjsMemberModel=function(k){var l={},n={},c=k.getNowObject();this.getMemberDetailsAndUpdates=function(b,h){var a=b.split("___")[0],g=l[a],e=n[a]||[],d;n[a]=e;runtime.assert(void 0!==h,"missing callback");for(d=0;dg?(m(1,0),e=m(0.5,1E4-g),d=m(0.2,2E4-g)):1E4<=g&&2E4>g?(m(0.5,0),d=m(0.2,2E4-g)):m(0.2,0)};this.getEdits= -function(){return l.getEdits()};this.clearEdits=function(){l.clearEdits();k.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return l};this.show=function(){a.style.display="block"};this.hide=function(){g.hideHandle();a.style.display="none"};this.showHandle=function(){k.show()};this.hideHandle=function(){k.hide()};(function(){var c=l.getOdtDocument().getDOM();a=c.createElementNS(c.documentElement.namespaceURI, -"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){g.showHandle()};a.onmouseout=function(){g.hideHandle()};b=l.getNode();b.appendChild(a);k=new gui.EditInfoHandle(b);f||g.hide()})()}; +gui.EditInfoMarker=function(k,l){function n(b,c){return runtime.getWindow().setTimeout(function(){a.style.opacity=b},c)}var c=this,b,h,a,g,e;this.addEdit=function(b,c){var f=Date.now()-c;k.addEdit(b,c);h.setEdits(k.getSortedEdits());a.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);if(g){var l=g;runtime.getWindow().clearTimeout(l)}e&&(l=e,runtime.getWindow().clearTimeout(l));1E4>f?(n(1,0),g=n(0.5,1E4-f),e=n(0.2,2E4-f)):1E4<=f&&2E4>f?(n(0.5,0),e=n(0.2,2E4-f)):n(0.2,0)};this.getEdits= +function(){return k.getEdits()};this.clearEdits=function(){k.clearEdits();h.setEdits([]);a.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&a.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return k};this.show=function(){a.style.display="block"};this.hide=function(){c.hideHandle();a.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};(function(){var d=k.getOdtDocument().getDOM();a=d.createElementNS(d.documentElement.namespaceURI, +"div");a.setAttribute("class","editInfoMarker");a.onmouseover=function(){c.showHandle()};a.onmouseout=function(){c.hideHandle()};b=k.getNode();b.appendChild(a);h=new gui.EditInfoHandle(b);l||c.hide()})()}; // Input 77 /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -1972,17 +2042,17 @@ function(){return l.getEdits()};this.clearEdits=function(){l.clearEdits();k.setE @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -runtime.loadClass("gui.Caret");runtime.loadClass("ops.TrivialUserModel");runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoMarker");gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0}; -gui.SessionView=function(){return function(l,f,m){function g(a,b,c){b=b.split("___")[0];return a+'[editinfo|memberid^="'+b+'"]'+c}function b(a,b,c){function d(b,c,e){c=g(b,a,e)+c;a:{var f=t.firstChild;for(b=g(b,a,e);f;){if(f.nodeType===Node.TEXT_NODE&&0===f.data.indexOf(b)){b=f;break a}f=f.nextSibling}b=null}b?b.data=c:t.appendChild(document.createTextNode(c))}d("div.editInfoMarker","{ background-color: "+c+"; }","");d("span.editInfoColor","{ background-color: "+c+"; }","");d("span.editInfoAuthor", -'{ content: "'+b+'"; }',":before");d("dc|creator",'{ content: "'+b+'"; display: none;}',":before");d("dc|creator","{ background-color: "+c+"; }","")}function k(a){var b,c;for(c in h)h.hasOwnProperty(c)&&(b=h[c],a?b.show():b.hide())}function a(a){m.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function e(a,c){var d=m.getCaret(a);void 0===c?runtime.log('UserModel sent undefined data for member "'+a+'".'):(null===c&&(c={memberid:a,fullname:"Unknown Identity",color:"black",imageurl:"avatar-joe.png"}), -d&&(d.setAvatarImageUrl(c.imageurl),d.setColor(c.color)),b(a,c.fullname,c.color))}function d(a){var b=a.getMemberId(),c=f.getUserModel();m.registerCursor(a,n,q);e(b,null);c.getUserDetailsAndUpdates(b,e);runtime.log("+++ View here +++ eagerly created an Caret for '"+b+"'! +++")}function c(a){var b=!1,c;for(c in h)if(h.hasOwnProperty(c)&&h[c].getEditInfo().getEdits().hasOwnProperty(a)){b=!0;break}b||f.getUserModel().unsubscribeUserDetailsUpdates(a,e)}var t,h={},s=void 0!==l.editInfoMarkersInitiallyVisible? -l.editInfoMarkersInitiallyVisible:!0,n=void 0!==l.caretAvatarsInitiallyVisible?l.caretAvatarsInitiallyVisible:!0,q=void 0!==l.caretBlinksOnRangeSelect?l.caretBlinksOnRangeSelect:!0;this.showEditInfoMarkers=function(){s||(s=!0,k(s))};this.hideEditInfoMarkers=function(){s&&(s=!1,k(s))};this.showCaretAvatars=function(){n||(n=!0,a(n))};this.hideCaretAvatars=function(){n&&(n=!1,a(n))};this.getSession=function(){return f};this.getCaret=function(a){return m.getCaret(a)};(function(){var a=f.getOdtDocument(), -b=document.getElementsByTagName("head")[0];a.subscribe(ops.OdtDocument.signalCursorAdded,d);a.subscribe(ops.OdtDocument.signalCursorRemoved,c);a.subscribe(ops.OdtDocument.signalParagraphChanged,function(a){var b=a.paragraphElement,c=a.memberId;a=a.timeStamp;var d,e="",g=b.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo")[0];g?(e=g.getAttributeNS("urn:webodf:names:editinfo","id"),d=h[e]):(e=Math.random().toString(),d=new ops.EditInfo(b,f.getOdtDocument()),d=new gui.EditInfoMarker(d,s), -g=b.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo")[0],g.setAttributeNS("urn:webodf:names:editinfo","id",e),h[e]=d);d.addEdit(c,new Date(a))});t=document.createElementNS(b.namespaceURI,"style");t.type="text/css";t.media="screen, print, handheld, projection";t.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names:editinfo);"));t.appendChild(document.createTextNode("@namespace dc url(http://purl.org/dc/elements/1.1/);"));b.appendChild(t)})()}}(); +runtime.loadClass("gui.Caret");runtime.loadClass("ops.TrivialMemberModel");runtime.loadClass("ops.EditInfo");runtime.loadClass("gui.EditInfoMarker");gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0}; +gui.SessionView=function(){return function(k,l,n){function c(a,b,c){b=b.split("___")[0];return a+'[editinfo|memberid^="'+b+'"]'+c}function b(a,b,d){function e(b,d,f){d=c(b,a,f)+d;a:{var g=t.firstChild;for(b=c(b,a,f);g;){if(g.nodeType===Node.TEXT_NODE&&0===g.data.indexOf(b)){b=g;break a}g=g.nextSibling}b=null}b?b.data=d:t.appendChild(document.createTextNode(d))}e("div.editInfoMarker","{ background-color: "+d+"; }","");e("span.editInfoColor","{ background-color: "+d+"; }","");e("span.editInfoAuthor", +'{ content: "'+b+'"; }',":before");e("dc|creator",'{ content: "'+b+'"; display: none;}',":before");e("dc|creator","{ background-color: "+d+"; }","")}function h(a){var b,c;for(c in f)f.hasOwnProperty(c)&&(b=f[c],a?b.show():b.hide())}function a(a){n.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function g(a,c){var d=n.getCaret(a);void 0===c?runtime.log('MemberModel sent undefined data for member "'+a+'".'):(null===c&&(c={memberid:a,fullname:"Unknown Identity",color:"black",imageurl:"avatar-joe.png"}), +d&&(d.setAvatarImageUrl(c.imageurl),d.setColor(c.color)),b(a,c.fullname,c.color))}function e(a){var b=a.getMemberId(),c=l.getMemberModel();n.registerCursor(a,m,r);g(b,null);c.getMemberDetailsAndUpdates(b,g);runtime.log("+++ View here +++ eagerly created an Caret for '"+b+"'! +++")}function d(a){var b=!1,c;for(c in f)if(f.hasOwnProperty(c)&&f[c].getEditInfo().getEdits().hasOwnProperty(a)){b=!0;break}b||l.getMemberModel().unsubscribeMemberDetailsUpdates(a,g)}var t,f={},s=void 0!==k.editInfoMarkersInitiallyVisible? +Boolean(k.editInfoMarkersInitiallyVisible):!0,m=void 0!==k.caretAvatarsInitiallyVisible?Boolean(k.caretAvatarsInitiallyVisible):!0,r=void 0!==k.caretBlinksOnRangeSelect?Boolean(k.caretBlinksOnRangeSelect):!0;this.showEditInfoMarkers=function(){s||(s=!0,h(s))};this.hideEditInfoMarkers=function(){s&&(s=!1,h(s))};this.showCaretAvatars=function(){m||(m=!0,a(m))};this.hideCaretAvatars=function(){m&&(m=!1,a(m))};this.getSession=function(){return l};this.getCaret=function(a){return n.getCaret(a)};(function(){var a= +l.getOdtDocument(),b=document.getElementsByTagName("head")[0];a.subscribe(ops.OdtDocument.signalCursorAdded,e);a.subscribe(ops.OdtDocument.signalCursorRemoved,d);a.subscribe(ops.OdtDocument.signalParagraphChanged,function(a){var b=a.paragraphElement,c=a.memberId;a=a.timeStamp;var d,e="",g=b.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo")[0];g?(e=g.getAttributeNS("urn:webodf:names:editinfo","id"),d=f[e]):(e=Math.random().toString(),d=new ops.EditInfo(b,l.getOdtDocument()),d=new gui.EditInfoMarker(d, +s),g=b.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo")[0],g.setAttributeNS("urn:webodf:names:editinfo","id",e),f[e]=d);d.addEdit(c,new Date(a))});t=document.createElementNS(b.namespaceURI,"style");t.type="text/css";t.media="screen, print, handheld, projection";t.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names:editinfo);"));t.appendChild(document.createTextNode("@namespace dc url(http://purl.org/dc/elements/1.1/);"));b.appendChild(t)})()}}(); // Input 78 /* - Copyright (C) 2012 KO GmbH + Copyright (C) 2012-2013 KO GmbH @licstart The JavaScript code in this page is free software: you can redistribute it @@ -2015,26 +2085,26 @@ g=b.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo")[0],g.setAttri @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("gui.Caret"); -gui.CaretManager=function(l){function f(){return l.getSession().getOdtDocument().getOdfCanvas().getElement()}function m(a){a===l.getInputMemberId()&&f().removeAttribute("tabindex",0);delete e[a]}function g(a){(a=e[a.getMemberId()])&&a.refreshCursor()}function b(a){var b=e[a.memberId];a.memberId===l.getInputMemberId()&&b&&b.ensureVisible()}function k(){var a=e[l.getInputMemberId()];a&&a.setFocus()}function a(){var a=e[l.getInputMemberId()];a&&a.removeFocus()}var e={};this.registerCursor=function(a, -b,g){var h=a.getMemberId(),k=f();b=new gui.Caret(a,b,g);e[h]=b;h===l.getInputMemberId()&&(runtime.log("Starting to track input on new cursor of "+h),a.handleUpdate=b.ensureVisible,k.setAttribute("tabindex",0),k.focus());return b};this.getCaret=function(a){return e[a]};this.getCarets=function(){return Object.keys(e).map(function(a){return e[a]})};(function(){var d=l.getSession().getOdtDocument(),c=f();d.subscribe(ops.OdtDocument.signalParagraphChanged,b);d.subscribe(ops.OdtDocument.signalCursorMoved, -g);d.subscribe(ops.OdtDocument.signalCursorRemoved,m);c.onfocus=k;c.onblur=a})()}; +gui.CaretManager=function(k){function l(a){return e.hasOwnProperty(a)?e[a]:null}function n(){return k.getSession().getOdtDocument().getOdfCanvas().getElement()}function c(a){a===k.getInputMemberId()&&n().removeAttribute("tabindex");delete e[a]}function b(a){a=a.getMemberId();a===k.getInputMemberId()&&(a=l(a))&&a.refreshCursorBlinking()}function h(a){a.memberId===k.getInputMemberId()&&(a=l(a.memberId))&&a.ensureVisible()}function a(){var a=l(k.getInputMemberId());a&&a.setFocus()}function g(){var a= +l(k.getInputMemberId());a&&a.removeFocus()}var e={};this.registerCursor=function(a,b,c){var g=a.getMemberId(),h=n();b=new gui.Caret(a,b,c);e[g]=b;g===k.getInputMemberId()&&(runtime.log("Starting to track input on new cursor of "+g),a.handleUpdate=b.ensureVisible,h.setAttribute("tabindex",0),h.focus());return b};this.getCaret=l;this.getCarets=function(){return Object.keys(e).map(function(a){return e[a]})};(function(){var d=k.getSession().getOdtDocument(),e=n();d.subscribe(ops.OdtDocument.signalParagraphChanged, +h);d.subscribe(ops.OdtDocument.signalCursorMoved,b);d.subscribe(ops.OdtDocument.signalCursorRemoved,c);e.onfocus=a;e.onblur=g})()}; // Input 79 runtime.loadClass("xmldom.XPath");runtime.loadClass("odf.Namespaces"); -gui.PresenterUI=function(){var l=new xmldom.XPath,f=runtime.getWindow();return function(m){var g=this;g.setInitialSlideMode=function(){g.startSlideMode("single")};g.keyDownHandler=function(b){if(!b.target.isContentEditable&&"input"!==b.target.nodeName)switch(b.keyCode){case 84:g.toggleToolbar();break;case 37:case 8:g.prevSlide();break;case 39:case 32:g.nextSlide();break;case 36:g.firstSlide();break;case 35:g.lastSlide()}};g.root=function(){return g.odf_canvas.odfContainer().rootElement};g.firstSlide= -function(){g.slideChange(function(b,f){return 0})};g.lastSlide=function(){g.slideChange(function(b,f){return f-1})};g.nextSlide=function(){g.slideChange(function(b,f){return b+1b?-1:b-1})};g.slideChange=function(b){var k=g.getPages(g.odf_canvas.odfContainer().rootElement),a=-1,e=0;k.forEach(function(b){b=b[1];b.hasAttribute("slide_current")&&(a=e,b.removeAttribute("slide_current"));e+=1});b=b(a,k.length);-1===b&&(b=a);k[b][1].setAttribute("slide_current", -"1");document.getElementById("pagelist").selectedIndex=b;"cont"===g.slide_mode&&f.scrollBy(0,k[b][1].getBoundingClientRect().top-30)};g.selectSlide=function(b){g.slideChange(function(f,a){return b>=a||0>b?-1:b})};g.scrollIntoContView=function(b){var k=g.getPages(g.odf_canvas.odfContainer().rootElement);0!==k.length&&f.scrollBy(0,k[b][1].getBoundingClientRect().top-30)};g.getPages=function(b){b=b.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var f=[],a;for(a=0;ab?-1:b-1})};c.slideChange=function(b){var h=c.getPages(c.odf_canvas.odfContainer().rootElement),a=-1,g=0;h.forEach(function(b){b=b[1];b.hasAttribute("slide_current")&&(a=g,b.removeAttribute("slide_current"));g+=1});b=b(a,h.length);-1===b&&(b=a);h[b][1].setAttribute("slide_current", +"1");document.getElementById("pagelist").selectedIndex=b;"cont"===c.slide_mode&&l.scrollBy(0,h[b][1].getBoundingClientRect().top-30)};c.selectSlide=function(b){c.slideChange(function(c,a){return b>=a||0>b?-1:b})};c.scrollIntoContView=function(b){var h=c.getPages(c.odf_canvas.odfContainer().rootElement);0!==h.length&&l.scrollBy(0,h[b][1].getBoundingClientRect().top-30)};c.getPages=function(b){b=b.getElementsByTagNameNS(odf.Namespaces.drawns,"page");var c=[],a;for(a=0;a=a.rangeCount||!q)||(a=a.getRangeAt(0),q.setPoint(a.startContainer,a.startOffset))}function k(){var a=l.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();q&&q.node()&&(b=q.node(),c=b.ownerDocument.createRange(), -c.setStart(b,q.position()),c.collapse(!0),a.addRange(c))}function a(a){var c=a.charCode||a.keyCode;if(q=null,q&&37===c)b(),q.stepBackward(),k();else if(16<=c&&20>=c||33<=c&&40>=c)return;g(a)}function e(a){g(a)}function d(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&d(b),b=b.nextSibling||b.parentNode;var c,e,f,b=a.attributes;c="";for(f=b.length-1;0<=f;f-=1)e=b.item(f),c=c+" "+e.nodeName+'="'+e.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", -c);b=a.firstChild;for(e=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&e.test(c.nodeValue)&&c.parentNode.removeChild(c)}function c(a,b){for(var d=a.firstChild,e,f,g;d&&d!==a;){if(d.nodeType===Node.ELEMENT_NODE)for(c(d,b),e=d.attributes,g=e.length-1;0<=g;g-=1)f=e.item(g),"http://www.w3.org/2000/xmlns/"!==f.namespaceURI||b[f.nodeValue]||(b[f.nodeValue]=f.localName);d=d.nextSibling||d.parentNode}}function t(){var a=l.ownerDocument.createElement("style"),b;b={};c(l,b); -var d={},e,g,k=0;for(e in b)if(b.hasOwnProperty(e)&&e){g=b[e];if(!g||d.hasOwnProperty(g)||"xmlns"===g){do g="ns"+k,k+=1;while(d.hasOwnProperty(g));b[e]=g}d[g]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+h;a.appendChild(l.ownerDocument.createTextNode(b));f=f.parentNode.replaceChild(a,f)}var h,s,n,q=null;l.id||(l.id="xml"+String(Math.random()).substring(2));s="#"+l.id+" ";h=s+"*,"+s+":visited, "+s+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ -s+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+s+":after {color: blue; content: '';}\n"+s+"{overflow: auto;}\n";(function(b){m(b,"click",e);m(b,"keydown",a);m(b,"drop",g);m(b,"dragend",g);m(b,"beforepaste",g);m(b,"paste",g)})(l);this.updateCSS=t;this.setXML=function(a){a=a.documentElement||a;n=a=l.ownerDocument.importNode(a,!0);for(d(a);l.lastChild;)l.removeChild(l.lastChild);l.appendChild(a);t();q=new core.PositionIterator(a)};this.getXML= -function(){return n}}; +gui.XMLEdit=function(k,l){function n(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c}function c(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function b(){var a=k.ownerDocument.defaultView.getSelection();!a||(0>=a.rangeCount||!r)||(a=a.getRangeAt(0),r.setPoint(a.startContainer,a.startOffset))}function h(){var a=k.ownerDocument.defaultView.getSelection(),b,c;a.removeAllRanges();r&&r.node()&&(b=r.node(),c=b.ownerDocument.createRange(), +c.setStart(b,r.position()),c.collapse(!0),a.addRange(c))}function a(a){var d=a.charCode||a.keyCode;if(r=null,r&&37===d)b(),r.stepBackward(),h();else if(16<=d&&20>=d||33<=d&&40>=d)return;c(a)}function g(a){c(a)}function e(a){for(var b=a.firstChild;b&&b!==a;)b.nodeType===Node.ELEMENT_NODE&&e(b),b=b.nextSibling||b.parentNode;var c,d,f,b=a.attributes;c="";for(f=b.length-1;0<=f;f-=1)d=b.item(f),c=c+" "+d.nodeName+'="'+d.nodeValue+'"';a.setAttribute("customns_name",a.nodeName);a.setAttribute("customns_atts", +c);b=a.firstChild;for(d=/^\s*$/;b&&b!==a;)c=b,b=b.nextSibling||b.parentNode,c.nodeType===Node.TEXT_NODE&&d.test(c.nodeValue)&&c.parentNode.removeChild(c)}function d(a,b){for(var c=a.firstChild,e,f,g;c&&c!==a;){if(c.nodeType===Node.ELEMENT_NODE)for(d(c,b),e=c.attributes,g=e.length-1;0<=g;g-=1)f=e.item(g),"http://www.w3.org/2000/xmlns/"!==f.namespaceURI||b[f.nodeValue]||(b[f.nodeValue]=f.localName);c=c.nextSibling||c.parentNode}}function t(){var a=k.ownerDocument.createElement("style"),b;b={};d(k,b); +var c={},e,g,h=0;for(e in b)if(b.hasOwnProperty(e)&&e){g=b[e];if(!g||c.hasOwnProperty(g)||"xmlns"===g){do g="ns"+h,h+=1;while(c.hasOwnProperty(g));b[e]=g}c[g]=!0}a.type="text/css";b="@namespace customns url(customns);\n"+f;a.appendChild(k.ownerDocument.createTextNode(b));l=l.parentNode.replaceChild(a,l)}var f,s,m,r=null;k.id||(k.id="xml"+String(Math.random()).substring(2));s="#"+k.id+" ";f=s+"*,"+s+":visited, "+s+":link {display:block; margin: 0px; margin-left: 10px; font-size: medium; color: black; background: white; font-variant: normal; font-weight: normal; font-style: normal; font-family: sans-serif; text-decoration: none; white-space: pre-wrap; height: auto; width: auto}\n"+ +s+":before {color: blue; content: '<' attr(customns_name) attr(customns_atts) '>';}\n"+s+":after {color: blue; content: '';}\n"+s+"{overflow: auto;}\n";(function(b){n(b,"click",g);n(b,"keydown",a);n(b,"drop",c);n(b,"dragend",c);n(b,"beforepaste",c);n(b,"paste",c)})(k);this.updateCSS=t;this.setXML=function(a){a=a.documentElement||a;m=a=k.ownerDocument.importNode(a,!0);for(e(a);k.lastChild;)k.removeChild(k.lastChild);k.appendChild(a);t();r=new core.PositionIterator(a)};this.getXML= +function(){return m}}; // Input 81 /* @@ -2070,8 +2140,8 @@ function(){return n}}; @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(l,f){};gui.UndoManager.prototype.unsubscribe=function(l,f){};gui.UndoManager.prototype.setOdtDocument=function(l){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(l){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; -gui.UndoManager.prototype.moveForward=function(l){};gui.UndoManager.prototype.moveBackward=function(l){};gui.UndoManager.prototype.onOperationExecuted=function(l){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); +gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(k,l){};gui.UndoManager.prototype.unsubscribe=function(k,l){};gui.UndoManager.prototype.setOdtDocument=function(k){};gui.UndoManager.prototype.saveInitialState=function(){};gui.UndoManager.prototype.resetInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(k){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){}; +gui.UndoManager.prototype.moveForward=function(k){};gui.UndoManager.prototype.moveBackward=function(k){};gui.UndoManager.prototype.onOperationExecuted=function(k){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";(function(){return gui.UndoManager})(); // Input 82 /* @@ -2107,8 +2177,8 @@ gui.UndoManager.prototype.moveForward=function(l){};gui.UndoManager.prototype.mo @source: http://www.webodf.org/ @source: http://gitorious.org/webodf/webodf/ */ -gui.UndoStateRules=function(){function l(f){return f.spec().optype}function f(f){switch(l(f)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=l;this.isEditOperation=f;this.isPartOfOperationSet=function(m,g){if(f(m)){if(0===g.length)return!0;var b;if(b=f(g[g.length-1]))a:{b=g.filter(f);var k=l(m),a;b:switch(k){case "RemoveText":case "InsertText":a=!0;break b;default:a=!1}if(a&&k===l(b[0])){if(1===b.length){b=!0;break a}k=b[b.length-2].spec().position; -b=b[b.length-1].spec().position;a=m.spec().position;if(b===a-(b-k)){b=!0;break a}}b=!1}return b}return!0}}; +gui.UndoStateRules=function(){function k(k){return k.spec().optype}function l(l){switch(k(l)){case "MoveCursor":case "AddCursor":case "RemoveCursor":return!1;default:return!0}}this.getOpType=k;this.isEditOperation=l;this.isPartOfOperationSet=function(n,c){if(l(n)){if(0===c.length)return!0;var b;if(b=l(c[c.length-1]))a:{b=c.filter(l);var h=k(n),a;b:switch(h){case "RemoveText":case "InsertText":a=!0;break b;default:a=!1}if(a&&h===k(b[0])){if(1===b.length){b=!0;break a}h=b[b.length-2].spec().position; +b=b[b.length-1].spec().position;a=n.spec().position;if(b===a-(b-h)){b=!0;break a}}b=!1}return b}return!0}}; // Input 83 /* @@ -2145,12 +2215,12 @@ b=b[b.length-1].spec().position;a=m.spec().position;if(b===a-(b-k)){b=!0;break a @source: http://gitorious.org/webodf/webodf/ */ runtime.loadClass("core.DomUtils");runtime.loadClass("gui.UndoManager");runtime.loadClass("gui.UndoStateRules"); -gui.TrivialUndoManager=function(l){function f(){r.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:a.hasUndoStates(),redoAvailable:a.hasRedoStates()})}function m(){s!==c&&s!==n[n.length-1]&&n.push(s)}function g(a){var b=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);e.normalizeTextNodes(b)}function b(a){return Object.keys(a).map(function(b){return a[b]})}function k(a){function c(a){var b=a.spec();if(f[b.memberid])switch(b.optype){case "AddCursor":d[b.memberid]||(d[b.memberid]= -a,delete f[b.memberid],g-=1);break;case "MoveCursor":e[b.memberid]||(e[b.memberid]=a)}}var d={},e={},f={},g,k=a.pop();h.getCursors().forEach(function(a){f[a.getMemberId()]=!0});for(g=Object.keys(f).length;k&&0=d;d+=1){b=a.container();c=a.unfilteredDomOffset();if(b.nodeType===Node.TEXT_NODE&&" "===b.data[c]&&e.isSignificantWhitespace(b, -c)){runtime.assert(" "===b.data[c],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=b.ownerDocument.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s");f.appendChild(b.ownerDocument.createTextNode(" "));b.deleteData(c,1);0= 0");1===s.acceptPosition(c)?(g=c.container(),g.nodeType===Node.TEXT_NODE&&(e=g,h=0)):a+=1;for(;0=e;e+=1){b=a.container();d=a.unfilteredDomOffset();if(b.nodeType===Node.TEXT_NODE&&" "===b.data[d]&&g.isSignificantWhitespace(b, +d)){runtime.assert(" "===b.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=b.ownerDocument.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s");f.appendChild(b.ownerDocument.createTextNode(" "));b.deleteData(d,1);0= 0");1===s.acceptPosition(c)?(f=c.container(),f.nodeType===Node.TEXT_NODE&&(d=f,g=0)):a+=1;for(;0 draw|image:nth-of-type(n+2) {\n display: none;\n}\ntext|list:before {\n display: none;\n content:\"\";\n}\ntext|list {\n counter-reset: list;\n}\ntext|list-item {\n display: block;\n}\ntext|number {\n display:none;\n}\n\ntext|a {\n color: blue;\n text-decoration: underline;\n cursor: pointer;\n}\ntext|note-citation {\n vertical-align: super;\n font-size: smaller;\n}\ntext|note-body {\n display: none;\n}\ntext|note:hover text|note-citation {\n background: #dddddd;\n}\ntext|note:hover text|note-body {\n display: block;\n left:1em;\n max-width: 80%;\n position: absolute;\n background: #ffffaa;\n}\nsvg|title, svg|desc {\n display: none;\n}\nvideo {\n width: 100%;\n height: 100%\n}\n\n/* below set up the cursor */\ncursor|cursor {\n display: inline;\n width: 0px;\n height: 1em;\n /* making the position relative enables the avatar to use\n the cursor as reference for its absolute position */\n position: relative;\n z-index: 1;\n}\ncursor|cursor > span {\n display: inline;\n position: absolute;\n top: 5%; /* push down the caret; 0px can do the job, 5% looks better, 10% is a bit over */\n height: 1em;\n border-left: 2px solid black;\n outline: none;\n}\n\ncursor|cursor > div {\n padding: 3px;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n border: none !important;\n border-radius: 5px;\n opacity: 0.3;\n}\n\ncursor|cursor > div > img {\n border-radius: 5px;\n}\n\ncursor|cursor > div.active {\n opacity: 0.8;\n}\n\ncursor|cursor > div:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 43%;\n}\n\n\n.editInfoMarker {\n position: absolute;\n width: 10px;\n height: 100%;\n left: -20px;\n opacity: 0.8;\n top: 0;\n border-radius: 5px;\n background-color: transparent;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n}\n.editInfoMarker:hover {\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);\n}\n\n.editInfoHandle {\n position: absolute;\n background-color: black;\n padding: 5px;\n border-radius: 5px;\n opacity: 0.8;\n box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);\n bottom: 100%;\n margin-bottom: 10px;\n z-index: 3;\n left: -25px;\n}\n.editInfoHandle:after {\n content: ' ';\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: black transparent transparent transparent;\n\n top: 100%;\n left: 5px;\n}\n.editInfo {\n font-family: sans-serif;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n color: white;\n width: 100%;\n height: 12pt;\n}\n.editInfoColor {\n float: left;\n width: 10pt;\n height: 10pt;\n border: 1px solid white;\n}\n.editInfoAuthor {\n float: left;\n margin-left: 5pt;\n font-size: 10pt;\n text-align: left;\n height: 12pt;\n line-height: 12pt;\n}\n.editInfoTime {\n float: right;\n margin-left: 30pt;\n font-size: 8pt;\n font-style: italic;\n color: yellow;\n height: 12pt;\n line-height: 12pt;\n}\n\n.annotationWrapper {\n display: inline;\n position: relative;\n}\n\n.annotationNote {\n width: 4cm;\n position: absolute;\n display: inline;\n z-index: 10;\n}\n.annotationNote > office|annotation {\n display: block;\n}\n\n.annotationConnector {\n position: absolute;\n display: inline;\n z-index: 10;\n border-top: 1px dashed brown;\n}\n.annotationConnector.angular {\n -moz-transform-origin: left top;\n -webkit-transform-origin: left top;\n -ms-transform-origin: left top;\n transform-origin: left top;\n}\n.annotationConnector.horizontal {\n left: 0;\n}\n.annotationConnector.horizontal:before {\n content: '';\n display: inline;\n position: absolute;\n width: 0px;\n height: 0px;\n border-style: solid;\n border-width: 8.7px 5px 0 5px;\n border-color: brown transparent transparent transparent;\n top: -1px;\n left: -5px;\n}\n\noffice|annotation {\n width: 100%;\n height: 100%;\n display: none;\n background: rgb(198, 238, 184);\n background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);\n box-shadow: 0 3px 4px -3px #ccc;\n}\n\noffice|annotation > dc|creator {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n color: white;\n background-color: brown;\n padding: 4px;\n}\noffice|annotation > dc|date {\n display: block;\n font-size: 10pt;\n font-weight: normal;\n font-style: normal;\n font-family: sans-serif;\n border: 4px solid transparent;\n}\noffice|annotation > text|list {\n display: block;\n padding: 5px;\n}\n\n/* This is very temporary CSS. This must go once\n * we start bundling webodf-default ODF styles for annotations.\n */\noffice|annotation text|p {\n font-size: 10pt;\n color: black;\n font-weight: normal;\n font-style: normal;\n text-decoration: none;\n font-family: sans-serif;\n}\n\ndc|*::selection {\n background: transparent;\n}\ndc|*::-moz-selection {\n background: transparent;\n}\n\n#annotationsPane {\n background-color: #EAEAEA;\n width: 4cm;\n height: 100%;\n display: inline-block;\n position: absolute;\n outline: 1px solid #ccc;\n}\n\n.annotationHighlight {\n background-color: yellow;\n position: relative;\n}\n";