From 78b9c424586b3395b2d07a73cbd52b3c6ffd143c Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Feb 2021 17:45:34 +0100 Subject: [PATCH] Fix sort and filter in sheets --- www/common/onlyoffice/inner.js | 94 +++++++++++-------- .../apps/spreadsheeteditor/main/app.js | 18 ++-- 2 files changed, 63 insertions(+), 49 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 207514b64..577c1d286 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -64,9 +64,9 @@ define([ var CURRENT_VERSION = 'v2b'; //var READONLY_REFRESH_TO = 15000; - var debug = function (x) { + var debug = function (x, type) { if (!window.CP_DEV_MODE) { return; } - console.debug(x); + console.debug(x, type); }; var stringify = function (obj) { @@ -812,10 +812,16 @@ define([ }; // Get all existing locks + var getUserLock = function (id) { + var l = content.locks[id] || {}; + return Object.keys(l).map(function (uid) { return l[uid]; }); + }; var getLock = function () { - return Object.keys(content.locks).map(function (id) { - return content.locks[id]; + var locks = []; + Object.keys(content.locks).forEach(function (id) { + Array.prototype.push.apply(locks, getUserLock(id)); }); + return locks; }; // Update the userlist in onlyoffice @@ -831,37 +837,38 @@ define([ }; // Update the locks status in onlyoffice var handleNewLocks = function (o, n) { - Object.keys(n).forEach(function (id) { - // New lock - if (!o[id]) { - ooChannel.send({ - type: "getLock", - locks: getLock() - }); - return; - } - // Updated lock - if (stringify(n[id]) !== stringify(o[id])) { - ooChannel.send({ - type: "releaseLock", - locks: [o[id]] - }); - ooChannel.send({ - type: "getLock", - locks: getLock() - }); - } + var hasNew = false; + // Check if we have at least one new lock + Object.keys(n).some(function (id) { + if (typeof(n[id]) !== "object") { return; } // Ignore old format + // n[id] = { uid: lock, uid2: lock2 }; + return Object.keys(n[id]).some(function (uid) { + // New lock + if (!o[id] || !o[id][uid]) { + hasNew = true; + return true; + } + }); }); + // Remove old locks Object.keys(o).forEach(function (id) { - // Removed lock - if (!n[id]) { - ooChannel.send({ - type: "releaseLock", - locks: [o[id]] - }); - return; - } + if (typeof(o[id]) !== "object") { return; } // Ignore old format + Object.keys(o[id]).forEach(function (uid) { + // Removed lock + if (!n[id] || !n[id][uid]) { + ooChannel.send({ + type: "releaseLock", + locks: [o[id][uid]] + }); + } + }); }); + if (hasNew) { + ooChannel.send({ + type: "getLock", + locks: getLock() + }); + } }; // Remove locks from offline users @@ -871,9 +878,11 @@ define([ Object.keys(locks).forEach(function (id) { var nId = id.slice(0,32); if (users.indexOf(nId) === -1) { + // Offline locks: support old format + var l = typeof(locks[id]) === "object" ? getUserLock(id) : [locks[id]]; ooChannel.send({ type: "releaseLock", - locks: [locks[id]] + locks: l }); delete content.locks[id]; } @@ -927,6 +936,8 @@ define([ data: {"type":"open","status":"ok","data":{"Editor.bin":obj.openCmd.url}} }); + /* + // TODO: make sure we don't have new popups that can break our integration var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === "childList") { @@ -942,6 +953,7 @@ define([ observer.observe(window.frames[0].document.body, { childList: true, }); + */ }; var handleLock = function (obj, send) { @@ -964,7 +976,9 @@ define([ block: obj.block && obj.block[0], }; var myId = getId(); - content.locks[myId] = msg; + content.locks[myId] = content.locks[myId] || {}; + var uid = Util.uid(); + content.locks[myId][uid] = msg; oldLocks = JSON.parse(JSON.stringify(content.locks)); // Remove old locks deleteOfflineLocks(); @@ -1047,7 +1061,7 @@ define([ type: "saveChanges", changes: parseChanges(obj.changes), changesIndex: ooChannel.cpIndex || 0, - locks: [content.locks[getId()]], + locks: getUserLock(getId()), excelAdditionalInfo: null }, null, function (err, hash) { if (err) { @@ -1072,7 +1086,7 @@ define([ ooChannel.lastHash = hash; // Check if a checkpoint is needed makeCheckpoint(); - // Remove my lock + // Remove my locks delete content.locks[getId()]; oldLocks = JSON.parse(JSON.stringify(content.locks)); APP.onLocal(); @@ -1094,12 +1108,12 @@ define([ APP.chan = chan; var send = ooChannel.send = function (obj) { - debug(obj); + debug(obj, 'toOO'); chan.event('CMD', obj); }; chan.on('CMD', function (obj) { - debug(obj); + debug(obj, 'fromOO'); switch (obj.type) { case "auth": handleAuth(obj, send); @@ -1144,7 +1158,7 @@ define([ if (obj.releaseLocks && content.locks && content.locks[getId()]) { send({ type: "releaseLock", - locks: [content.locks[getId()]] + locks: getUserLock(getId()) }); delete content.locks[getId()]; APP.onLocal(); @@ -2460,7 +2474,7 @@ define([ if (content.hashes) { var latest = getLastCp(true); var newLatest = getLastCp(); - if (newLatest.index > latest.index) { + if (newLatest.index > latest.index || (newLatest.index && !latest.index)) { ooChannel.queue = []; ooChannel.ready = false; // New checkpoint diff --git a/www/common/onlyoffice/v2b/web-apps/apps/spreadsheeteditor/main/app.js b/www/common/onlyoffice/v2b/web-apps/apps/spreadsheeteditor/main/app.js index 5ec434ede..82c9e70be 100644 --- a/www/common/onlyoffice/v2b/web-apps/apps/spreadsheeteditor/main/app.js +++ b/www/common/onlyoffice/v2b/web-apps/apps/spreadsheeteditor/main/app.js @@ -54,12 +54,12 @@ textsearch:this.txtSearch.val(),textreplace:this.txtReplace.val(),matchcase:this f1:_.bind(this.onShortcut,this,"help")}}),Common.util.Shortcuts.suspendEvents();var t=this;this.leftMenu.$el.find("button").each(function(){$(this).on("keydown",function(e){Common.UI.Keys.RETURN!==e.keyCode&&Common.UI.Keys.SPACE!==e.keyCode||(t.leftMenu.btnAbout.toggle(!1),this.blur(),e.preventDefault(),t.api.asc_enableKeyEvents(!0))})})},setApi:function(t){if(this.api=t,this.api.asc_registerCallback("asc_onRenameCellTextEnd",_.bind(this.onRenameText,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onApiServerDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onApiServerDisconnect,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),Common.NotificationCenter.on("download:cancel",_.bind(this.onDownloadCancel,this)),this.mode.canCoAuthoring&&(this.mode.canChat&&this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage",_.bind(this.onApiChatMessage,this)),this.mode.canComments)){this.api.asc_registerCallback("asc_onAddComment",_.bind(this.onApiAddComment,this)),this.api.asc_registerCallback("asc_onAddComments",_.bind(this.onApiAddComments,this));var e=this.getApplication().getController("Common.Controllers.Comments").groupCollection;for(var i in e)for(var n=e[i],o=Common.Utils.InternalSettings.get("sse-settings-resolvedcomment"),s=0;s0&&(i=i.substring(0,n)+this.isFromFileDownloadAs)}e.mode.canRequestSaveAs?Common.Gateway.requestSaveAs(t,i):(e._saveCopyDlg=new Common.Views.SaveAsDlg({saveFolderUrl:e.mode.saveAsUrl,saveFileUrl:t,defFileName:i}),e._saveCopyDlg.on("saveaserror",function(t,i){var n={closable:!1,title:e.textWarning,msg:i,iconCls:"warn",buttons:["ok"],callback:function(t){Common.NotificationCenter.trigger("edit:complete",e)}};Common.UI.alert(n)}).on("close",function(t){e._saveCopyDlg=void 0}),e._saveCopyDlg.show())}this.isFromFileDownloadAs=!1},onDownloadCancel:function(){this.isFromFileDownloadAs=!1},applySettings:function(t){var e=Common.localStorage.getItem("sse-settings-fontrender");Common.Utils.InternalSettings.set("sse-settings-fontrender",e),this.api.asc_setFontRenderingMode(parseInt(e)),e=Common.localStorage.getBool("sse-settings-livecomment",!0),Common.Utils.InternalSettings.set("sse-settings-livecomment",e);var i=Common.localStorage.getBool("sse-settings-resolvedcomment");Common.Utils.InternalSettings.set("sse-settings-resolvedcomment",i),this.mode.canViewComments&&this.leftMenu.panelComments.isVisible()&&(e=i=!0),e?this.api.asc_showComments(i):this.api.asc_hideComments(),e=Common.localStorage.getBool("sse-settings-r1c1"),Common.Utils.InternalSettings.set("sse-settings-r1c1",e),this.api.asc_setR1C1Mode(e),this.mode.isEdit&&!this.mode.isOffline&&this.mode.canCoAuthoring&&(e=Common.localStorage.getBool("sse-settings-coauthmode",!0),Common.Utils.InternalSettings.set("sse-settings-coauthmode",e),this.api.asc_SetFastCollaborative(e)),this.mode.isEdit&&(e=parseInt(Common.localStorage.getItem("sse-settings-autosave")),Common.Utils.InternalSettings.set("sse-settings-autosave",e),this.api.asc_setAutoSaveGap(e)),e=Common.localStorage.getItem("sse-settings-reg-settings"),null!==e&&this.api.asc_setLocale(parseInt(e)),t.hide(),this.leftMenu.fireEvent("settings:apply")},onCreateNew:function(t,e){if(!Common.Controllers.Desktop.process("create:new")){var i=window.open("blank"==e?this.mode.createUrl:e,"_blank");i&&i.focus()}t&&t.hide()},onOpenRecent:function(t,e){t&&t.hide();var i=window.open(e);i&&i.focus(),Common.component.Analytics.trackEvent("Open Recent")},clickToolbarSettings:function(t){this.leftMenu.showMenu("file:opts")},clickToolbarTab:function(t,e){"file"==t?this.leftMenu.showMenu("file"):this.leftMenu.menuFile.hide()},changeToolbarSaveState:function(t){var e=this.leftMenu.menuFile.getButton("save");e&&e.setDisabled(t)},clickStatusbarUsers:function(){this.leftMenu.menuFile.panels.rights.changeAccessRights()},onHideChat:function(){$(this.leftMenu.btnChat.el).blur(),Common.NotificationCenter.trigger("layout:changed","leftmenu")},onHidePlugins:function(){Common.NotificationCenter.trigger("layout:changed","leftmenu")},onQuerySearch:function(t,e,i){if(i.textsearch&&i.textsearch.length){var n=this.dlgSearch.findOptions;if(n.asc_setFindWhat(i.textsearch),n.asc_setScanForward("back"!=t),n.asc_setIsMatchCase(i.matchcase),n.asc_setIsWholeCell(i.matchword),n.asc_setScanOnOnlySheet(this.dlgSearch.menuWithin.menu.items[0].checked),n.asc_setScanByRows(this.dlgSearch.menuSearch.menu.items[0].checked),n.asc_setLookIn(this.dlgSearch.menuLookin.menu.items[0].checked?Asc.c_oAscFindLookIn.Formulas:Asc.c_oAscFindLookIn.Value),!this.api.asc_findText(n)){var o=this;Common.UI.info({msg:this.textNoTextFound,callback:function(){o.dlgSearch.focus()}})}}},onQueryReplace:function(t,e){if(!_.isEmpty(e.textsearch)){this.api.isReplaceAll=!1;var i=this.dlgSearch.findOptions;i.asc_setFindWhat(e.textsearch),i.asc_setReplaceWith(e.textreplace),i.asc_setIsMatchCase(e.matchcase),i.asc_setIsWholeCell(e.matchword),i.asc_setScanOnOnlySheet(this.dlgSearch.menuWithin.menu.items[0].checked),i.asc_setScanByRows(this.dlgSearch.menuSearch.menu.items[0].checked),i.asc_setLookIn(this.dlgSearch.menuLookin.menu.items[0].checked?Asc.c_oAscFindLookIn.Formulas:Asc.c_oAscFindLookIn.Value),i.asc_setIsReplaceAll(!1),this.api.asc_replaceText(i)}},onQueryReplaceAll:function(t,e){if(!_.isEmpty(e.textsearch)){this.api.isReplaceAll=!0;var i=this.dlgSearch.findOptions;i.asc_setFindWhat(e.textsearch),i.asc_setReplaceWith(e.textreplace),i.asc_setIsMatchCase(e.matchcase),i.asc_setIsWholeCell(e.matchword),i.asc_setScanOnOnlySheet(this.dlgSearch.menuWithin.menu.items[0].checked),i.asc_setScanByRows(this.dlgSearch.menuSearch.menu.items[0].checked),i.asc_setLookIn(this.dlgSearch.menuLookin.menu.items[0].checked?Asc.c_oAscFindLookIn.Formulas:Asc.c_oAscFindLookIn.Value),i.asc_setIsReplaceAll(!0),this.api.asc_replaceText(i)}},onSearchHighlight:function(t,e){this.api.asc_selectSearchingResults(e)},showSearchDlg:function(t,e){if(!this.dlgSearch){var i=new Common.UI.MenuItem({caption:this.textWithin,menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[{caption:this.textSheet,toggleGroup:"searchWithih",checkable:!0,checked:!0},{caption:this.textWorkbook,toggleGroup:"searchWithih",checkable:!0,checked:!1}]})}),n=new Common.UI.MenuItem({caption:this.textSearch,menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[{caption:this.textByRows,toggleGroup:"searchByrows",checkable:!0,checked:!0},{caption:this.textByColumns,toggleGroup:"searchByrows",checkable:!0,checked:!1}]})}),o=new Common.UI.MenuItem({caption:this.textLookin,menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[{caption:this.textFormulas,toggleGroup:"searchLookin",checkable:!0,checked:!0},{caption:this.textValues,toggleGroup:"searchLookin",checkable:!0,checked:!1}]})});this.dlgSearch=new Common.UI.SearchDialog({matchcase:!0,matchword:!0,matchwordstr:this.textItemEntireCell,markresult:{applied:!0},extraoptions:[i,n,o]}),this.dlgSearch.menuWithin=i,this.dlgSearch.menuSearch=n,this.dlgSearch.menuLookin=o,this.dlgSearch.findOptions=new Asc.asc_CFindOptions}if(t){var s=this.mode.isEdit&&!this.viewmode?e||void 0:"no-replace";this.dlgSearch.isVisible()?(this.dlgSearch.setMode(s),this.dlgSearch.focus()):this.dlgSearch.show(s),this.api.asc_closeCellEditor()}else this.dlgSearch.hide()},onMenuSearch:function(t,e){this.showSearchDlg(e)},onSearchDlgHide:function(){this.leftMenu.btnSearch.toggle(!1,!0),this.api.asc_selectSearchingResults(!1),$(this.leftMenu.btnSearch.el).blur(),this.api.asc_enableKeyEvents(!0)},onRenameText:function(t,e){var i=this;if(this.api.isReplaceAll)Common.UI.info({msg:t?!t-e?Common.Utils.String.format(this.textReplaceSuccess,e):Common.Utils.String.format(this.textReplaceSkipped,t-e):this.textNoTextFound,callback:function(){i.dlgSearch.focus()}});else{var n=this.dlgSearch.getSettings(),o=this.dlgSearch.findOptions;o.asc_setFindWhat(n.textsearch),o.asc_setScanForward(!0),o.asc_setIsMatchCase(n.matchcase),o.asc_setIsWholeCell(n.matchword),o.asc_setScanOnOnlySheet(this.dlgSearch.menuWithin.menu.items[0].checked),o.asc_setScanByRows(this.dlgSearch.menuSearch.menu.items[0].checked),o.asc_setLookIn(this.dlgSearch.menuLookin.menu.items[0].checked?Asc.c_oAscFindLookIn.Formulas:Asc.c_oAscFindLookIn.Value),i.api.asc_findText(o)||Common.UI.info({msg:this.textNoTextFound,callback:function(){i.dlgSearch.focus()}})}},setPreviewMode:function(t){this.viewmode!==t&&(this.viewmode=t,this.dlgSearch&&this.dlgSearch.setMode(this.viewmode?"no-replace":"search"))},onApiServerDisconnect:function(t){this.mode.isEdit=!1,this.leftMenu.close(),this.leftMenu.btnComments.setDisabled(!0),this.leftMenu.btnChat.setDisabled(!0),this.leftMenu.btnPlugins.setDisabled(!0),this.leftMenu.btnSpellcheck.setDisabled(!0),this.leftMenu.getMenu("file").setMode({isDisconnected:!0,enableDownload:!!t}),this.dlgSearch&&(this.leftMenu.btnSearch.toggle(!1,!0),this.dlgSearch.hide())},onApiChatMessage:function(){this.leftMenu.markCoauthOptions("chat")},onApiAddComment:function(t,e){var i=Common.Utils.InternalSettings.get("sse-settings-resolvedcomment");!e||e.asc_getUserId()===this.mode.user.id||!i&&e.asc_getSolved()||this.leftMenu.markCoauthOptions("comments")},onApiAddComments:function(t){for(var e=Common.Utils.InternalSettings.get("sse-settings-resolvedcomment"),i=0;i [data-toggle="dropdown"]');if(n.length)return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.mode.canPlugins&&this.leftMenu.panelPlugins&&!0!==this.api.isCellEdited&&(n=this.leftMenu.panelPlugins.$el.find('#menu-plugin-container.open > [data-toggle="dropdown"]'),n.length))return $.fn.dropdown.Constructor.prototype.keydown.call(n[0],e),!1;if(this.leftMenu.btnAbout.pressed||($(e.target).parents("#left-menu").length||this.leftMenu.btnPlugins.pressed||this.leftMenu.btnComments.pressed)&&!0!==this.api.isCellEdited)return this.leftMenu.close(),Common.NotificationCenter.trigger("layout:changed","leftmenu"),!1;if((this.mode.isEditDiagram||this.mode.isEditMailMerge)&&(n=$(document.body).find(".open > .dropdown-menu"),!this.api.isCellEdited&&!n.length))return Common.Gateway.internalMessage("shortcut",{key:"escape"}),!1;break;case"chat":return this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")),!1;case"comments":return this.mode.canCoAuthoring&&this.mode.canViewComments&&!this.mode.isLightVersion&&(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("comments"),this.getApplication().getController("Common.Controllers.Comments").onAfterShow()),!1}}},onCellsRange:function(t){var e=t!=Asc.c_oAscSelectionDialogType.None;this.leftMenu.btnAbout.setDisabled(e),this.leftMenu.btnSearch.setDisabled(e),this.leftMenu.btnSpellcheck.setDisabled(e),this.mode.canPlugins&&this.leftMenu.panelPlugins&&(this.leftMenu.panelPlugins.setLocked(e),this.leftMenu.panelPlugins.disableControls(e))},onApiEditCell:function(t){var e=t==Asc.c_oAscCellEditorState.editFormula;this.leftMenu.btnAbout.setDisabled(e),this.leftMenu.btnSearch.setDisabled(e),this.leftMenu.btnSpellcheck.setDisabled(e),this.mode.canPlugins&&this.leftMenu.panelPlugins&&(this.leftMenu.panelPlugins.setLocked(e),this.leftMenu.panelPlugins.disableControls(e))},onPluginOpen:function(t,e,i){"onboard"==e&&("open"==i?(this.leftMenu.close(),this.leftMenu.panelPlugins.show(),this.leftMenu.onBtnMenuClick({pressed:!0,options:{action:"plugins"}}),this.leftMenu._state.pluginIsRunning=!0):(this.leftMenu._state.pluginIsRunning=!1,this.leftMenu.close()))},onShowHideChat:function(t){this.mode.canCoAuthoring&&this.mode.canChat&&!this.mode.isLightVersion&&(t?(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("chat")):(this.leftMenu.btnChat.toggle(!1,!0),this.leftMenu.onBtnMenuClick(this.leftMenu.btnChat)))},textNoTextFound:"Text not found",newDocumentTitle:"Unnamed document",textItemEntireCell:"Entire cell contents",requestEditRightsText:"Requesting editing rights...",textReplaceSuccess:"Search has been done. {0} occurrences have been replaced",textReplaceSkipped:"The replacement has been made. {0} occurrences were skipped.",warnDownloadAs:"If you continue saving in this format all features except the text will be lost.
Are you sure you want to continue?",textWarning:"Warning",textSheet:"Sheet",textWorkbook:"Workbook",textByColumns:"By columns",textByRows:"By rows",textFormulas:"Formulas",textValues:"Values",textWithin:"Within",textSearch:"Search",textLookin:"Look in",txtUntitled:"Untitled"},SSE.Controllers.LeftMenu||{}))}),void 0===Common)var Common={};if(Common.IrregularStack=function(t){var e=[],i=function(t,e){return"object"==typeof t&&"object"==typeof e&&window.JSON?window.JSON.stringify(t)===window.JSON.stringify(e):t===e};t=t||{};var n=t.strongCompare||i,o=t.weakCompare||i,s=function(t,i){for(var n=e.length-1;n>=0;n--)if(i(e[n],t))return n;return-1};return{push:function(t){e.push(t)},pop:function(t){var i=s(t,n);if(-1!=i)return e.splice(i,1)[0]},get:function(t){var i=s(t,o);if(-1!=i)return e[i]},exist:function(t){return!(s(t,n)<0)}}},define("irregularstack",function(){}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Fonts",["core","common/main/lib/collection/Fonts"],function(){"use strict";Common.Controllers.Fonts=Backbone.Controller.extend(function(){function t(t,e){for(var i,n=e.get("type")==o,s=-1,a=t.length,l=e.get("name");!n&&++s','
','",'
','",'
','','',"
","
",'
','"].join(""),this.api=t.api,this.formulasGroups=t.formulasGroups,this.handler=t.handler,i.tpl=_.template(this.template)(i),Common.UI.Window.prototype.initialize.call(this,i)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.syntaxLabel=$("#formula-dlg-args"),this.descLabel=$("#formula-dlg-desc"),this.fillFormulasGroups()},show:function(t){if(this.$window){var e,i,n,o,s=this.initConfig.height;void 0===window.innerHeight?(e=document.documentElement.offsetWidth,i=document.documentElement.offsetHeight):(e=Common.Utils.innerWidth(),i=Common.Utils.innerHeight()),n=(parseInt(i,10)-parseInt(s,10))/2,o=(parseInt(e,10)-parseInt(this.initConfig.width,10))/2,this.$window.css("left",Math.floor(o)),this.$window.css("top",Math.floor(n))}Common.UI.Window.prototype.show.call(this),this.mask=$(".modals-mask"),this.mask.on("mousedown",_.bind(this.onUpdateFocus,this)),this.$window.on("mousedown",_.bind(this.onUpdateFocus,this)),t&&this.cmbFuncGroup.setValue(t),(t||"Last10"==this.cmbFuncGroup.getValue())&&this.fillFunctions(this.cmbFuncGroup.getValue()),this.cmbListFunctions&&_.delay(function(t){t.cmbListFunctions.$el.find(".listview").focus()},100,this)},hide:function(){this.mask.off("mousedown",_.bind(this.onUpdateFocus,this)),this.$window.off("mousedown",_.bind(this.onUpdateFocus,this)),Common.UI.Window.prototype.hide.call(this)},onBtnClick:function(t){"ok"===t.currentTarget.attributes.result.value&&this.handler&&this.handler.call(this,this.applyFunction),this.hide()},onDblClickFunction:function(){this.handler&&this.handler.call(this,this.applyFunction),this.hide()},onSelectGroup:function(t,e){_.isUndefined(e)||_.isUndefined(e.value)||e.value&&this.fillFunctions(e.value),this.onUpdateFocus()},onSelectFunction:function(t,e,i){this.formulasGroups&&(this.applyFunction={name:i.get("value"),origin:i.get("origin")},this.syntaxLabel.text(this.applyFunction.name+i.get("args")),this.descLabel.text(i.get("desc")))},onPrimary:function(t,e,i){this.handler&&this.handler.call(this,this.applyFunction),this.hide()},onUpdateFocus:function(){_.delay(function(t){t.cmbListFunctions.$el.find(".listview").focus()},100,this)},fillFormulasGroups:function(){if(this.formulasGroups){var t=Common.Utils.InternalSettings.get("sse-settings-func-locale");_.isEmpty(t)&&(t="en");var e,i=[],n=this.formulasGroups.length;for(e=0;e<%= value %>
')}),this.cmbListFunctions.on("item:select",_.bind(this.onSelectFunction,this)),this.cmbListFunctions.on("item:dblclick",_.bind(this.onDblClickFunction,this)),this.cmbListFunctions.on("entervalue",_.bind(this.onPrimary,this)),this.cmbListFunctions.onKeyDown=_.bind(this.onKeyDown,this.cmbListFunctions),this.cmbListFunctions.$el.find(".listview").focus(),this.cmbListFunctions.scrollToRecord=_.bind(this.onScrollToRecordCustom,this.cmbListFunctions)),this.functions)){this.functions.reset();var e=0,i=0,n=null,o=this.formulasGroups.findWhere({name:t});if(o&&(n=o.get("functions"))&&n.length){for(i=n.length,e=0;e64&&t.keyCode<91&&a&&a.length){for(a=a.toLocaleLowerCase(),d=this.store.findWhere({selected:!0}),d&&(l=d.get("value"),h=l&&l.length&&l[0].toLocaleLowerCase()===a),n=0;ni+e.height())&&(this.scroller?this.scroller.scrollTop(e.scrollTop()+o-i,0):e.scrollTop(e.scrollTop()+o-i))},cancelButtonText:"Cancel",okButtonText:"Ok",textGroupDescription:"Select Function Group",textListDescription:"Select Function",sDescription:"Description",txtTitle:"Insert Function"},SSE.Views.FormulaDialog||{}))}),define("spreadsheeteditor/main/app/view/FormulaTab",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout"],function(){"use strict";SSE.Views.FormulaTab=Common.UI.BaseView.extend(_.extend(function(){function t(){var t=this;t.btnAutosum.on("click",function(){t.fireEvent("function:apply",[{name:t.api.asc_getFormulaLocaleName("SUM"),origin:"SUM"},!0])}),t.btnAutosum.menu.on("item:click",function(e,i,n){t.fireEvent("function:apply",[{name:i.caption,origin:i.value},!0])}),t.btnFormula.on("click",function(){t.fireEvent("function:apply",[{name:"more",origin:"more"}])})}return{options:{},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this),this.toolbar=t.toolbar,this.formulasGroups=t.formulasGroups,this.lockedControls=[];var e=this,i=e.toolbar.$el,n=SSE.enumLock,o=SSE.getController("FormulaDialog");this.btnFinancial=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-finance",caption:o.sCategoryFinancial,hint:o.sCategoryFinancial,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-financial"),this.btnFinancial),this.lockedControls.push(this.btnFinancial),this.btnLogical=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-logic",caption:o.sCategoryLogical,hint:o.sCategoryLogical,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-logical"),this.btnLogical),this.lockedControls.push(this.btnLogical),this.btnTextData=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-func-text",caption:o.sCategoryTextAndData,hint:o.sCategoryTextAndData,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-text"),this.btnTextData),this.lockedControls.push(this.btnTextData),this.btnDateTime=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-datetime",caption:o.sCategoryDateAndTime,hint:o.sCategoryDateAndTime,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-datetime"),this.btnDateTime),this.lockedControls.push(this.btnDateTime),this.btnReference=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-lookup",caption:o.sCategoryLookupAndReference,hint:o.sCategoryLookupAndReference,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-lookup"),this.btnReference),this.lockedControls.push(this.btnReference),this.btnMath=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-func-math",caption:o.sCategoryMathematic,hint:o.sCategoryMathematic,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-math"),this.btnMath),this.lockedControls.push(this.btnMath),this.btnRecent=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-recent",caption:this.txtRecent,hint:this.txtRecent,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-recent"),this.btnRecent),this.lockedControls.push(this.btnRecent),this.btnAutosum=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-autosum",caption:this.txtAutosum,hint:this.txtAutosumTip,split:!0,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth],menu:new Common.UI.Menu({items:[{caption:"SUM",value:"SUM"},{caption:"MIN",value:"MIN"},{caption:"MAX",value:"MAX"},{caption:"COUNT",value:"COUNT"},{caption:"--"},{caption:e.txtAdditional,value:"more"}]})}),Common.Utils.injectComponent(i.find("#slot-btn-autosum"),this.btnAutosum),this.lockedControls.push(this.btnAutosum),this.btnFormula=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ins-formula",caption:this.txtFormula,hint:this.txtFormulaTip,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-additional-formula"),this.btnFormula),this.lockedControls.push(this.btnFormula),this.btnMore=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-more",caption:this.txtMore,hint:this.txtMore,menu:!0,split:!1,disabled:!0,lock:[n.editText,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.selRangeEdit,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-more"),this.btnMore),this.lockedControls.push(this.btnMore),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this},onAppReady:function(e){var i=this;new Promise(function(t,e){t()}).then(function(){t.call(i)})},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButtons:function(t){return this.lockedControls},SetDisabled:function(t){this.lockedControls&&this.lockedControls.forEach(function(e){e&&e.setDisabled(t)},this)},focusInner:function(t,e){e.keyCode==Common.UI.Keys.UP?t.items[t.items.length-1].cmpEl.find("> a").focus():t.items[0].cmpEl.find("> a").focus()},focusOuter:function(t,e){t.items[2].cmpEl.find("> a").focus()},onBeforeKeyDown:function(t,e){if(e.keyCode==Common.UI.Keys.RETURN){e.preventDefault(),e.stopPropagation();var i=$(e.target).closest("li");i.length>0&&i.click(),Common.UI.Menu.Manager.hideAll()}else if("after.bs.dropdown"!==e.namespace&&(e.keyCode==Common.UI.Keys.DOWN||e.keyCode==Common.UI.Keys.UP)){var n=$("> [role=menu] > li:not(.divider):not(.disabled):visible",t.$el).find("> a");if(!n.length)return;var o=n.index(n.filter(":focus")),s=this;(t._outerMenu&&(e.keyCode==Common.UI.Keys.UP&&0==o||e.keyCode==Common.UI.Keys.DOWN&&o==n.length-1)||t._innerMenu&&(e.keyCode==Common.UI.Keys.UP||e.keyCode==Common.UI.Keys.DOWN)&&-1!==o)&&(e.preventDefault(),e.stopPropagation(),_.delay(function(){t._outerMenu?s.focusOuter(t._outerMenu,e):s.focusInner(t._innerMenu,e)},10))}},setButtonMenu:function(t,e){var i=this,n=[],o=i.formulasGroups.findWhere({name:e});if(o){var s=o.get("functions");s&&s.forEach(function(t){n.push(new Common.UI.MenuItem({caption:t.get("name"),value:t.get("origin")}))})}if(n.length)if(t.menu&&t.menu.rendered){var a=t.menu._innerMenu;a&&(a.removeAll(),n.forEach(function(t){a.addItem(t)}))}else{t.setMenu(new Common.UI.Menu({items:[{template:_.template('
')},{caption:"--"},{caption:i.txtAdditional,value:"more"}]})),t.menu.items[2].on("click",function(t,n){i.fireEvent("function:apply",[{name:t.caption,origin:t.value},!1,e])}),t.menu.on("show:after",function(t,e){t._innerMenu.scroller.update({alwaysVisibleY:!0}),_.delay(function(){t._innerMenu&&t._innerMenu.cmpEl.focus()},10)}).on("keydown:before",_.bind(i.onBeforeKeyDown,this));var a=new Common.UI.Menu({maxHeight:300,cls:"internal-menu",items:n});a.render(t.menu.items[0].cmpEl.children(":first")),a.cmpEl.css({display:"block",position:"relative",left:0,top:0}),a.cmpEl.attr({tabindex:"-1"}),a.on("item:click",function(t,n,o){i.fireEvent("function:apply",[{name:n.caption,origin:n.value},!1,e])}).on("keydown:before",_.bind(i.onBeforeKeyDown,this)),t.menu._innerMenu=a,a._outerMenu=t.menu}t.setDisabled(n.length<1)},setMenuItemMenu:function(t){var e=this,i=[],n=SSE.getController("FormulaDialog"),o=e.formulasGroups.findWhere({name:t});if(o){var s=o.get("functions");if(s&&s.forEach(function(t){i.push(new Common.UI.MenuItem({caption:t.get("name"),value:t.get("origin")}))}),i.length){var a=new Common.UI.MenuItem({caption:n["sCategory"+t]||t,menu:new Common.UI.Menu({menuAlign:"tl-tr",items:[{template:_.template('
')},{caption:"--"},{caption:e.txtAdditional,value:"more"}]})});a.menu.items[2].on("click",function(i,n){e.fireEvent("function:apply",[{name:i.caption,origin:i.value},!1,t])}),a.menu.on("show:after",function(t,e){t._innerMenu.scroller.update({alwaysVisibleY:!0}),_.delay(function(){t._innerMenu&&t._innerMenu.items[0].cmpEl.find("> a").focus()},10)}).on("keydown:before",_.bind(e.onBeforeKeyDown,this)).on("keydown:before",function(t,e){if(e.keyCode==Common.UI.Keys.LEFT||e.keyCode==Common.UI.Keys.ESC){var i=t.cmpEl.parent();i.hasClass("dropdown-submenu")&&i.hasClass("over")&&(i.removeClass("over"),i.find("> a").focus())}});var l=new Common.UI.Menu({maxHeight:300,cls:"internal-menu",items:i});return l.on("item:click",function(i,n,o){e.fireEvent("function:apply",[{name:n.caption,origin:n.value},!1,t])}).on("keydown:before",_.bind(e.onBeforeKeyDown,this)),a.menu._innerMenu=l,l._outerMenu=a.menu,a}}},fillFunctions:function(){if(this.formulasGroups){this.setButtonMenu(this.btnFinancial,"Financial"),this.setButtonMenu(this.btnLogical,"Logical"),this.setButtonMenu(this.btnTextData,"TextAndData"),this.setButtonMenu(this.btnDateTime,"DateAndTime"),this.setButtonMenu(this.btnReference,"LookupAndReference"),this.setButtonMenu(this.btnMath,"Mathematic"),this.setButtonMenu(this.btnRecent,"Last10");for(var t=this.btnAutosum.menu.items,e=0;e a, #header-back > div"},e={toolbar:"#viewport #toolbar",leftMenu:"#viewport #left-menu, #viewport #id-toolbar-full-placeholder-btn-settings, #viewport #id-toolbar-short-placeholder-btn-settings",rightMenu:"#viewport #right-menu",statusBar:"#statusbar"};return Common.localStorage.setId("table"),Common.localStorage.setKeysFilter("sse-,asc.table"),Common.localStorage.sync(),{models:[],collections:["ShapeGroups","EquationGroups","TableTemplates","Common.Collections.TextArt"],views:[],initialize:function(){this.addListeners({FileMenu:{"settings:apply":_.bind(this.applySettings,this)},"Common.Views.ReviewChanges":{"settings:apply":_.bind(this.applySettings,this)}})},onLaunch:function(){var t=this;if(this._state={isDisconnected:!1,usersCount:1,fastCoauth:!0,lostEditingRights:!1,licenseType:!1},this.translationTable=[],this.isModalShowed=0,!Common.Utils.isBrowserSupported())return Common.Utils.showBrowserRestriction(),void Common.Gateway.reportError(void 0,this.unsupportedBrowserErrorText);var e=Common.localStorage.getItem("sse-settings-fontrender");null===e&&(e=window.devicePixelRatio>1?"1":"3"),Common.Utils.InternalSettings.set("sse-settings-fontrender",e);var i=["Normal","Neutral","Bad","Good","Input","Output","Calculation","Check Cell","Explanatory Text","Note","Linked Cell","Warning Text","Heading 1","Heading 2","Heading 3","Heading 4","Title","Total","Currency","Percent","Comma"],n={Series:this.txtSeries,"Diagram Title":this.txtDiagramTitle,"X Axis":this.txtXAxis,"Y Axis":this.txtYAxis,"Your text here":this.txtArt,Table:this.txtTable,Print_Area:this.txtPrintArea,Confidential:this.txtConfidential,"Prepared by ":this.txtPreparedBy+" ",Page:this.txtPage,"Page %1 of %2":this.txtPageOf,Pages:this.txtPages,Date:this.txtDate,Time:this.txtTime,Tab:this.txtTab,File:this.txtFile};i.forEach(function(e){n[e]=t.translationTable[e]=t["txtStyle_"+e.replace(/ /g,"_")]||e}),n["Currency [0]"]=t.translationTable["Currency [0]"]=t.txtStyle_Currency+" [0]",n["Comma [0]"]=t.translationTable["Comma [0]"]=t.txtStyle_Comma+" [0]";for(var o=1;o<7;o++)n["Accent"+o]=t.translationTable["Accent"+o]=t.txtAccent+o,n["20% - Accent"+o]=t.translationTable["20% - Accent"+o]="20% - "+t.txtAccent+o,n["40% - Accent"+o]=t.translationTable["40% - Accent"+o]="40% - "+t.txtAccent+o,n["60% - Accent"+o]=t.translationTable["60% - Accent"+o]="60% - "+t.txtAccent+o;this.api=new Asc.spreadsheet_api({"id-view":"editor_sdk","id-input":"ce-cell-content",translate:n}),this.api.asc_setFontRenderingMode(parseInt(e)),this.api.asc_registerCallback("asc_onOpenDocumentProgress",_.bind(this.onOpenDocument,this)),this.api.asc_registerCallback("asc_onEndAction",_.bind(this.onLongActionEnd,this)),this.api.asc_registerCallback("asc_onError",_.bind(this.onError,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)),this.api.asc_registerCallback("asc_onAdvancedOptions",_.bind(this.onAdvancedOptions,this)),this.api.asc_registerCallback("asc_onDocumentUpdateVersion",_.bind(this.onUpdateVersion,this)),this.api.asc_registerCallback("asc_onServerVersion",_.bind(this.onServerVersion,this)),this.api.asc_registerCallback("asc_onDocumentName",_.bind(this.onDocumentName,this)),this.api.asc_registerCallback("asc_onPrintUrl",_.bind(this.onPrintUrl,this)),this.api.asc_registerCallback("asc_onMeta",_.bind(this.onMeta,this)),this.api.asc_registerCallback("asc_onSpellCheckInit",_.bind(this.loadLanguages,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("goback",_.bind(this.goBack,this)),Common.NotificationCenter.on("namedrange:locked",_.bind(this.onNamedRangeLocked,this)),Common.NotificationCenter.on("download:cancel",_.bind(this.onDownloadCancel,this)),Common.NotificationCenter.on("download:advanced",_.bind(this.onAdvancedOptions,this)),this.stackLongActions=new Common.IrregularStack({strongCompare:this._compareActionStrong,weakCompare:this._compareActionWeak}),this.stackLongActions.push({id:-254,type:Asc.c_oAscAsyncActionType.BlockInteraction}),this.isShowOpenDialog=!1,this.editorConfig={},Common.Gateway.on("init",_.bind(this.loadConfig,this)),Common.Gateway.on("showmessage",_.bind(this.onExternalMessage,this)),Common.Gateway.on("opendocument",_.bind(this.loadDocument,this)),Common.Gateway.on("internalcommand",_.bind(this.onInternalCommand,this)),Common.Gateway.appReady(),this.getApplication().getController("Viewport").setApi(this.api),$(document.body).on("focus","input, textarea:not(#ce-cell-content)",function(e){!0!==t.isAppDisabled&&e&&e.target&&!/area_id/.test(e.target.id)&&(/msg-reply/.test(e.target.className)?t.dontCloseDummyComment=!0:/chat-msg-text/.test(e.target.id)?t.dontCloseChat=!0:!t.isModalShowed&&/form-control/.test(e.target.className)&&(t.inFormControl=!0))}),$(document.body).on("blur","input, textarea",function(e){if(!0!==t.isAppDisabled&&!t.isFrameClosed&&!(t.isModalShowed&&!($(".asc-window.enable-key-events:visible").length>0)||t.loadMask&&t.loadMask.isVisible())){if(/form-control/.test(e.target.className)&&(t.inFormControl=!1),t.getApplication().getController("LeftMenu").getView("LeftMenu").getMenu("file").isVisible())return;if(!e.relatedTarget||!/area_id/.test(e.target.id)&&!("input"==e.target.localName&&$(e.target).parent().find(e.relatedTarget).length>0)&&!("textarea"==e.target.localName&&$(e.target).closest(".asc-window").find(".dropdown-menu").find(e.relatedTarget).length>0)&&("input"!=e.relatedTarget.localName||!/form-control/.test(e.relatedTarget.className))&&("textarea"!=e.relatedTarget.localName||/area_id/.test(e.relatedTarget.id))){if(Common.Utils.isIE&&e.originalEvent&&e.originalEvent.target&&/area_id/.test(e.originalEvent.target.id)&&e.originalEvent.target===e.originalEvent.srcElement)return;t.api.asc_enableKeyEvents(!0),/msg-reply/.test(e.target.className)?t.dontCloseDummyComment=!1:/chat-msg-text/.test(e.target.id)&&(t.dontCloseChat=!1)}}}).on("dragover",function(t){var e=t.originalEvent;if(e.target&&$(e.target).closest("#editor_sdk").length<1)return e.preventDefault(),e.dataTransfer.dropEffect="none",!1}).on("dragstart",function(t){var e=t.originalEvent;if(e.target){var i=$(e.target);(i.closest(".combobox").length>0||i.closest(".dropdown-menu").length>0||i.closest(".ribtab").length>0||i.closest(".combo-dataview").length>0)&&e.preventDefault()}}),Common.NotificationCenter.on({"modal:show":function(e){t.isModalShowed++,t.api.asc_enableKeyEvents(!1)},"modal:close":function(e){--t.isModalShowed||t.api.asc_enableKeyEvents(!0)},"modal:hide":function(e){--t.isModalShowed||t.api.asc_enableKeyEvents(!0)},"dataview:focus":function(t){},"dataview:blur":function(e){t.isModalShowed||t.api.asc_enableKeyEvents(!0)},"menu:show":function(t){},"menu:hide":function(e,i){t.isModalShowed||e&&e.cmpEl.hasClass("from-cell-edit")||i||(t.api.asc_InputClearKeyboardElement(),t.api.asc_enableKeyEvents(!0))},"edit:complete":_.bind(this.onEditComplete,this),"settings:unitschanged":_.bind(this.unitsChanged,this)}),this.initNames(),Common.util.Shortcuts.delegateShortcuts({shortcuts:{"command+s,ctrl+s,command+p,ctrl+p,command+k,ctrl+k,command+d,ctrl+d":_.bind(function(t){t.preventDefault(),t.stopPropagation()},this)}}),t.defaultTitleText="ONLYOFFICE",t.warnNoLicense=t.warnNoLicense.replace("%1","ONLYOFFICE"),t.warnNoLicenseUsers=t.warnNoLicenseUsers.replace("%1","ONLYOFFICE"),t.textNoLicenseTitle=t.textNoLicenseTitle.replace("%1","ONLYOFFICE")},loadConfig:function(t){this.editorConfig=$.extend(this.editorConfig,t.config),this.appOptions={},this.editorConfig.user=this.appOptions.user=Common.Utils.fillUserInfo(this.editorConfig.user,this.editorConfig.lang,this.textAnonymous),this.appOptions.isDesktopApp="desktop"==this.editorConfig.targetApp,this.appOptions.canCreateNew=!_.isEmpty(this.editorConfig.createUrl),this.appOptions.canOpenRecent=void 0!==this.editorConfig.recent&&!this.appOptions.isDesktopApp,this.appOptions.templates=this.editorConfig.templates,this.appOptions.recent=this.editorConfig.recent,this.appOptions.createUrl=this.editorConfig.createUrl,this.appOptions.lang=this.editorConfig.lang,this.appOptions.location="string"==typeof this.editorConfig.location?this.editorConfig.location.toLowerCase():"",this.appOptions.region="string"==typeof this.editorConfig.region?this.editorConfig.region.toLowerCase():this.editorConfig.region,this.appOptions.canAutosave=!1,this.appOptions.canAnalytics=!1,this.appOptions.sharingSettingsUrl=this.editorConfig.sharingSettingsUrl,this.appOptions.saveAsUrl=this.editorConfig.saveAsUrl,this.appOptions.fileChoiceUrl=this.editorConfig.fileChoiceUrl,this.appOptions.isEditDiagram="editdiagram"==this.editorConfig.mode,this.appOptions.isEditMailMerge="editmerge"==this.editorConfig.mode,this.appOptions.customization=this.editorConfig.customization,this.appOptions.canBackToFolder=!1!==this.editorConfig.canBackToFolder&&"object"==typeof this.editorConfig.customization&&"object"==typeof this.editorConfig.customization.goback&&!_.isEmpty(this.editorConfig.customization.goback.url),this.appOptions.canBack=!0===this.appOptions.canBackToFolder,this.appOptions.canPlugins=!1,this.appOptions.canRequestUsers=this.editorConfig.canRequestUsers,this.appOptions.canRequestSendNotify=this.editorConfig.canRequestSendNotify,this.appOptions.canRequestSaveAs=this.editorConfig.canRequestSaveAs,this.appOptions.canRequestInsertImage=this.editorConfig.canRequestInsertImage,this.headerView=this.getApplication().getController("Viewport").getView("Common.Views.Header"),this.headerView.setCanBack(!0===this.appOptions.canBackToFolder,this.appOptions.canBackToFolder?this.editorConfig.customization.goback.text:"").setUserName(this.appOptions.user.fullname);var e=Common.localStorage.getItem("sse-settings-reg-settings");null!==e?this.api.asc_setLocale(parseInt(e)):(e=this.appOptions.region,e=Common.util.LanguageInfo.getLanguages().hasOwnProperty(e)?e:Common.util.LanguageInfo.getLocalLanguageCode(e),e=null!==e?parseInt(e):this.editorConfig.lang?parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.editorConfig.lang)):1033,this.api.asc_setLocale(e)),e=Common.localStorage.getBool("sse-settings-r1c1"),Common.Utils.InternalSettings.set("sse-settings-r1c1",e),this.api.asc_setR1C1Mode(e),"us"!=this.appOptions.location&&"ca"!=this.appOptions.location||Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch),this.isFrameClosed=this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge,Common.Controllers.Desktop.init(this.appOptions)},loadDocument:function(t){this.appOptions.spreadsheet=t.doc,this.permissions={};var e={};if(t.doc){this.permissions=_.extend(this.permissions,t.doc.permissions);var i=$.extend({},t.doc.permissions),n=$.extend({},t.doc.options,this.editorConfig.actionLink||{}),o=new Asc.asc_CUserInfo;o.put_Id(this.appOptions.user.id),o.put_FullName(this.appOptions.user.fullname),e=new Asc.asc_CDocInfo,e.put_Id(t.doc.key),e.put_Url(t.doc.url),e.put_Title(t.doc.title),e.put_Format(t.doc.fileType),e.put_VKey(t.doc.vkey),e.put_Options(n),e.put_UserInfo(o),e.put_CallbackUrl(this.editorConfig.callbackUrl),e.put_Token(t.doc.token),e.put_Permissions(i),this.headerView&&this.headerView.setDocumentCaption(t.doc.title)}this.api.asc_registerCallback("asc_onGetEditorPermissions",_.bind(this.onEditorPermissions,this)),this.api.asc_registerCallback("asc_onLicenseChanged",_.bind(this.onLicenseChanged,this)),this.api.asc_setDocInfo(e),this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl,this.editorConfig.customerId)},onProcessSaveResult:function(t){this.api.asc_OnSaveEnd(t.result),t&&!1===t.result&&Common.UI.error({title:this.criticalErrorTitle,msg:_.isEmpty(t.message)?this.errorProcessSaveResult:t.message})},onProcessRightsChange:function(t){if(t&&!1===t.enabled){var e=this,i=this._state.lostEditingRights;this._state.lostEditingRights=!this._state.lostEditingRights,this.api.asc_coAuthoringDisconnect(),Common.NotificationCenter.trigger("collaboration:sharingdeny"),Common.NotificationCenter.trigger("api:disconnect"),i||Common.UI.warning({title:this.notcriticalErrorTitle,maxwidth:600,msg:_.isEmpty(t.message)?this.warnProcessRightsChange:t.message,callback:function(){e._state.lostEditingRights=!1,e.onEditComplete()}})}},onDownloadAs:function(t){if(!this.appOptions.canDownload)return void Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny,this.errorAccessDeny);this._state.isFromGatewayDownloadAs=!0;var e=t&&"string"==typeof t?Asc.c_oAscFileType[t.toUpperCase()]:null,i=[Asc.c_oAscFileType.XLSX,Asc.c_oAscFileType.ODS,Asc.c_oAscFileType.CSV,Asc.c_oAscFileType.PDF,Asc.c_oAscFileType.PDFA,Asc.c_oAscFileType.XLTX,Asc.c_oAscFileType.OTS];(!e||i.indexOf(e)<0)&&(e=Asc.c_oAscFileType.XLSX),e==Asc.c_oAscFileType.PDF||e==Asc.c_oAscFileType.PDFA?Common.NotificationCenter.trigger("download:settings",this,e,!0):this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(e,!0))},onProcessMouse:function(t){if("mouseup"==t.type){var e=document.getElementById("editor_sdk");if(e){var i=e.getBoundingClientRect(),n=t.event||{};this.api.asc_onMouseUp(n,t.x-i.left,t.y-i.top)}}},goBack:function(t){var e=this;if(!Common.Controllers.Desktop.process("goback")){var i=e.appOptions.customization.goback.url;t||!1===e.appOptions.customization.goback.blank?parent.location.href=i:window.open(i,"_blank")}},onEditComplete:function(t,e){e&&e.restorefocus&&this.api.isCEditorFocused?(this.formulaInput.blur(),this.formulaInput.focus()):(this.getApplication().getController("DocumentHolder").getView("DocumentHolder").focus(),this.api.isCEditorFocused=!1)},onSelectionChanged:function(t){this._isChartDataReady||t.asc_getFlags().asc_getSelectionType()!=Asc.c_oAscSelectionType.RangeChart||(this._isChartDataReady=!0,Common.Gateway.internalMessage("chartDataReady"))},onLongActionBegin:function(t,e){var i={id:e,type:t};this.stackLongActions.push(i),this.setLongActionView(i)},onLongActionEnd:function(t,e){var i={id:e,type:t};this.stackLongActions.pop(i),this.headerView&&this.headerView.setDocumentCaption(this.api.asc_getDocumentName()),this.updateWindowTitle(this.api.asc_isDocumentModified(),!0),t===Asc.c_oAscAsyncActionType.BlockInteraction&&e==Asc.c_oAscAsyncAction.Open&&(Common.Gateway.internalMessage("documentReady",{}),this.onDocumentContentReady()),i=this.stackLongActions.get({type:Asc.c_oAscAsyncActionType.Information}),i&&this.setLongActionView(i),e==Asc.c_oAscAsyncAction.Save&&this.toolbarView&&this.toolbarView.synchronizeChanges(),i=this.stackLongActions.get({type:Asc.c_oAscAsyncActionType.BlockInteraction}),i?this.setLongActionView(i):(this.loadMask&&(!this.loadMask.isVisible()||this.dontCloseDummyComment||this.dontCloseChat||this.isModalShowed||this.inFormControl||this.api.asc_enableKeyEvents(!0),this.loadMask.hide()),t!=Asc.c_oAscAsyncActionType.BlockInteraction||(e==Asc.c_oAscAsyncAction.LoadDocumentFonts||e==Asc.c_oAscAsyncAction.ApplyChanges)&&(this.dontCloseDummyComment||this.dontCloseChat||this.isModalShowed||this.inFormControl)||this.onEditComplete(this.loadMask,{restorefocus:!0}))},setLongActionView:function(t){var e="";switch(t.id){case Asc.c_oAscAsyncAction.Open:e=this.openTitleText;break;case Asc.c_oAscAsyncAction.Save:e=this.saveTitleText;break;case Asc.c_oAscAsyncAction.ForceSaveTimeout:case Asc.c_oAscAsyncAction.ForceSaveButton:break;case Asc.c_oAscAsyncAction.LoadDocumentFonts:e=this.loadFontsTitleText;break;case Asc.c_oAscAsyncAction.LoadDocumentImages:e=this.loadImagesTitleText;break;case Asc.c_oAscAsyncAction.LoadFont:e=this.loadFontTitleText;break;case Asc.c_oAscAsyncAction.LoadImage:e=this.loadImageTitleText;break;case Asc.c_oAscAsyncAction.DownloadAs:e=this.downloadTitleText;break;case Asc.c_oAscAsyncAction.Print:e=this.printTitleText;break;case Asc.c_oAscAsyncAction.UploadImage:e=this.uploadImageTitleText;break;case Asc.c_oAscAsyncAction.Recalc:e=this.titleRecalcFormulas;break;case Asc.c_oAscAsyncAction.SlowOperation:e=this.textPleaseWait;break;case Asc.c_oAscAsyncAction.PrepareToSave:e=this.savePreparingText;break;case Asc.c_oAscAsyncAction.Waiting:e=this.waitText;break;case-255:e=this.txtEditingMode;break;case-256:e=this.loadingDocumentTitleText;break;default:"string"==typeof t.id&&(e=t.id)}t.type==Asc.c_oAscAsyncActionType.BlockInteraction&&(!this.loadMask&&(this.loadMask=new Common.UI.LoadMask({owner:$("#viewport")})),this.loadMask.setTitle(e),this.isShowOpenDialog||(this.api.asc_enableKeyEvents(!1),this.loadMask.show()))},onApplyEditRights:function(t){t&&!t.allowed&&Common.UI.info({title:this.requestEditFailedTitleText,msg:t.message||this.requestEditFailedMessageText})},onDocumentContentReady:function(){function t(){if(!window.AscDesktopEditor){var e=[];Common.Utils.isIE9m&&e.push(i.warnBrowserIE9),e.length&&i.showTips(e)}document.removeEventListener("visibilitychange",t)}if(!this._isDocReady){this._state.openDlg&&this._state.openDlg.close();var e,i=this;i._isDocReady=!0,Common.NotificationCenter.trigger("app:ready",this.appOptions),i.hidePreloader(),i.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256),e=this.appOptions.isEditMailMerge||this.appOptions.isEditDiagram?100:Common.localStorage.getItem("sse-settings-zoom"),Common.Utils.InternalSettings.set("sse-settings-zoom",e);var n=null!==e?parseInt(e)/100:this.appOptions.customization&&this.appOptions.customization.zoom?parseInt(this.appOptions.customization.zoom)/100:1;this.api.asc_setZoom(n>0?n:1),this.isLiveCommenting=Common.localStorage.getBool("sse-settings-livecomment",!0),Common.Utils.InternalSettings.set("sse-settings-livecomment",this.isLiveCommenting),e=Common.localStorage.getBool("sse-settings-resolvedcomment"),Common.Utils.InternalSettings.set("sse-settings-resolvedcomment",e),this.isLiveCommenting?this.api.asc_showComments(e):this.api.asc_hideComments(),this.appOptions.isEdit&&!this.appOptions.isOffline&&this.appOptions.canCoAuthoring?(e=Common.localStorage.getItem("sse-settings-coauthmode"),null===e&&null===Common.localStorage.getItem("sse-settings-autosave")&&this.appOptions.customization&&!1===this.appOptions.customization.autosave&&(e=0),this._state.fastCoauth=null===e||1==parseInt(e)):(this._state.fastCoauth=!this.appOptions.isEdit&&this.appOptions.isRestrictedEdit,this._state.fastCoauth&&(this.api.asc_setAutoSaveGap(1),Common.Utils.InternalSettings.set("sse-settings-autosave",1))),this.api.asc_SetFastCollaborative(this._state.fastCoauth),Common.Utils.InternalSettings.set("sse-settings-coauthmode",i._state.fastCoauth),i.api.asc_registerCallback("asc_onStartAction",_.bind(i.onLongActionBegin,i)),i.api.asc_registerCallback("asc_onConfirmAction",_.bind(i.onConfirmAction,i)),i.api.asc_registerCallback("asc_onActiveSheetChanged",_.bind(i.onActiveSheetChanged,i)),i.api.asc_registerCallback("asc_onPrint",_.bind(i.onPrint,i));var o=i.getApplication();i.headerView.setDocumentCaption(i.api.asc_getDocumentName()),i.updateWindowTitle(i.api.asc_isDocumentModified(),!0);var s=o.getController("Toolbar"),a=o.getController("Statusbar"),l=o.getController("DocumentHolder"),r=o.getController("RightMenu"),c=o.getController("LeftMenu"),h=o.getController("CellEditor"),d=a.getView("Statusbar"),p=c.getView("LeftMenu"),m=l.getView("DocumentHolder"),u=o.getController("Common.Controllers.Chat"),g=o.getController("Common.Controllers.Plugins"),b=o.getController("Spellcheck");if(p.getMenu("file").loadDocument({doc:i.appOptions.spreadsheet}),c.setMode(i.appOptions).createDelayedElements().setApi(i.api),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram||g.setApi(i.api),p.disableMenu("all",!1),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram||!i.appOptions.canBranding||i.getApplication().getController("LeftMenu").leftMenu.getMenu("about").setLicInfo(i.editorConfig.customization),l.setApi(i.api).loadConfig({config:i.editorConfig}),u.setApi(this.api).setMode(this.appOptions),a.createDelayedElements(),a.setApi(i.api),m.setApi(i.api),d.update(),this.formulaInput=h.getView("CellEditor").$el.find("textarea"),i.appOptions.isEdit){b.setApi(i.api).setMode(i.appOptions),i.appOptions.canAutosave?(e=Common.localStorage.getItem("sse-settings-autosave"),null===e&&i.appOptions.customization&&!1===i.appOptions.customization.autosave&&(e=0),e=i._state.fastCoauth||null===e?i.appOptions.canCoAuthoring?1:0:parseInt(e)):e=0,i.api.asc_setAutoSaveGap(e),Common.Utils.InternalSettings.set("sse-settings-autosave",e),i.appOptions.canForcesave&&(i.appOptions.forcesave=Common.localStorage.getBool("sse-settings-forcesave",i.appOptions.canForcesave),Common.Utils.InternalSettings.set("sse-settings-forcesave",i.appOptions.forcesave),i.api.asc_setIsForceSaveOnUserSave(i.appOptions.forcesave)),i.needToUpdateVersion&&(Common.NotificationCenter.trigger("api:disconnect"),s.onApiCoAuthoringDisconnect());var f=setInterval(function(){if(window.styles_loaded||i.appOptions.isEditDiagram||i.appOptions.isEditMailMerge){if(clearInterval(f),Common.NotificationCenter.trigger("comments:updatefilter",["doc","sheet"+i.api.asc_getActiveWorksheetId()]),m.createDelayedElements(),s.createDelayedElements(),i.setLanguages(),!i.appOptions.isEditMailMerge&&!i.appOptions.isEditDiagram){var t=i.api.asc_getPropertyEditorShapes();t&&i.fillAutoShapes(t[0],t[1]),i.fillTextArt(i.api.asc_getTextArtPreviews()),i.updateThemeColors(),s.activateControls()}r.createDelayedElements(),i.api.asc_registerCallback("asc_onDocumentCanSaveChanged",_.bind(i.onDocumentCanSaveChanged,i)),i.api.asc_registerCallback("asc_OnTryUndoInFastCollaborative",_.bind(i.onTryUndoInFastCollaborative,i)),i.onDocumentModifiedChanged(i.api.asc_isDocumentModified());var e=o.getController("FormulaDialog");e&&e.setMode(i.appOptions).setApi(i.api),i.needToUpdateVersion&&s.onApiCoAuthoringDisconnect(),Common.NotificationCenter.trigger("document:ready","main"),i.applyLicense()}},50)}else m.createDelayedElementsViewer(),Common.NotificationCenter.trigger("document:ready","main");i.appOptions.canAnalytics,1,Common.Gateway.on("applyeditrights",_.bind(i.onApplyEditRights,i)),Common.Gateway.on("processsaveresult",_.bind(i.onProcessSaveResult,i)),Common.Gateway.on("processrightschange",_.bind(i.onProcessRightsChange,i)),Common.Gateway.on("processmouse",_.bind(i.onProcessMouse,i)),Common.Gateway.on("downloadas",_.bind(i.onDownloadAs,i)),Common.Gateway.sendInfo({mode:i.appOptions.isEdit?"edit":"view"}),$(document).on("contextmenu",_.bind(i.onContextMenu,i)),void 0!==document.hidden&&document.hidden?document.addEventListener("visibilitychange",t):t(),Common.Gateway.documentReady()}},onLicenseChanged:function(t){if(!this.appOptions.isEditDiagram&&!this.appOptions.isEditMailMerge){var e=t.asc_getLicenseType();void 0===e||!this.appOptions.canEdit||"view"===this.editorConfig.mode||e!==Asc.c_oLicenseResult.Connections&&e!==Asc.c_oLicenseResult.UsersCount&&e!==Asc.c_oLicenseResult.ConnectionsOS&&e!==Asc.c_oLicenseResult.UsersCountOS||(this._state.licenseType=e),this._isDocReady&&this.applyLicense()}},applyLicense:function(){},disableEditing:function(t){var e=this.getApplication();this.appOptions.canEdit&&"view"!==this.editorConfig.mode&&(e.getController("RightMenu").getView("RightMenu").clearSelection(),e.getController("Toolbar").DisableToolbar(t))},onOpenDocument:function(t){var e=document.getElementById("loadmask-text"),i=(t.asc_getCurrentFont()+t.asc_getCurrentImage())/(t.asc_getFontsCount()+t.asc_getImagesCount());i=this.textLoadingDocument+": "+Math.min(Math.round(100*i),100)+"%",e?e.innerHTML=i:this.loadMask&&this.loadMask.setTitle(i)},onEditorPermissions:function(t){var e=t?t.asc_getLicenseType():Asc.c_oLicenseResult.Error;if(!t||this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge)this.appOptions.canModifyFilter=!0;else{if(this.onServerVersion(t.asc_getBuildVersion()))return;t.asc_getRights()!==Asc.c_oRights.Edit&&(this.permissions.edit=!1),this.appOptions.canAutosave=!0,this.appOptions.canAnalytics=t.asc_getIsAnalyticsEnable(),this.appOptions.isOffline=this.api.asc_isOffline(),this.appOptions.canLicense=e===Asc.c_oLicenseResult.Success||e===Asc.c_oLicenseResult.SuccessLimit,this.appOptions.isLightVersion=t.asc_getIsLight(),this.appOptions.canCoAuthoring=!this.appOptions.isLightVersion,this.appOptions.canComments=this.appOptions.canLicense&&(void 0===this.permissions.comment?!1!==this.permissions.edit:this.permissions.comment)&&"view"!==this.editorConfig.mode,this.appOptions.canComments=this.appOptions.canComments&&!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.comments),this.appOptions.canViewComments=this.appOptions.canComments||!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.comments),this.appOptions.canChat=this.appOptions.canLicense&&!this.appOptions.isOffline&&!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.chat),this.appOptions.canRename=this.editorConfig.canRename&&!!this.permissions.rename,this.appOptions.trialMode=t.asc_getLicenseMode(),this.appOptions.canModifyFilter=!1!==this.permissions.modifyFilter,this.appOptions.canBranding=t.asc_getCustomization(),this.appOptions.canBranding&&this.headerView.setBranding(this.editorConfig.customization),this.appOptions.canRename&&this.headerView.setCanRename(!0)}this.appOptions.canRequestEditRights=this.editorConfig.canRequestEditRights,this.appOptions.canRequestClose=this.editorConfig.canRequestClose,this.appOptions.canEdit=!1!==this.permissions.edit&&(this.editorConfig.canRequestEditRights||"view"!==this.editorConfig.mode),this.appOptions.isEdit=(this.appOptions.canLicense||this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge)&&!1!==this.permissions.edit&&"view"!==this.editorConfig.mode,this.appOptions.canDownload=!1!==this.permissions.download,this.appOptions.canPrint=!1!==this.permissions.print,this.appOptions.canForcesave=this.appOptions.isEdit&&!this.appOptions.isOffline&&!(this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge)&&"object"==typeof this.editorConfig.customization&&!!this.editorConfig.customization.forcesave,this.appOptions.forcesave=this.appOptions.canForcesave,this.appOptions.canEditComments=this.appOptions.isOffline||!("object"==typeof this.editorConfig.customization&&this.editorConfig.customization.commentAuthorOnly),this.appOptions.isSignatureSupport=this.appOptions.isEdit&&this.appOptions.isDesktopApp&&this.appOptions.isOffline&&this.api.asc_isSignaturesSupport()&&!(this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge),this.appOptions.isPasswordSupport=this.appOptions.isEdit&&this.appOptions.isDesktopApp&&this.appOptions.isOffline&&this.api.asc_isProtectionSupport()&&!(this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge),this.appOptions.canProtect=this.appOptions.isSignatureSupport||this.appOptions.isPasswordSupport,this.appOptions.canHelp=!("object"==typeof this.editorConfig.customization&&!1===this.editorConfig.customization.help),this.appOptions.isRestrictedEdit=!this.appOptions.isEdit&&this.appOptions.canComments,this.appOptions.isEditDiagram||this.appOptions.isEditMailMerge||(this.appOptions.canBrandingExt=t.asc_getCanBranding()&&("object"==typeof this.editorConfig.customization||this.editorConfig.plugins),this.getApplication().getController("Common.Controllers.Plugins").setMode(this.appOptions)),this.applyModeCommonElements(),this.applyModeEditorElements(),this.appOptions.isEdit||(Common.NotificationCenter.trigger("app:face",this.appOptions),this.hidePreloader(),this.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,-256)),this.api.asc_setViewMode(!this.appOptions.isEdit&&!this.appOptions.isRestrictedEdit),this.appOptions.isRestrictedEdit&&this.appOptions.canComments&&this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyComments),this.api.asc_LoadDocument()},applyModeCommonElements:function(){window.editor_elements_prepared=!0;var t=this.getApplication(),e=t.getController("Viewport").getView("Viewport"),i=t.getController("Statusbar").getView("Statusbar");if(this.headerView&&this.headerView.setVisible(!this.appOptions.isEditMailMerge&&!this.appOptions.isDesktopApp&&!this.appOptions.isEditDiagram),e&&e.setMode(this.appOptions,!0),i&&i.setMode(this.appOptions),t.getController("Toolbar").setMode(this.appOptions),t.getController("DocumentHolder").setMode(this.appOptions), -(this.appOptions.isEditMailMerge||this.appOptions.isEditDiagram)&&(i.hide(),t.getController("LeftMenu").getView("LeftMenu").hide(),$(window).mouseup(function(t){Common.Gateway.internalMessage("processMouse",{event:"mouse:up"})}).mousemove($.proxy(function(t){this.isDiagramDrag&&Common.Gateway.internalMessage("processMouse",{event:"mouse:move",pagex:t.pageX*Common.Utils.zoom(),pagey:t.pageY*Common.Utils.zoom()})},this))),!this.appOptions.isEditMailMerge&&!this.appOptions.isEditDiagram){this.api.asc_registerCallback("asc_onSendThemeColors",_.bind(this.onSendThemeColors,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),this.api.asc_registerCallback("asc_onDocumentModifiedChanged",_.bind(this.onDocumentModifiedChanged,this));var n=t.getController("Print");n&&this.api&&n.setApi(this.api)}var o=this.getApplication().getController("CellEditor");o&&o.setApi(this.api).setMode(this.appOptions)},applyModeEditorElements:function(t){var e=this.getApplication().getController("Common.Controllers.Comments");if(e&&(e.setMode(this.appOptions),e.setConfig({config:this.editorConfig,sdkviewname:"#ws-canvas-outer",hintmode:!0},this.api)),this.appOptions.isEdit){var i=this,n=this.getApplication(),o=n.getController("Toolbar"),s=n.getController("Statusbar"),a=n.getController("RightMenu"),l=n.getController("Common.Controllers.Fonts"),r=n.getController("Common.Controllers.ReviewChanges");l&&l.setApi(i.api),o&&o.setApi(i.api),a&&a.setApi(i.api),r.setMode(i.appOptions).setConfig({config:i.editorConfig},i.api),i.appOptions.canProtect&&n.getController("Common.Controllers.Protection").setMode(i.appOptions).setConfig({config:i.editorConfig},i.api),s&&s.getView("Statusbar").changeViewMode(!0),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram||i.appOptions.isOffline||n.getController("PivotTable").setMode(i.appOptions).setConfig({config:i.editorConfig},i.api);this.getApplication().getController("Viewport").getView("Viewport").applyEditorMode(),a.getView("RightMenu").setMode(i.appOptions).setApi(i.api),this.toolbarView=o.getView("Toolbar");var c=Common.localStorage.getItem("sse-settings-unit");if(c=null!==c?parseInt(c):Common.Utils.Metric.getDefaultMetric(),Common.Utils.Metric.setCurrentMetric(c),Common.Utils.InternalSettings.set("sse-settings-unit",c),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram)a.getView("RightMenu").hide();else{var h={};JSON.parse(Common.localStorage.getItem("sse-hidden-formula"))&&(h.formula=!0),n.getController("Toolbar").hideElements(h)}i.api.asc_registerCallback("asc_onAuthParticipantsChanged",_.bind(i.onAuthParticipantsChanged,i)),i.api.asc_registerCallback("asc_onParticipantsChanged",_.bind(i.onAuthParticipantsChanged,i)),i.appOptions.isEditDiagram&&i.api.asc_registerCallback("asc_onSelectionChanged",_.bind(i.onSelectionChanged,i)),i.api.asc_setFilteringMode&&i.api.asc_setFilteringMode(i.appOptions.canModifyFilter),i.stackLongActions.exist({id:-255,type:Asc.c_oAscAsyncActionType.BlockInteraction})?i.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-255):this._isDocReady||(Common.NotificationCenter.trigger("app:face",this.appOptions),i.hidePreloader(),i.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,-256)),window.onbeforeunload=_.bind(i.onBeforeUnload,i),window.onunload=_.bind(i.onUnload,i)}},onExternalMessage:function(t){t&&t.msg&&(t.msg=t.msg.toString(),this.showTips([t.msg.charAt(0).toUpperCase()+t.msg.substring(1)]),Common.component.Analytics.trackEvent("External Error"))},onError:function(t,e,i){if(t==Asc.c_oAscError.ID.LoadingScriptError)return this.showTips([this.scriptLoadError]),void(this.tooltip&&this.tooltip.getBSTip().$tip.css("z-index",1e4));this.hidePreloader(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256);var n={closable:!0};switch(t){case Asc.c_oAscError.ID.Unknown:n.msg=this.unknownErrorText;break;case Asc.c_oAscError.ID.ConvertationTimeout:n.msg=this.convertationTimeoutText;break;case Asc.c_oAscError.ID.ConvertationOpenError:n.msg=this.openErrorText;break;case Asc.c_oAscError.ID.ConvertationSaveError:n.msg=this.saveErrorText;break;case Asc.c_oAscError.ID.DownloadError:n.msg=this.downloadErrorText;break;case Asc.c_oAscError.ID.UplImageSize:n.msg=this.uploadImageSizeMessage;break;case Asc.c_oAscError.ID.UplImageExt:n.msg=this.uploadImageExtMessage;break;case Asc.c_oAscError.ID.UplImageFileCount:n.msg=this.uploadImageFileCountMessage;break;case Asc.c_oAscError.ID.PastInMergeAreaError:n.msg=this.pastInMergeAreaError;break;case Asc.c_oAscError.ID.FrmlWrongCountParentheses:n.msg=this.errorWrongBracketsCount;break;case Asc.c_oAscError.ID.FrmlWrongOperator:n.msg=this.errorWrongOperator;break;case Asc.c_oAscError.ID.FrmlWrongMaxArgument:n.msg=this.errorCountArgExceed;break;case Asc.c_oAscError.ID.FrmlWrongCountArgument:n.msg=this.errorCountArg;break;case Asc.c_oAscError.ID.FrmlWrongFunctionName:n.msg=this.errorFormulaName;break;case Asc.c_oAscError.ID.FrmlAnotherParsingError:n.msg=this.errorFormulaParsing;break;case Asc.c_oAscError.ID.FrmlWrongArgumentRange:n.msg=this.errorArgsRange;break;case Asc.c_oAscError.ID.FrmlOperandExpected:n.msg=this.errorOperandExpected;break;case Asc.c_oAscError.ID.FrmlWrongReferences:n.msg=this.errorFrmlWrongReferences;break;case Asc.c_oAscError.ID.UnexpectedGuid:n.msg=this.errorUnexpectedGuid;break;case Asc.c_oAscError.ID.Database:n.msg=this.errorDatabaseConnection;break;case Asc.c_oAscError.ID.FileRequest:n.msg=this.errorFileRequest;break;case Asc.c_oAscError.ID.FileVKey:n.msg=this.errorFileVKey;break;case Asc.c_oAscError.ID.StockChartError:n.msg=this.errorStockChart;break;case Asc.c_oAscError.ID.DataRangeError:n.msg=this.errorDataRange;break;case Asc.c_oAscError.ID.MaxDataPointsError:n.msg=this.errorMaxPoints;break;case Asc.c_oAscError.ID.VKeyEncrypt:n.msg=this.errorToken;break;case Asc.c_oAscError.ID.KeyExpire:n.msg=this.errorTokenExpire;break;case Asc.c_oAscError.ID.UserCountExceed:n.msg=this.errorUsersExceed;break;case Asc.c_oAscError.ID.CannotMoveRange:n.msg=this.errorMoveRange;break;case Asc.c_oAscError.ID.UplImageUrl:n.msg=this.errorBadImageUrl;break;case Asc.c_oAscError.ID.CoAuthoringDisconnect:n.msg=this.errorViewerDisconnect;break;case Asc.c_oAscError.ID.ConvertationPassword:n.msg=this.errorFilePassProtect;break;case Asc.c_oAscError.ID.AutoFilterDataRangeError:n.msg=this.errorAutoFilterDataRange;break;case Asc.c_oAscError.ID.AutoFilterChangeFormatTableError:n.msg=this.errorAutoFilterChangeFormatTable;break;case Asc.c_oAscError.ID.AutoFilterChangeError:n.msg=this.errorAutoFilterChange;break;case Asc.c_oAscError.ID.AutoFilterMoveToHiddenRangeError:n.msg=this.errorAutoFilterHiddenRange;break;case Asc.c_oAscError.ID.CannotFillRange:n.msg=this.errorFillRange;break;case Asc.c_oAscError.ID.UserDrop:if(this._state.lostEditingRights)return void(this._state.lostEditingRights=!1);this._state.lostEditingRights=!0,n.msg=this.errorUserDrop,Common.NotificationCenter.trigger("collaboration:sharingdeny");break;case Asc.c_oAscError.ID.InvalidReferenceOrName:n.msg=this.errorInvalidRef;break;case Asc.c_oAscError.ID.LockCreateDefName:n.msg=this.errorCreateDefName;break;case Asc.c_oAscError.ID.PasteMaxRangeError:n.msg=this.errorPasteMaxRange;break;case Asc.c_oAscError.ID.LockedAllError:n.msg=this.errorLockedAll;break;case Asc.c_oAscError.ID.Warning:n.msg=this.errorConnectToServer.replace("%1","https://api.onlyoffice.com/editors/callback"),n.closable=!1;break;case Asc.c_oAscError.ID.LockedWorksheetRename:n.msg=this.errorLockedWorksheetRename;break;case Asc.c_oAscError.ID.OpenWarning:n.msg=this.errorOpenWarning;break;case Asc.c_oAscError.ID.CopyMultiselectAreaError:n.msg=this.errorCopyMultiselectArea;break;case Asc.c_oAscError.ID.PrintMaxPagesCount:n.msg=this.errorPrintMaxPagesCount;break;case Asc.c_oAscError.ID.SessionAbsolute:n.msg=this.errorSessionAbsolute;break;case Asc.c_oAscError.ID.SessionIdle:n.msg=this.errorSessionIdle;break;case Asc.c_oAscError.ID.SessionToken:n.msg=this.errorSessionToken;break;case Asc.c_oAscError.ID.AccessDeny:n.msg=this.errorAccessDeny;break;case Asc.c_oAscError.ID.LockedCellPivot:n.msg=this.errorLockedCellPivot;break;case Asc.c_oAscError.ID.ForceSaveButton:n.msg=this.errorForceSave;break;case Asc.c_oAscError.ID.ForceSaveTimeout:n.msg=this.errorForceSave,console.warn(n.msg);break;case Asc.c_oAscError.ID.DataEncrypted:n.msg=this.errorDataEncrypted;break;case Asc.c_oAscError.ID.EditingError:n.msg=this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.errorEditingSaveas:this.errorEditingDownloadas;break;case Asc.c_oAscError.ID.CannotChangeFormulaArray:n.msg=this.errorChangeArray;break;case Asc.c_oAscError.ID.MultiCellsInTablesFormulaArray:n.msg=this.errorMultiCellFormula;break;case Asc.c_oAscError.ID.MailToClientMissing:n.msg=this.errorEmailClient;break;case Asc.c_oAscError.ID.NoDataToParse:n.msg=this.errorNoDataToParse;break;case Asc.c_oAscError.ID.CannotUngroupError:n.msg=this.errorCannotUngroup;break;case Asc.c_oAscError.ID.FrmlMaxTextLength:n.msg=this.errorFrmlMaxTextLength;break;case Asc.c_oAscError.ID.DataValidate:var o=i?i.asc_getErrorStyle():void 0;void 0!==o&&(n.iconCls=o==Asc.c_oAscEDataValidationErrorStyle.Stop?"error":o==Asc.c_oAscEDataValidationErrorStyle.Information?"info":"warn"),i&&i.asc_getErrorTitle()&&(n.title=i.asc_getErrorTitle()),n.buttons=["ok","cancel"],n.msg=i&&i.asc_getError()?i.asc_getError():this.errorDataValidate,n.maxwidth=600;break;default:n.msg="string"==typeof t?t:this.errorDefaultMessage.replace("%1",t)}e==Asc.c_oAscError.Level.Critical?(Common.Gateway.reportError(t,n.msg),n.title=this.criticalErrorTitle,n.iconCls="error",n.closable=!1,this.appOptions.canBackToFolder&&!this.appOptions.isDesktopApp&&"string"!=typeof t&&(n.msg+="

"+this.criticalErrorExtText,n.callback=function(t){"ok"==t&&Common.NotificationCenter.trigger("goback",!0)}),t==Asc.c_oAscError.ID.DataEncrypted&&(this.api.asc_coAuthoringDisconnect(),Common.NotificationCenter.trigger("api:disconnect"))):(Common.Gateway.reportWarning(t,n.msg),n.title=n.title||this.notcriticalErrorTitle,n.iconCls=n.iconCls||"warn",n.buttons=n.buttons||["ok"],n.callback=_.bind(function(e){t==Asc.c_oAscError.ID.Warning&&"ok"==e&&this.appOptions.canDownload?(Common.UI.Menu.Manager.hideAll(),this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.api.asc_DownloadAs():this.getApplication().getController("LeftMenu").leftMenu.showMenu("file:saveas")):t==Asc.c_oAscError.ID.EditingError?(this.disableEditing(!0),Common.NotificationCenter.trigger("api:disconnect",!0)):t==Asc.c_oAscError.ID.DataValidate&&"ok"!==e&&this.api.asc_closeCellEditor(!0),this._state.lostEditingRights=!1,this.onEditComplete()},this)),$(".asc-window.modal.alert:visible").length<1&&t!==Asc.c_oAscError.ID.ForceSaveTimeout&&(Common.UI.alert(n),Common.component.Analytics.trackEvent("Internal Error",t.toString()))},onCoAuthoringDisconnect:function(){this.getApplication().getController("Viewport").getView("Viewport").setMode({isDisconnected:!0}),this.getApplication().getController("Viewport").getView("Common.Views.Header").setCanRename(!1),this.appOptions.canRename=!1,this._state.isDisconnected=!0},showTips:function(t){function e(){var e=t.shift();e&&(e+="\n"+i.textCloseTip,n.setTitle(e),n.show())}var i=this;if(t.length){"object"!=typeof t&&(t=[t]),this.tooltip||(this.tooltip=new Common.UI.Tooltip({owner:this.getApplication().getController("Toolbar").getView("Toolbar"),hideonclick:!0,placement:"bottom",cls:"main-info",offset:30}));var n=this.tooltip;n.on("tooltip:hide",function(){setTimeout(e,300)}),e()}},updateWindowTitle:function(t,e){if(this._state.isDocModified!==t||e){if(this.headerView){var i=this.defaultTitleText;if(_.isEmpty(this.headerView.getDocumentCaption())||(i=this.headerView.getDocumentCaption()+" - "+i),t)clearTimeout(this._state.timerCaption),_.isUndefined(i)||(i="* "+i,this.headerView.setDocumentCaption(this.headerView.getDocumentCaption(),!0));else if(this._state.fastCoauth&&this._state.usersCount>1){var n=this;this._state.timerCaption=setTimeout(function(){n.headerView.setDocumentCaption(n.headerView.getDocumentCaption(),!1)},500)}else this.headerView.setDocumentCaption(this.headerView.getDocumentCaption(),!1);window.document.title!=i&&(window.document.title=i)}Common.Gateway.setDocumentModified(t),this._state.isDocModified=t}},onDocumentChanged:function(){},onDocumentModifiedChanged:function(t){if(this.updateWindowTitle(t),Common.Gateway.setDocumentModified(t),this.toolbarView&&this.toolbarView.btnCollabChanges&&this.api){var e=this.toolbarView.btnCollabChanges.$icon.hasClass("btn-synch"),i=this.appOptions.forcesave,n=this.api.asc_isDocumentCanSave(),o=!n&&!e&&!i||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!i;this.toolbarView.btnSave.setDisabled(o)}},onDocumentCanSaveChanged:function(t){if(this.toolbarView&&this.toolbarView.btnCollabChanges){var e=this.toolbarView.btnCollabChanges.$icon.hasClass("btn-synch"),i=this.appOptions.forcesave,n=!t&&!e&&!i||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!i;this.toolbarView.btnSave.setDisabled(n)}},onBeforeUnload:function(){if(Common.localStorage.save(),!1!==this.permissions.edit&&"view"!==this.editorConfig.mode&&"editdiagram"!==this.editorConfig.mode&&"editmerge"!==this.editorConfig.mode&&this.api.asc_isDocumentModified()){var t=this;return this.api.asc_stopSaving(),this.continueSavingTimer=window.setTimeout(function(){t.api.asc_continueSaving()},500),this.leavePageText}},onUnload:function(){this.continueSavingTimer&&clearTimeout(this.continueSavingTimer)},hidePreloader:function(){var i;this._state.customizationDone||(this._state.customizationDone=!0,this.appOptions.customization&&(this.appOptions.isDesktopApp?this.appOptions.customization.about=!1:this.appOptions.canBrandingExt||(this.appOptions.customization.about=!0)),Common.Utils.applyCustomization(this.appOptions.customization,t),this.appOptions.canBrandingExt&&(Common.Utils.applyCustomization(this.appOptions.customization,e),i=this.getApplication().getController("Common.Controllers.Plugins").applyUICustomization())),this.stackLongActions.pop({id:-254,type:Asc.c_oAscAsyncActionType.BlockInteraction}),Common.NotificationCenter.trigger("layout:changed","main"),(i||new Promise(function(t,e){t()})).then(function(){$("#loading-mask").hide().remove(),Common.Controllers.Desktop.process("preloader:hide")})},onDownloadUrl:function(t){this._state.isFromGatewayDownloadAs&&Common.Gateway.downloadAs(t),this._state.isFromGatewayDownloadAs=!1},onDownloadCancel:function(){this._state.isFromGatewayDownloadAs=!1},onUpdateVersion:function(t){var e=this;e.needToUpdateVersion=!0,e.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256),Common.UI.error({msg:this.errorUpdateVersion,callback:function(){_.defer(function(){Common.Gateway.updateVersion(),t&&t.call(e),e.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,-256)})}})},onServerVersion:function(t){return!1},onAdvancedOptions:function(t,e,i,n){if(!this._state.openDlg){var o=this;t==Asc.c_oAscAdvancedOptionsID.CSV?o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitle.replace("%1","CSV"),closable:2==i,type:Common.Utils.importTextType.CSV,preview:e.asc_getData(),codepages:e.asc_getCodePages(),settings:e.asc_getRecommendedSettings(),api:o.api,handler:function(e,s,a,l){o.isShowOpenDialog=!1,"ok"==e&&o&&o.api&&(2==i?(n&&n.asc_setAdvancedOptions(new Asc.asc_CTextOptions(s,a,l)),o.api.asc_DownloadAs(n)):o.api.asc_setAdvancedOptions(t,new Asc.asc_CTextOptions(s,a,l)),o.loadMask&&o.loadMask.show()),o._state.openDlg=null}}):t==Asc.c_oAscAdvancedOptionsID.DRM&&(o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitleProtected,closeFile:o.appOptions.canRequestClose,type:Common.Utils.importTextType.DRM,warning:!(o.appOptions.isDesktopApp&&o.appOptions.isOffline),validatePwd:!!o._state.isDRM,handler:function(e,i){o.isShowOpenDialog=!1,"ok"==e?o&&o.api&&(o.api.asc_setAdvancedOptions(t,new Asc.asc_CDRMAdvancedOptions(i)),o.loadMask&&o.loadMask.show()):(Common.Gateway.requestClose(),Common.Controllers.Desktop.requestClose()),o._state.openDlg=null}}),o._state.isDRM=!0),o._state.openDlg&&(this.isShowOpenDialog=!0,this.loadMask&&this.loadMask.hide(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256),o._state.openDlg.show())}},onActiveSheetChanged:function(t){this.appOptions.isEditMailMerge||this.appOptions.isEditDiagram||!window.editor_elements_prepared||(this.application.getController("Statusbar").selectTab(t),this.appOptions.canViewComments&&!this.dontCloseDummyComment&&Common.NotificationCenter.trigger("comments:updatefilter",["doc","sheet"+this.api.asc_getWorksheetId(t)],!1))},onConfirmAction:function(t,e){var i=this;t==Asc.c_oAscConfirm.ConfirmReplaceRange?Common.UI.warning({title:this.notcriticalErrorTitle,msg:this.confirmMoveCellRange,buttons:["yes","no"],primary:"yes",callback:_.bind(function(t){e&&e("yes"===t),"yes"==t&&i.onEditComplete(i.application.getController("DocumentHolder").getView("DocumentHolder"))},this)}):t==Asc.c_oAscConfirm.ConfirmPutMergeRange&&Common.UI.warning({closable:!1,title:this.notcriticalErrorTitle,msg:this.confirmPutMergeRange,buttons:["ok"],primary:"ok",callback:_.bind(function(t){e&&e(),i.onEditComplete(i.application.getController("DocumentHolder").getView("DocumentHolder"))},this)})},initNames:function(){this.shapeGroupNames=[this.txtBasicShapes,this.txtFiguredArrows,this.txtMath,this.txtCharts,this.txtStarsRibbons,this.txtCallouts,this.txtButtons,this.txtRectangles,this.txtLines]},fillAutoShapes:function(t,e){if(!_.isEmpty(e)&&!_.isEmpty(t)&&e.length==t.length){var i=this,n=[],o=this.getCollection("ShapeGroups");o.reset();t.length;_.each(t,function(t,o){var s=new Backbone.Collection([],{model:SSE.Models.ShapeModel}),a=e[o].length>18?7:6,l=35*Math.ceil(e[o].length/a)+3,r=30*a;_.each(e[o],function(t,e){s.add({data:{shapeType:t.Type},tip:i["txtShape_"+t.Type]||i.textShape+" "+(e+1),allowSelected:!0,selected:!1})}),n.push({groupName:i.shapeGroupNames[o],groupStore:s,groupWidth:r,groupHeight:l})}),o.add(n),setTimeout(function(){i.getApplication().getController("Toolbar").fillAutoShapes()},50)}},fillTextArt:function(t){if(!_.isEmpty(t)){var e=this,i=[],n=this.getCollection("Common.Collections.TextArt");_.each(t,function(t,e){i.push({imageUrl:t,data:e,allowSelected:!0,selected:!1})}),n.reset(i),setTimeout(function(){e.getApplication().getController("Toolbar").fillTextArt()},50),setTimeout(function(){e.getApplication().getController("RightMenu").fillTextArt()},50)}},updateThemeColors:function(){var t=this;setTimeout(function(){t.getApplication().getController("RightMenu").UpdateThemeColors()},50),setTimeout(function(){t.getApplication().getController("Toolbar").updateThemeColors()},50),setTimeout(function(){t.getApplication().getController("Statusbar").updateThemeColors()},50)},onSendThemeColors:function(t,e){if(Common.Utils.ThemeColor.setColors(t,e),window.styles_loaded&&!this.appOptions.isEditMailMerge&&!this.appOptions.isEditDiagram){this.updateThemeColors();var i=this;setTimeout(function(){i.fillTextArt(i.api.asc_getTextArtPreviews())},1)}},loadLanguages:function(t){this.languages=t,window.styles_loaded&&this.setLanguages()},setLanguages:function(){this.getApplication().getController("Spellcheck").setLanguages(this.languages)},onInternalCommand:function(t){if(t)switch(t.command){case"setChartData":this.setChartData(t.data);break;case"getChartData":this.getChartData();break;case"clearChartData":this.clearChartData();break;case"setMergeData":this.setMergeData(t.data);break;case"getMergeData":this.getMergeData();break;case"setAppDisabled":void 0!==this.isAppDisabled||t.data||(Common.NotificationCenter.trigger("layout:changed","main"),this.loadMask&&this.loadMask.isVisible()&&this.loadMask.updatePosition()),this.isAppDisabled=t.data;break;case"queryClose":0===$("body .asc-window:visible").length?(this.isFrameClosed=!0,this.api.asc_closeCellEditor(),Common.UI.Menu.Manager.hideAll(),Common.Gateway.internalMessage("canClose",{mr:t.data.mr,answer:!0})):Common.Gateway.internalMessage("canClose",{answer:!1});break;case"window:drag":this.isDiagramDrag=t.data;break;case"processmouse":this.onProcessMouse(t.data)}},setChartData:function(t){"object"==typeof t&&this.api&&(this.api.asc_addChartDrawingObject(t),this.isFrameClosed=!1)},getChartData:function(){if(this.api){var t=this.api.asc_getWordChartObject();"object"==typeof t&&Common.Gateway.internalMessage("chartData",{data:t})}},clearChartData:function(){this.api&&this.api.asc_closeCellEditor()},setMergeData:function(t){"object"==typeof t&&this.api&&(this.api.asc_setData(t),this.isFrameClosed=!1)},getMergeData:function(){if(this.api){var t=this.api.asc_getData();"object"==typeof t&&Common.Gateway.internalMessage("mergeData",{data:t})}},unitsChanged:function(t){var e=Common.localStorage.getItem("sse-settings-unit");e=null!==e?parseInt(e):Common.Utils.Metric.getDefaultMetric(),Common.Utils.Metric.setCurrentMetric(e),Common.Utils.InternalSettings.set("sse-settings-unit",e),this.getApplication().getController("RightMenu").updateMetricUnit(),this.getApplication().getController("Print").getView("MainSettingsPrint").updateMetricUnit(),this.getApplication().getController("Toolbar").getView("Toolbar").updateMetricUnit()},_compareActionStrong:function(t,e){return t.id===e.id&&t.type===e.type},_compareActionWeak:function(t,e){return t.type===e.type},onContextMenu:function(t){var e=t.target.getAttribute("data-can-copy"),i=t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement;if(i&&"false"===e||!i&&"true"!==e)return t.stopPropagation(),t.preventDefault(),!1},onNamedRangeLocked:function(){$(".asc-window.modal.alert:visible").length<1&&Common.UI.alert({msg:this.errorCreateDefName,title:this.notcriticalErrorTitle,iconCls:"warn",buttons:["ok"],callback:_.bind(function(t){this.onEditComplete()},this)})},onTryUndoInFastCollaborative:function(){var t=window.localStorage.getItem("sse-hide-try-undoredo");t&&1==parseInt(t)||Common.UI.info({width:500,msg:this.textTryUndoRedo,iconCls:"info",buttons:["custom","cancel"],primary:"custom",customButtonText:this.textStrict,dontshow:!0,callback:_.bind(function(t,e){e&&window.localStorage.setItem("sse-hide-try-undoredo",1),"custom"==t&&(Common.localStorage.setItem("sse-settings-coauthmode",0),this.api.asc_SetFastCollaborative(!1),Common.Utils.InternalSettings.set("sse-settings-coauthmode",!1),this.getApplication().getController("Common.Controllers.ReviewChanges").applySettings(),this._state.fastCoauth=!1),this.onEditComplete()},this)})},onAuthParticipantsChanged:function(t){var e=0;_.each(t,function(t){t.asc_getView()||e++}),this._state.usersCount=e},applySettings:function(){if(this.appOptions.isEdit&&!this.appOptions.isOffline&&this.appOptions.canCoAuthoring){var t=Common.localStorage.getItem("sse-settings-coauthmode"),e=this._state.fastCoauth;this._state.fastCoauth=null===t||1==parseInt(t),this._state.fastCoauth&&!e&&this.toolbarView.synchronizeChanges()}this.appOptions.canForcesave&&(this.appOptions.forcesave=Common.localStorage.getBool("sse-settings-forcesave",this.appOptions.canForcesave),Common.Utils.InternalSettings.set("sse-settings-forcesave",this.appOptions.forcesave),this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave))},onDocumentName:function(t){this.headerView.setDocumentCaption(t),this.updateWindowTitle(this.api.asc_isDocumentModified(),!0)},onMeta:function(t){var e=this.getApplication(),i=e.getController("LeftMenu").getView("LeftMenu").getMenu("file");e.getController("Viewport").getView("Common.Views.Header").setDocumentCaption(t.title),this.updateWindowTitle(this.api.asc_isDocumentModified(),!0),this.appOptions.spreadsheet.title=t.title,i.loadDocument({doc:this.appOptions.spreadsheet}),i.panels.info.updateInfo(this.appOptions.spreadsheet),Common.Gateway.metaChange(t)},onPrint:function(){this.appOptions.canPrint&&!this.isModalShowed&&Common.NotificationCenter.trigger("print",this)},onPrintUrl:function(t){if(this.iframePrint&&(this.iframePrint.parentNode.removeChild(this.iframePrint),this.iframePrint=null),!this.iframePrint){var e=this;this.iframePrint=document.createElement("iframe"),this.iframePrint.id="id-print-frame",this.iframePrint.style.display="none",this.iframePrint.style.visibility="hidden",this.iframePrint.style.position="fixed",this.iframePrint.style.right="0",this.iframePrint.style.bottom="0",document.body.appendChild(this.iframePrint),this.iframePrint.onload=function(){try{e.iframePrint.contentWindow.focus(),e.iframePrint.contentWindow.print(),e.iframePrint.contentWindow.blur(),window.focus()}catch(i){var t=new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF);t.asc_setAdvancedOptions(e.getApplication().getController("Print").getPrintParams()),e.api.asc_DownloadAs(t)}}}t&&(this.iframePrint.src=t)},leavePageText:"You have unsaved changes in this document. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.",criticalErrorTitle:"Error",notcriticalErrorTitle:"Warning",errorDefaultMessage:"Error code: %1",criticalErrorExtText:'Press "OK" to to back to document list.',openTitleText:"Opening Document",openTextText:"Opening document...",saveTitleText:"Saving Document",saveTextText:"Saving document...",loadFontsTitleText:"Loading Data",loadFontsTextText:"Loading data...",loadImagesTitleText:"Loading Images",loadImagesTextText:"Loading images...",loadFontTitleText:"Loading Data",loadFontTextText:"Loading data...",loadImageTitleText:"Loading Image",loadImageTextText:"Loading image...",downloadTitleText:"Downloading Document",downloadTextText:"Downloading document...",printTitleText:"Printing Document",printTextText:"Printing document...",uploadImageTitleText:"Uploading Image",uploadImageTextText:"Uploading image...",savePreparingText:"Preparing to save",savePreparingTitle:"Preparing to save. Please wait...",loadingDocumentTitleText:"Loading spreadsheet",uploadImageSizeMessage:"Maximium image size limit exceeded.",uploadImageExtMessage:"Unknown image format.",uploadImageFileCountMessage:"No images uploaded.",reloadButtonText:"Reload Page",unknownErrorText:"Unknown error.",convertationTimeoutText:"Convertation timeout exceeded.",downloadErrorText:"Download failed.",unsupportedBrowserErrorText:"Your browser is not supported.",requestEditFailedTitleText:"Access denied",requestEditFailedMessageText:"Someone is editing this document right now. Please try again later.",warnBrowserZoom:"Your browser's current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.",warnBrowserIE9:"The application has low capabilities on IE9. Use IE10 or higher",pastInMergeAreaError:"Cannot change part of a merged cell",titleRecalcFormulas:"Calculating formulas...",textRecalcFormulas:"Calculating formulas...",textPleaseWait:"It's working hard. Please wait...",errorWrongBracketsCount:"Found an error in the formula entered.
Wrong cout of brackets.",errorWrongOperator:"An error in the entered formula. Wrong operator is used.
Please correct the error or use the Esc button to cancel the formula editing.",errorCountArgExceed:"Found an error in the formula entered.
Count of arguments exceeded.",errorCountArg:"Found an error in the formula entered.
Invalid number of arguments.",errorFormulaName:"Found an error in the formula entered.
Incorrect formula name.",errorFormulaParsing:"Internal error while the formula parsing.",errorArgsRange:"Found an error in the formula entered.
Incorrect arguments range.",errorUnexpectedGuid:"External error.
Unexpected Guid. Please, contact support.",errorDatabaseConnection:"External error.
Database connection error. Please, contact support.",errorFileRequest:"External error.
File Request. Please, contact support.",errorFileVKey:"External error.
Incorrect securety key. Please, contact support.",errorStockChart:"Incorrect row order. To build a stock chart place the data on the sheet in the following order:
opening price, max price, min price, closing price.",errorDataRange:"Incorrect data range.",errorOperandExpected:"The entered function syntax is not correct. Please check if you are missing one of the parentheses - '(' or ')'.",errorKeyEncrypt:"Unknown key descriptor",errorKeyExpire:"Key descriptor expired",errorUsersExceed:"Count of users was exceed",errorMoveRange:"Cann't change a part of merged cell",errorBadImageUrl:"Image url is incorrect",errorCoAuthoringDisconnect:"Server connection lost. You can't edit anymore.",errorFilePassProtect:"The file is password protected and cannot be opened.",errorLockedAll:"The operation could not be done as the sheet has been locked by another user.",txtEditingMode:"Set editing mode...",textLoadingDocument:"Loading spreadsheet",textConfirm:"Confirmation",confirmMoveCellRange:"The destination cell's range can contain data. Continue the operation?",textYes:"Yes",textNo:"No",textAnonymous:"Anonymous",txtBasicShapes:"Basic Shapes",txtFiguredArrows:"Figured Arrows",txtMath:"Math",txtCharts:"Charts",txtStarsRibbons:"Stars & Ribbons",txtCallouts:"Callouts",txtButtons:"Buttons",txtRectangles:"Rectangles",txtLines:"Lines",txtDiagramTitle:"Chart Title",txtXAxis:"X Axis",txtYAxis:"Y Axis",txtSeries:"Seria",warnProcessRightsChange:"You have been denied the right to edit the file.",errorProcessSaveResult:"Saving is failed.",errorAutoFilterDataRange:"The operation could not be done for the selected range of cells.
Select a uniform data range inside or outside the table and try again.",errorAutoFilterChangeFormatTable:"The operation could not be done for the selected cells as you cannot move a part of the table.
Select another data range so that the whole table was shifted and try again.",errorAutoFilterHiddenRange:"The operation cannot be performed because the area contains filtered cells.
Please unhide the filtered elements and try again.",errorAutoFilterChange:"The operation is not allowed, as it is attempting to shift cells in a table on your worksheet.",textCloseTip:"Click to close the tip.",textShape:"Shape",errorFillRange:"Could not fill the selected range of cells.
All the merged cells need to be the same size.",errorUpdateVersion:"The file version has been changed. The page will be reloaded.",errorUserDrop:"The file cannot be accessed right now.",txtArt:"Your text here",errorInvalidRef:"Enter a correct name for the selection or a valid reference to go to.",errorCreateDefName:"The existing named ranges cannot be edited and the new ones cannot be created
at the moment as some of them are being edited.",errorPasteMaxRange:"The copy and paste area does not match. Please select an area with the same size or click the first cell in a row to paste the copied cells.",errorConnectToServer:' The document could not be saved. Please check connection settings or contact your administrator.
When you click the \'OK\' button, you will be prompted to download the document.

Find more information about connecting Document Server here',errorLockedWorksheetRename:"The sheet cannot be renamed at the moment as it is being renamed by another user",textTryUndoRedo:"The Undo/Redo functions are disabled for the Fast co-editing mode.
Click the 'Strict mode' button to switch to the Strict co-editing mode to edit the file without other users interference and send your changes only after you save them. You can switch between the co-editing modes using the editor Advanced settings.",textStrict:"Strict mode",errorOpenWarning:"The length of one of the formulas in the file exceeded
the allowed number of characters and it was removed.",errorFrmlWrongReferences:"The function refers to a sheet that does not exist.
Please check the data and try again.",textBuyNow:"Visit website",textNoLicenseTitle:"%1 open source version",textContactUs:"Contact sales", -confirmPutMergeRange:"The source data contains merged cells.
They will be unmerged before they are pasted into the table.",errorViewerDisconnect:"Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.",warnLicenseExp:"Your license has expired.
Please update your license and refresh the page.",titleLicenseExp:"License expired",openErrorText:"An error has occurred while opening the file",saveErrorText:"An error has occurred while saving the file",errorCopyMultiselectArea:"This command cannot be used with multiple selections.
Select a single range and try again.",errorPrintMaxPagesCount:"Unfortunately, it’s not possible to print more than 1500 pages at once in the current version of the program.
This restriction will be eliminated in upcoming releases.",errorToken:"The document security token is not correctly formed.
Please contact your Document Server administrator.",errorTokenExpire:"The document security token has expired.
Please contact your Document Server administrator.",errorSessionAbsolute:"The document editing session has expired. Please reload the page.",errorSessionIdle:"The document has not been edited for quite a long time. Please reload the page.",errorSessionToken:"The connection to the server has been interrupted. Please reload the page.",errorAccessDeny:"You are trying to perform an action you do not have rights for.
Please contact your Document Server administrator.",titleServerVersion:"Editor updated",errorServerVersion:"The editor version has been updated. The page will be reloaded to apply the changes.",errorLockedCellPivot:"You cannot change data inside a pivot table.",txtAccent:"Accent",txtStyle_Normal:"Normal",txtStyle_Heading_1:"Heading 1",txtStyle_Heading_2:"Heading 2",txtStyle_Heading_3:"Heading 3",txtStyle_Heading_4:"Heading 4",txtStyle_Title:"Title",txtStyle_Neutral:"Neutral",txtStyle_Bad:"Bad",txtStyle_Good:"Good",txtStyle_Input:"Input",txtStyle_Output:"Output",txtStyle_Calculation:"Calculation",txtStyle_Check_Cell:"Check Cell",txtStyle_Explanatory_Text:"Explanatory Text",txtStyle_Note:"Note",txtStyle_Linked_Cell:"Linked Cell",txtStyle_Warning_Text:"Warning Text",txtStyle_Total:"Total",txtStyle_Currency:"Currency",txtStyle_Percent:"Percent",txtStyle_Comma:"Comma",errorForceSave:"An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.",errorMaxPoints:"The maximum number of points in series per chart is 4096.",warnNoLicense:"This version of %1 editors has certain limitations for concurrent connections to the document server.
If you need more please consider purchasing a commercial license.",warnNoLicenseUsers:"This version of %1 Editors has certain limitations for concurrent users.
If you need more please consider purchasing a commercial license.",warnLicenseExceeded:"The number of concurrent connections to the document server has been exceeded and the document will be opened for viewing only.
Please contact your administrator for more information.",warnLicenseUsersExceeded:"The number of concurrent users has been exceeded and the document will be opened for viewing only.
Please contact your administrator for more information.",errorDataEncrypted:"Encrypted changes have been received, they cannot be deciphered.",textClose:"Close",textPaidFeature:"Paid feature",scriptLoadError:"The connection is too slow, some of the components could not be loaded. Please reload the page.",errorEditingSaveas:"An error occurred during the work with the document.
Use the 'Save as...' option to save the file backup copy to your computer hard drive.",errorEditingDownloadas:"An error occurred during the work with the document.
Use the 'Download as...' option to save the file backup copy to your computer hard drive.",txtShape_textRect:"Text Box",txtShape_rect:"Rectangle",txtShape_ellipse:"Ellipse",txtShape_triangle:"Triangle",txtShape_rtTriangle:"Right Triangle",txtShape_parallelogram:"Parallelogram",txtShape_trapezoid:"Trapezoid",txtShape_diamond:"Diamond",txtShape_pentagon:"Pentagon",txtShape_hexagon:"Hexagon",txtShape_heptagon:"Heptagon",txtShape_octagon:"Octagon",txtShape_decagon:"Decagon",txtShape_dodecagon:"Dodecagon",txtShape_pie:"Pie",txtShape_chord:"Chord",txtShape_teardrop:"Teardrop",txtShape_frame:"Frame",txtShape_halfFrame:"Half Frame",txtShape_corner:"Corner",txtShape_diagStripe:"Diagonal Stripe",txtShape_plus:"Plus",txtShape_plaque:"Sign",txtShape_can:"Can",txtShape_cube:"Cube",txtShape_bevel:"Bevel",txtShape_donut:"Donut",txtShape_noSmoking:'"No" Symbol',txtShape_blockArc:"Block Arc",txtShape_foldedCorner:"Folded Corner",txtShape_smileyFace:"Smiley Face",txtShape_heart:"Heart",txtShape_lightningBolt:"Lightning Bolt",txtShape_sun:"Sun",txtShape_moon:"Moon",txtShape_cloud:"Cloud",txtShape_arc:"Arc",txtShape_bracePair:"Double Brace",txtShape_leftBracket:"Left Bracket",txtShape_rightBracket:"Right Bracket",txtShape_leftBrace:"Left Brace",txtShape_rightBrace:"Right Brace",txtShape_rightArrow:"Right Arrow",txtShape_leftArrow:"Left Arrow",txtShape_upArrow:"Up Arrow",txtShape_downArrow:"Down Arrow",txtShape_leftRightArrow:"Left Right Arrow",txtShape_upDownArrow:"Up Down Arrow",txtShape_quadArrow:"Quad Arrow",txtShape_leftRightUpArrow:"Left Right Up Arrow",txtShape_bentArrow:"Bent Arrow",txtShape_uturnArrow:"U-Turn Arrow",txtShape_leftUpArrow:"Left Up Arrow",txtShape_bentUpArrow:"Bent Up Arrow",txtShape_curvedRightArrow:"Curved Right Arrow",txtShape_curvedLeftArrow:"Curved Left Arrow",txtShape_curvedUpArrow:"Curved Up Arrow",txtShape_curvedDownArrow:"Curved Down Arrow",txtShape_stripedRightArrow:"Striped Right Arrow",txtShape_notchedRightArrow:"Notched Right Arrow",txtShape_homePlate:"Pentagon",txtShape_chevron:"Chevron",txtShape_rightArrowCallout:"Right Arrow Callout",txtShape_downArrowCallout:"Down Arrow Callout",txtShape_leftArrowCallout:"Left Arrow Callout",txtShape_upArrowCallout:"Up Arrow Callout",txtShape_leftRightArrowCallout:"Left Right Arrow Callout",txtShape_quadArrowCallout:"Quad Arrow Callout",txtShape_circularArrow:"Circular Arrow",txtShape_mathPlus:"Plus",txtShape_mathMinus:"Minus",txtShape_mathMultiply:"Multiply",txtShape_mathDivide:"Division",txtShape_mathEqual:"Equal",txtShape_mathNotEqual:"Not Equal",txtShape_flowChartProcess:"Flowchart: Process",txtShape_flowChartAlternateProcess:"Flowchart: Alternate Process",txtShape_flowChartDecision:"Flowchart: Decision",txtShape_flowChartInputOutput:"Flowchart: Data",txtShape_flowChartPredefinedProcess:"Flowchart: Predefined Process",txtShape_flowChartInternalStorage:"Flowchart: Internal Storage",txtShape_flowChartDocument:"Flowchart: Document",txtShape_flowChartMultidocument:"Flowchart: Multidocument ",txtShape_flowChartTerminator:"Flowchart: Terminator",txtShape_flowChartPreparation:"Flowchart: Preparation",txtShape_flowChartManualInput:"Flowchart: Manual Input",txtShape_flowChartManualOperation:"Flowchart: Manual Operation",txtShape_flowChartConnector:"Flowchart: Connector",txtShape_flowChartOffpageConnector:"Flowchart: Off-page Connector",txtShape_flowChartPunchedCard:"Flowchart: Card",txtShape_flowChartPunchedTape:"Flowchart: Punched Tape",txtShape_flowChartSummingJunction:"Flowchart: Summing Junction",txtShape_flowChartOr:"Flowchart: Or",txtShape_flowChartCollate:"Flowchart: Collate",txtShape_flowChartSort:"Flowchart: Sort",txtShape_flowChartExtract:"Flowchart: Extract",txtShape_flowChartMerge:"Flowchart: Merge",txtShape_flowChartOnlineStorage:"Flowchart: Stored Data",txtShape_flowChartDelay:"Flowchart: Delay",txtShape_flowChartMagneticTape:"Flowchart: Sequential Access Storage",txtShape_flowChartMagneticDisk:"Flowchart: Magnetic Disk",txtShape_flowChartMagneticDrum:"Flowchart: Direct Access Storage",txtShape_flowChartDisplay:"Flowchart: Display",txtShape_irregularSeal1:"Explosion 1",txtShape_irregularSeal2:"Explosion 2",txtShape_star4:"4-Point Star",txtShape_star5:"5-Point Star",txtShape_star6:"6-Point Star",txtShape_star7:"7-Point Star",txtShape_star8:"8-Point Star",txtShape_star10:"10-Point Star",txtShape_star12:"12-Point Star",txtShape_star16:"16-Point Star",txtShape_star24:"24-Point Star",txtShape_star32:"32-Point Star",txtShape_ribbon2:"Up Ribbon",txtShape_ribbon:"Down Ribbon",txtShape_ellipseRibbon2:"Curved Up Ribbon",txtShape_ellipseRibbon:"Curved Down Ribbon",txtShape_verticalScroll:"Vertical Scroll",txtShape_horizontalScroll:"Horizontal Scroll",txtShape_wave:"Wave",txtShape_doubleWave:"Double Wave",txtShape_wedgeRectCallout:"Rectangular Callout",txtShape_wedgeRoundRectCallout:"Rounded Rectangular Callout",txtShape_wedgeEllipseCallout:"Oval Callout",txtShape_cloudCallout:"Cloud Callout",txtShape_borderCallout1:"Line Callout 1",txtShape_borderCallout2:"Line Callout 2",txtShape_borderCallout3:"Line Callout 3",txtShape_accentCallout1:"Line Callout 1 (Accent Bar)",txtShape_accentCallout2:"Line Callout 2 (Accent Bar)",txtShape_accentCallout3:"Line Callout 3 (Accent Bar)",txtShape_callout1:"Line Callout 1 (No Border)",txtShape_callout2:"Line Callout 2 (No Border)",txtShape_callout3:"Line Callout 3 (No Border)",txtShape_accentBorderCallout1:"Line Callout 1 (Border and Accent Bar)",txtShape_accentBorderCallout2:"Line Callout 2 (Border and Accent Bar)",txtShape_accentBorderCallout3:"Line Callout 3 (Border and Accent Bar)",txtShape_actionButtonBackPrevious:"Back or Previous Button",txtShape_actionButtonForwardNext:"Forward or Next Button",txtShape_actionButtonBeginning:"Beginning Button",txtShape_actionButtonEnd:"End Button",txtShape_actionButtonHome:"Home Button",txtShape_actionButtonInformation:"Information Button",txtShape_actionButtonReturn:"Return Button",txtShape_actionButtonMovie:"Movie Button",txtShape_actionButtonDocument:"Document Button",txtShape_actionButtonSound:"Sound Button",txtShape_actionButtonHelp:"Help Button",txtShape_actionButtonBlank:"Blank Button",txtShape_roundRect:"Round Corner Rectangle",txtShape_snip1Rect:"Snip Single Corner Rectangle",txtShape_snip2SameRect:"Snip Same Side Corner Rectangle",txtShape_snip2DiagRect:"Snip Diagonal Corner Rectangle",txtShape_snipRoundRect:"Snip and Round Single Corner Rectangle",txtShape_round1Rect:"Round Single Corner Rectangle",txtShape_round2SameRect:"Round Same Side Corner Rectangle",txtShape_round2DiagRect:"Round Diagonal Corner Rectangle",txtShape_line:"Line",txtShape_lineWithArrow:"Arrow",txtShape_lineWithTwoArrows:"Double Arrow",txtShape_bentConnector5:"Elbow Connector",txtShape_bentConnector5WithArrow:"Elbow Arrow Connector",txtShape_bentConnector5WithTwoArrows:"Elbow Double-Arrow Connector",txtShape_curvedConnector3:"Curved Connector",txtShape_curvedConnector3WithArrow:"Curved Arrow Connector",txtShape_curvedConnector3WithTwoArrows:"Curved Double-Arrow Connector",txtShape_spline:"Curve",txtShape_polyline1:"Scribble",txtShape_polyline2:"Freeform",errorChangeArray:"You cannot change part of an array.",errorMultiCellFormula:"Multi-cell array formulas are not allowed in tables.",errorEmailClient:"No email client could be found",txtPrintArea:"Print_Area",txtTable:"Table",textCustomLoader:"Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.",errorNoDataToParse:"No data was selected to parse.",errorCannotUngroup:"Cannot ungroup. To start an outline, select the detail rows or columns and group them.",errorFrmlMaxTextLength:"Text values in formulas are limited to 255 characters.
Use the CONCATENATE function or concatenation operator (&)",waitText:"Please, wait...",errorDataValidate:"The value you entered is not valid.
A user has restricted values that can be entered into this cell.",txtConfidential:"Confidential",txtPreparedBy:"Prepared by",txtPage:"Page",txtPageOf:"Page %1 of %2",txtPages:"Pages",txtDate:"Date",txtTime:"Time",txtTab:"Tab",txtFile:"File"}}(),SSE.Controllers.Main||{}))}),define("common/main/lib/view/DocumentAccessDialog",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.DocumentAccessDialog=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:600,height:536,header:!0},t),this.template=['
'].join(""),e.tpl=_.template(this.template)(e),this.settingsurl=t.settingsurl||"",Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=500,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-sharing-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-sharing-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.settingsurl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&"onlyoffice"==t.Referer&&(t.needUpdate&&this.trigger("accessrights",this,t.sharingSettings),Common.NotificationCenter.trigger("window:close",this))},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Sharing Settings",textLoading:"Loading"},Common.Views.DocumentAccessDialog||{}))}),define("spreadsheeteditor/main/app/view/FileMenuPanels",["common/main/lib/view/DocumentAccessDialog"],function(){"use strict";!SSE.Views.FileMenuPanels&&(SSE.Views.FileMenuPanels={}),SSE.Views.FileMenuPanels.ViewSaveAs=Common.UI.BaseView.extend({el:"#panel-saveas",menu:void 0,formats:[[{name:"XLSX",imgCls:"xlsx",type:Asc.c_oAscFileType.XLSX},{name:"PDF",imgCls:"pdf",type:Asc.c_oAscFileType.PDF},{name:"ODS",imgCls:"ods",type:Asc.c_oAscFileType.ODS},{name:"CSV",imgCls:"csv",type:Asc.c_oAscFileType.CSV}],[{name:"XLTX",imgCls:"xltx",type:Asc.c_oAscFileType.XLTX},{name:"PDFA",imgCls:"pdfa",type:Asc.c_oAscFileType.PDFA},{name:"OTS",imgCls:"ots",type:Asc.c_oAscFileType.OTS}]],template:_.template(["","<% _.each(rows, function(row) { %>","","<% _.each(row, function(item) { %>",'","<% }) %>","","<% }) %>","
','',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({rows:this.formats})),$(".btn-doc-format",this.el).on("click",_.bind(this.onFormatClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onFormatClick:function(t){var e=t.currentTarget.attributes.format;!_.isUndefined(e)&&this.menu&&this.menu.fireEvent("saveas:format",[this.menu,parseInt(e.value)])}}),SSE.Views.FileMenuPanels.ViewSaveCopy=Common.UI.BaseView.extend({el:"#panel-savecopy",menu:void 0,formats:[[{name:"XLSX",imgCls:"xlsx",type:Asc.c_oAscFileType.XLSX,ext:".xlsx"},{name:"PDF",imgCls:"pdf",type:Asc.c_oAscFileType.PDF,ext:".pdf"},{name:"ODS",imgCls:"ods",type:Asc.c_oAscFileType.ODS,ext:".ods"},{name:"CSV",imgCls:"csv",type:Asc.c_oAscFileType.CSV,ext:".csv"}],[{name:"XLTX",imgCls:"xltx",type:Asc.c_oAscFileType.XLTX,ext:".xltx"},{name:"PDFA",imgCls:"pdfa",type:Asc.c_oAscFileType.PDFA,ext:".pdf"},{name:"OTS",imgCls:"ots",type:Asc.c_oAscFileType.OTS,ext:".ots"}]],template:_.template(["","<% _.each(rows, function(row) { %>","","<% _.each(row, function(item) { %>",'","<% }) %>","","<% }) %>","
','',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({rows:this.formats})),$(".btn-doc-format",this.el).on("click",_.bind(this.onFormatClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onFormatClick:function(t){var e=t.currentTarget.attributes.format,i=t.currentTarget.attributes["format-ext"];_.isUndefined(e)||_.isUndefined(i)||!this.menu||this.menu.fireEvent("savecopy:format",[this.menu,parseInt(e.value),i.value])}}),SSE.Views.FileMenuPanels.Settings=Common.UI.BaseView.extend(_.extend({el:"#panel-settings",menu:void 0,template:_.template(['
','
','
','
','
',"
","
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template()),this.generalSettings=new SSE.Views.FileMenuPanels.MainSettingsGeneral({menu:this.menu}),this.generalSettings.options={alias:"MainSettingsGeneral"},this.generalSettings.render(),this.printSettings=SSE.getController("Print").getView("MainSettingsPrint"),this.printSettings.menu=this.menu,this.printSettings.render($("#panel-settings-print")),this.viewSettingsPicker=new Common.UI.DataView({el:$("#id-settings-menu"),store:new Common.UI.DataViewStore([{name:this.txtGeneral,panel:this.generalSettings,iconCls:"mnu-settings-general",selected:!0},{name:this.txtPageSettings,panel:this.printSettings,iconCls:"mnu-print"}]),itemTemplate:_.template(['
','
',"
<%= name %>","
"].join(""))}),this.viewSettingsPicker.on("item:select",_.bind(function(t,e,i){var n=i.get("panel");$("#id-settings-content > div").removeClass("active"),n.$el.addClass("active"),n.show()},this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments);var t=this.viewSettingsPicker.getSelectedRec();t&&t.get("panel").show()},setMode:function(t){this.mode=t,this.mode.canPrint||this.viewSettingsPicker.store.pop(),this.generalSettings&&this.generalSettings.setMode(this.mode)},setApi:function(t){this.generalSettings&&this.generalSettings.setApi(t)},txtGeneral:"General",txtPageSettings:"Page Settings"},SSE.Views.FileMenuPanels.Settings||{})),SSE.Views.MainSettingsPrint=Common.UI.BaseView.extend(_.extend({menu:void 0,template:_.template(['',"",'','',"",'','',"",'','',"",'',"",'','',"",'',"",'','',"",'',"",'','","",'',"",'','","",'','',"",'','',"","
','',"","","","","",'','',"","","","","","",'','',"","
","
','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.spinners=[],this._initSettings=!0},render:function(t){return t&&this.setElement(t,!1),$(this.el).html(this.template({scope:this})),this.cmbSheet=new Common.UI.ComboBox({el:$("#advsettings-print-combo-sheets"),style:"width: 242px;",menuStyle:"min-width: 242px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[]}),this.cmbPaperSize=new Common.UI.ComboBox({el:$("#advsettings-print-combo-pages"),style:"width: 242px;",menuStyle:"max-height: 280px; min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:"215.9|279.4",displayValue:"US Letter (21,59cm x 27,94cm)",caption:"US Letter"},{value:"215.9|355.6",displayValue:"US Legal (21,59cm x 35,56cm)",caption:"US Legal"},{value:"210|297",displayValue:"A4 (21cm x 29,7cm)",caption:"A4"},{value:"148|210",displayValue:"A5 (14,8cm x 21cm)",caption:"A5"},{value:"176|250",displayValue:"B5 (17,6cm x 25cm)",caption:"B5"},{value:"104.8|241.3",displayValue:"Envelope #10 (10,48cm x 24,13cm)",caption:"Envelope #10"},{value:"110|220",displayValue:"Envelope DL (11cm x 22cm)",caption:"Envelope DL"},{value:"279.4|431.8",displayValue:"Tabloid (27,94cm x 43,178m)",caption:"Tabloid"},{value:"297|420",displayValue:"A3 (29,7cm x 42cm)",caption:"A3"},{value:"304.8|457.1",displayValue:"Tabloid Oversize (30,48cm x 45,71cm)",caption:"Tabloid Oversize"},{value:"196.8|273",displayValue:"ROC 16K (19,68cm x 27,3cm)",caption:"ROC 16K"},{value:"119.9|234.9",displayValue:"Envelope Choukei 3 (11,99cm x 23,49cm)",caption:"Envelope Choukei 3"},{value:"330.2|482.5",displayValue:"Super B/A3 (33,02cm x 48,25cm)",caption:"Super B/A3"}]}),this.cmbPaperOrientation=new Common.UI.ComboBox({el:$("#advsettings-print-combo-orient"),style:"width: 132px;",menuStyle:"min-width: 132px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPageOrientation.PagePortrait,displayValue:this.strPortrait},{value:Asc.c_oAscPageOrientation.PageLandscape,displayValue:this.strLandscape}]}),this.cmbLayout=new Common.UI.ComboBox({el:$("#advsettings-print-combo-layout"),style:"width: 242px;",menuStyle:"min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:0,displayValue:this.textActualSize},{value:1,displayValue:this.textFitPage},{value:2,displayValue:this.textFitCols},{value:3,displayValue:this.textFitRows}]}),this.chPrintGrid=new Common.UI.CheckBox({el:$("#advsettings-print-chb-grid"),labelText:this.textPrintGrid}),this.chPrintRows=new Common.UI.CheckBox({el:$("#advsettings-print-chb-rows"),labelText:this.textPrintHeadings}),this.spnMarginTop=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-top"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginTop),this.spnMarginBottom=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-bottom"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginBottom),this.spnMarginLeft=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-left"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginLeft),this.spnMarginRight=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-right"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginRight),this.btnOk=new Common.UI.Button({el:"#advsettings-print-button-save"}),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this.fireEvent("render:after",this),this},updateMetricUnit:function(){if(this.spinners)for(var t=0;t','','','
',"",'','','','
',"",'','','','',"",'','','','',"",'',"",'','
',"",'','','','','
','
',"",'',"",'','
',"",'',"",'','',"",'','','','',"",'','','','','
','
',"",'','','','','
','
',"",'',"",'','',"",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){$(this.el).html(this.template({scope:this})),this.chLiveComment=new Common.UI.CheckBox({el:$("#fms-chb-live-comment"),labelText:this.strLiveComment}).on("change",_.bind(function(t,e,i,n){this.chResolvedComment.setDisabled("checked"!==t.getValue())},this)),this.chResolvedComment=new Common.UI.CheckBox({el:$("#fms-chb-resolved-comment"),labelText:this.strResolvedComment}),this.chR1C1Style=new Common.UI.CheckBox({el:$("#fms-chb-r1c1-style"),labelText:this.strR1C1}),this.cmbCoAuthMode=new Common.UI.ComboBox({el:$("#fms-cmb-coauth-mode"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:1,displayValue:this.strFast,descValue:this.strCoAuthModeDescFast},{value:0,displayValue:this.strStrict,descValue:this.strCoAuthModeDescStrict}]}).on("selected",_.bind(function(t,e){1==e.value&&"checked"!==this.chAutosave.getValue()&&this.chAutosave.setValue(1),this.lblCoAuthMode.text(e.descValue)},this)),this.lblCoAuthMode=$("#fms-lbl-coauth-mode"),this.cmbZoom=new Common.UI.ComboBox({el:$("#fms-cmb-zoom"),style:"width: 160px;",editable:!1,cls:"input-group-nr",menuStyle:"max-height: 210px;",data:[{value:50,displayValue:"50%"},{value:60,displayValue:"60%"},{value:70,displayValue:"70%"},{value:80,displayValue:"80%"},{value:90,displayValue:"90%"},{value:100,displayValue:"100%"},{value:110,displayValue:"110%"},{value:120,displayValue:"120%"},{value:150,displayValue:"150%"},{value:175,displayValue:"175%"},{value:200,displayValue:"200%"}]}),this.cmbFontRender=new Common.UI.ComboBox({el:$("#fms-cmb-font-render"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscFontRenderingModeType.hintingAndSubpixeling,displayValue:this.txtWin},{value:Asc.c_oAscFontRenderingModeType.noHinting,displayValue:this.txtMac},{value:Asc.c_oAscFontRenderingModeType.hinting,displayValue:this.txtNative}]}),this.chAutosave=new Common.UI.CheckBox({el:$("#fms-chb-autosave"),labelText:this.strAutosave}).on("change",_.bind(function(t,e,i,n){"checked"!==t.getValue()&&this.cmbCoAuthMode.getValue()&&(this.cmbCoAuthMode.setValue(0),this.lblCoAuthMode.text(this.strCoAuthModeDescStrict))},this)),this.lblAutosave=$("#fms-lbl-autosave"),this.chForcesave=new Common.UI.CheckBox({el:$("#fms-chb-forcesave"),labelText:this.strForcesave}),this.cmbUnit=new Common.UI.ComboBox({el:$("#fms-cmb-unit"), -style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:Common.Utils.Metric.c_MetricUnits.cm,displayValue:this.txtCm},{value:Common.Utils.Metric.c_MetricUnits.pt,displayValue:this.txtPt},{value:Common.Utils.Metric.c_MetricUnits.inch,displayValue:this.txtInch}]}),this.cmbFuncLocale=new Common.UI.ComboBox({el:$("#fms-cmb-func-locale"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:"en",displayValue:this.txtEn,exampleValue:this.txtExampleEn},{value:"de",displayValue:this.txtDe,exampleValue:this.txtExampleDe},{value:"es",displayValue:this.txtEs,exampleValue:this.txtExampleEs},{value:"fr",displayValue:this.txtFr,exampleValue:this.txtExampleFr},{value:"it",displayValue:this.txtIt,exampleValue:this.txtExampleIt},{value:"ru",displayValue:this.txtRu,exampleValue:this.txtExampleRu},{value:"pl",displayValue:this.txtPl,exampleValue:this.txtExamplePl}]}).on("selected",_.bind(function(t,e){this.updateFuncExample(e.exampleValue)},this));var t=[{value:1068},{value:1026},{value:1029},{value:1031},{value:2055},{value:1032},{value:3081},{value:2057},{value:1033},{value:3082},{value:2058},{value:1035},{value:1036},{value:1040},{value:1041},{value:1042},{value:1062},{value:1043},{value:1045},{value:1046},{value:2070},{value:1049},{value:1051},{value:1060},{value:2077},{value:1053},{value:1055},{value:1058},{value:1066},{value:2052}];return t.forEach(function(t){var e=Common.util.LanguageInfo.getLocalLanguageName(t.value);t.displayValue=e[1],t.langName=e[0]}),this.cmbRegSettings=new Common.UI.ComboBox({el:$("#fms-cmb-reg-settings"),style:"width: 160px;",menuStyle:"max-height: 185px;",editable:!1,cls:"input-group-nr",data:t,template:_.template(['','','','','",""].join(""))}).on("selected",_.bind(function(t,e){this.updateRegionalExample(e.value)},this)),this.cmbRegSettings.scroller&&this.cmbRegSettings.scroller.update({alwaysVisibleY:!0}),this.btnApply=new Common.UI.Button({el:"#fms-btn-apply"}),this.btnApply.on("click",_.bind(this.applySettings,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateSettings()},setMode:function(t){this.mode=t,$("tr.edit",this.el)[t.isEdit?"show":"hide"](),$("tr.autosave",this.el)[t.isEdit?"show":"hide"](),this.mode.isDesktopApp&&this.mode.isOffline&&(this.chAutosave.setCaption(this.strAutoRecover),this.lblAutosave.text(this.textAutoRecover)),$("tr.forcesave",this.el)[t.canForcesave?"show":"hide"](),$("tr.comments",this.el)[t.canCoAuthoring?"show":"hide"](),$("tr.coauth.changes",this.el)[t.isEdit&&!t.isOffline&&t.canCoAuthoring?"show":"hide"]()},setApi:function(t){this.api=t},updateSettings:function(){var t=Common.Utils.InternalSettings.get("sse-settings-zoom");t=null!==t?parseInt(t):this.mode.customization&&this.mode.customization.zoom?parseInt(this.mode.customization.zoom):100;var e=this.cmbZoom.store.findWhere({value:t});this.cmbZoom.setValue(e?parseInt(e.get("value")):t>0?t+"%":100),this.chLiveComment.setValue(Common.Utils.InternalSettings.get("sse-settings-livecomment")),this.chResolvedComment.setValue(Common.Utils.InternalSettings.get("sse-settings-resolvedcomment")),this.chR1C1Style.setValue(Common.Utils.InternalSettings.get("sse-settings-r1c1"));var i=Common.Utils.InternalSettings.get("sse-settings-coauthmode");e=this.cmbCoAuthMode.store.findWhere({value:i?1:0}),this.cmbCoAuthMode.setValue(e?e.get("value"):1),this.lblCoAuthMode.text(e?e.get("descValue"):this.strCoAuthModeDescFast),t=Common.Utils.InternalSettings.get("sse-settings-fontrender"),e=this.cmbFontRender.store.findWhere({value:parseInt(t)}),this.cmbFontRender.setValue(e?e.get("value"):window.devicePixelRatio>1?Asc.c_oAscFontRenderingModeType.noHinting:Asc.c_oAscFontRenderingModeType.hintingAndSubpixeling),t=Common.Utils.InternalSettings.get("sse-settings-unit"),e=this.cmbUnit.store.findWhere({value:t}),this.cmbUnit.setValue(e?parseInt(e.get("value")):Common.Utils.Metric.getDefaultMetric()),this._oldUnits=this.cmbUnit.getValue(),t=Common.Utils.InternalSettings.get("sse-settings-autosave"),this.chAutosave.setValue(1==t),this.mode.canForcesave&&this.chForcesave.setValue(Common.Utils.InternalSettings.get("sse-settings-forcesave")),t=Common.Utils.InternalSettings.get("sse-settings-func-locale"),e=this.cmbFuncLocale.store.findWhere({value:t}),!e&&t&&(e=this.cmbFuncLocale.store.findWhere({value:t.split(/[\-\_]/)[0]})),this.cmbFuncLocale.setValue(e?e.get("value"):"en"),this.updateFuncExample(e?e.get("exampleValue"):this.txtExampleEn),t=this.api.asc_getLocale(),t?(e=this.cmbRegSettings.store.findWhere({value:t}),this.cmbRegSettings.setValue(e?e.get("value"):Common.util.LanguageInfo.getLocalLanguageName(t)[1]),e&&(t=this.cmbRegSettings.getValue())):(t=this.mode.lang?parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)):1033,this.cmbRegSettings.setValue(Common.util.LanguageInfo.getLocalLanguageName(t)[1])),this.updateRegionalExample(t)},applySettings:function(){Common.localStorage.setItem("sse-settings-zoom",this.cmbZoom.getValue()),Common.Utils.InternalSettings.set("sse-settings-zoom",Common.localStorage.getItem("sse-settings-zoom")),Common.localStorage.setItem("sse-settings-livecomment",this.chLiveComment.isChecked()?1:0),Common.localStorage.setItem("sse-settings-resolvedcomment",this.chResolvedComment.isChecked()?1:0),this.mode.isEdit&&!this.mode.isOffline&&this.mode.canCoAuthoring&&Common.localStorage.setItem("sse-settings-coauthmode",this.cmbCoAuthMode.getValue()),Common.localStorage.setItem("sse-settings-r1c1",this.chR1C1Style.isChecked()?1:0),Common.localStorage.setItem("sse-settings-fontrender",this.cmbFontRender.getValue()),Common.localStorage.setItem("sse-settings-unit",this.cmbUnit.getValue()),Common.localStorage.setItem("sse-settings-autosave",this.chAutosave.isChecked()?1:0),this.mode.canForcesave&&Common.localStorage.setItem("sse-settings-forcesave",this.chForcesave.isChecked()?1:0),Common.localStorage.setItem("sse-settings-func-locale",this.cmbFuncLocale.getValue()),this.cmbRegSettings.getSelectedRecord()&&Common.localStorage.setItem("sse-settings-reg-settings",this.cmbRegSettings.getValue()),Common.localStorage.save(),this.menu&&(this.menu.fireEvent("settings:apply",[this.menu]),this._oldUnits!==this.cmbUnit.getValue()&&Common.NotificationCenter.trigger("settings:unitschanged",this))},updateRegionalExample:function(t){if(this.api){var e="";if(t){var i=new Asc.asc_CFormatCellsInfo;i.asc_setType(Asc.c_oAscNumFormatType.None),i.asc_setSymbol(t);var n=this.api.asc_getFormatCells(i);e=this.api.asc_getLocaleExample(n[4],1000.01,t),e=e+" "+this.api.asc_getLocaleExample(n[5],Asc.cDate().getExcelDateWithTime(),t),e=e+" "+this.api.asc_getLocaleExample(n[6],Asc.cDate().getExcelDateWithTime(),t)}$("#fms-lbl-reg-settings").text(_.isEmpty(e)?"":this.strRegSettingsEx+e)}var o=this.cmbRegSettings.$el.find(".input-icon"),s=o.attr("lang"),a=Common.util.LanguageInfo.getLocalLanguageName(t)[0];s&&o.removeClass(s),o.addClass(a).attr("lang",a)},updateFuncExample:function(t){$("#fms-lbl-func-locale").text(_.isEmpty(t)?"":this.strRegSettingsEx+t)},strLiveComment:"Turn on option",strZoom:"Default Zoom Value",okButtonText:"Apply",txtLiveComment:"Live Commenting",txtWin:"as Windows",txtMac:"as OS X",txtNative:"Native",strFontRender:"Font Hinting",strUnit:"Unit of Measurement",txtCm:"Centimeter",txtPt:"Point",strAutosave:"Turn on autosave",textAutoSave:"Autosave",txtEn:"English",txtDe:"Deutsch",txtRu:"Russian",txtPl:"Polish",txtEs:"Spanish",txtFr:"French",txtIt:"Italian",txtExampleEn:" SUM; MIN; MAX; COUNT",txtExampleDe:" SUMME; MIN; MAX; ANZAHL",txtExampleRu:" СУММ; МИН; МАКС; СЧЁТ",txtExamplePl:" SUMA; MIN; MAX; ILE.LICZB",txtExampleEs:" SUMA; MIN; MAX; CALCULAR",txtExampleFr:" SOMME; MIN; MAX; NB",txtExampleIt:" SOMMA; MIN; MAX; CONTA.NUMERI",strFuncLocale:"Formula Language",strFuncLocaleEx:"Example: SUM; MIN; MAX; COUNT",strRegSettings:"Regional Settings",strRegSettingsEx:"Example: ",strCoAuthMode:"Co-editing mode",strCoAuthModeDescFast:"Other users will see your changes at once",strCoAuthModeDescStrict:"You will need to accept changes before you can see them",strFast:"Fast",strStrict:"Strict",textAutoRecover:"Autorecover",strAutoRecover:"Turn on autorecover",txtInch:"Inch",textForceSave:"Save to Server",strForcesave:"Always save to server (otherwise save to server on document close)",strResolvedComment:"Turn on display of the resolved comments",textRefStyle:"Reference Style",strR1C1:"Turn on R1C1 style"},SSE.Views.FileMenuPanels.MainSettingsGeneral||{})),SSE.Views.FileMenuPanels.RecentFiles=Common.UI.BaseView.extend({el:"#panel-recentfiles",menu:void 0,template:_.template(['
'].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.recent=t.recent},render:function(){return $(this.el).html(this.template()),this.viewRecentPicker=new Common.UI.DataView({el:$("#id-recent-view"),store:new Common.UI.DataViewStore(this.recent),itemTemplate:_.template(['
','
','
<%= Common.Utils.String.htmlEncode(title) %>
','
<%= Common.Utils.String.htmlEncode(folder) %>
',"
"].join(""))}),this.viewRecentPicker.on("item:click",_.bind(this.onRecentFileClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onRecentFileClick:function(t,e,i){this.menu&&this.menu.fireEvent("recent:open",[this.menu,i.get("url")])}}),SSE.Views.FileMenuPanels.CreateNew=Common.UI.BaseView.extend(_.extend({el:"#panel-createnew",menu:void 0,events:function(){return{"click .blank-document-btn":_.bind(this._onBlankDocument,this),"click .thumb-list .thumb-wrap":_.bind(this._onDocumentTemplate,this)}},template:_.template(['

<%= scope.fromBlankText %>


','
','
','','',"","
",'
',"

<%= scope.newDocumentText %>

","<%= scope.newDescriptionText %>","
","
","

<%= scope.fromTemplateText %>


",'
',"<% _.each(docs, function(item) { %>",'
','
\") } else { print(\">\") } %>","
",'
<%= item.name %>
',"
","<% }) %>","
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({scope:this,docs:this.options[0].docs})),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},_onBlankDocument:function(){this.menu&&this.menu.fireEvent("create:new",[this.menu,"blank"])},_onDocumentTemplate:function(t){this.menu&&this.menu.fireEvent("create:new",[this.menu,t.currentTarget.attributes.template.value])},fromBlankText:"From Blank",newDocumentText:"New Spreadsheet",newDescriptionText:"Create a new blank text document which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a document of a certain type or purpose where some styles have already been pre-applied.",fromTemplateText:"From Template"},SSE.Views.FileMenuPanels.CreateNew||{})),SSE.Views.FileMenuPanels.DocumentInfo=Common.UI.BaseView.extend(_.extend({el:"#panel-info",menu:void 0,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.rendered=!1,this.template=_.template(['',"",'",'',"","",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"","",'",'","","
',"","",'',"","
","
"].join("")),this.menu=t.menu,this.coreProps=null,this.authors=[],this._locked=!1},render:function(){$(this.el).html(this.template());var t=this;this.lblPlacement=$("#id-info-placement"),this.lblOwner=$("#id-info-owner"),this.lblUploaded=$("#id-info-uploaded");var e=function(t,e){if(e.keyCode===Common.UI.Keys.ESC){var i=t._input.val(),n=t.getValue();i!==n&&(t.setValue(n),e.stopPropagation())}};return this.inputTitle=new Common.UI.InputField({el:$("#id-info-title"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putTitle(t.inputTitle.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.inputSubject=new Common.UI.InputField({el:$("#id-info-subject"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putSubject(t.inputSubject.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.inputComment=new Common.UI.InputField({el:$("#id-info-comment"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putDescription(t.inputComment.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.lblModifyDate=$("#id-info-modify-date"),this.lblModifyBy=$("#id-info-modify-by"),this.lblDate=$("#id-info-date"),this.lblApplication=$("#id-info-appname"),this.tblAuthor=$("#id-info-author table"),this.trAuthor=$("#id-info-add-author").closest("tr"),this.authorTpl='
',this.tblAuthor.on("click",function(e){var i=$(e.target);if(i.hasClass("close")&&!i.hasClass("disabled")){var n=i.closest("tr"),o=t.tblAuthor.find("tr").index(n);n.remove(),t.authors.splice(o,1),t.coreProps&&t.api&&(t.coreProps.asc_putCreator(t.authors.join(";")),t.api.asc_setCoreProps(t.coreProps))}}),this.inputAuthor=new Common.UI.InputField({el:$("#id-info-add-author"),style:"width: 200px;",validateOnBlur:!1,placeHolder:this.txtAddAuthor}).on("changed:after",function(e,i,n){if(i!=n){var o=i.trim();o&&o!==n.trim()&&(o.split(/\s*[,;]\s*/).forEach(function(e){var i=e.trim();if(i){var n=$(Common.Utils.String.format(t.authorTpl,Common.Utils.String.htmlEncode(i)));t.trAuthor.before(n),t.authors.push(e)}}),t.inputAuthor.setValue(""),t.coreProps&&t.api&&(t.coreProps.asc_putCreator(t.authors.join(";")),t.api.asc_setCoreProps(t.coreProps)))}}).on("keydown:before",e),this.rendered=!0,this.updateInfo(this.doc),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateFileInfo()},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments)},updateInfo:function(t){if(!this.doc&&t&&t.info&&(t.info.author&&console.log("Obsolete: The 'author' parameter of the document 'info' section is deprecated. Please use 'owner' instead."),t.info.created&&console.log("Obsolete: The 'created' parameter of the document 'info' section is deprecated. Please use 'uploaded' instead.")),this.doc=t,this.rendered){var e=!1;if(t=t||{},t.info){t.info.folder&&this.lblPlacement.text(t.info.folder),e=this._ShowHideInfoItem(this.lblPlacement,void 0!==t.info.folder&&null!==t.info.folder)||e;var i=t.info.owner||t.info.author;i&&this.lblOwner.text(i),e=this._ShowHideInfoItem(this.lblOwner,!!i)||e,i=t.info.uploaded||t.info.created,i&&this.lblUploaded.text(i),e=this._ShowHideInfoItem(this.lblUploaded,!!i)||e}else this._ShowHideDocInfo(!1);$("tr.divider.general",this.el)[e?"show":"hide"]();var n=this.api?this.api.asc_getAppProps():null;if(n&&(n=(n.asc_getApplication()||"")+" "+(n.asc_getAppVersion()||""),this.lblApplication.text(n)),this._ShowHideInfoItem(this.lblApplication,!!n),this.coreProps=this.api?this.api.asc_getCoreProps():null,this.coreProps){var i=this.coreProps.asc_getCreated();i&&this.lblDate.text(i.toLocaleString()),this._ShowHideInfoItem(this.lblDate,!!i)}}},updateFileInfo:function(){if(this.rendered){var t,e=this,i=this.api?this.api.asc_getCoreProps():null;if(this.coreProps=i,i){var n=!1;t=i.asc_getModified(),t&&this.lblModifyDate.text(t.toLocaleString()),n=this._ShowHideInfoItem(this.lblModifyDate,!!t)||n,t=i.asc_getLastModifiedBy(),t&&this.lblModifyBy.text(t),n=this._ShowHideInfoItem(this.lblModifyBy,!!t)||n,$("tr.divider.modify",this.el)[n?"show":"hide"](),t=i.asc_getTitle(),this.inputTitle.setValue(t||""),t=i.asc_getSubject(),this.inputSubject.setValue(t||""),t=i.asc_getDescription(),this.inputComment.setValue(t||""),this.tblAuthor.find("tr:not(:last-of-type)").remove(),this.authors=[],t=i.asc_getCreator(),t&&t.split(/\s*[,;]\s*/).forEach(function(t){var i=$(Common.Utils.String.format(e.authorTpl,Common.Utils.String.htmlEncode(t)));e.trAuthor.before(i),e.authors.push(t)}),this.tblAuthor.find(".close").toggleClass("hidden",!this.mode.isEdit)}this.SetDisabled()}},_ShowHideInfoItem:function(t,e){return t.closest("tr")[e?"show":"hide"](),e},_ShowHideDocInfo:function(t){this._ShowHideInfoItem(this.lblPlacement,t),this._ShowHideInfoItem(this.lblOwner,t),this._ShowHideInfoItem(this.lblUploaded,t)},setMode:function(t){return this.mode=t,this.inputAuthor.setVisible(t.isEdit),this.tblAuthor.find(".close").toggleClass("hidden",!t.isEdit),this.SetDisabled(),this},setApi:function(t){return this.api=t,this.api.asc_registerCallback("asc_onLockCore",_.bind(this.onLockCore,this)),this.updateInfo(this.doc),this},onLockCore:function(t){this._locked=t,this.updateFileInfo()},SetDisabled:function(){var t=!this.mode.isEdit||this._locked;this.inputTitle.setDisabled(t),this.inputSubject.setDisabled(t),this.inputComment.setDisabled(t),this.inputAuthor.setDisabled(t),this.tblAuthor.find(".close").toggleClass("disabled",this._locked),this.tblAuthor.toggleClass("disabled",t)},txtPlacement:"Location",txtOwner:"Owner",txtUploaded:"Uploaded",txtAppName:"Application",txtTitle:"Title",txtSubject:"Subject",txtComment:"Comment",txtModifyDate:"Last Modified",txtModifyBy:"Last Modified By",txtCreated:"Created",txtAuthor:"Author",txtAddAuthor:"Add Author",txtAddText:"Add Text",txtMinutes:"min"},SSE.Views.FileMenuPanels.DocumentInfo||{})),SSE.Views.FileMenuPanels.DocumentRights=Common.UI.BaseView.extend(_.extend({el:"#panel-rights",menu:void 0,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.rendered=!1,this.template=_.template(['','','",'',"",'','","","
"].join("")),this.templateRights=_.template(["","<% _.each(users, function(item) { %>","",'',"","","<% }); %>","
<%= Common.Utils.String.htmlEncode(item.user) %><%= Common.Utils.String.htmlEncode(item.permissions) %>
"].join("")),this.menu=t.menu},render:function(){return $(this.el).html(this.template()),this.cntRights=$("#id-info-rights"),this.btnEditRights=new Common.UI.Button({el:"#id-info-btn-edit"}),this.btnEditRights.on("click",_.bind(this.changeAccessRights,this)),this.rendered=!0,this.updateInfo(this.doc),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),Common.NotificationCenter.on("collaboration:sharing",_.bind(this.changeAccessRights,this)),Common.NotificationCenter.on("collaboration:sharingdeny",_.bind(this.onLostEditRights,this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments)},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments)},updateInfo:function(t){this.doc=t,this.rendered&&(t=t||{},t.info?(t.info.sharingSettings&&this.cntRights.html(this.templateRights({users:t.info.sharingSettings})),this._ShowHideInfoItem("rights",void 0!==t.info.sharingSettings&&null!==t.info.sharingSettings&&t.info.sharingSettings.length>0),this._ShowHideInfoItem("edit-rights",!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&!0!==this._readonlyRights)):this._ShowHideDocInfo(!1))},_ShowHideInfoItem:function(t,e){$("tr."+t,this.el)[e?"show":"hide"]()},_ShowHideDocInfo:function(t){this._ShowHideInfoItem("rights",t),this._ShowHideInfoItem("edit-rights",t)},setMode:function(t){return this.sharingSettingsUrl=t.sharingSettingsUrl,!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&Common.Gateway.on("showsharingsettings",_.bind(this.changeAccessRights,this)),!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&Common.Gateway.on("setsharingsettings",_.bind(this.setSharingSettings,this)),this},changeAccessRights:function(t,e,i){if(!this._docAccessDlg&&!this._readonlyRights){var n=this;n._docAccessDlg=new Common.Views.DocumentAccessDialog({settingsurl:this.sharingSettingsUrl}),n._docAccessDlg.on("accessrights",function(t,e){n.updateSharingSettings(e)}).on("close",function(t){n._docAccessDlg=void 0}),n._docAccessDlg.show()}},setSharingSettings:function(t){t&&this.updateSharingSettings(t.sharingSettings)},updateSharingSettings:function(t){this.doc.info.sharingSettings=t,this._ShowHideInfoItem("rights",void 0!==this.doc.info.sharingSettings&&null!==this.doc.info.sharingSettings&&this.doc.info.sharingSettings.length>0),this.cntRights.html(this.templateRights({users:this.doc.info.sharingSettings})),Common.NotificationCenter.trigger("mentions:clearusers",this)},onLostEditRights:function(){this._readonlyRights=!0,this.rendered&&this._ShowHideInfoItem("edit-rights",!1)},txtRights:"Persons who have rights",txtBtnAccessRights:"Change access rights"},SSE.Views.FileMenuPanels.DocumentRights||{})),SSE.Views.FileMenuPanels.Help=Common.UI.BaseView.extend({el:"#panel-help",menu:void 0,template:_.template(['
','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.urlPref="resources/help/en/",this.en_data=[{src:"ProgramInterface/ProgramInterface.htm",name:"Introducing Spreadsheet Editor user interface",headername:"Program Interface"},{src:"ProgramInterface/FileTab.htm",name:"File tab"},{src:"ProgramInterface/HomeTab.htm",name:"Home Tab"},{src:"ProgramInterface/InsertTab.htm",name:"Insert tab"},{src:"ProgramInterface/PluginsTab.htm",name:"Plugins tab"},{src:"UsageInstructions/OpenCreateNew.htm",name:"Create a new spreadsheet or open an existing one",headername:"Basic operations"},{src:"UsageInstructions/CopyPasteData.htm",name:"Cut/copy/paste data"},{src:"UsageInstructions/UndoRedo.htm",name:"Undo/redo your actions"},{src:"UsageInstructions/ManageSheets.htm",name:"Manage sheets",headername:"Operations with sheets"},{src:"UsageInstructions/FontTypeSizeStyle.htm",name:"Set font type, size, style, and colors",headername:"Cell text formatting"},{src:"UsageInstructions/AddHyperlinks.htm",name:"Add hyperlinks"},{src:"UsageInstructions/ClearFormatting.htm",name:"Clear text, format in a cell, copy cell format"},{src:"UsageInstructions/AddBorders.htm",name:"Add borders",headername:"Editing cell properties"},{src:"UsageInstructions/AlignText.htm",name:"Align data in cells"},{src:"UsageInstructions/MergeCells.htm",name:"Merge cells"},{src:"UsageInstructions/ChangeNumberFormat.htm",name:"Change number format"},{src:"UsageInstructions/InsertDeleteCells.htm",name:"Manage cells, rows, and columns",headername:"Editing rows/columns"},{src:"UsageInstructions/SortData.htm",name:"Sort and filter data"},{src:"UsageInstructions/InsertFunction.htm",name:"Insert function",headername:"Work with functions"},{src:"UsageInstructions/UseNamedRanges.htm",name:"Use named ranges"},{src:"UsageInstructions/InsertImages.htm",name:"Insert images",headername:"Operations on objects"},{src:"UsageInstructions/InsertChart.htm",name:"Insert chart"},{src:"UsageInstructions/InsertAutoshapes.htm",name:"Insert and format autoshapes"},{src:"UsageInstructions/InsertTextObjects.htm",name:"Insert text objects"},{src:"UsageInstructions/ManipulateObjects.htm",name:"Manipulate objects"},{src:"UsageInstructions/InsertEquation.htm",name:"Insert equations",headername:"Math equations"},{src:"HelpfulHints/CollaborativeEditing.htm",name:"Collaborative spreadsheet editing",headername:"Spreadsheet co-editing"},{src:"UsageInstructions/ViewDocInfo.htm",name:"View file information",headername:"Tools and settings"},{src:"UsageInstructions/SavePrintDownload.htm",name:"Save/print/download your spreadsheet"},{src:"HelpfulHints/AdvancedSettings.htm",name:"Advanced settings of Spreadsheet Editor"},{src:"HelpfulHints/Navigation.htm",name:"View settings and navigation tools"},{src:"HelpfulHints/Search.htm",name:"Search and replace functions"},{src:"HelpfulHints/About.htm",name:"About Spreadsheet Editor",headername:"Helpful hints"},{src:"HelpfulHints/SupportedFormats.htm",name:"Supported formats of spreadsheets"},{src:"HelpfulHints/KeyboardShortcuts.htm",name:"Keyboard shortcuts"}],Common.Utils.isIE&&(window.onhelp=function(){return!1})},render:function(){var t=this;return $(this.el).html(this.template()),this.viewHelpPicker=new Common.UI.DataView({el:$("#id-help-contents"),store:new Common.UI.DataViewStore([]),keyMoveDirection:"vertical",itemTemplate:_.template(['
','
<%= name %>
',"
"].join(""))}),this.viewHelpPicker.on("item:add",function(t,e,i){i.has("headername")&&$(e.el).before('
'+i.get("headername")+"
")}),this.viewHelpPicker.on("item:select",function(e,i,n){t.iFrame.src=t.urlPref+n.get("src")}),this.iFrame=document.createElement("iframe"),this.iFrame.src="",this.iFrame.align="top",this.iFrame.frameBorder="0",this.iFrame.width="100%",this.iFrame.height="100%",Common.Gateway.on("internalcommand",function(e){if("help:hyperlink"==e.type){var i=e.data,n=t.viewHelpPicker.store.find(function(t){return i.indexOf(t.get("src"))>0});n&&(t.viewHelpPicker.selectRecord(n,!0),t.viewHelpPicker.scrollToRecord(n))}}),$("#id-help-frame").append(this.iFrame),this},setLangConfig:function(t){var e=this,i=this.viewHelpPicker.store;if(t){t=t.split(/[\-\_]/)[0];var n={dataType:"json",error:function(){e.urlPref.indexOf("resources/help/en/")<0?(e.urlPref="resources/help/en/",i.url="resources/help/en/Contents.json",i.fetch(n)):(e.urlPref="resources/help/en/",i.reset(e.en_data))},success:function(){var t=i.at(0);e.viewHelpPicker.selectRecord(t),e.iFrame.src=e.urlPref+t.get("src")}};i.url="resources/help/"+t+"/Contents.json",i.fetch(n),this.urlPref="resources/help/"+t+"/"}},show:function(){Common.UI.BaseView.prototype.show.call(this),this._scrollerInited||(this.viewHelpPicker.scroller.update(),this._scrollerInited=!0)}}),SSE.Views.FileMenuPanels.ProtectDoc=Common.UI.BaseView.extend(_.extend({el:"#panel-protect",menu:void 0,template:_.template(['','
','','
','',"",'',"","",'','',"","
","
",'
','','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu;var e=this;this.templateSignature=_.template(['',"",'',"","",'",'","","
"].join(""))},render:function(){$(this.el).html(this.template({scope:this}));var t=SSE.getController("Common.Controllers.Protection").getView();return this.btnAddPwd=t.getButton("add-password"),this.btnAddPwd.render(this.$el.find("#fms-btn-add-pwd")),this.btnAddPwd.on("click",_.bind(this.closeMenu,this)),this.btnChangePwd=t.getButton("change-password"), -this.btnChangePwd.render(this.$el.find("#fms-btn-change-pwd")),this.btnChangePwd.on("click",_.bind(this.closeMenu,this)),this.btnDeletePwd=t.getButton("del-password"),this.btnDeletePwd.render(this.$el.find("#fms-btn-delete-pwd")),this.btnDeletePwd.on("click",_.bind(this.closeMenu,this)),this.cntPassword=$("#id-fms-password"),this.cntPasswordView=$("#id-fms-view-pwd"),this.btnAddInvisibleSign=t.getButton("signature"),this.btnAddInvisibleSign.render(this.$el.find("#fms-btn-invisible-sign")),this.btnAddInvisibleSign.on("click",_.bind(this.closeMenu,this)),this.cntSignature=$("#id-fms-signature"),this.cntSignatureView=$("#id-fms-signature-view"),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this.$el.on("click",".signature-edit-link",_.bind(this.onEdit,this)),this.$el.on("click",".signature-view-link",_.bind(this.onView,this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateSignatures(),this.updateEncrypt()},setMode:function(t){this.mode=t,this.cntSignature.toggleClass("hidden",!this.mode.isSignatureSupport),this.cntPassword.toggleClass("hidden",!this.mode.isPasswordSupport)},setApi:function(t){return this.api=t,this},closeMenu:function(){this.menu&&this.menu.hide()},onEdit:function(){this.menu&&this.menu.hide();var t=this;Common.UI.warning({title:this.notcriticalErrorTitle,msg:this.txtEditWarning,buttons:["ok","cancel"],primary:"ok",callback:function(e){"ok"==e&&t.api.asc_RemoveAllSignatures()}})},onView:function(){this.menu&&this.menu.hide(),SSE.getController("RightMenu").rightmenu.SetActivePane(Common.Utils.documentSettingsType.Signature,!0)},updateSignatures:function(){var t=this.api.asc_getRequestSignatures(),e=this.api.asc_getSignatures(),i=t&&t.length>0,n=!1,o=!1;_.each(e,function(t,e){0==t.asc_getValid()?n=!0:o=!0});var s=o?this.txtSignedInvalid:n?this.txtSigned:"";i&&(s=this.txtRequestedSignatures+(""!=s?"

":"")+s),this.cntSignatureView.html(this.templateSignature({tipText:s,hasSigned:n||o,hasRequested:i}))},updateEncrypt:function(){this.cntPasswordView.toggleClass("hidden",this.btnAddPwd.isVisible())},strProtect:"Protect Workbook",strSignature:"With Signature",txtView:"View signatures",txtEdit:"Edit workbook",txtSigned:"Valid signatures has been added to the workbook. The workbook is protected from editing.",txtSignedInvalid:"Some of the digital signatures in workbook are invalid or could not be verified. The workbook is protected from editing.",txtRequestedSignatures:"This workbook needs to be signed.",notcriticalErrorTitle:"Warning",txtEditWarning:"Editing will remove the signatures from the workbook.
Are you sure you want to continue?",strEncrypt:"With Password",txtEncrypted:"This workbook has been protected by password"},SSE.Views.FileMenuPanels.ProtectDoc||{}))}),define("text!spreadsheeteditor/main/app/template/PrintSettings.template",[],function(){return'
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n'}),define("spreadsheeteditor/main/app/view/PrintSettings",["text!spreadsheeteditor/main/app/template/PrintSettings.template","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox","common/main/lib/component/RadioBox","common/main/lib/component/ListView"],function(t){"use strict";SSE.Views.PrintSettings=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{alias:"PrintSettings",contentWidth:280,height:475},initialize:function(e){this.type=e.type||"print",_.extend(this.options,{title:"print"==this.type?this.textTitle:this.textTitlePDF,template:['
','",'
'+_.template(t)({scope:this})+"
","
",'
','"].join("")},e),Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options),this.spinners=[]},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this),this.cmbRange=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-range"),style:"width: 132px;",menuStyle:"min-width: 132px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPrintType.ActiveSheets,displayValue:this.textCurrentSheet},{value:Asc.c_oAscPrintType.EntireWorkbook,displayValue:this.textAllSheets},{value:Asc.c_oAscPrintType.Selection,displayValue:this.textSelection}]}),this.cmbRange.on("selected",_.bind(this.comboRangeChange,this)),this.chIgnorePrintArea=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-ignore"),labelText:this.textIgnore}),this.cmbSheet=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-sheets"),style:"width: 242px;",menuStyle:"min-width: 242px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[]}),this.cmbPaperSize=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-pages"),style:"width: 242px;",menuStyle:"max-height: 280px; min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:"215.9|279.4",displayValue:"US Letter (21,59cm x 27,94cm)",caption:"US Letter"},{value:"215.9|355.6",displayValue:"US Legal (21,59cm x 35,56cm)",caption:"US Legal"},{value:"210|297",displayValue:"A4 (21cm x 29,7cm)",caption:"A4"},{value:"148|210",displayValue:"A5 (14,8cm x 21cm)",caption:"A5"},{value:"176|250",displayValue:"B5 (17,6cm x 25cm)",caption:"B5"},{value:"104.8|241.3",displayValue:"Envelope #10 (10,48cm x 24,13cm)",caption:"Envelope #10"},{value:"110|220",displayValue:"Envelope DL (11cm x 22cm)",caption:"Envelope DL"},{value:"279.4|431.8",displayValue:"Tabloid (27,94cm x 43,18cm)",caption:"Tabloid"},{value:"297|420",displayValue:"A3 (29,7cm x 42cm)",caption:"A3"},{value:"304.8|457.1",displayValue:"Tabloid Oversize (30,48cm x 45,71cm)",caption:"Tabloid Oversize"},{value:"196.8|273",displayValue:"ROC 16K (19,68cm x 27,3cm)",caption:"ROC 16K"},{value:"119.9|234.9",displayValue:"Envelope Choukei 3 (11,99cm x 23,49cm)",caption:"Envelope Choukei 3"},{value:"330.2|482.5",displayValue:"Super B/A3 (33,02cm x 48,25cm)",caption:"Super B/A3"}]}),this.cmbPaperOrientation=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-orient"),style:"width: 132px;",menuStyle:"min-width: 132px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPageOrientation.PagePortrait,displayValue:this.strPortrait},{value:Asc.c_oAscPageOrientation.PageLandscape,displayValue:this.strLandscape}]}),this.chPrintGrid=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-grid"),labelText:"print"==this.type?this.textPrintGrid:this.textShowGrid}),this.chPrintRows=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-rows"),labelText:"print"==this.type?this.textPrintHeadings:this.textShowHeadings}),this.spnMarginTop=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-top"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginTop),this.spnMarginBottom=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-bottom"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginBottom),this.spnMarginLeft=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-left"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginLeft),this.spnMarginRight=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-right"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginRight),this.cmbLayout=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-layout"),style:"width: 242px;",menuStyle:"min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:0,displayValue:this.textActualSize},{value:1,displayValue:this.textFitPage},{value:2,displayValue:this.textFitCols},{value:3,displayValue:this.textFitRows}]}),this.btnHide=new Common.UI.Button({el:$("#printadv-dlg-btn-hide")}),this.btnHide.on("click",_.bind(this.handlerShowDetails,this)),this.panelDetails=$("#printadv-dlg-content-to-hide"),this.updateMetricUnit(),this.options.afterrender&&this.options.afterrender.call(this);var t=Common.localStorage.getItem("sse-hide-print-settings");this.extended=null!==t&&0==parseInt(t),this.handlerShowDetails(this.btnHide)},setRange:function(t){this.cmbRange.setValue(t)},getRange:function(){return this.cmbRange.getValue()},setIgnorePrintArea:function(t){this.chIgnorePrintArea.setValue(t)},getIgnorePrintArea:function(){return"checked"==this.chIgnorePrintArea.getValue()},comboRangeChange:function(t,e){this.fireEvent("changerange",this)},updateMetricUnit:function(){if(this.spinners)for(var t=0;te?l="left":o>e-n?l="right":s>i?l="top":a>i-s&&(l="bottom"),!l||(Common.UI.warning({title:this.textWarning,msg:this.warnCheckMargings,callback:function(e,i){switch(l){case"left":return void t.spnMarginLeft.$el.focus();case"right":return void t.spnMarginRight.$el.focus();case"top":return void t.spnMarginTop.$el.focus();case"bottom":return void t.spnMarginBottom.$el.focus()}}}),!1)},registerControlEvents:function(t){t.cmbPaperSize.on("selected",_.bind(this.propertyChange,this,t)),t.cmbPaperOrientation.on("selected",_.bind(this.propertyChange,this,t)),t.cmbLayout.on("selected",_.bind(this.propertyChange,this,t)),t.spnMarginTop.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginBottom.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginLeft.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginRight.on("change",_.bind(this.propertyChange,this,t)),t.chPrintGrid.on("change",_.bind(this.propertyChange,this,t)),t.chPrintRows.on("change",_.bind(this.propertyChange,this,t))},propertyChange:function(t){this._changedProps&&(this._changedProps[t.cmbSheet.getValue()]=this.getPageOptions(t))},getPrintParams:function(){return this.adjPrintParams},warnCheckMargings:"Margins are incorrect",strAllSheets:"All Sheets",textWarning:"Warning",txtCustom:"Custom"},SSE.Controllers.Print||{}))}),define("spreadsheeteditor/main/app/view/DataTab",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout"],function(){"use strict";SSE.Views.DataTab=Common.UI.BaseView.extend(_.extend(function(){function t(){var t=this;t.btnUngroup.menu.on("item:click",function(e,i,n){t.fireEvent("data:ungroup",[i.value])}),t.btnUngroup.on("click",function(e,i){t.fireEvent("data:ungroup")}),t.btnGroup.menu.on("item:click",function(e,i,n){t.fireEvent("data:group",[i.value,i.checked])}),t.btnGroup.on("click",function(e,i){t.fireEvent("data:group")}),t.btnGroup.menu.on("show:before",function(e,i){t.fireEvent("data:groupsettings",[e])}),t.btnTextToColumns.on("click",function(e,i){t.fireEvent("data:tocolumns")}),t.btnShow.on("click",function(e,i){t.fireEvent("data:show")}),t.btnHide.on("click",function(e,i){t.fireEvent("data:hide")}),t.btnsSortDown.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:sort",[Asc.c_oAscSortOptions.Ascending])})}),t.btnsSortUp.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:sort",[Asc.c_oAscSortOptions.Descending])})}),t.btnsSetAutofilter.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:setfilter",[Asc.c_oAscSortOptions.Descending])})}),t.btnsClearAutofilter.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:clearfilter",[Asc.c_oAscSortOptions.Descending])})})}return{options:{},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this),this.toolbar=t.toolbar,this.lockedControls=[];var e=this,i=e.toolbar.$el,n=SSE.enumLock;this.btnGroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-cell-group",caption:this.capBtnGroup,split:!0,menu:!0,disabled:!0,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.sheetLock,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-group"),this.btnGroup),this.lockedControls.push(this.btnGroup),this.btnUngroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-cell-ungroup",caption:this.capBtnUngroup,split:!0,menu:!0,disabled:!0,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.sheetLock,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-ungroup"),this.btnUngroup),this.lockedControls.push(this.btnUngroup),this.btnTextToColumns=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-to-columns",caption:this.capBtnTextToCol,split:!1,disabled:!0,lock:[n.multiselect,n.multiselectCols,n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-text-column"),this.btnTextToColumns),this.lockedControls.push(this.btnTextToColumns),this.btnShow=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-show-details",style:"padding-right: 2px;",caption:this.capBtnTextShow,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-show-details"),this.btnShow),this.lockedControls.push(this.btnShow),this.btnHide=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-hide-details",style:"padding-right: 2px;",caption:this.capBtnTextHide,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-hide-details"),this.btnHide),this.lockedControls.push(this.btnHide),this.btnsSortDown=Common.Utils.injectButtons(i.find(".slot-sortdesc"),"","btn-sort-down","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter]),this.btnsSortUp=Common.Utils.injectButtons(i.find(".slot-sortasc"),"","btn-sort-up","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter]),this.btnsSetAutofilter=Common.Utils.injectButtons(i.find(".slot-btn-setfilter"),"","btn-autofilter","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter],!1,!1,!0),this.btnsClearAutofilter=Common.Utils.injectButtons(i.find(".slot-btn-clear-filter"),"","btn-clear-filter","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleDelFilter,n.editPivot]),Array.prototype.push.apply(this.lockedControls,this.btnsSortDown.concat(this.btnsSortUp,this.btnsSetAutofilter,this.btnsClearAutofilter)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this},onAppReady:function(e){var i=this;new Promise(function(t,e){t()}).then(function(){i.btnUngroup.updateHint(i.tipUngroup);var e=new Common.UI.Menu({items:[{caption:i.textRows,value:"rows"},{caption:i.textColumns,value:"columns"},{caption:i.textClear,value:"clear"}]});i.btnUngroup.setMenu(e),i.btnGroup.updateHint(i.tipGroup),e=new Common.UI.Menu({items:[{caption:i.textGroupRows,value:"rows"},{caption:i.textGroupColumns,value:"columns"},{caption:"--"},{caption:i.textBelow,value:"below",checkable:!0},{caption:i.textRightOf,value:"right",checkable:!0}]}),i.btnGroup.setMenu(e),i.btnTextToColumns.updateHint(i.tipToColumns),i.btnsSortDown.forEach(function(t){t.updateHint(i.toolbar.txtSortAZ)}),i.btnsSortUp.forEach(function(t){t.updateHint(i.toolbar.txtSortZA)}),i.btnsSetAutofilter.forEach(function(t){t.updateHint(i.toolbar.txtFilter+" (Ctrl+Shift+L)")}),i.btnsClearAutofilter.forEach(function(t){t.updateHint(i.toolbar.txtClearFilter)}),t.call(i)})},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButtons:function(t){return"sort-down"==t?this.btnsSortDown:"sort-up"==t?this.btnsSortUp:"set-filter"==t?this.btnsSetAutofilter:"clear-filter"==t?this.btnsClearAutofilter:void 0===t?this.lockedControls:[]},SetDisabled:function(t){this.lockedControls&&this.lockedControls.forEach(function(e){e&&e.setDisabled(t)},this)},capBtnGroup:"Group",capBtnUngroup:"Ungroup",textRows:"Ungroup rows",textColumns:"Ungroup columns",textGroupRows:"Group rows",textGroupColumns:"Group columns",textClear:"Clear outline",tipGroup:"Group range of cells",tipUngroup:"Ungroup range of cells",capBtnTextToCol:"Text to Columns",tipToColumns:"Separate cell text into columns",capBtnTextShow:"Show details",capBtnTextHide:"Hide details",textBelow:"Summary rows below detail",textRightOf:"Summary columns to right of detail"}}(),SSE.Views.DataTab||{}))}),define("spreadsheeteditor/main/app/view/GroupDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox"],function(){"use strict";SSE.Views.GroupDialog=Common.UI.Window.extend(_.extend({options:{width:214,header:!0,style:"min-width: 214px;",cls:"modal-dlg"},initialize:function(t){_.extend(this.options,t||{}),this.template=['
','
','
','"].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.radioRows=new Common.UI.RadioBox({el:$("#group-radio-rows"),labelText:this.textRows,name:"asc-radio-group-cells",checked:"rows"==this.options.props}),this.radioColumns=new Common.UI.RadioBox({el:$("#group-radio-cols"),labelText:this.textColumns,name:"asc-radio-group-cells",checked:"columns"==this.options.props}), -"rows"==this.options.props?this.radioRows.setValue(!0):this.radioColumns.setValue(!0),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return this.radioRows.getValue()},onPrimary:function(){return this._handleInput("ok"),!1},cancelButtonText:"Cancel",okButtonText:"Ok",textRows:"Rows",textColumns:"Columns"},SSE.Views.GroupDialog||{}))}),define("spreadsheeteditor/main/app/controller/DataTab",["core","spreadsheeteditor/main/app/view/DataTab","spreadsheeteditor/main/app/view/GroupDialog"],function(){"use strict";SSE.Controllers.DataTab=Backbone.Controller.extend(_.extend({models:[],collections:[],views:["DataTab"],sdkViewName:"#id_main",initialize:function(){this._state={CSVOptions:new Asc.asc_CTextOptions(0,4,"")}},onLaunch:function(){},setApi:function(t){return t&&(this.api=t,this.api.asc_registerCallback("asc_onSelectionChanged",_.bind(this.onSelectionChanged,this)),this.api.asc_registerCallback("asc_onWorksheetLocked",_.bind(this.onWorksheetLocked,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))),this},setConfig:function(t){this.toolbar=t.toolbar,this.view=this.createView("DataTab",{toolbar:this.toolbar.toolbar}),this.addListeners({DataTab:{"data:group":this.onGroup,"data:ungroup":this.onUngroup,"data:tocolumns":this.onTextToColumn,"data:show":this.onShowClick,"data:hide":this.onHideClick,"data:groupsettings":this.onGroupSettings},Statusbar:{"sheet:changed":this.onApiSheetChanged}})},SetDisabled:function(t){this.view&&this.view.SetDisabled(t)},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)},onSelectionChanged:function(t){this.toolbar.editMode&&this.view&&(Common.Utils.lockControls(SSE.enumLock.multiselectCols,t.asc_getSelectedColsCount()>1,{array:[this.view.btnTextToColumns]}),Common.Utils.lockControls(SSE.enumLock.multiselect,t.asc_getFlags().asc_getMultiselect(),{array:[this.view.btnTextToColumns]}))},onUngroup:function(t){var e=this;if("rows"==t)void 0!==e.api.asc_checkAddGroup(!0)&&e.api.asc_ungroup(!0);else if("columns"==t)void 0!==e.api.asc_checkAddGroup(!0)&&e.api.asc_ungroup(!1);else if("clear"==t)e.api.asc_clearOutline();else{var i=e.api.asc_checkAddGroup(!0);null===i?new SSE.Views.GroupDialog({title:e.view.capBtnUngroup,props:"rows",handler:function(t,i){"ok"==i&&e.api.asc_ungroup(t.getSettings()),Common.NotificationCenter.trigger("edit:complete",e.toolbar)}}).show():void 0!==i&&e.api.asc_ungroup(i)}Common.NotificationCenter.trigger("edit:complete",e.toolbar)},onGroup:function(t,e){if("rows"==t)void 0!==this.api.asc_checkAddGroup()&&this.api.asc_group(!0);else if("columns"==t)void 0!==this.api.asc_checkAddGroup()&&this.api.asc_group(!1);else if("below"==t)this.api.asc_setGroupSummary(e,!1);else if("right"==t)this.api.asc_setGroupSummary(e,!0);else{var i=this,n=i.api.asc_checkAddGroup();null===n?new SSE.Views.GroupDialog({title:i.view.capBtnGroup,props:"rows",handler:function(t,e){"ok"==e&&i.api.asc_group(t.getSettings()),Common.NotificationCenter.trigger("edit:complete",i.toolbar)}}).show():void 0!==n&&i.api.asc_group(n)}Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onGroupSettings:function(t){var e=this.api.asc_getGroupSummaryBelow();t.items[3].setChecked(!!e,!0),e=this.api.asc_getGroupSummaryRight(),t.items[4].setChecked(!!e,!0)},onTextToColumn:function(){this.api.asc_TextImport(this._state.CSVOptions,_.bind(this.onTextToColumnCallback,this),!1)},onTextToColumnCallback:function(t){if(t&&t.length){var e=this;new Common.Views.OpenDialog({title:e.textWizard,closable:!0,type:Common.Utils.importTextType.Columns,preview:!0,previewData:t,settings:e._state.CSVOptions,api:e.api,handler:function(t,i,n,o){"ok"==t&&e&&e.api&&e.api.asc_TextToColumns(new Asc.asc_CTextOptions(i,n,o))}}).show()}},onShowClick:function(){this.api.asc_changeGroupDetails(!0)},onHideClick:function(){this.api.asc_changeGroupDetails(!1)},onWorksheetLocked:function(t,e){t==this.api.asc_getActiveWorksheetIndex()&&Common.Utils.lockControls(SSE.enumLock.sheetLock,e,{array:[this.view.btnGroup,this.view.btnUngroup]})},onApiSheetChanged:function(){if(this.toolbar.mode&&this.toolbar.mode.isEdit&&!this.toolbar.mode.isEditDiagram&&!this.toolbar.mode.isEditMailMerge){var t=this.api.asc_getActiveWorksheetIndex();this.onWorksheetLocked(t,this.api.asc_isWorksheetLockedOrDeleted(t))}},textWizard:"Text to Columns Wizard"},SSE.Controllers.DataTab||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Comment",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.Comment=e.Model.extend({defaults:{uid:0,guid:"",userid:0,username:"Guest",usercolor:null,date:void 0,quote:"",comment:"",resolved:!1,lock:!1,lockuserid:"",unattached:!1,id:Common.UI.getId(),time:0,showReply:!1,showReplyInPopover:!1,editText:!1,editTextInPopover:!1,last:void 0,replys:[],hideAddReply:!1,scope:null,hide:!1,hint:!1,dummy:void 0,editable:!0}}),Common.Models.Reply=e.Model.extend({defaults:{time:0,userid:0,username:"Guest",usercolor:null,reply:"",date:void 0,id:Common.UI.getId(),editText:!1,editTextInPopover:!1,scope:null,editable:!0}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Comments",["underscore","backbone","common/main/lib/model/Comment"],function(t,e){"use strict";Common.Collections.Comments=e.Collection.extend({model:Common.Models.Comment,groups:null,clearEditing:function(){this.each(function(t){t.set("editText",!1),t.set("editTextInPopover",!1),t.set("showReply",!1),t.set("showReplyInPopover",!1),t.set("hideAddReply",!1)})},getCommentsReplysCount:function(t){var e=0;return this.each(function(i){i.get("userid")==t&&e++;var n=i.get("replys");n&&n.length>0&&n.forEach(function(i){i.get("userid")==t&&e++})}),e}})}),define("text!common/main/lib/template/CommentsPopover.template",[],function(){return'
\r\n\r\n \x3c!-- comment block --\x3e\r\n\r\n
\r\n
<%= scope.getUserName(username) %>\r\n
\r\n
<%=date%>
\r\n <% if (!editTextInPopover || hint) { %>\r\n
<%=scope.pickLink(comment)%>
\r\n <% } else { %>\r\n
\r\n \r\n <% if (hideAddReply) { %>\r\n \r\n <% } else { %>\r\n \r\n <% } %>\r\n \r\n
\r\n <% } %>\r\n\r\n \x3c!-- replys elements --\x3e\r\n\r\n <% if (replys.length) { %>\r\n
\r\n <% _.each(replys, function (item) { %>\r\n
\r\n
\r\n
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getUserName(item.get("username")) %>\r\n
\r\n
<%=item.get("date")%>
\r\n <% if (!item.get("editTextInPopover")) { %>\r\n
<%=scope.pickLink(item.get("reply"))%>
\r\n <% if (!hint) { %>\r\n
\r\n <% if (item.get("editable")) { %>\r\n
">
\r\n
">
\r\n <%}%>\r\n
\r\n <%}%>\r\n <% } else { %>\r\n
\r\n \r\n \r\n \r\n
\r\n <% } %>\r\n
\r\n <% }); %>\r\n\r\n <% } %>\r\n\r\n \x3c!-- add reply button --\x3e\r\n\r\n <% if (!showReplyInPopover && !hideAddReply && !hint) { %>\r\n <% if (replys.length) { %>\r\n \r\n <% } else { %>\r\n \r\n <% } %>\r\n <% } %>\r\n\r\n \x3c!-- edit buttons --\x3e\r\n\r\n <% if (!editTextInPopover && !lock && !hint) { %>\r\n
\r\n <% if (editable) { %>\r\n
\r\n
\r\n <% } %>\r\n <% if (resolved) { %>\r\n
\r\n <% } else { %>\r\n
\r\n <% } %>\r\n
\r\n <% } %>\r\n\r\n \x3c!-- reply --\x3e\r\n\r\n <% if (showReplyInPopover) { %>\r\n
\r\n \r\n \r\n \r\n
\r\n <% } %>\r\n\r\n \x3c!-- locked user --\x3e\r\n\r\n <% if (lock) { %>\r\n
\r\n
<%=lockuserid%>
\r\n <% } %>\r\n\r\n
'}),define("text!common/main/lib/template/ReviewChangesPopover.template",[],function(){return'
\r\n
\r\n
<%= scope.getUserName(username) %>\r\n
\r\n
<%=date%>
\r\n
<%=changetext%>
\r\n
\r\n <% if (goto) { %>\r\n
\r\n <% } %>\r\n <% if (!hint) { %>\r\n <% if (scope.appConfig.isReviewOnly) { %>\r\n <% if (editable) { %>\r\n
\r\n <% } %>\r\n <% } else { %>\r\n
\r\n
\r\n <% } %>\r\n <% } %>\r\n
\r\n <% if (!hint && lock) { %>\r\n
\r\n
<%=lockuser%>
\r\n <% } %>\r\n
'}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/ReviewPopover",["text!common/main/lib/template/CommentsPopover.template","text!common/main/lib/template/ReviewChangesPopover.template","common/main/lib/util/utils","common/main/lib/component/Button","common/main/lib/component/ComboBox","common/main/lib/component/DataView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(t,e){"use strict";function i(t,e){var i,n,o=t;for(i in e)void 0!==i&&(n=e[i],o=o.replace(new RegExp(i,"g"),n));return o}Common.Views.ReviewPopover=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};return _.extend(e,{closable:!1,width:265,height:120,header:!1,modal:!1,alias:"Common.Views.ReviewPopover"},t),this.template=t.template||['
','
','
','
',"
",'
',"
"].join(""),this.commentsStore=t.commentsStore,this.reviewStore=t.reviewStore,this.canRequestUsers=t.canRequestUsers,this.canRequestSendNotify=t.canRequestSendNotify,this.externalUsers=[],this._state={commentsVisible:!1,reviewVisible:!1},e.tpl=_.template(this.template)(e),this.arrow={margin:20,width:10,height:30},this.sdkBounds={width:0,height:0,padding:10,paddingTop:20},Common.UI.Window.prototype.initialize.call(this,e),this.canRequestUsers&&(Common.Gateway.on("setusers",_.bind(this.setUsers,this)),Common.NotificationCenter.on("mentions:clearusers",_.bind(this.clearUsers,this))),this},render:function(n,o){Common.UI.Window.prototype.render.call(this);var s=this,a=this.$window;a.css({height:"",minHeight:"",overflow:"hidden",position:"absolute",zIndex:"990"});var l=a.find(".body");l&&l.css("position","relative");var r=Common.UI.DataView.extend(function(){var t=s;return{options:{handleSelect:!1,allowScrollbar:!1,template:_.template('
')},getTextBox:function(){var t=$(this.el).find("textarea");return t&&t.length?t:void 0},setFocusToTextBox:function(t){var e=$(this.el).find("textarea");if(t)e.blur();else if(e&&e.length){var i=e.val();e.focus(),e.val(""),e.val(i)}},getActiveTextBoxVal:function(){var t=$(this.el).find("textarea");return t&&t.length?t.val().trim():""},autoHeightTextBox:function(){function e(){l=t.scroller.getScrollTop(),n.scrollHeight>n.clientHeight?(i.css({height:n.scrollHeight+a+"px"}),t.calculateSizeOfContent()):(r=n.clientHeight)>=o&&(i.css({height:o+"px"}),n.scrollHeight>n.clientHeight&&(c=Math.max(n.scrollHeight+a,o),i.css({height:c+"px"})),t.calculateSizeOfContent(),t.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),t.calculateSizeOfContent()),t.scroller.scrollTop(l),t.autoScrollToEditButtons()}var i=this.$el.find("textarea"),n=null,o=50,a=0,l=0,r=0,c=0;i&&i.length&&(n=i.get(0))&&(a=.25*parseInt(i.css("lineHeight"),10),e(),i.bind("input propertychange",e)),this.textBox=i},clearTextBoxBind:function(){this.textBox&&(this.textBox.unbind("input propertychange"),this.textBox=void 0)}}}());if(r)if(this.commentsView)this.commentsView.render($("#id-comments-popover")),this.commentsView.onResetItems();else{this.commentsView=new r({el:$("#id-comments-popover"),store:s.commentsStore,itemTemplate:_.template(i(t,{textAddReply:s.textAddReply,textAdd:s.textAdd,textCancel:s.textCancel,textEdit:s.textEdit,textReply:s.textReply,textClose:s.textClose,maxCommLength:Asc.c_oAscMaxCellOrCommentLength,textMention:s.canRequestSendNotify?s.textMention:""}))});var c=function(t,e,i){e.tipsArray&&e.tipsArray.forEach(function(t){t.remove()});var n=[],o=$(e.el).find(".btn-resolve");o.tooltip({title:s.textResolve,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),o=$(e.el).find(".btn-resolve-check"),o.tooltip({title:s.textOpenAgain,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),e.tipsArray=n,this.autoHeightTextBox()},h=function(){s._isMouseOver=!0},d=function(){s._isMouseOver=!1};this.commentsView.on("item:add",c),this.commentsView.on("item:remove",c),this.commentsView.on("item:change",c),this.commentsView.cmpEl.on("mouseover",h).on("mouseout",d),this.commentsView.on("item:click",function(t,e,i,n){function o(){s.update()}var a,l,r,c,h,d;if(a=$(n.target)){if(l=i.get("editTextInPopover"),r=i.get("showReplyInPopover"),d=i.get("hideAddReply"),c=i.get("uid"),h=a.attr("data-value"),i.get("hint"))return void s.fireEvent("comment:disableHint",[i]);if(a.hasClass("btn-edit"))_.isUndefined(h)?l||(s.fireEvent("comment:closeEditing"),i.set("editTextInPopover",!0),s.fireEvent("comment:show",[c]),this.autoHeightTextBox(),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox()):(s.fireEvent("comment:closeEditing",[c]),s.fireEvent("comment:editReply",[c,h,!0]),this.replyId=h,this.autoHeightTextBox(),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox());else if(a.hasClass("btn-delete"))_.isUndefined(h)?s.fireEvent("comment:remove",[c]):(s.fireEvent("comment:removeReply",[c,h]),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent()),s.fireEvent("comment:closeEditing"),o();else if(a.hasClass("user-reply"))s.fireEvent("comment:closeEditing"),i.set("showReplyInPopover",!0),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),this.autoHeightTextBox(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox();else if(a.hasClass("btn-reply",!1))r&&(this.clearTextBoxBind(),s.fireEvent("comment:addReply",[c,this.getActiveTextBoxVal()]),s.fireEvent("comment:closeEditing"),s.calculateSizeOfContent(),o());else if(a.hasClass("btn-close",!1))s.fireEvent("comment:closeEditing",[c]),s.calculateSizeOfContent(),s.fireEvent("comment:show",[c]),o();else if(a.hasClass("btn-inner-edit",!1)){if(i.get("dummy")){var p=this.getActiveTextBoxVal();if(s.clearDummyText(),p.length>0)s.fireEvent("comment:addDummyComment",[p]);else{var m=s.$window.find("textarea:not(.user-message)");m&&m.length&&setTimeout(function(){m.focus()},10)}return}this.clearTextBoxBind(),_.isUndefined(this.replyId)?l&&(s.fireEvent("comment:change",[c,this.getActiveTextBoxVal()]),s.fireEvent("comment:closeEditing"),s.calculateSizeOfContent()):(s.fireEvent("comment:changeReply",[c,this.replyId,this.getActiveTextBoxVal()]),this.replyId=void 0,s.fireEvent("comment:closeEditing")),o()}else if(a.hasClass("btn-inner-close",!1)){if(i.get("dummy"))return s.clearDummyText(),void s.hide();d&&this.getActiveTextBoxVal().length>0?(s.saveText(),i.set("hideAddReply",!1),this.getTextBox().val(s.textVal),this.autoHeightTextBox()):(this.clearTextBoxBind(),s.fireEvent("comment:closeEditing",[c])),this.replyId=void 0,s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o()}else if(a.hasClass("btn-resolve",!1)){var u=a.data("bs.tooltip");u&&(u.dontShow=!0),s.fireEvent("comment:resolve",[c]),o()}else if(a.hasClass("btn-resolve-check",!1)){var u=a.data("bs.tooltip");u&&(u.dontShow=!0),s.fireEvent("comment:resolve",[c]),o()}}}),this.emailMenu=new Common.UI.Menu({maxHeight:190,cyclic:!1,items:[]}).on("render:after",function(t){this.scroller=new Common.UI.Scroller({el:$(this.el).find(".dropdown-menu "),useKeyboard:this.enableKeyEvents&&!this.handleSelect,minScrollbarLength:40,alwaysVisibleY:!0})}).on("show:after",function(){this.scroller.update({alwaysVisibleY:!0}),s.$window.css({zIndex:"1001"})}).on("hide:after",function(){s.$window.css({zIndex:"990"})}),s.on({show:function(){s.commentsView.autoHeightTextBox(),s.$window.find("textarea").keydown(function(t){t.keyCode==Common.UI.Keys.ESC&&s.hide(!0)})},"animate:before":function(){var t=s.$window.find("textarea");t&&t.length&&t.focus()}})}var p=Common.UI.DataView.extend(function(){return{options:{handleSelect:!1,scrollable:!0,template:_.template('
')}}}());if(p)if(this.reviewChangesView)this.reviewChangesView.render($("#id-review-popover")),this.reviewChangesView.onResetItems();else{this.reviewChangesView=new p({el:$("#id-review-popover"),store:s.reviewStore,itemTemplate:_.template(e)});var c=function(t,e,i){e.tipsArray&&e.tipsArray.forEach(function(t){t.remove()});var n=[],o=$(e.el).find(".btn-goto");o.tooltip({title:s.textFollowMove,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),e.tipsArray=n};this.reviewChangesView.on("item:add",c),this.reviewChangesView.on("item:remove",c),this.reviewChangesView.on("item:change",c),this.reviewChangesView.on("item:click",function(t,e,i,n){var o=$(n.target);if(o)if(o.hasClass("btn-accept"))s.fireEvent("reviewchange:accept",[i.get("changedata")]);else if(o.hasClass("btn-reject"))s.fireEvent("reviewchange:reject",[i.get("changedata")]);else if(o.hasClass("btn-delete"))s.fireEvent("reviewchange:delete",[i.get("changedata")]);else if(o.hasClass("btn-goto")){var a=o.data("bs.tooltip");a&&(a.dontShow=!0),s.fireEvent("reviewchange:goto",[i.get("changedata")])}})}_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:a.find("#id-popover"),minScrollbarLength:40,wheelSpeed:10,alwaysVisibleY:!0}))},showComments:function(t,e,i,n){this.options.animate=t;var o=this.commentsView.getTextBox();e&&this.textVal&&o&&o.val(this.textVal),n&&n.length&&o&&o.val(n),this.show(t),this.hookTextBox(),this._state.commentsVisible=!0},showReview:function(t,e,i){this.show(t),this._state.reviewVisible=!0},show:function(t,e,i,n){this.options.animate=t,Common.UI.Window.prototype.show.call(this),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})},hideComments:function(){this.handlerHide&&this.handlerHide(),this.hideTips(),this._state.commentsVisible=!1,this._state.reviewVisible?this.calculateSizeOfContent():this.hide()},hideReview:function(){this.handlerHide&&this.handlerHide(),this.hideTips(),this._state.reviewVisible=!1,this._state.commentsVisible?this.calculateSizeOfContent():this.hide()},hide:function(){this.handlerHide&&this.handlerHide.apply(this,arguments),this.hideTips(),Common.UI.Window.prototype.hide.call(this),_.isUndefined(this.e)||this.e.keyCode!=Common.UI.Keys.ESC||(this.e.preventDefault(),this.e.stopImmediatePropagation(),this.e=void 0)},update:function(t){this.commentsView&&t&&this.commentsView.onResetItems(),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})},isVisible:function(){return this.$window&&this.$window.is(":visible")},setLeftTop:function(t,e,i,n,o){if(this.$window||this.render(),n&&(t=this.arrowPosX,e=this.arrowPosY,i=this.leftX),!_.isUndefined(t)||!_.isUndefined(e)){this.arrowPosX=t,this.arrowPosY=e,this.leftX=i;var s=$("#id-popover"),a=$("#id-comments-arrow"),l=$("#editor_sdk"),r=null,c=0,h="",d=0,p="",m=0,u="",g=0,b="",f=0,C=0,v=0,y=0,x=0,w=0;s&&a&&l&&l.get(0)&&(r=l.get(0).getBoundingClientRect())&&(c=r.height-2*this.sdkBounds.padding,this.$window.css({maxHeight:c+"px"}),this.sdkBounds.width=r.width,this.sdkBounds.height=r.height,_.isUndefined(t)||(h=$("#id_vertical_scroll"),h.length?d="none"!==h.css("display")?h.width():0:(h=$("#ws-v-scrollbar"),h.length&&(d="none"!==h.css("display")?h.width():0)),this.sdkBounds.width-=d,p=$("#id_panel_left"),p.length&&(m="none"!==p.css("display")?p.width():0),u=$("#id_panel_thumbnails"),u.length&&(g="none"!==u.css("display")?u.width():0,this.sdkBounds.width-=g),C=Math.min(0+t+this.arrow.width,0+this.sdkBounds.width-this.$window.outerWidth()-25),C=Math.max(0+m+this.arrow.width,C),a.removeClass("right").addClass("left"),_.isUndefined(i)||(v=this.$window.outerWidth())&&(t+v>this.sdkBounds.width-this.arrow.width+5&&this.leftX>v?(C=this.leftX-v+0-this.arrow.width,a.removeClass("left").addClass("right")):C=0+t+this.arrow.width),this.$window.css("left",C+"px")),_.isUndefined(e)||(b=$("#id_panel_top"),w=0,b.length?(f="none"!==b.css("display")?b.height():0,w+=this.sdkBounds.paddingTop):(b=$("#ws-h-scrollbar"),b.length&&(f="none"!==b.css("display")?b.height():0)),this.sdkBounds.height-=f,y=this.$window.outerHeight(),x=Math.min(0+c-y,this.arrowPosY+0-this.arrow.height),x=Math.max(x,w),parseInt(a.css("top"))+this.arrow.height>y&&a.css({top:y-this.arrow.height+"px"}),this.$window.css("top",x+"px"))),o||this.calculateSizeOfContent()}},calculateSizeOfContent:function(t){if(!t||this.$window.is(":visible")){this.$window.css({overflow:"hidden"});var e=$("#id-comments-arrow"),i=$("#id-popover"),n=null,o=null,s=null,a=0,l="",r=0,c=0,h=0,d=0,p=0,m=0;if(i&&e&&i.get(0)){var u=this.scroller.getScrollTop();i.css({height:"100%"}),n=i.get(0).getBoundingClientRect(),n&&(o=$("#editor_sdk"))&&o.get(0)&&(s=o.get(0).getBoundingClientRect())&&(a=s.height-2*this.sdkBounds.padding,m=0,h=this.$window.outerHeight(),l=$("#id_panel_top"),l.length?(r="none"!==l.css("display")?l.height():0,m+=this.sdkBounds.paddingTop):(l=$("#ws-h-scrollbar"),l.length&&(r="none"!==l.css("display")?l.height():0)),d=Math.max(i.outerHeight(),this.$window.outerHeight()),a<=d?(this.$window.css({maxHeight:a-r+"px",top:0+r+"px"}),i.css({height:a-r-3+"px"}),c=Math.min(c,a-(r+this.arrow.margin+this.arrow.height)),e.css({top:c+"px"}),this.scroller.scrollTop(u)):(d=h,d>0&&(n.top+d>a+0||0===n.height)&&(p=Math.min(0+a-d,this.arrowPosY+0-this.arrow.height),p=Math.max(p,m),this.$window.css({top:p+"px"})),c=Math.max(this.arrow.margin,this.arrowPosY-(a-d)-this.arrow.height),c=Math.min(c,d-this.arrow.margin-this.arrow.height),e.css({top:c+"px"})))}this.$window.css({overflow:""}),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})}},saveText:function(t){this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1&&(this.textVal=void 0,t?this.commentsView.clearTextBoxBind():this.textVal=this.commentsView.getActiveTextBoxVal())},loadText:function(){if(this.textVal&&this.commentsView){var t=this.commentsView.getTextBox();t&&t.val(this.textVal)}},getEditText:function(){if(this.commentsView)return this.commentsView.getActiveTextBoxVal()},saveDummyText:function(){this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1&&(this.textDummyVal=this.commentsView.getActiveTextBoxVal())},clearDummyText:function(){if(this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1){this.textDummyVal=void 0;var t=this.commentsView.getTextBox();t&&t.val(""),this.commentsView.clearTextBoxBind()}},getDummyText:function(){return this.textDummyVal||""},hookTextBox:function(){var t=this,e=this.commentsView.getTextBox();e&&e.keydown(function(e){if(!e.ctrlKey&&!e.metaKey||e.altKey||e.keyCode!==Common.UI.Keys.RETURN){if(e.keyCode===Common.UI.Keys.TAB){var i,n,o;o=this.selectionStart,n=this.selectionEnd,i=$(this),i.val(i.val().substring(0,o)+"\t"+i.val().substring(n)),this.selectionStart=this.selectionEnd=o+1,e.stopImmediatePropagation(),e.preventDefault()}}else{var s=$("#id-comments-change-popover");s&&s.length&&s.click(),e.stopImmediatePropagation()}t.e=e}),this.canRequestUsers&&(e&&e.keydown(function(e){e.keyCode==Common.UI.Keys.SPACE||e.keyCode==Common.UI.Keys.HOME||e.keyCode==Common.UI.Keys.END||e.keyCode==Common.UI.Keys.RIGHT||e.keyCode==Common.UI.Keys.LEFT||e.keyCode==Common.UI.Keys.UP?t.onEmailListMenu():e.keyCode==Common.UI.Keys.DOWN&&t.emailMenu&&t.emailMenu.rendered&&t.emailMenu.isVisible()&&_.delay(function(){var e=t.emailMenu.cmpEl.find("li:not(.divider):first");e=e.find("a"),e.focus()},10),t.e=e}),e&&e.on("input",function(e){for(var i=$(this),n=this.selectionStart,o=i.val().replace(/[\n]$/,""),s=0,a=o.length-1,l=n-1;l>=0;l--)if(32==o.charCodeAt(l)||13==o.charCodeAt(l)||10==o.charCodeAt(l)||9==o.charCodeAt(l)){s=l+1;break}for(var l=n;l<=a;l++)if(32==o.charCodeAt(l)||13==o.charCodeAt(l)||10==o.charCodeAt(l)||9==o.charCodeAt(l)){a=l-1;break}var r=o.substring(s,a+1),c=r.match(/^(?:[@]|[+](?!1))(\S*)/);c&&c.length>1&&(r=c[1],t.onEmailListMenu(r,s,a))}))},hideTips:function(){this.commentsView&&_.each(this.commentsView.dataViewItems,function(t){t.tipsArray&&t.tipsArray.forEach(function(t){t.hide()})},this),this.reviewChangesView&&_.each(this.reviewChangesView.dataViewItems,function(t){t.tipsArray&&t.tipsArray.forEach(function(t){t.hide()})},this)},isCommentsViewMouseOver:function(){return this._isMouseOver},setReviewStore:function(t){this.reviewStore=t,this.reviewChangesView&&this.reviewChangesView.setStore(this.reviewStore)},setCommentsStore:function(t){this.commentsStore=t,this.commentsView&&this.commentsView.setStore(this.commentsStore)},setUsers:function(t){this.externalUsers=t.users||[],this.isUsersLoading=!1,this._state.emailSearch&&this.onEmailListMenu(this._state.emailSearch.str,this._state.emailSearch.left,this._state.emailSearch.right),this._state.emailSearch=null},clearUsers:function(){this.externalUsers=[]},getPopover:function(t){return this.popover||(this.popover=new Common.Views.ReviewPopover(t)),this.popover},autoScrollToEditButtons:function(){var t=$("#id-comments-change-popover"),e=null,i=this.$window[0].getBoundingClientRect(),n=0;t.length&&(e=t.get(0).getBoundingClientRect())&&i&&(n=i.bottom-(e.bottom+7))<0&&this.scroller.scrollTop(this.scroller.getScrollTop()-n)},onEmailListMenu:function(t,e,i,n){var o=this,s=o.externalUsers,a=o.emailMenu;if(s.length<1){if(this._state.emailSearch={str:t,left:e,right:i},this.isUsersLoading)return;return this.isUsersLoading=!0,void Common.Gateway.requestUsers()}if("string"==typeof t){var l=o.$window.find(Common.Utils.String.format("#menu-container-{0}",a.id)),r=this.commentsView.getTextBox(),c=r?r[0]:null,h=c?[c.offsetLeft,c.offsetTop+c.clientHeight+3]:[0,0];a.rendered||(l.length<1&&(l=$(Common.Utils.String.format('',a.id)),o.$window.append(l)),a.render(l),a.cmpEl.css("min-width",c?c.clientWidth:220),a.cmpEl.attr({tabindex:"-1"}),a.on("hide:after",function(){setTimeout(function(){var t=o.commentsView.getTextBox();t&&t.focus()},10)}));for(var d=0;d0){t=t.toLowerCase(),t.length>0&&(s=_.filter(s,function(e){return e.email&&0===e.email.toLowerCase().indexOf(t)||e.name&&0===e.name.toLowerCase().indexOf(t)}));var p=_.template('
<%= Common.Utils.String.htmlEncode(caption) %>
<%= Common.Utils.String.htmlEncode(options.value) %>
'),m=!1;_.each(s,function(t,n){if(m&&!t.hasAccess&&(m=!1,a.addItem(new Common.UI.MenuItem({caption:"--"}))),t.email&&t.name){var s=new Common.UI.MenuItem({caption:t.name,value:t.email,template:p}).on("click",function(t,n){o.insertEmailToTextbox(t.options.value,e,i)});a.addItem(s),t.hasAccess&&(m=!0)}})}a.items.length>0?(l.css({left:h[0],top:h[1]}),a.menuAlignEl=r,a.show(),a.cmpEl.css("display",""),a.alignPosition("bl-tl",-5),a.scroller.update({alwaysVisibleY:!0})):a.rendered&&a.cmpEl.css("display","none")}else a.rendered&&a.cmpEl.css("display","none")},insertEmailToTextbox:function(t,e,i){var n=this.commentsView.getTextBox(),o=n.val();n.val(o.substring(0,e)+"+"+t+o.substring(i+1,o.length)),setTimeout(function(){ -n[0].selectionStart=n[0].selectionEnd=e+t.length+1},10)},textAddReply:"Add Reply",textAdd:"Add",textCancel:"Cancel",textEdit:"Edit",textReply:"Reply",textClose:"Close",textResolve:"Resolve",textOpenAgain:"Open Again",textFollowMove:"Follow Move",textMention:"+mention will provide access to the document and send an email"},Common.Views.ReviewPopover||{}))}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Comments",["core","common/main/lib/model/Comment","common/main/lib/collection/Comments","common/main/lib/view/Comments","common/main/lib/view/ReviewPopover"],function(){"use strict";function t(){return void 0!==Asc.asc_CCommentDataWord?new Asc.asc_CCommentDataWord(null):new Asc.asc_CCommentData(null)}Common.Controllers.Comments=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.Comments"],views:["Common.Views.Comments","Common.Views.ReviewPopover"],sdkViewName:"#id_main",subEditStrings:{},filter:void 0,hintmode:!1,viewmode:!1,isSelectedComment:!1,uids:[],oldUids:[],isDummyComment:!1,initialize:function(){this.addListeners({"Common.Views.Comments":{"comment:add":_.bind(this.onCreateComment,this),"comment:change":_.bind(this.onChangeComment,this),"comment:remove":_.bind(this.onRemoveComment,this),"comment:resolve":_.bind(this.onResolveComment,this),"comment:show":_.bind(this.onShowComment,this),"comment:addReply":_.bind(this.onAddReplyComment,this),"comment:changeReply":_.bind(this.onChangeReplyComment,this),"comment:removeReply":_.bind(this.onRemoveReplyComment,this),"comment:editReply":_.bind(this.onShowEditReplyComment,this),"comment:closeEditing":_.bind(this.closeEditing,this)},"Common.Views.ReviewPopover":{"comment:change":_.bind(this.onChangeComment,this),"comment:remove":_.bind(this.onRemoveComment,this),"comment:resolve":_.bind(this.onResolveComment,this),"comment:show":_.bind(this.onShowComment,this),"comment:addReply":_.bind(this.onAddReplyComment,this),"comment:changeReply":_.bind(this.onChangeReplyComment,this),"comment:removeReply":_.bind(this.onRemoveReplyComment,this),"comment:editReply":_.bind(this.onShowEditReplyComment,this),"comment:closeEditing":_.bind(this.closeEditing,this),"comment:disableHint":_.bind(this.disableHint,this),"comment:addDummyComment":_.bind(this.onAddDummyComment,this)}}),Common.NotificationCenter.on("comments:updatefilter",_.bind(this.onUpdateFilter,this)),Common.NotificationCenter.on("app:comment:add",_.bind(this.onAppAddComment,this)),Common.NotificationCenter.on("layout:changed",function(t){Common.Utils.asyncCall(function(t){"toolbar"!=t&&"status"!=t||!this.view.$el.is(":visible")||this.onAfterShow()},this,t)}.bind(this))},onLaunch:function(){this.collection=this.getApplication().getCollection("Common.Collections.Comments"),this.collection&&(this.collection.comparator=function(t){return-t.get("time")}),this.popoverComments=new Common.Collections.Comments,this.popoverComments&&(this.popoverComments.comparator=function(t){return t.get("time")}),this.groupCollection=[],this.view=this.createView("Common.Views.Comments",{store:this.collection}),this.view.render(),this.userCollection=this.getApplication().getCollection("Common.Collections.Users"),this.userCollection.on("reset",_.bind(this.onUpdateUsers,this)),this.userCollection.on("add",_.bind(this.onUpdateUsers,this)),this.bindViewEvents(this.view,this.events)},setConfig:function(t,e){this.setApi(e),t&&(this.currentUserId=t.config.user.id,this.currentUserName=t.config.user.fullname,this.sdkViewName=t.sdkviewname||this.sdkViewName,this.hintmode=t.hintmode||!1,this.viewmode=t.viewmode||!1)},setApi:function(t){t&&(this.api=t,this.api.asc_registerCallback("asc_onAddComment",_.bind(this.onApiAddComment,this)),this.api.asc_registerCallback("asc_onAddComments",_.bind(this.onApiAddComments,this)),this.api.asc_registerCallback("asc_onRemoveComment",_.bind(this.onApiRemoveComment,this)),this.api.asc_registerCallback("asc_onChangeComments",_.bind(this.onChangeComments,this)),this.api.asc_registerCallback("asc_onRemoveComments",_.bind(this.onRemoveComments,this)),this.api.asc_registerCallback("asc_onChangeCommentData",_.bind(this.onApiChangeCommentData,this)),this.api.asc_registerCallback("asc_onLockComment",_.bind(this.onApiLockComment,this)),this.api.asc_registerCallback("asc_onUnLockComment",_.bind(this.onApiUnLockComment,this)),this.api.asc_registerCallback("asc_onShowComment",_.bind(this.onApiShowComment,this)),this.api.asc_registerCallback("asc_onHideComment",_.bind(this.onApiHideComment,this)),this.api.asc_registerCallback("asc_onUpdateCommentPosition",_.bind(this.onApiUpdateCommentPosition,this)),this.api.asc_registerCallback("asc_onDocumentPlaceChanged",_.bind(this.onDocumentPlaceChanged,this)))},setMode:function(t){return this.mode=t,this.isModeChanged=!0,this.view.viewmode=!this.mode.canComments,this.view.changeLayout(t),this},onCreateComment:function(e,i,n,o,s){if(this.api&&i&&i.length>0){var a=t();a&&(this.showPopover=!0,this.editPopover=!!n,this.hidereply=o,this.isSelectedComment=!1,this.uids=[],a.asc_putText(i),a.asc_putTime(this.utcDateToString(new Date)),a.asc_putOnlyOfficeTime(this.ooDateToString(new Date)),a.asc_putUserId(this.currentUserId),a.asc_putUserName(this.currentUserName),a.asc_putSolved(!1),_.isUndefined(a.asc_putDocumentFlag)||a.asc_putDocumentFlag(s),this.api.asc_addComment(a),this.view.showEditContainer(!1))}this.view.txtComment.focus()},onRemoveComment:function(t){this.api&&t&&this.api.asc_removeComment(t)},onResolveComment:function(e){var i=this,n=null,o=null,s=t(),a=i.findComment(e);return _.isUndefined(e)&&(e=a.get("uid")),!(!s||!a)&&(s.asc_putText(a.get("comment")),s.asc_putQuoteText(a.get("quote")),s.asc_putTime(i.utcDateToString(new Date(a.get("time")))),s.asc_putOnlyOfficeTime(i.ooDateToString(new Date(a.get("time")))),s.asc_putUserId(a.get("userid")),s.asc_putUserName(a.get("username")),s.asc_putSolved(!a.get("resolved")),s.asc_putGuid(a.get("guid")),_.isUndefined(s.asc_putDocumentFlag)||s.asc_putDocumentFlag(a.get("unattached")),n=a.get("replys"),n&&n.length&&n.forEach(function(e){(o=t())&&(o.asc_putText(e.get("reply")),o.asc_putTime(i.utcDateToString(new Date(e.get("time")))),o.asc_putOnlyOfficeTime(i.ooDateToString(new Date(e.get("time")))),o.asc_putUserId(e.get("userid")),o.asc_putUserName(e.get("username")),s.asc_addReply(o))}),i.api.asc_changeComment(e,s),!0)},onShowComment:function(t,e){var i=this.findComment(t);if(i)if(null!==i.get("quote")){if(this.api){if(this.hintmode){if(this.animate=!0,i.get("unattached")&&this.getPopover())return void this.getPopover().hideComments()}else{var n=this.popoverComments.findWhere({uid:t});if(n&&!this.getPopover().isVisible())return this.getPopover().showComments(!0),void this.api.asc_selectComment(t)}!_.isUndefined(e)&&this.hintmode&&(this.isSelectedComment=e),this.api.asc_selectComment(t),this._dontScrollToComment=!0,this.api.asc_showComment(t,!1)}}else this.hintmode&&this.api.asc_selectComment(t),this.getPopover()&&this.getPopover().hideComments(),this.isSelectedComment=!1,this.uids=[]},onChangeComment:function(e,i){if(i&&i.length>0){var n=this,o=null,s=null,a=null,l=t(),r=n.findComment(e);if(r&&l)return l.asc_putText(i),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(n.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(n.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(n.currentUserId),l.asc_putUserName(n.currentUserName),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),r.set("editTextInPopover",!1),o=n.findPopupComment(e),o&&o.set("editTextInPopover",!1),n.subEditStrings[e]&&delete n.subEditStrings[e],n.subEditStrings[e+"-R"]&&delete n.subEditStrings[e+"-R"],s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(a.asc_putText(e.get("reply")),a.asc_putTime(n.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username")),l.asc_addReply(a))}),n.api.asc_changeComment(e,l),!0}return!1},onChangeReplyComment:function(e,i,n){if(n&&n.length>0){var o=this,s=null,a=null,l=t(),r=o.findComment(e);if(l&&r)return l.asc_putText(r.get("comment")),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(o.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(o.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(r.get("userid")),l.asc_putUserName(r.get("username")),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(e.get("id")!==i||_.isUndefined(n)?(a.asc_putText(e.get("reply")),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username"))):(a.asc_putText(n),a.asc_putUserId(o.currentUserId),a.asc_putUserName(o.currentUserName)),a.asc_putTime(o.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(o.ooDateToString(new Date(e.get("time")))),l.asc_addReply(a))}),o.api.asc_changeComment(e,l),!0}return!1},onAddReplyComment:function(e,i){if(i.length>0){var n=this,o=null,s=null,a=null,l=t(),r=n.findComment(e);if(l&&r&&(o=r.get("uid"),o&&(n.subEditStrings[o]&&delete n.subEditStrings[o],n.subEditStrings[o+"-R"]&&delete n.subEditStrings[o+"-R"],r.set("showReplyInPopover",!1)),l.asc_putText(r.get("comment")),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(n.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(n.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(r.get("userid")),l.asc_putUserName(r.get("username")),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(a.asc_putText(e.get("reply")),a.asc_putTime(n.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username")),l.asc_addReply(a))}),a=t()))return a.asc_putText(i),a.asc_putTime(n.utcDateToString(new Date)),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date)),a.asc_putUserId(n.currentUserId),a.asc_putUserName(n.currentUserName),l.asc_addReply(a),n.api.asc_changeComment(e,l),n.mode&&n.mode.canRequestUsers&&n.view.pickEMail(l.asc_getGuid(),i),!0}return!1},onRemoveReplyComment:function(e,i){if(!_.isUndefined(e)&&!_.isUndefined(i)){var n=this,o=null,s=null,a=t(),l=n.findComment(e);if(a&&l)return a.asc_putText(l.get("comment")),a.asc_putQuoteText(l.get("quote")),a.asc_putTime(n.utcDateToString(new Date(l.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(l.get("time")))),a.asc_putUserId(l.get("userid")),a.asc_putUserName(l.get("username")),a.asc_putSolved(l.get("resolved")),a.asc_putGuid(l.get("guid")),_.isUndefined(a.asc_putDocumentFlag)||a.asc_putDocumentFlag(l.get("unattached")),o=l.get("replys"),o&&o.length&&o.forEach(function(e){e.get("id")!==i&&(s=t())&&(s.asc_putText(e.get("reply")),s.asc_putTime(n.utcDateToString(new Date(e.get("time")))),s.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),s.asc_putUserId(e.get("userid")),s.asc_putUserName(e.get("username")),a.asc_addReply(s))}),n.api.asc_changeComment(e,a),!0}return!1},onShowEditReplyComment:function(t,e,i){var n,o,s,a;if(!_.isUndefined(t)&&!_.isUndefined(e))if(i){if((o=this.popoverComments.findWhere({uid:t}))&&(s=o.get("replys"),a=_.clone(o.get("replys"))))for(n=0;n=0;--s)o?this.collection.at(s).set("last",!0,{silent:!0}):this.collection.at(s).get("last")&&this.collection.at(s).set("last",!1,{silent:!0}),o=!1;this.view.render(),this.view.update()}}},onAppAddComment:function(t,e){this.api.can_AddQuotedComment&&!1===this.api.can_AddQuotedComment()||e||this.addDummyComment()},addCommentToGroupCollection:function(t){var e=t.get("groupName");this.groupCollection[e]||(this.groupCollection[e]=new Backbone.Collection([],{model:Common.Models.Comment})),this.groupCollection[e].push(t)},onApiAddComment:function(t,e){var i=this.readSDKComment(t,e);i&&(i.get("groupName")?(this.addCommentToGroupCollection(i),_.indexOf(this.collection.groups,i.get("groupName"))>-1&&this.collection.push(i)):this.collection.push(i),this.updateComments(!0),this.showPopover&&(null!==e.asc_getQuoteText()&&(this.api.asc_selectComment(t),this._dontScrollToComment=!0,this.api.asc_showComment(t,!0)),this.showPopover=void 0,this.editPopover=!1))},onApiAddComments:function(t){for(var e=0;e100&&(clearInterval(n.timerUpdateComments),n.timerUpdateComments=void 0,n.updateCommentsView(t,e,i))},25))},updateCommentsView:function(t,e,i){if(t&&!this.view.isVisible())return this.view.needRender=t,void this.onUpdateFilter(this.filter,!0);var n,o=!0;if(_.isUndefined(e)&&this.collection.sort(),t){for(this.onUpdateFilter(this.filter,!0),n=this.collection.length-1;n>=0;--n)o?this.collection.at(n).set("last",!0,{silent:!0}):this.collection.at(n).get("last")&&this.collection.at(n).set("last",!1,{silent:!0}),o=!1;this.view.render(),this.view.needRender=!1}this.view.update(),i&&this.view.loadText()},findComment:function(t){return this.collection.findWhere({uid:t})},findPopupComment:function(t){return this.popoverComments.findWhere({id:t})},findCommentInGroup:function(t){for(var e in this.groupCollection){var i=this.groupCollection[e],n=i.findWhere({uid:t});if(n)return n}},closeEditing:function(t){if(!_.isUndefined(t)){var e=this.findPopupComment(t);e&&(e.set("editTextInPopover",!1),e.set("showReplyInPopover",!1)),this.subEditStrings[t]&&delete this.subEditStrings[t],this.subEditStrings[t+"-R"]&&delete this.subEditStrings[t+"-R"]}this.collection.clearEditing(),this.collection.each(function(t){var e=_.clone(t.get("replys"));t.get("replys").length=0,e.forEach(function(t){t.get("editText")&&t.set("editText",!1),t.get("editTextInPopover")&&t.set("editTextInPopover",!1)}),t.set("replys",e)}),this.view.showEditContainer(!1),this.view.update()},disableHint:function(t){t&&this.mode.canComments&&(t.set("hint",!1),this.api.asc_showComment(t.get("uid"),!1),this.isSelectedComment=!0)},blockPopover:function(t){this.isSelectedComment=t,t&&this.getPopover().isVisible()&&this.getPopover().hide()},getPopover:function(){return _.isUndefined(this.popover)&&(this.popover=Common.Views.ReviewPopover.prototype.getPopover({commentsStore:this.popoverComments,renderTo:this.sdkViewName,canRequestUsers:this.mode?this.mode.canRequestUsers:void 0,canRequestSendNotify:this.mode?this.mode.canRequestSendNotify:void 0}),this.popover.setCommentsStore(this.popoverComments)),this.popover},onUpdateUsers:function(){var t=this.userCollection,e=!1;for(var i in this.groupCollection)e=!0,this.groupCollection[i].each(function(e){var i=t.findOriginalUser(e.get("userid")),n=i?i.get("color"):null,o=!1;n!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0})),e.get("replys").forEach(function(e){i=t.findOriginalUser(e.get("userid")),(n=i?i.get("color"):null)!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0}))}),o&&e.trigger("change")});!e&&this.collection.each(function(e){var i=t.findOriginalUser(e.get("userid")),n=i?i.get("color"):null,o=!1;n!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0})),e.get("replys").forEach(function(e){i=t.findOriginalUser(e.get("userid")),(n=i?i.get("color"):null)!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0}))}),o&&e.trigger("change")})},readSDKComment:function(t,e){var i=e.asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getOnlyOfficeTime())):""==e.asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getTime())),n=this.userCollection.findOriginalUser(e.asc_getUserId()),o=t.substr(0,t.lastIndexOf("_")+1).match(/^(doc|sheet[0-9_]+)_/),s=new Common.Models.Comment({uid:t,guid:e.asc_getGuid(),userid:e.asc_getUserId(),username:e.asc_getUserName(),usercolor:n?n.get("color"):null,date:this.dateToLocaleTimeString(i),quote:e.asc_getQuoteText(),comment:e.asc_getText(),resolved:e.asc_getSolved(),unattached:!_.isUndefined(e.asc_getDocumentFlag)&&e.asc_getDocumentFlag(),id:Common.UI.getId(),time:i.getTime(),showReply:!1,editText:!1,last:void 0,editTextInPopover:!!this.editPopover,showReplyInPopover:!1,hideAddReply:_.isUndefined(this.hidereply)?!!this.showPopover:this.hidereply,scope:this.view,editable:this.mode.canEditComments||e.asc_getUserId()==this.currentUserId,hint:!this.mode.canComments,groupName:o&&o.length>1?o[1]:null});if(s){var a=this.readSDKReplies(e);a.length&&s.set("replys",a)}return s},readSDKReplies:function(t){var e=0,i=[],n=null,o=t.asc_getRepliesCount();if(o)for(e=0;e0){var i=t();i&&(this.showPopover=!0,this.editPopover=!1,this.hidereply=!1,this.isSelectedComment=!1,this.uids=[],this.popoverComments.reset(),this.getPopover().isVisible()&&this.getPopover().hideComments(),this.isDummyComment=!1,i.asc_putText(e),i.asc_putTime(this.utcDateToString(new Date)),i.asc_putOnlyOfficeTime(this.ooDateToString(new Date)),i.asc_putUserId(this.currentUserId),i.asc_putUserName(this.currentUserName),i.asc_putSolved(!1),_.isUndefined(i.asc_putDocumentFlag)||i.asc_putDocumentFlag(!1),this.api.asc_addComment(i),this.view.showEditContainer(!1),this.mode&&this.mode.canRequestUsers&&this.view.pickEMail(i.asc_getGuid(),e),_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||this.api.asc_SetDocumentPlaceChangedEnabled(!1))}},clearDummyComment:function(t){if(this.isDummyComment){this.isDummyComment=!1,this.showPopover=!0,this.editPopover=!1,this.hidereply=!1,this.isSelectedComment=!1,this.uids=[];var e=this.getPopover();e&&(t&&e.clearDummyText(),e.saveDummyText(),e.handlerHide=function(){},e.isVisible()&&e.hideComments()),this.popoverComments.reset(),_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||this.api.asc_SetDocumentPlaceChangedEnabled(!1),Common.NotificationCenter.trigger("comments:cleardummy")}},onEditComments:function(t){if(this.api){var e=0,i=this,n=null,o=this.api.asc_getAnchorPosition();if(o){for(this.isSelectedComment=!0,this.popoverComments.reset(),e=0;e0&&(this.getPopover().isVisible()&&this.getPopover().hide(),this.getPopover().setLeftTop(o.asc_getX()+o.asc_getWidth(),o.asc_getY(),this.hintmode?o.asc_getX():void 0),this.getPopover().showComments(!0,!1,!0))}}},onAfterShow:function(){if(this.view&&this.api){var t=$(".new-comment-ct",this.view.el);t&&t.length&&"none"!==t.css("display")&&this.view.txtComment.focus(),this.view.needRender?this.updateComments(!0):this.view.needUpdateFilter&&this.onUpdateFilter(this.view.needUpdateFilter),this.view.update()}},onBeforeHide:function(){this.view&&this.view.showEditContainer(!1)},timeZoneOffsetInMs:6e4*(new Date).getTimezoneOffset(),stringOOToLocalDate:function(t){return"string"==typeof t?parseInt(t):0},ooDateToString:function(t){return"[object Date]"===Object.prototype.toString.call(t)?t.getTime().toString():""},stringUtcToLocalDate:function(t){return"string"==typeof t?parseInt(t)+this.timeZoneOffsetInMs:0},utcDateToString:function(t){return"[object Date]"===Object.prototype.toString.call(t)?(t.getTime()-this.timeZoneOffsetInMs).toString():""},dateToLocaleTimeString:function(t){return t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear()+" "+function(t){var e=t.getHours(),i=t.getMinutes(),n=e>=12?"pm":"am";return e%=12,e=e||12,i=i<10?"0"+i:i,e+":"+i+" "+n}(t)},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},setPreviewMode:function(t){this.viewmode!==t&&(this.viewmode=t,t&&(this.prevcanComments=this.mode.canComments),this.mode.canComments=!t&&this.prevcanComments,this.closeEditing(),this.setMode(this.mode),this.updateComments(!0),this.getPopover()&&(t?this.getPopover().hide():this.getPopover().update(!0)))},clearCollections:function(){this.collection.reset(),this.groupCollection=[]}},Common.Controllers.Comments||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/User",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.User=e.Model.extend({defaults:function(){return{iid:Common.UI.getId(),id:void 0,idOriginal:void 0,username:"Guest",color:"#fff",colorval:null,online:!1,view:!1}}})}),define("common/main/lib/collection/Users",["backbone","common/main/lib/model/User"],function(t){"use strict";Common.Collections=Common.Collections||{},Common.Collections.Users=t.Collection.extend({model:Common.Models.User,getOnlineCount:function(){var t=0;return this.each(function(e){e.get("online")&&++t}),t},getEditingCount:function(){return this.filter(function(t){return t.get("online")&&!t.get("view")}).length},getEditingOriginalCount:function(){return this.chain().filter(function(t){return t.get("online")&&!t.get("view")}).groupBy(function(t){return t.get("idOriginal")}).size().value()},findUser:function(t){return this.find(function(e){return e.get("id")==t})},findOriginalUser:function(t){return this.find(function(e){return e.get("idOriginal")==t})}}),Common.Collections.HistoryUsers=t.Collection.extend({model:Common.Models.User,findUser:function(t){return this.find(function(e){return e.get("id")==t})}})}),define("common/main/lib/model/ChatMessage",["backbone"],function(t){"use strict";Common.Models=Common.Models||{},Common.Models.ChatMessage=t.Model.extend({defaults:{type:0,userid:null,username:"",message:""}})}),define("common/main/lib/collection/ChatMessages",["backbone","common/main/lib/model/ChatMessage"],function(t){"use strict";!Common.Collections&&(Common.Collections={}),Common.Collections.ChatMessages=t.Collection.extend({model:Common.Models.ChatMessage})}),define("common/main/lib/controller/Chat",["core","common/main/lib/collection/Users","common/main/lib/collection/ChatMessages","common/main/lib/view/Chat"],function(){"use strict";Common.Controllers.Chat=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.Users","Common.Collections.ChatMessages"],views:["Common.Views.Chat"],initialize:function(){this.addListeners({"Common.Views.Chat":{"message:add":_.bind(this.onSendMessage,this)}});var t=this;Common.NotificationCenter.on("layout:changed",function(e){Common.Utils.asyncCall(function(e){"toolbar"!=e&&"status"!=e||!t.panelChat.$el.is(":visible")||(t.panelChat.updateLayout(!0),t.panelChat.setupAutoSizingTextBox())},this,e)})},events:{},onLaunch:function(){this.panelChat=this.createView("Common.Views.Chat",{storeUsers:this.getApplication().getCollection("Common.Collections.Users"),storeMessages:this.getApplication().getCollection("Common.Collections.ChatMessages")})},setMode:function(t){return this.mode=t,this.api&&(this.mode.canCoAuthoring&&this.mode.canChat&&this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage",_.bind(this.onReceiveMessage,this)), -this.mode.isEditDiagram||this.mode.isEditMailMerge||(this.api.asc_registerCallback("asc_onAuthParticipantsChanged",_.bind(this.onUsersChanged,this)),this.api.asc_registerCallback("asc_onConnectionStateChanged",_.bind(this.onUserConnection,this)),this.api.asc_coAuthoringGetUsers()),this.mode.canCoAuthoring&&this.mode.canChat&&this.api.asc_coAuthoringChatGetMessages()),this},setApi:function(t){return this.api=t,this},onUsersChanged:function(t,e){if(!this.mode.canLicense||!this.mode.canCoAuthoring){var i=0;for(o in t)void 0!==o&&i++;if(i>1&&void 0==this._isCoAuthoringStopped)return this._isCoAuthoringStopped=!0,this.api.asc_coAuthoringDisconnect(),void Common.NotificationCenter.trigger("api:disconnect")}var n=this.getApplication().getCollection("Common.Collections.Users");if(n){var o,s,a=[];for(o in t)if(void 0!==o&&(s=t[o])){var l=new Common.Models.User({id:s.asc_getId(),idOriginal:s.asc_getIdOriginal(),username:s.asc_getUserName(),online:!0,color:s.asc_getColor(),view:s.asc_getView()});a[s.asc_getId()==e?"unshift":"push"](l)}n[n.size()>0?"add":"reset"](a)}},onUserConnection:function(t){var e=this.getApplication().getCollection("Common.Collections.Users");if(e){var i=e.findUser(t.asc_getId());i?i.set({online:t.asc_getState()}):e.add(new Common.Models.User({id:t.asc_getId(),idOriginal:t.asc_getIdOriginal(),username:t.asc_getUserName(),online:t.asc_getState(),color:t.asc_getColor(),view:t.asc_getView()}))}},onReceiveMessage:function(t,e){var i=this.getApplication().getCollection("Common.Collections.ChatMessages");if(i){var n=[];t.forEach(function(t){n.push(new Common.Models.ChatMessage({userid:t.useridoriginal,message:t.message,username:t.username}))}),i[i.size()<1||e?"reset":"add"](n)}},onSendMessage:function(t,e){if(e.length>0){var i=this;(function(t,e){for(var i=[];t;){if(t.length .group",e.$toolbarPanelPlugins),o=$('').appendTo(n);i.render(o)}},onResetPlugins:function(t){var e=this;if(e.appOptions.canPlugins=!t.isEmpty(),e.$toolbarPanelPlugins){e.$toolbarPanelPlugins.empty();var i=$('
'),n=-1,o=0;t.each(function(t){var s=t.get("groupRank");s!==n&&n>-1&&o>0&&(i.appendTo(e.$toolbarPanelPlugins),$('
').appendTo(e.$toolbarPanelPlugins),i=$('
'),o=0);var a=e.panelPlugins.createPluginButton(t);if(a){var l=$('').appendTo(i);a.render(l),o++}n=s}),i.appendTo(e.$toolbarPanelPlugins)}else console.error("toolbar panel isnot created")},onSelectPlugin:function(t,e,i,n){var o=$(n.target);if(o&&o.hasClass("plugin-caret")){var s=this.panelPlugins.pluginMenu;if(s.isVisible())return void s.hide();var a,l=this,r=$(n.currentTarget),c=$(this.panelPlugins.el),h=r.offset(),d=c.offset();if(a=[h.left-d.left+r.width(),h.top-d.top+r.height()/2],void 0!=i){for(var p=0;p0?u.get("description"):l.panelPlugins.textStart,value:parseInt(u.get("index"))}).on("click",function(t,e){l.api&&l.api.asc_pluginRun(i.get("guid"),t.value,"")});s.addItem(g)}}var b=c.find("#menu-plugin-container");s.rendered||(b.length<1&&(b=$('',s.id),c.append(b)),s.render(b),s.cmpEl.attr({tabindex:"-1"}),s.on({"show:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!0)},"hide:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!1)}})),b.css({left:a[0],top:a[1]}),s.menuAlignEl=r,s.setOffset(-20,-r.height()/2-3),s.show(),_.delay(function(){s.cmpEl.focus()},10),n.stopPropagation(),n.preventDefault()}else this.api.asc_pluginRun(i.get("guid"),0,"")},onPluginShow:function(t,e,i,n){var o=t.get_Variations()[e];if(o.get_Visual()){var s=o.get_Url();if(s=(0==t.get_BaseUrl().length?s:t.get_BaseUrl())+s,n&&(s+=n),o.get_InsideMode())this.panelPlugins.openInsideMode(t.get_Name(),s,i)||this.api.asc_pluginButtonClick(-1);else{var a=this,l=o.get_CustomWindow(),r=o.get_Buttons(),c={},h=o.get_Size();(!h||h.length<2)&&(h=[800,600]),_.isArray(r)&&_.each(r,function(t,e){t.visible&&(c[e]={text:t.text,cls:"custom"+(t.primary?" primary":"")})}),a.pluginDlg=new Common.Views.PluginDlg({cls:l?"plain":"",header:!l,title:t.get_Name(),width:h[0],height:h[1],url:s,frameId:i,buttons:l?void 0:c,toolcallback:_.bind(this.onToolClose,this)}),a.pluginDlg.on({"render:after":function(t){t.getChild(".footer .dlg-btn").on("click",_.bind(a.onDlgBtnClick,a)),a.pluginContainer=a.pluginDlg.$window.find("#id-plugin-container")},close:function(t){a.pluginDlg=void 0},drag:function(t){a.api.asc_pluginEnableMouseEvents("start"==t[1])},resize:function(t){a.api.asc_pluginEnableMouseEvents("start"==t[1])}}),a.pluginDlg.show()}}this.panelPlugins.openedPluginMode(t.get_Guid())},onPluginClose:function(t){this.pluginDlg?this.pluginDlg.close():this.panelPlugins.iframePlugin&&this.panelPlugins.closeInsideMode(),this.panelPlugins.closedPluginMode(t.get_Guid()),this.runAutoStartPlugins()},onPluginResize:function(t,e,i,n){if(this.pluginDlg){var o=e&&e.length>1&&i&&i.length>1&&(i[0]>e[0]||i[1]>e[1]||0==i[0]||0==i[1]);this.pluginDlg.setResizable(o,e,i),this.pluginDlg.setInnerSize(t[0],t[1]),n&&n.call()}},onDlgBtnClick:function(t){var e=t.currentTarget.attributes.result.value;this.api.asc_pluginButtonClick(parseInt(e))},onToolClose:function(){this.api.asc_pluginButtonClick(-1)},onPluginMouseUp:function(t,e){this.pluginDlg?(this.pluginDlg.binding.dragStop&&this.pluginDlg.binding.dragStop(),this.pluginDlg.binding.resizeStop&&this.pluginDlg.binding.resizeStop()):Common.NotificationCenter.trigger("frame:mouseup",{pageX:t*Common.Utils.zoom()+this._moveOffset.x,pageY:e*Common.Utils.zoom()+this._moveOffset.y})},onPluginMouseMove:function(t,e){if(this.pluginDlg){var i=this.pluginContainer.offset();this.pluginDlg.binding.drag&&this.pluginDlg.binding.drag({pageX:t*Common.Utils.zoom()+i.left,pageY:e*Common.Utils.zoom()+i.top}),this.pluginDlg.binding.resize&&this.pluginDlg.binding.resize({pageX:t*Common.Utils.zoom()+i.left,pageY:e*Common.Utils.zoom()+i.top})}else Common.NotificationCenter.trigger("frame:mousemove",{pageX:t*Common.Utils.zoom()+this._moveOffset.x,pageY:e*Common.Utils.zoom()+this._moveOffset.y})},onPluginsInit:function(t){!(t instanceof Array)&&(t=t.pluginsData),this.parsePlugins(t)},runAutoStartPlugins:function(){this.autostart&&this.autostart.length>0&&this.api.asc_pluginRun(this.autostart.shift(),0,"")},resetPluginsList:function(){this.getApplication().getCollection("Common.Collections.Plugins").reset()},applyUICustomization:function(){var me=this;return new Promise(function(resolve,reject){var timer_sl=setInterval(function(){if(me.customPluginsComplete){clearInterval(timer_sl);try{me.configPlugins.UIplugins&&me.configPlugins.UIplugins.forEach(function(c){c.code&&eval(c.code)})}catch(t){}resolve()}},10)})},parsePlugins:function(t,e){var i=this,n=this.getApplication().getCollection("Common.Collections.Plugins"),o=i.appOptions.isEdit,s=i.editor;if(t instanceof Array){var a=[],l=[],r=i.appOptions.lang.split(/[\-_]/)[0];t.forEach(function(t){if(!(a.some(function(e){return e.get("baseUrl")==t.baseUrl||e.get("guid")==t.guid})||n.findWhere({baseUrl:t.baseUrl})||n.findWhere({guid:t.guid}))){var e=[],i=!1;if(t.variations.forEach(function(n){var a=(o||n.isViewer&&!1!==n.isDisplayedInViewer)&&_.contains(n.EditorsSupport,s)&&!n.isSystem;if(a&&(i=!0),t.isUICustomizer)a&&l.push({url:t.baseUrl+n.url});else{var c=new Common.Models.PluginVariation(n),h=n.description;"object"==typeof n.descriptionLocale&&(h=n.descriptionLocale[r]||n.descriptionLocale.en||h||""),_.each(n.buttons,function(t,e){"object"==typeof t.textLocale&&(t.text=t.textLocale[r]||t.textLocale.en||t.text||""),t.visible=o||!1!==t.isViewer}),c.set({description:h,index:e.length,url:n.url,icons:n.icons,buttons:n.buttons,visible:a}),e.push(c)}}),e.length>0&&!t.isUICustomizer){var c=t.name;"object"==typeof t.nameLocale&&(c=t.nameLocale[r]||t.nameLocale.en||c||""),a.push(new Common.Models.Plugin({name:c,guid:t.guid,baseUrl:t.baseUrl,variations:e,currentVariation:0,visible:i,groupName:t.group?t.group.name:"",groupRank:t.group?t.group.rank:0}))}}}),!1!==e&&(i.configPlugins.UIplugins=l),!e&&n&&(a=n.models.concat(a),a.sort(function(t,e){var i=t.get("groupRank"),n=e.get("groupRank");return in?0==n?-1:1:0}),n.reset(a),this.appOptions.canPlugins=!n.isEmpty())}else e||(this.appOptions.canPlugins=!1);e||this.getApplication().getController("LeftMenu").enablePlugins(),this.appOptions.canPlugins&&(this.refreshPluginsList(),this.runAutoStartPlugins())},getPlugins:function(t,e){if(!t||t.length<1)return Promise.resolve([]);e=e||function(t){return fetch(t).then(function(e){return e.ok?e.json():Promise.reject(t)}).then(function(e){return e.baseUrl=t.substring(0,t.lastIndexOf("config.json")),e})};var i=[];return t.map(e).reduce(function(t,e){return t.then(function(){return e}).then(function(t){return i.push(t),Promise.resolve(t)}).catch(function(t){return Promise.resolve(t)})},Promise.resolve()).then(function(){return Promise.resolve(i)})},mergePlugins:function(){if(void 0!==this.serverPlugins.plugins&&void 0!==this.configPlugins.plugins){var t=[],e=[],i=this.configPlugins,n=!1;if(i.plugins&&i.plugins.length>0){e=i.plugins;var o=i.config.autostart||i.config.autoStartGuid;"string"==typeof o&&(o=[o]),n=!!i.config.autoStartGuid,t=o||[]}if(i=this.serverPlugins,i.plugins&&i.plugins.length>0){e=e.concat(i.plugins);var o=i.config.autostart||i.config.autoStartGuid;"string"==typeof o&&(o=[o]),(n||i.config.autoStartGuid)&&console.warn("Obsolete: The autoStartGuid parameter is deprecated. Please check the documentation for new plugin connection configuration."),t=t.concat(o||[])}this.autostart=t,this.parsePlugins(e,!1)}},getAppCustomPlugins:function(t){var e=this,i=function(){e.customPluginsComplete=!0};t.config?this.getPlugins(t.config.UIpluginsData).then(function(n){e.parsePlugins(n,!0),e.getPlugins(t.UIplugins,function(t){return fetch(t.url).then(function(t){return t.ok?t.text():Promise.reject()}).then(function(e){return t.code=e,e})}).then(i,i)},i):i()}},Common.Controllers.Plugins||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/ReviewChange",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.ReviewChange=e.Model.extend({defaults:{uid:0,userid:0,username:"Guest",usercolor:null,date:void 0,changetext:"",lock:!1,lockuser:"",type:0,changedata:null,hint:!1,editable:!1,id:Common.UI.getId(),scope:null}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/ReviewChanges",["underscore","backbone","common/main/lib/model/ReviewChange"],function(t,e){"use strict";Common.Collections.ReviewChanges=e.Collection.extend({model:Common.Models.ReviewChange})}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/ReviewChanges",["common/main/lib/util/utils","common/main/lib/component/Button","common/main/lib/component/DataView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(){"use strict";Common.Views.ReviewChanges=Common.UI.BaseView.extend(_.extend(function(){function t(t,e){this.appConfig.canReview&&(Common.NotificationCenter.trigger("reviewchanges:turn",t.pressed?"on":"off"),Common.NotificationCenter.trigger("edit:complete"))}function e(){var e=this;e.appConfig.canReview&&(this.btnAccept.on("click",function(t){e.fireEvent("reviewchange:accept",[e.btnAccept,"current"])}),this.btnAccept.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchange:accept",[t,i])}),this.btnReject.on("click",function(t){e.fireEvent("reviewchange:reject",[e.btnReject,"current"])}),this.btnReject.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchange:reject",[t,i])}),this.btnsTurnReview.forEach(function(i){i.on("click",t.bind(e))})),this.appConfig.canViewReview&&(this.btnPrev.on("click",function(t){e.fireEvent("reviewchange:preview",[e.btnPrev,"prev"])}),this.btnNext.on("click",function(t){e.fireEvent("reviewchange:preview",[e.btnNext,"next"])}),this.btnReviewView&&this.btnReviewView.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchanges:view",[t,i])})),this.btnsSpelling.forEach(function(t){t.on("click",function(t,i){Common.NotificationCenter.trigger("spelling:turn",t.pressed?"on":"off"),Common.NotificationCenter.trigger("edit:complete",e)})}),this.btnsDocLang.forEach(function(t){t.on("click",function(t,i){e.fireEvent("lang:document",this)})}),this.btnSharing&&this.btnSharing.on("click",function(t,e){Common.NotificationCenter.trigger("collaboration:sharing")}),this.btnCoAuthMode&&this.btnCoAuthMode.menu.on("item:click",function(t,i,n){e.fireEvent("collaboration:coauthmode",[t,i])}),this.btnHistory&&this.btnHistory.on("click",function(t,e){Common.NotificationCenter.trigger("collaboration:history")}),this.btnChat&&this.btnChat.on("click",function(t,i){e.fireEvent("collaboration:chat",[t.pressed])})}return{options:{},initialize:function(t){if(Common.UI.BaseView.prototype.initialize.call(this,t),this.appConfig=t.mode,this.appConfig.canReview&&(this.btnAccept=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",caption:this.txtAccept,split:!0,iconCls:"review-save"}),this.btnReject=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",caption:this.txtReject,split:!0,iconCls:"review-deny"}),this.btnTurnOn=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-review",caption:this.txtTurnon,enableToggle:!0}),this.btnsTurnReview=[this.btnTurnOn]),this.appConfig.canViewReview&&(this.btnPrev=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"review-prev",caption:this.txtPrev}),this.btnNext=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"review-next",caption:this.txtNext}),!this.appConfig.isRestrictedEdit)){var e=_.template('
<%= caption %>
<% if (options.description !== null) { %><% } %>
');this.btnReviewView=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-reviewview",caption:this.txtView,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.txtMarkupCap,checkable:!0,toggleGroup:"menuReviewView",checked:!0,value:"markup",template:e,description:this.txtMarkup},{caption:this.txtFinalCap,checkable:!0,toggleGroup:"menuReviewView",checked:!1,template:e,description:this.txtFinal,value:"final"},{caption:this.txtOriginalCap,checkable:!0,toggleGroup:"menuReviewView",checked:!1,template:e,description:this.txtOriginal,value:"original"}]})})}this.appConfig.sharingSettingsUrl&&this.appConfig.sharingSettingsUrl.length&&!0!==this._readonlyRights&&(this.btnSharing=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-sharing",caption:this.txtSharing})),this.appConfig.isEdit&&!this.appConfig.isOffline&&this.appConfig.canCoAuthoring&&(this.btnCoAuthMode=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-coedit",caption:this.txtCoAuthMode,menu:!0})),this.btnsSpelling=[],this.btnsDocLang=[],this.appConfig.canUseHistory&&!this.appConfig.isDisconnected&&(this.btnHistory=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-history",caption:this.txtHistory})),this.appConfig.canCoAuthoring&&this.appConfig.canChat&&(this.btnChat=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-chat",caption:this.txtChat,enableToggle:!0}));var i=Common.localStorage.getKeysFilter();this.appPrefix=i&&i.length?i.split(",")[0]:"",Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this.boxSdk=$("#editor_sdk"),t&&t.html(this.getPanel()),this},onAppReady:function(t){var i=this;new Promise(function(t,e){t()}).then(function(){var n=_.template('
<%= caption %>
<% if (options.description !== null) { %><% } %>
');if(t.canReview&&(i.btnTurnOn.updateHint(i.tipReview),i.btnAccept.setMenu(new Common.UI.Menu({items:[{caption:i.txtAcceptCurrent,value:"current"},{caption:i.txtAcceptAll,value:"all"}]})),i.btnAccept.updateHint([i.tipAcceptCurrent,i.txtAcceptChanges]),i.btnReject.setMenu(new Common.UI.Menu({items:[{caption:i.txtRejectCurrent,value:"current"},{caption:i.txtRejectAll,value:"all"}]})),i.btnReject.updateHint([i.tipRejectCurrent,i.txtRejectChanges]),i.btnAccept.setDisabled(t.isReviewOnly),i.btnReject.setDisabled(t.isReviewOnly)),i.appConfig.canViewReview&&(i.btnPrev.updateHint(i.hintPrev),i.btnNext.updateHint(i.hintNext),i.btnReviewView&&i.btnReviewView.updateHint(i.tipReviewView)),i.btnSharing&&i.btnSharing.updateHint(i.tipSharing),i.btnHistory&&i.btnHistory.updateHint(i.tipHistory),i.btnChat&&i.btnChat.updateHint(i.txtChat+Common.Utils.String.platformKey("Alt+Q")),i.btnCoAuthMode){i.btnCoAuthMode.setMenu(new Common.UI.Menu({cls:"ppm-toolbar",style:"max-width: 220px;",items:[{caption:i.strFast,checkable:!0,toggleGroup:"menuCoauthMode",checked:!0,template:n,description:i.strFastDesc,value:1},{caption:i.strStrict,checkable:!0,toggleGroup:"menuCoauthMode",checked:!1,template:n,description:i.strStrictDesc,value:0}]})),i.btnCoAuthMode.updateHint(i.tipCoAuthMode);var o=Common.localStorage.getItem(i.appPrefix+"settings-coauthmode");null===o&&!Common.localStorage.itemExists(i.appPrefix+"settings-autosave")&&t.customization&&!1===t.customization.autosave&&(o=0),i.turnCoAuthMode((null===o||1==parseInt(o))&&!(t.isDesktopApp&&t.isOffline)&&t.canCoAuthoring)}var s,a=i.btnSharing||i.btnCoAuthMode?".separator.sharing":i.$el.find(".separator.sharing"),l=t.canComments&&t.canCoAuthoring?".separator.comments":i.$el.find(".separator.comments"),r=t.canReview||t.canViewReview?".separator.review":i.$el.find(".separator.review"),c=i.btnChat?".separator.chat":i.$el.find(".separator.chat");"object"==typeof a?a.hide().prev(".group").hide():s=a,"object"==typeof l?l.hide().prev(".group").hide():s=l,"object"==typeof r?r.hide().prevUntil(".separator.comments").hide():s=r,"object"==typeof c?c.hide().prev(".group").hide():s=c,!i.btnHistory&&s&&i.$el.find(s).hide(),Common.NotificationCenter.trigger("tab:visible","review",t.isEdit||t.canViewReview),e.call(i)})},getPanel:function(){return this.$el=$(_.template('
')({})),this.appConfig.canReview&&(this.btnAccept.render(this.$el.find("#btn-change-accept")),this.btnReject.render(this.$el.find("#btn-change-reject")),this.btnTurnOn.render(this.$el.find("#btn-review-on"))),this.btnPrev&&this.btnPrev.render(this.$el.find("#btn-change-prev")),this.btnNext&&this.btnNext.render(this.$el.find("#btn-change-next")),this.btnReviewView&&this.btnReviewView.render(this.$el.find("#btn-review-view")),this.btnSharing&&this.btnSharing.render(this.$el.find("#slot-btn-sharing")),this.btnCoAuthMode&&this.btnCoAuthMode.render(this.$el.find("#slot-btn-coauthmode")),this.btnHistory&&this.btnHistory.render(this.$el.find("#slot-btn-history")),this.btnChat&&this.btnChat.render(this.$el.find("#slot-btn-chat")),this.$el},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButton:function(t,e){if("turn"==t&&"statusbar"==e){var i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-review",hintAnchor:"top",hint:this.tipReview,enableToggle:!0});return this.btnsTurnReview.push(i),i}return"spelling"==t?(i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-docspell",hintAnchor:"top",hint:this.tipSetSpelling,enableToggle:!0}),this.btnsSpelling.push(i),i):"doclang"==t&&"statusbar"==e?(i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-doclang",hintAnchor:"top",hint:this.tipSetDocLang,disabled:!0}),this.btnsDocLang.push(i),i):void 0},getUserName:function(t){return Common.Utils.String.htmlEncode(t)},turnChanges:function(t){this.btnsTurnReview.forEach(function(e){e&&e.pressed!=t&&e.toggle(t,!0)},this)},markChanges:function(t){this.btnsTurnReview.forEach(function(e){if(e){$(".icon",e.cmpEl)[t?"addClass":"removeClass"]("btn-ic-changes")}},this)},turnSpelling:function(t){this.btnsSpelling.forEach(function(e){e&&e.pressed!=t&&e.toggle(t,!0)},this)},turnCoAuthMode:function(t){this.btnCoAuthMode&&(this.btnCoAuthMode.menu.items[0].setChecked(t,!0),this.btnCoAuthMode.menu.items[1].setChecked(!t,!0))},turnChat:function(t){this.btnChat&&this.btnChat.toggle(t,!0)},turnDisplayMode:function(t){this.btnReviewView&&(this.btnReviewView.menu.items[0].setChecked("markup"==t,!0),this.btnReviewView.menu.items[1].setChecked("final"==t,!0),this.btnReviewView.menu.items[2].setChecked("original"==t,!0))},SetDisabled:function(t,e){this.btnsSpelling&&this.btnsSpelling.forEach(function(e){e&&e.setDisabled(t)},this),this.btnsDocLang&&this.btnsDocLang.forEach(function(i){i&&i.setDisabled(t||e&&e.length<1)},this),this.btnsTurnReview&&this.btnsTurnReview.forEach(function(e){e&&e.setDisabled(t)},this),this.btnChat&&this.btnChat.setDisabled(t)},onLostEditRights:function(){this._readonlyRights=!0,this.rendered&&this.btnSharing&&this.btnSharing.setDisabled(!0)},txtAccept:"Accept",txtAcceptCurrent:"Accept current Changes",txtAcceptAll:"Accept all Changes",txtReject:"Reject",txtRejectCurrent:"Reject current Changes",txtRejectAll:"Reject all Changes",hintNext:"To Next Change",hintPrev:"To Previous Change",txtPrev:"Previous",txtNext:"Next",txtTurnon:"Turn On",txtSpelling:"Spell checking",txtDocLang:"Language",tipSetDocLang:"Set Document Language",tipSetSpelling:"Spell checking",tipReview:"Review",txtAcceptChanges:"Accept Changes",txtRejectChanges:"Reject Changes",txtView:"Display Mode",txtMarkup:"Text with changes (Editing)",txtFinal:"All changes like accept (Preview)",txtOriginal:"Text without changes (Preview)",tipReviewView:"Select the way you want the changes to be displayed",tipAcceptCurrent:"Accept current changes",tipRejectCurrent:"Reject current changes",txtSharing:"Sharing",tipSharing:"Manage document access rights",txtCoAuthMode:"Co-editing Mode",tipCoAuthMode:"Set co-editing mode",strFast:"Fast",strStrict:"Strict",txtHistory:"Version History",tipHistory:"Show version history",txtChat:"Chat",txtMarkupCap:"Markup",txtFinalCap:"Final",txtOriginalCap:"Original",strFastDesc:"Real-time co-editing. All changes are saved automatically.",strStrictDesc:"Use the 'Save' button to sync the changes you and others make."}}(),Common.Views.ReviewChanges||{})),Common.Views.ReviewChangesDialog=Common.UI.Window.extend(_.extend({options:{width:330,height:90,title:"Review Changes",modal:!1,cls:"review-changes modal-dlg",alias:"Common.Views.ReviewChangesDialog"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
','
','
','
','
','
',"
","
"].join(""),this.options.tpl=_.template(this.template)(this.options),this.popoverChanges=this.options.popoverChanges,this.mode=this.options.mode,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.btnPrev=new Common.UI.Button({cls:"dlg-btn iconic",iconCls:"img-commonctrl prev",hint:this.txtPrev,hintAnchor:"top"}),this.btnPrev.render(this.$window.find("#id-review-button-prev")),this.btnNext=new Common.UI.Button({cls:" dlg-btn iconic",iconCls:"img-commonctrl next",hint:this.txtNext,hintAnchor:"top"}),this.btnNext.render(this.$window.find("#id-review-button-next")),this.btnAccept=new Common.UI.Button({cls:"btn-toolbar",caption:this.txtAccept,split:!0,disabled:this.mode.isReviewOnly,menu:new Common.UI.Menu({items:[this.mnuAcceptCurrent=new Common.UI.MenuItem({caption:this.txtAcceptCurrent,value:"current"}),this.mnuAcceptAll=new Common.UI.MenuItem({caption:this.txtAcceptAll,value:"all"})]})}),this.btnAccept.render(this.$window.find("#id-review-button-accept")),this.btnReject=new Common.UI.Button({cls:"btn-toolbar",caption:this.txtReject,split:!0,disabled:this.mode.isReviewOnly,menu:new Common.UI.Menu({items:[this.mnuRejectCurrent=new Common.UI.MenuItem({caption:this.txtRejectCurrent,value:"current"}),this.mnuRejectAll=new Common.UI.MenuItem({caption:this.txtRejectAll,value:"all"})]})}),this.btnReject.render(this.$window.find("#id-review-button-reject")) -;var t=this;return this.btnPrev.on("click",function(e){t.fireEvent("reviewchange:preview",[t.btnPrev,"prev"])}),this.btnNext.on("click",function(e){t.fireEvent("reviewchange:preview",[t.btnNext,"next"])}),this.btnAccept.on("click",function(e){t.fireEvent("reviewchange:accept",[t.btnAccept,"current"])}),this.btnAccept.menu.on("item:click",function(e,i,n){t.fireEvent("reviewchange:accept",[e,i])}),this.btnReject.on("click",function(e){t.fireEvent("reviewchange:reject",[t.btnReject,"current"])}),this.btnReject.menu.on("item:click",function(e,i,n){t.fireEvent("reviewchange:reject",[e,i])}),this},textTitle:"Review Changes",txtPrev:"To previous change",txtNext:"To next change",txtAccept:"Accept",txtAcceptCurrent:"Accept Current Change",txtAcceptAll:"Accept All Changes",txtReject:"Reject",txtRejectCurrent:"Reject Current Change",txtRejectAll:"Reject All Changes"},Common.Views.ReviewChangesDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/LanguageDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.LanguageDialog=Common.UI.Window.extend(_.extend({options:{header:!1,width:350,cls:"modal-dlg"},template:'
',initialize:function(t){_.extend(this.options,t||{},{label:this.labelSelect,btns:{ok:this.btnOk,cancel:this.btnCancel}}),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this.getChild();t.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.cmbLanguage=new Common.UI.ComboBox({el:t.find("#id-document-language"),cls:"input-group-nr",menuStyle:"min-width: 318px; max-height: 285px;",editable:!1,template:_.template(['','','','','",""].join("")),data:this.options.languages,search:!0}),this.cmbLanguage.scroller&&this.cmbLanguage.scroller.update({alwaysVisibleY:!0}),this.cmbLanguage.on("selected",_.bind(this.onLangSelect,this));var e=Common.util.LanguageInfo.getLocalLanguageName(this.options.current);this.cmbLanguage.setValue(e[0],e[1]),this.onLangSelect(this.cmbLanguage,this.cmbLanguage.getSelectedRecord())},close:function(t){this.getChild().find(".combobox.open").length||Common.UI.Window.prototype.close.call(this,arguments)},onBtnClick:function(t){this.options.handler&&this.options.handler.call(this,t.currentTarget.attributes.result.value,this.cmbLanguage.getValue()),this.close()},onLangSelect:function(t,e,i){t.$el.find(".input-icon").toggleClass("spellcheck-lang",e&&e.spellcheck),t._input.css("padding-left",e&&e.spellcheck?25:3)},onPrimary:function(){return this.options.handler&&this.options.handler.call(this,"ok",this.cmbLanguage.getValue()),this.close(),!1},labelSelect:"Select document language",btnCancel:"Cancel",btnOk:"Ok"},Common.Views.LanguageDialog||{}))}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/ReviewChanges",["core","common/main/lib/model/ReviewChange","common/main/lib/collection/ReviewChanges","common/main/lib/view/ReviewChanges","common/main/lib/view/ReviewPopover","common/main/lib/view/LanguageDialog"],function(){"use strict";Common.Controllers.ReviewChanges=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.ReviewChanges"],views:["Common.Views.ReviewChanges","Common.Views.ReviewPopover"],sdkViewName:"#id_main",initialize:function(){this.addListeners({FileMenu:{"settings:apply":this.applySettings.bind(this)},"Common.Views.ReviewChanges":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:delete":_.bind(this.onDeleteClick,this),"reviewchange:preview":_.bind(this.onBtnPreviewClick,this),"reviewchanges:view":_.bind(this.onReviewViewClick,this),"lang:document":_.bind(this.onDocLanguage,this),"collaboration:coauthmode":_.bind(this.onCoAuthMode,this)},"Common.Views.ReviewChangesDialog":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:preview":_.bind(this.onBtnPreviewClick,this)},"Common.Views.ReviewPopover":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:delete":_.bind(this.onDeleteClick,this),"reviewchange:goto":_.bind(this.onGotoClick,this)}})},onLaunch:function(){this.collection=this.getApplication().getCollection("Common.Collections.ReviewChanges"),this.userCollection=this.getApplication().getCollection("Common.Collections.Users"),this._state={posx:-1e3,posy:-1e3,popoverVisible:!1,previewMode:!1},Common.NotificationCenter.on("reviewchanges:turn",this.onTurnPreview.bind(this)),Common.NotificationCenter.on("spelling:turn",this.onTurnSpelling.bind(this)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this)),this.userCollection.on("reset",_.bind(this.onUpdateUsers,this)),this.userCollection.on("add",_.bind(this.onUpdateUsers,this))},setConfig:function(t,e){this.setApi(e),t&&(this.currentUserId=t.config.user.id,this.sdkViewName=t.sdkviewname||this.sdkViewName)},setApi:function(t){t&&(this.api=t,(this.appConfig.canReview||this.appConfig.canViewReview)&&(this.api.asc_registerCallback("asc_onShowRevisionsChange",_.bind(this.onApiShowChange,this)),this.api.asc_registerCallback("asc_onUpdateRevisionsChangesPosition",_.bind(this.onApiUpdateChangePosition,this))),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)))},setMode:function(t){return this.appConfig=t,this.popoverChanges=new Common.Collections.ReviewChanges,this.view=this.createView("Common.Views.ReviewChanges",{mode:t}),this},SetDisabled:function(t){this.dlgChanges&&this.dlgChanges.close(),this.view&&this.view.SetDisabled(t,this.langs),this.setPreviewMode(t)},setPreviewMode:function(t){if(this.viewmode!==t){this.viewmode=t,t&&(this.prevcanReview=this.appConfig.canReview),this.appConfig.canReview=!t&&this.prevcanReview;var e=this;this.popoverChanges&&this.popoverChanges.each(function(t){t.set("hint",!e.appConfig.canReview)})}},onApiShowChange:function(t){if(this.getPopover())if(t&&t.length>0){var e=this.readSDKChange(t),i=t[0].get_X(),n=t[0].get_Y(),o=Math.abs(this._state.posx-i)>.001||Math.abs(this._state.posy-n)>.001||t.length!==this._state.changes_length,s=null!==t[0].get_LockUserId(),a=this.getUserName(t[0].get_LockUserId());this.getPopover().hideTips(),this.popoverChanges.reset(e),o&&(this.getPopover().isVisible()&&this.getPopover().hide(),this.getPopover().setLeftTop(i,n)),this.getPopover().showReview(o,s,a),this.appConfig.canReview&&!this.appConfig.isReviewOnly&&this._state.lock!==s&&(this.view.btnAccept.setDisabled(1==s),this.view.btnReject.setDisabled(1==s),this.dlgChanges&&(this.dlgChanges.btnAccept.setDisabled(1==s),this.dlgChanges.btnReject.setDisabled(1==s)),this._state.lock=s),this._state.posx=i,this._state.posy=n,this._state.changes_length=t.length,this._state.popoverVisible=!0}else this._state.popoverVisible&&(this._state.posx=this._state.posy=-1e3,this._state.changes_length=0,this._state.popoverVisible=!1,this.getPopover().hideTips(),this.popoverChanges.reset(),this.getPopover().hideReview())},onApiUpdateChangePosition:function(t,e){this.getPopover()&&(e<0||this.getPopover().sdkBounds.height0&&(this.getPopover().isVisible()||this.getPopover().show(!1),this.getPopover().setLeftTop(t,e)))},findChange:function(t,e){return _.isUndefined(t)?this.collection.findWhere({id:e}):this.collection.findWhere({uid:t})},getPopover:function(){return(this.appConfig.canReview||this.appConfig.canViewReview)&&_.isUndefined(this.popover)&&(this.popover=Common.Views.ReviewPopover.prototype.getPopover({reviewStore:this.popoverChanges,renderTo:this.sdkViewName}),this.popover.setReviewStore(this.popoverChanges)),this.popover},readSDKChange:function(t){var e=this,i=[];return _.each(t,function(t){var n="",o="",s=t.get_Value(),a=t.get_MoveType();switch(t.get_Type()){case Asc.c_oAscRevisionsChangeType.TextAdd:n=a==Asc.c_oAscRevisionsMove.NoMove?e.textInserted:e.textParaMoveTo,"object"==typeof s?_.each(s,function(t){if("string"==typeof t)n+=" "+Common.Utils.String.htmlEncode(t);else switch(t){case 0:n+=" <"+e.textImage+">";break;case 1:n+=" <"+e.textShape+">";break;case 2:n+=" <"+e.textChart+">";break;case 3:n+=" <"+e.textEquation+">"}}):"string"==typeof s&&(n+=" "+Common.Utils.String.htmlEncode(s));break;case Asc.c_oAscRevisionsChangeType.TextRem:n=a==Asc.c_oAscRevisionsMove.NoMove?e.textDeleted:t.is_MovedDown()?e.textParaMoveFromDown:e.textParaMoveFromUp,"object"==typeof s?_.each(s,function(t){if("string"==typeof t)n+=" "+Common.Utils.String.htmlEncode(t);else switch(t){case 0:n+=" <"+e.textImage+">";break;case 1:n+=" <"+e.textShape+">";break;case 2:n+=" <"+e.textChart+">";break;case 3:n+=" <"+e.textEquation+">"}}):"string"==typeof s&&(n+=" "+Common.Utils.String.htmlEncode(s));break;case Asc.c_oAscRevisionsChangeType.ParaAdd:n=e.textParaInserted;break;case Asc.c_oAscRevisionsChangeType.ParaRem:n=e.textParaDeleted;break;case Asc.c_oAscRevisionsChangeType.TextPr:n=""+e.textFormatted,void 0!==s.Get_Bold()&&(o+=(s.Get_Bold()?"":e.textNot)+e.textBold+", "),void 0!==s.Get_Italic()&&(o+=(s.Get_Italic()?"":e.textNot)+e.textItalic+", "),void 0!==s.Get_Underline()&&(o+=(s.Get_Underline()?"":e.textNot)+e.textUnderline+", "),void 0!==s.Get_Strikeout()&&(o+=(s.Get_Strikeout()?"":e.textNot)+e.textStrikeout+", "),void 0!==s.Get_DStrikeout()&&(o+=(s.Get_DStrikeout()?"":e.textNot)+e.textDStrikeout+", "),void 0!==s.Get_Caps()&&(o+=(s.Get_Caps()?"":e.textNot)+e.textCaps+", "),void 0!==s.Get_SmallCaps()&&(o+=(s.Get_SmallCaps()?"":e.textNot)+e.textSmallCaps+", "),void 0!==s.Get_VertAlign()&&(o+=(1==s.Get_VertAlign()?e.textSuperScript:2==s.Get_VertAlign()?e.textSubScript:e.textBaseline)+", "),void 0!==s.Get_Color()&&(o+=e.textColor+", "),void 0!==s.Get_Highlight()&&(o+=e.textHighlight+", "),void 0!==s.Get_Shd()&&(o+=e.textShd+", "),void 0!==s.Get_FontFamily()&&(o+=s.Get_FontFamily()+", "),void 0!==s.Get_FontSize()&&(o+=s.Get_FontSize()+", "),void 0!==s.Get_Spacing()&&(o+=e.textSpacing+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_Spacing()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Position()&&(o+=e.textPosition+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_Position()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Lang()&&(o+=Common.util.LanguageInfo.getLocalLanguageName(s.Get_Lang())[1]+", "),_.isEmpty(o)||(n+=": ",o=o.substring(0,o.length-2)),n+="",n+=o;break;case Asc.c_oAscRevisionsChangeType.ParaPr:if(n=""+e.textParaFormatted,s.Get_ContextualSpacing()&&(o+=(s.Get_ContextualSpacing()?e.textContextual:e.textNoContextual)+", "),void 0!==s.Get_IndLeft()&&(o+=e.textIndentLeft+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndLeft()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_IndRight()&&(o+=e.textIndentRight+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndRight()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_IndFirstLine()&&(o+=e.textFirstLine+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndFirstLine()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Jc())switch(s.Get_Jc()){case 0:o+=e.textRight+", ";break;case 1:o+=e.textLeft+", ";break;case 2:o+=e.textCenter+", ";break;case 3:o+=e.textJustify+", "}if(void 0!==s.Get_KeepLines()&&(o+=(s.Get_KeepLines()?e.textKeepLines:e.textNoKeepLines)+", "),s.Get_KeepNext()&&(o+=(s.Get_KeepNext()?e.textKeepNext:e.textNoKeepNext)+", "),s.Get_PageBreakBefore()&&(o+=(s.Get_PageBreakBefore()?e.textBreakBefore:e.textNoBreakBefore)+", "),void 0!==s.Get_SpacingLineRule()&&void 0!==s.Get_SpacingLine()&&(o+=e.textLineSpacing,o+=(s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_LEAST?e.textAtLeast:s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_AUTO?e.textMultiple:e.textExact)+" ",o+=(s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_AUTO?s.Get_SpacingLine():Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingLine()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName())+", "),s.Get_SpacingBeforeAutoSpacing()?o+=e.textSpacingBefore+" "+e.textAuto+", ":void 0!==s.Get_SpacingBefore()&&(o+=e.textSpacingBefore+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingBefore()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),s.Get_SpacingAfterAutoSpacing()?o+=e.textSpacingAfter+" "+e.textAuto+", ":void 0!==s.Get_SpacingAfter()&&(o+=e.textSpacingAfter+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingAfter()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),s.Get_WidowControl()&&(o+=(s.Get_WidowControl()?e.textWidow:e.textNoWidow)+", "),void 0!==s.Get_Tabs()&&(o+=o+=e.textTabs+", "),void 0!==s.Get_NumPr()&&(o+=o+=e.textNum+", "),void 0!==s.Get_PStyle()){var l=e.api.asc_GetStyleNameById(s.Get_PStyle());_.isEmpty(l)||(o+=l+", ")}_.isEmpty(o)||(n+=": ",o=o.substring(0,o.length-2)),n+="",n+=o;break;case Asc.c_oAscRevisionsChangeType.TablePr:n=e.textTableChanged;break;case Asc.c_oAscRevisionsChangeType.RowsAdd:n=e.textTableRowsAdd;break;case Asc.c_oAscRevisionsChangeType.RowsRem:n=e.textTableRowsDel}var r=""==t.get_DateTime()?new Date:new Date(t.get_DateTime()),c=e.userCollection.findOriginalUser(t.get_UserId()),h=new Common.Models.ReviewChange({uid:Common.UI.getId(),userid:t.get_UserId(),username:t.get_UserName(),usercolor:c?c.get("color"):null,date:e.dateToLocaleTimeString(r),changetext:n,id:Common.UI.getId(),lock:null!==t.get_LockUserId(),lockuser:e.getUserName(t.get_LockUserId()),type:t.get_Type(),changedata:t,scope:e.view,hint:!e.appConfig.canReview,goto:t.get_MoveType()==Asc.c_oAscRevisionsMove.MoveTo||t.get_MoveType()==Asc.c_oAscRevisionsMove.MoveFrom,editable:t.get_UserId()==e.currentUserId});i.push(h)}),i},getUserName:function(t){if(this.userCollection&&null!==t){var e=this.userCollection.findUser(t);if(e)return e.get("username")}return""},dateToLocaleTimeString:function(t){return t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear()+" "+function(t){var e=t.getHours(),i=t.getMinutes(),n=e>=12?"pm":"am";return e%=12,e=e||12,i=i<10?"0"+i:i,e+":"+i+" "+n}(t)},onBtnPreviewClick:function(t,e){switch(e){case"prev":this.api.asc_GetPrevRevisionsChange();break;case"next":this.api.asc_GetNextRevisionsChange()}Common.NotificationCenter.trigger("edit:complete",this.view)},onAcceptClick:function(t,e,i){this.api&&(e?"all"===e.value?this.api.asc_AcceptAllChanges():this.api.asc_AcceptChanges():this.api.asc_AcceptChanges(t)),Common.NotificationCenter.trigger("edit:complete",this.view)},onRejectClick:function(t,e,i){this.api&&(e?"all"===e.value?this.api.asc_RejectAllChanges():this.api.asc_RejectChanges():this.api.asc_RejectChanges(t)),Common.NotificationCenter.trigger("edit:complete",this.view)},onDeleteClick:function(t){this.api&&this.api.asc_RejectChanges(t),Common.NotificationCenter.trigger("edit:complete",this.view)},onGotoClick:function(t){this.api&&this.api.asc_FollowRevisionMove(t),Common.NotificationCenter.trigger("edit:complete",this.view)},onTurnPreview:function(t){this.appConfig.isReviewOnly?this.view.turnChanges(!0):this.appConfig.canReview&&(t="on"==t,this.api.asc_SetTrackRevisions(t),Common.localStorage.setItem(this.view.appPrefix+"track-changes-"+(this.appConfig.fileKey||""),t?1:0),this.view.turnChanges(t))},onTurnSpelling:function(t){t="on"==t,this.view.turnSpelling(t),Common.localStorage.setItem(this.view.appPrefix+"settings-spellcheck",t?1:0),this.api.asc_setSpellCheck(t),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-spellcheck",t)},onReviewViewClick:function(t,e,i){this.turnDisplayMode(e.value),!this.appConfig.canReview&&Common.localStorage.setItem(this.view.appPrefix+"review-mode",e.value),Common.NotificationCenter.trigger("edit:complete",this.view)},turnDisplayMode:function(t){this.api&&("final"===t?this.api.asc_BeginViewModeInReview(!0):"original"===t?this.api.asc_BeginViewModeInReview(!1):this.api.asc_EndViewModeInReview()),this.disableEditing("final"==t||"original"==t),this._state.previewMode="final"==t||"original"==t},isPreviewChangesMode:function(){return this._state.previewMode},onCoAuthMode:function(t,e,i){if(Common.localStorage.setItem(this.view.appPrefix+"settings-coauthmode",e.value),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-coauthmode",e.value),this.api){if(this.api.asc_SetFastCollaborative(1==e.value),this.api.SetCollaborativeMarksShowType){var n=Common.localStorage.getItem(e.value?this.view.appPrefix+"settings-showchanges-fast":this.view.appPrefix+"settings-showchanges-strict");null!==n?this.api.SetCollaborativeMarksShowType("all"==n?Asc.c_oAscCollaborativeMarksShowType.All:"none"==n?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges):this.api.SetCollaborativeMarksShowType(e.value?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges)}n=Common.localStorage.getItem(this.view.appPrefix+"settings-autosave"),null===n&&this.appConfig.customization&&!1===this.appConfig.customization.autosave&&(n=0),n=e.value||null===n?1:parseInt(n),Common.localStorage.setItem(this.view.appPrefix+"settings-autosave",n),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-autosave",n),this.api.asc_setAutoSaveGap(n)}Common.NotificationCenter.trigger("edit:complete",this.view),this.view.fireEvent("settings:apply",[this])},disableEditing:function(t){var e=this.getApplication();e.getController("Toolbar").DisableToolbar(t,!1,!0),e.getController("DocumentHolder").getView().SetDisabled(t),this.appConfig.canReview&&(e.getController("RightMenu").getView("RightMenu").clearSelection(),e.getController("RightMenu").SetDisabled(t,!1),e.getController("Statusbar").getView("Statusbar").SetDisabled(t),e.getController("Navigation")&&e.getController("Navigation").SetDisabled(t),e.getController("Common.Controllers.Plugins").getView("Common.Views.Plugins").disableControls(t));var i=e.getController("Common.Controllers.Comments");i&&i.setPreviewMode(t);var n=e.getController("LeftMenu");n.leftMenu.getMenu("file").miProtect.setDisabled(t),n.setPreviewMode(t),this.view&&(this.view.$el.find(".no-group-mask").css("opacity",1),this.view.btnsDocLang&&this.view.btnsDocLang.forEach(function(e){e&&e.setDisabled(t||!this.langs||this.langs.length<1)},this))},createToolbarPanel:function(){return this.view.getPanel()},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onAppReady:function(t){var e=this;if(e.view&&Common.localStorage.getBool(e.view.appPrefix+"settings-spellcheck",!0)&&e.view.turnSpelling(!0),t.canReview)new Promise(function(t){t()}).then(function(){var i=t.isReviewOnly||Common.localStorage.getBool(e.view.appPrefix+"track-changes-"+(t.fileKey||""));if(e.api.asc_HaveRevisionsChanges()&&e.view.markChanges(!0),function(t){e.view.turnChanges(t),e.api.asc_SetTrackRevisions(t)}(i),"object"==typeof e.appConfig.customization&&1==e.appConfig.customization.showReviewChanges){e.dlgChanges=new Common.Views.ReviewChangesDialog({popoverChanges:e.popoverChanges,mode:e.appConfig});var n=$("#editor_sdk"),o=n.offset();e.dlgChanges.show(Math.max(10,o.left+n.width()-300),Math.max(10,o.top+n.height()-150))}});else if(t.canViewReview&&(t.canViewReview=t.isEdit||e.api.asc_HaveRevisionsChanges(!0),t.canViewReview)){var i=Common.localStorage.getItem(e.view.appPrefix+"review-mode");null===i&&(i=e.appConfig.customization&&/^(original|final|markup)$/i.test(e.appConfig.customization.reviewDisplay)?e.appConfig.customization.reviewDisplay.toLocaleLowerCase():"original"),e.turnDisplayMode(t.isEdit||t.isRestrictedEdit?"markup":i),e.view.turnDisplayMode(t.isEdit||t.isRestrictedEdit?"markup":i)}e.view&&e.view.btnChat&&e.getApplication().getController("LeftMenu").leftMenu.btnChat.on("toggle",function(t,i){i!==e.view.btnChat.pressed&&e.view.turnChat(i)})},applySettings:function(t){this.view&&this.view.turnSpelling(Common.localStorage.getBool(this.view.appPrefix+"settings-spellcheck",!0)),this.view&&this.view.turnCoAuthMode(Common.localStorage.getBool(this.view.appPrefix+"settings-coauthmode",!0))},synchronizeChanges:function(){this.appConfig&&this.appConfig.canReview&&this.view.markChanges(this.api.asc_HaveRevisionsChanges())},setLanguages:function(t){this.langs=t,this.view&&this.view.btnsDocLang&&this.view.btnsDocLang.forEach(function(t){t&&t.setDisabled(this.langs.length<1)},this)},onDocLanguage:function(){var t=this;new Common.Views.LanguageDialog({languages:t.langs,current:t.api.asc_getDefaultLanguage(),handler:function(e,i){if("ok"==e){var n=_.findWhere(t.langs,{value:i});n&&t.api.asc_setDefaultLanguage(n.code)}}}).show()},onLostEditRights:function(){this.view&&this.view.onLostEditRights()},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)},onUpdateUsers:function(){var t=this.userCollection;this.popoverChanges&&this.popoverChanges.each(function(e){var i=t.findOriginalUser(e.get("userid"));e.set("usercolor",i?i.get("color"):null)})},textInserted:"Inserted:",textDeleted:"Deleted:",textParaInserted:"Paragraph Inserted ",textParaDeleted:"Paragraph Deleted ",textFormatted:"Formatted",textParaFormatted:"Paragraph Formatted",textNot:"Not ",textBold:"Bold",textItalic:"Italic",textStrikeout:"Strikeout",textUnderline:"Underline",textColor:"Font color",textBaseline:"Baseline",textSuperScript:"Superscript",textSubScript:"Subscript",textHighlight:"Highlight color",textSpacing:"Spacing",textDStrikeout:"Double strikeout",textCaps:"All caps",textSmallCaps:"Small caps",textPosition:"Position",textFontSize:"Font size",textShd:"Background color",textContextual:"Don't add interval between paragraphs of the same style",textNoContextual:"Add interval between paragraphs of the same style",textIndentLeft:"Indent left",textIndentRight:"Indent right",textFirstLine:"First line",textRight:"Align right",textLeft:"Align left",textCenter:"Align center",textJustify:"Align justify",textBreakBefore:"Page break before",textKeepNext:"Keep with next",textKeepLines:"Keep lines together",textNoBreakBefore:"No page break before",textNoKeepNext:"Don't keep with next",textNoKeepLines:"Don't keep lines together",textLineSpacing:"Line Spacing: ",textMultiple:"multiple",textAtLeast:"at least",textExact:"exactly",textSpacingBefore:"Spacing before",textSpacingAfter:"Spacing after",textAuto:"auto",textWidow:"Widow control",textNoWidow:"No widow control",textTabs:"Change tabs",textNum:"Change numbering",textEquation:"Equation",textImage:"Image",textChart:"Chart",textShape:"Shape",textTableChanged:"Table Settings Changed",textTableRowsAdd:"Table Rows Added",textTableRowsDel:"Table Rows Deleted",textParaMoveTo:"Moved:",textParaMoveFromUp:"Moved Up:",textParaMoveFromDown:"Moved Down:"},Common.Controllers.ReviewChanges||{}))}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/Protection",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(t){"use strict";Common.Views.Protection=Common.UI.BaseView.extend(_.extend(function(){function t(){var t=this;t.appConfig.isPasswordSupport&&(this.btnsAddPwd.concat(this.btnsChangePwd).forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:password",[e,"add"])})}),this.btnsDelPwd.forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:password",[e,"delete"])})}),this.btnPwd.menu.on("item:click",function(e,i,n){t.fireEvent("protect:password",[e,i.value])})),t.appConfig.isSignatureSupport&&(this.btnSignature.menu&&this.btnSignature.menu.on("item:click",function(e,i,n){t.fireEvent("protect:signature",[i.value,!1])}),this.btnsInvisibleSignature.forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:signature",["invisible"])})}))}return{options:{},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.appConfig=t.mode,this.btnsInvisibleSignature=[],this.btnsAddPwd=[],this.btnsDelPwd=[],this.btnsChangePwd=[],this._state={disabled:!1,hasPassword:!1,disabledPassword:!1,invisibleSignDisabled:!1};var e=Common.localStorage.getKeysFilter();this.appPrefix=e&&e.length?e.split(",")[0]:"",this.appConfig.isPasswordSupport&&(this.btnAddPwd=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-protect",caption:this.txtEncrypt}),this.btnsAddPwd.push(this.btnAddPwd),this.btnPwd=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-protect",caption:this.txtEncrypt,menu:!0,visible:!1})),this.appConfig.isSignatureSupport&&(this.btnSignature=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-signature",caption:this.txtSignature,menu:"pe-"!==this.appPrefix}),this.btnSignature.menu||this.btnsInvisibleSignature.push(this.btnSignature)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this.boxSdk=$("#editor_sdk"),t&&t.html(this.getPanel()),this},onAppReady:function(e){var i=this;new Promise(function(t,e){t()}).then(function(){e.canProtect&&(e.isPasswordSupport&&(i.btnAddPwd.updateHint(i.hintAddPwd),i.btnPwd.updateHint(i.hintPwd),i.btnPwd.setMenu(new Common.UI.Menu({items:[{caption:i.txtChangePwd,value:"add"},{caption:i.txtDeletePwd,value:"delete"}]}))),i.btnSignature&&(i.btnSignature.updateHint(i.btnSignature.menu?i.hintSignature:i.txtInvisibleSignature),i.btnSignature.menu&&i.btnSignature.setMenu(new Common.UI.Menu({items:[{caption:i.txtInvisibleSignature,value:"invisible"},{caption:i.txtSignatureLine,value:"visible",disabled:i._state.disabled}]}))),Common.NotificationCenter.trigger("tab:visible","protect",!0)),t.call(i)})},getPanel:function(){return this.$el=$(_.template('
')({})),this.appConfig.canProtect&&(this.btnAddPwd&&this.btnAddPwd.render(this.$el.find("#slot-btn-add-password")),this.btnPwd&&this.btnPwd.render(this.$el.find("#slot-btn-change-password")),this.btnSignature&&this.btnSignature.render(this.$el.find("#slot-btn-signature"))),this.$el},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButton:function(t,e){if("signature"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtInvisibleSignature,disabled:this._state.invisibleSignDisabled});return this.btnsInvisibleSignature.push(i),i}if("add-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtAddPwd,disabled:this._state.disabled||this._state.disabledPassword,visible:!this._state.hasPassword});return this.btnsAddPwd.push(i),i}if("del-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtDeletePwd,disabled:this._state.disabled||this._state.disabledPassword,visible:this._state.hasPassword});return this.btnsDelPwd.push(i),i}if("change-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtChangePwd,disabled:this._state.disabled||this._state.disabledPassword,visible:this._state.hasPassword});return this.btnsChangePwd.push(i),i}},SetDisabled:function(t,e){this._state.disabled=t,this._state.invisibleSignDisabled=t&&!e,this.btnsInvisibleSignature&&this.btnsInvisibleSignature.forEach(function(i){i&&i.setDisabled(t&&!e)},this),this.btnSignature&&this.btnSignature.menu&&(this.btnSignature.menu.items&&this.btnSignature.menu.items[1].setDisabled(t),this.btnSignature.setDisabled(t&&!e)),this.btnsAddPwd.concat(this.btnsDelPwd,this.btnsChangePwd).forEach(function(e){e&&e.setDisabled(t||this._state.disabledPassword)},this)},onDocumentPassword:function(t,e){this._state.hasPassword=t,this._state.disabledPassword=!!e;var i=this._state.disabledPassword||this._state.disabled;this.btnsAddPwd&&this.btnsAddPwd.forEach(function(e){e&&(e.setVisible(!t),e.setDisabled(i))},this),this.btnsDelPwd.concat(this.btnsChangePwd).forEach(function(e){e&&(e.setVisible(t),e.setDisabled(i))},this),this.btnPwd.setVisible(t)},txtEncrypt:"Encrypt",txtSignature:"Signature",hintAddPwd:"Encrypt with password",hintPwd:"Change or delete password",hintSignature:"Add digital signature or signature line",txtChangePwd:"Change password",txtDeletePwd:"Delete password",txtAddPwd:"Add password",txtInvisibleSignature:"Add digital signature",txtSignatureLine:"Add Signature line"}}(),Common.Views.Protection||{}))}),define("common/main/lib/view/PasswordDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.PasswordDialog=Common.UI.Window.extend(_.extend({applyFunction:void 0,initialize:function(t){var e=this,i={};_.extend(i,{width:350,height:220,header:!0,cls:"modal-dlg",contentTemplate:"",title:e.txtTitle},t),this.template=t.template||['
','
',"","
",'
',"","
",'
','
',"","
",'
',"
",'
','"].join(""),this.handler=t.handler,this.settings=t.settings,i.tpl=_.template(this.template)(i),Common.UI.Window.prototype.initialize.call(this,i)},render:function(){if(Common.UI.Window.prototype.render.call(this),this.$window){var t=this;this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.inputPwd=new Common.UI.InputField({el:$("#id-password-txt"),type:"password",allowBlank:!1,style:"width: 100%;",validateOnBlur:!1}),this.repeatPwd=new Common.UI.InputField({el:$("#id-repeat-txt"),type:"password",allowBlank:!1,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return t.txtIncorrectPwd}})}},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;setTimeout(function(){t.inputPwd.cmpEl.find("input").focus()},500)},onPrimary:function(t){return this._handleInput("ok"),!1},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},_handleInput:function(t){ -if(this.handler){if("ok"==t){if(!0!==this.inputPwd.checkValidate())return void this.inputPwd.cmpEl.find("input").focus();if(this.inputPwd.getValue()!==this.repeatPwd.getValue())return this.repeatPwd.checkValidate(),void this.repeatPwd.cmpEl.find("input").focus()}this.handler.call(this,t,this.inputPwd.getValue())}this.close()},okButtonText:"OK",cancelButtonText:"Cancel",txtTitle:"Set Password",txtPassword:"Password",txtDescription:"A Password is required to open this document",txtRepeat:"Repeat password",txtIncorrectPwd:"Confirmation password is not identical"},Common.Views.PasswordDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/SignDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/Window","common/main/lib/component/ComboBoxFonts"],function(){"use strict";Common.Views.SignDialog=Common.UI.Window.extend(_.extend({options:{width:370,style:"min-width: 350px;",cls:"modal-dlg"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.api=this.options.api,this.signType=this.options.signType||"invisible",this.signSize=this.options.signSize||{width:0,height:0},this.certificateId=null,this.signObject=null,this.fontStore=this.options.fontStore,this.font={size:11,name:"Arial",bold:!1,italic:!1},this.template=['
','
','
',"","
",'
',"
",'
','
',"","
",'
','
','
','
','
','
',"","
",'",'
','","
",'
',"
",'',"",'","",'',"
","
",'"].join(""),this.templateCertificate=_.template(['',''].join("")),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputPurpose=new Common.UI.InputField({el:$("#id-dlg-sign-purpose"),style:"width: 100%;"}),t.inputName=new Common.UI.InputField({el:$("#id-dlg-sign-name"),style:"width: 100%;",validateOnChange:!0}).on("changing",_.bind(t.onChangeName,t)),t.cmbFonts=new Common.UI.ComboBoxFonts({el:$("#id-dlg-sign-fonts"),cls:"input-group-nr",style:"width: 234px;",menuCls:"scrollable-menu",menuStyle:"min-width: 234px;max-height: 270px;",store:new Common.Collections.Fonts,recent:0,hint:t.tipFontName}).on("selected",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),i.name,t.font.size,t.font.italic,t.font.bold),t.font.name=i.name}),this.cmbFontSize=new Common.UI.ComboBox({el:$("#id-dlg-sign-font-size"),cls:"input-group-nr",style:"width: 55px;",menuCls:"scrollable-menu",menuStyle:"min-width: 55px;max-height: 270px;",hint:this.tipFontSize,data:[{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}]}).on("selected",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,i.value,t.font.italic,t.font.bold),t.font.size=i.value}),this.cmbFontSize.setValue(this.font.size),t.btnBold=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-bold",enableToggle:!0,hint:t.textBold}),t.btnBold.render($("#id-dlg-sign-bold")),t.btnBold.on("click",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,t.font.size,t.font.italic,e.pressed),t.font.bold=e.pressed}),t.btnItalic=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-italic",enableToggle:!0,hint:t.textItalic}),t.btnItalic.render($("#id-dlg-sign-italic")),t.btnItalic.on("click",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,t.font.size,e.pressed,t.font.bold),t.font.italic=e.pressed}),t.btnSelectImage=new Common.UI.Button({el:"#id-dlg-sign-image"}),t.btnSelectImage.on("click",_.bind(t.onSelectImage,t)),t.btnChangeCertificate=new Common.UI.Button({el:"#id-dlg-sign-change"}),t.btnChangeCertificate.on("click",_.bind(t.onChangeCertificate,t)),t.btnOk=new Common.UI.Button({el:e.find(".primary"),disabled:!0}),t.cntCertificate=$("#id-dlg-sign-certificate"),t.cntVisibleSign=$("#id-dlg-sign-visible"),t.cntInvisibleSign=$("#id-dlg-sign-invisible"),"visible"==t.signType?t.cntInvisibleSign.addClass("hidden"):t.cntVisibleSign.addClass("hidden"),e.find(".dlg-btn").on("click",_.bind(t.onBtnClick,t)),t.afterRender()},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){("visible"==t.signType?t.inputName:t.inputPurpose).cmpEl.find("input").focus()},500)},close:function(){this.api.asc_unregisterCallback("on_signature_defaultcertificate_ret",this.binding.certificateChanged),this.api.asc_unregisterCallback("on_signature_selectsertificate_ret",this.binding.certificateChanged),Common.UI.Window.prototype.close.apply(this,arguments),this.signObject&&this.signObject.destroy()},afterRender:function(){this.api&&(this.binding||(this.binding={}),this.binding.certificateChanged=_.bind(this.onCertificateChanged,this),this.api.asc_registerCallback("on_signature_defaultcertificate_ret",this.binding.certificateChanged),this.api.asc_registerCallback("on_signature_selectsertificate_ret",this.binding.certificateChanged),this.api.asc_GetDefaultCertificate()),"visible"==this.signType&&(this.cmbFonts.fillFonts(this.fontStore),this.cmbFonts.selectRecord(this.fontStore.findWhere({name:this.font.name})||this.fontStore.at(0)),this.signObject=new AscCommon.CSignatureDrawer("signature-preview-img",this.api,this.signSize.width,this.signSize.height))},getSettings:function(){var t={};return t.certificateId=this.certificateId,"invisible"==this.signType?t.purpose=this.inputPurpose.getValue():t.images=this.signObject?this.signObject.getImages():[null,null],t},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.options.handler){if("ok"==t&&(this.btnOk.isDisabled()||this.signObject&&!this.signObject.isValid()))return;this.options.handler.call(this,this,t)}this.close()},onChangeCertificate:function(){this.api.asc_SelectCertificate()},onCertificateChanged:function(t){this.certificateId=t.id;var e=t.date,i="string"==typeof e?e.split(" - "):["",""];this.cntCertificate.html(this.templateCertificate({name:t.name,valid:this.textValid.replace("%1",i[0]).replace("%2",i[1])})),this.cntCertificate.toggleClass("hidden",_.isEmpty(this.certificateId)||this.certificateId<0),this.btnChangeCertificate.setCaption(_.isEmpty(this.certificateId)||this.certificateId<0?this.textSelect:this.textChange),this.btnOk.setDisabled(_.isEmpty(this.certificateId)||this.certificateId<0)},onSelectImage:function(){this.signObject&&(this.signObject.selectImage(),this.inputName.setValue(""))},onChangeName:function(t,e){this.signObject&&this.signObject.setText(e,this.font.name,this.font.size,this.font.italic,this.font.bold)},textTitle:"Sign Document",textPurpose:"Purpose for signing this document",textCertificate:"Certificate",textValid:"Valid from %1 to %2",textChange:"Change",cancelButtonText:"Cancel",okButtonText:"Ok",textInputName:"Input signer name",textUseImage:"or click 'Select Image' to use a picture as signature",textSelectImage:"Select Image",textSignature:"Signature looks as",tipFontName:"Font Name",tipFontSize:"Font Size",textBold:"Bold",textItalic:"Italic",textSelect:"Select"},Common.Views.SignDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/SignSettingsDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/CheckBox","common/main/lib/component/Window"],function(){"use strict";Common.Views.SignSettingsDialog=Common.UI.Window.extend(_.extend({options:{width:350,style:"min-width: 350px;",cls:"modal-dlg",type:"edit"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
','
',"","
",'
',"","
",'
','
',"","
",'
','
',"","
",'
','
',"","
",'','
',"
",'"].join(""),this.api=this.options.api,this.type=this.options.type||"edit",this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputName=new Common.UI.InputField({el:$("#id-dlg-sign-settings-name"),style:"width: 100%;",disabled:"view"==this.type}),t.inputTitle=new Common.UI.InputField({el:$("#id-dlg-sign-settings-title"),style:"width: 100%;",disabled:"view"==this.type}),t.inputEmail=new Common.UI.InputField({el:$("#id-dlg-sign-settings-email"),style:"width: 100%;",disabled:"view"==this.type}),t.textareaInstructions=this.$window.find("textarea"),t.textareaInstructions.keydown(function(t){t.keyCode==Common.UI.Keys.RETURN&&t.stopPropagation()}),"view"==this.type?this.textareaInstructions.attr("disabled","disabled"):this.textareaInstructions.removeAttr("disabled"),this.textareaInstructions.toggleClass("disabled","view"==this.type),this.chDate=new Common.UI.CheckBox({el:$("#id-dlg-sign-settings-date"),labelText:this.textShowDate,disabled:"view"==this.type}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){t.inputName.cmpEl.find("input").focus()},500)},setSettings:function(t){if(t){var e=this,i=t.asc_getSigner1();e.inputName.setValue(i||""),i=t.asc_getSigner2(),e.inputTitle.setValue(i||""),i=t.asc_getEmail(),e.inputEmail.setValue(i||""),i=t.asc_getInstructions(),e.textareaInstructions.val(i||""),e.chDate.setValue(t.asc_getShowDate())}},getSettings:function(){var t=this,e=new AscCommon.asc_CSignatureLine;return e.asc_setSigner1(t.inputName.getValue()),e.asc_setSigner2(t.inputTitle.getValue()),e.asc_setEmail(t.inputEmail.getValue()),e.asc_setInstructions(t.textareaInstructions.val()),e.asc_setShowDate("checked"==t.chDate.getValue()),e},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},textInfo:"Signer Info",textInfoName:"Name",textInfoTitle:"Signer Title",textInfoEmail:"E-mail",textInstructions:"Instructions for Signer",cancelButtonText:"Cancel",okButtonText:"Ok",txtEmpty:"This field is required",textAllowComment:"Allow signer to add comment in the signature dialog",textShowDate:"Show sign date in signature line",textTitle:"Signature Setup"},Common.Views.SignSettingsDialog||{}))}),void 0===Common)var Common={};Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Protection",["core","common/main/lib/view/Protection","common/main/lib/view/PasswordDialog","common/main/lib/view/SignDialog","common/main/lib/view/SignSettingsDialog"],function(){"use strict";Common.Controllers.Protection=Backbone.Controller.extend(_.extend({models:[],collections:[],views:["Common.Views.Protection"],sdkViewName:"#id_main",initialize:function(){this.addListeners({"Common.Views.Protection":{"protect:password":_.bind(this.onPasswordClick,this),"protect:signature":_.bind(this.onSignatureClick,this)}})},onLaunch:function(){this._state={},Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))},setConfig:function(t,e){this.setApi(e),t&&(this.sdkViewName=t.sdkviewname||this.sdkViewName)},setApi:function(t){t&&(this.api=t,this.appConfig.isPasswordSupport&&this.api.asc_registerCallback("asc_onDocumentPassword",_.bind(this.onDocumentPassword,this)),this.appConfig.isSignatureSupport&&(Common.NotificationCenter.on("protect:sign",_.bind(this.onSignatureRequest,this)),Common.NotificationCenter.on("protect:signature",_.bind(this.onSignatureClick,this)),this.api.asc_registerCallback("asc_onSignatureClick",_.bind(this.onSignatureSign,this)),this.api.asc_registerCallback("asc_onUpdateSignatures",_.bind(this.onApiUpdateSignatures,this))),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)))},setMode:function(t){return this.appConfig=t,this.view=this.createView("Common.Views.Protection",{mode:t}),this},onDocumentPassword:function(t,e){this.view&&this.view.onDocumentPassword(t,e)},SetDisabled:function(t,e){this.view&&this.view.SetDisabled(t,e)},onPasswordClick:function(t,e){switch(e){case"add":this.addPassword();break;case"delete":this.deletePassword()}Common.NotificationCenter.trigger("edit:complete",this.view)},onSignatureRequest:function(t){this.api.asc_RequestSign(t)},onSignatureClick:function(t,e,i){switch(t){case"invisible":this.onSignatureRequest("unvisibleAdd");break;case"visible":this.addVisibleSignature(e,i)}},createToolbarPanel:function(){return this.view.getPanel()},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onAppReady:function(t){},addPassword:function(){var t=this;new Common.Views.PasswordDialog({api:t.api,signType:"invisible",handler:function(e,i){"ok"==e&&t.api.asc_setCurrentPassword(i),Common.NotificationCenter.trigger("edit:complete")}}).show()},deletePassword:function(){this.api.asc_resetPassword()},addInvisibleSignature:function(){var t=this;new Common.Views.SignDialog({api:t.api,signType:"invisible",handler:function(e,i){if("ok"==i){var n=e.getSettings();t.api.asc_Sign(n.certificateId)}Common.NotificationCenter.trigger("edit:complete")}}).show()},addVisibleSignature:function(t,e){var i=this,n=new Common.Views.SignSettingsDialog({type:t?"view":"edit",handler:function(e,n){t||"ok"!=n||i.api.asc_AddSignatureLine2(e.getSettings()),Common.NotificationCenter.trigger("edit:complete")}});n.show(),e&&n.setSettings(this.api.asc_getSignatureSetup(e))},signVisibleSignature:function(t,e,i){var n=this;if(_.isUndefined(n.fontStore)){n.fontStore=new Common.Collections.Fonts;var o=n.getApplication().getController("Toolbar").getView("Toolbar").cmbFontName.store.toJSON(),s=[];_.each(o,function(t,e){t.cloneid||s.push(_.clone(t))}),n.fontStore.add(s)}new Common.Views.SignDialog({api:n.api,signType:"visible",fontStore:n.fontStore,signSize:{width:e||0,height:i||0},handler:function(e,i){if("ok"==i){var o=e.getSettings();n.api.asc_Sign(o.certificateId,t,o.images[0],o.images[1])}Common.NotificationCenter.trigger("edit:complete")}}).show()},onSignatureSign:function(t,e,i,n){n?this.signVisibleSignature(t,e,i):this.addInvisibleSignature()},onApiUpdateSignatures:function(t,e){this.SetDisabled(t&&t.length>0,!0)},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)}},Common.Controllers.Protection||{}))}),define("common/main/lib/controller/Desktop",["core"],function(){"use strict";var t=function(){var t={},e=window.AscDesktopEditor;return e&&(window.on_native_message=function(i,n){if(/^style:change/.test(i)){var o=JSON.parse(n);if("toolbar"==o.element)"off"==o.action&&"native-color"==o.style&&$(".toolbar").removeClass("editor-native-color");else if("body"==o.element&&"merge"==o.action){var s=document.createElement("style");s.innerHTML=o.style,document.body.appendChild(s)}}else if(/window:features/.test(i)){var o=JSON.parse(n);"true"==o.canUndock&&(t.canUndock||(t.canUndock=!0,_.isEmpty(t)||Common.NotificationCenter.trigger("app:config",{canUndock:!0})))}else if(/window:status/.test(i)){var o=JSON.parse(n);"undocking"==o.action&&Common.NotificationCenter.trigger("undock:status",{status:"undocked"==o.status?"undocked":"docked"})}else/editor:config/.test(i)&&"request"==n&&e.execCommand("editor:config",JSON.stringify({user:t.user,extraleft:$("#box-document-title #slot-btn-dt-save").parent().width()}))},e.execCommand("webapps:events","loading"),e.execCommand("window:features","request")),{init:function(i){_.extend(t,i),t.isDesktopApp&&(Common.NotificationCenter.on("app:ready",function(i){_.extend(t,i),!!e&&e.execCommand("doc:onready",""),$(".toolbar").addClass("editor-native-color")}),Common.NotificationCenter.on("action:undocking",function(t){e.execCommand("editor:event",JSON.stringify({action:"undocking",state:"dock"==t?"dock":"undock"}))}),Common.NotificationCenter.on("app:face",function(e){t.canUndock&&Common.NotificationCenter.trigger("app:config",{canUndock:!0})}))},process:function(i){if(t.isDesktopApp&&e){if("goback"==i)return e.execCommand("go:folder",t.isOffline?"offline":t.customization.goback.url),!0;if("preloader:hide"==i)return e.execCommand("editor:onready",""),!0;if("create:new"==i&&"desktop://create.new"==t.createUrl)return e.LocalFileCreate(window.SSE?2:window.PE?1:0),!0}return!1},requestClose:function(){t.isDesktopApp&&e&&e.execCommand("editor:event",JSON.stringify({action:"close",url:t.customization.goback.url}))}}};Common.Controllers.Desktop=new t});var reqerr;require.config({baseUrl:"../../",paths:{jquery:"../vendor/jquery/jquery",underscore:"../vendor/underscore/underscore",backbone:"../vendor/backbone/backbone",bootstrap:"../vendor/bootstrap/dist/js/bootstrap",text:"../vendor/requirejs-text/text",perfectscrollbar:"common/main/lib/mods/perfect-scrollbar",jmousewheel:"../vendor/perfect-scrollbar/src/jquery.mousewheel",xregexp:"../vendor/xregexp/xregexp-all-min",sockjs:"../vendor/sockjs/sockjs.min",jszip:"../vendor/jszip/jszip.min",jsziputils:"../vendor/jszip-utils/jszip-utils.min",allfonts:"../../sdkjs/common/AllFonts",sdk:"../../sdkjs/cell/sdk-all-min",api:"api/documents/api",core:"common/main/lib/core/application",notification:"common/main/lib/core/NotificationCenter",keymaster:"common/main/lib/core/keymaster",tip:"common/main/lib/util/Tip",localstorage:"common/main/lib/util/LocalStorage",analytics:"common/Analytics",gateway:"common/Gateway",locale:"common/locale",irregularstack:"common/IrregularStack"},shim:{underscore:{exports:"_"},backbone:{deps:["underscore","jquery"],exports:"Backbone"},bootstrap:{deps:["jquery"]},perfectscrollbar:{deps:["jmousewheel"]},notification:{deps:["backbone"]},core:{deps:["backbone","notification","irregularstack"]},sdk:{deps:["jquery","underscore","allfonts","xregexp","sockjs","jszip","jsziputils"]},gateway:{deps:["jquery"]},analytics:{deps:["jquery"]}}}),require(["backbone","bootstrap","core","sdk","api","analytics","gateway","locale"],function(t,e,i){t.history.start();var n=new t.Application({nameSpace:"SSE",autoCreate:!1,controllers:["Viewport","DocumentHolder","CellEditor","FormulaDialog","Print","Toolbar","Statusbar","Spellcheck","RightMenu","LeftMenu","Main","PivotTable","DataTab","Common.Controllers.Fonts","Common.Controllers.Chat","Common.Controllers.Comments","Common.Controllers.Plugins","Common.Controllers.ReviewChanges","Common.Controllers.Protection"]});Common.Locale.apply(function(){require(["spreadsheeteditor/main/app/controller/Viewport","spreadsheeteditor/main/app/controller/DocumentHolder","spreadsheeteditor/main/app/controller/CellEditor","spreadsheeteditor/main/app/controller/Toolbar","spreadsheeteditor/main/app/controller/Statusbar","spreadsheeteditor/main/app/controller/Spellcheck","spreadsheeteditor/main/app/controller/RightMenu","spreadsheeteditor/main/app/controller/LeftMenu","spreadsheeteditor/main/app/controller/Main","spreadsheeteditor/main/app/controller/Print","spreadsheeteditor/main/app/controller/PivotTable","spreadsheeteditor/main/app/controller/DataTab","spreadsheeteditor/main/app/view/FileMenuPanels","spreadsheeteditor/main/app/view/ParagraphSettings","spreadsheeteditor/main/app/view/ImageSettings","spreadsheeteditor/main/app/view/ChartSettings","spreadsheeteditor/main/app/view/ShapeSettings","spreadsheeteditor/main/app/view/TextArtSettings","spreadsheeteditor/main/app/view/PivotSettings","spreadsheeteditor/main/app/view/FieldSettingsDialog","spreadsheeteditor/main/app/view/ValueFieldSettingsDialog","spreadsheeteditor/main/app/view/SignatureSettings","common/main/lib/util/utils","common/main/lib/util/LocalStorage","common/main/lib/controller/Fonts","common/main/lib/controller/Comments","common/main/lib/controller/Chat","common/main/lib/controller/Plugins","common/main/lib/controller/ReviewChanges","common/main/lib/controller/Protection","common/main/lib/controller/Desktop"],function(){n.start()})})},function(t){"timeout"==t.requireType&&!reqerr&&window.requireTimeourError&&(reqerr=window.requireTimeourError(),window.alert(reqerr),window.location.reload())}),define("../apps/spreadsheeteditor/main/app.js",function(){}); \ No newline at end of file +(this.appOptions.isEditMailMerge||this.appOptions.isEditDiagram)&&(i.hide(),t.getController("LeftMenu").getView("LeftMenu").hide(),$(window).mouseup(function(t){Common.Gateway.internalMessage("processMouse",{event:"mouse:up"})}).mousemove($.proxy(function(t){this.isDiagramDrag&&Common.Gateway.internalMessage("processMouse",{event:"mouse:move",pagex:t.pageX*Common.Utils.zoom(),pagey:t.pageY*Common.Utils.zoom()})},this))),!this.appOptions.isEditMailMerge&&!this.appOptions.isEditDiagram){this.api.asc_registerCallback("asc_onSendThemeColors",_.bind(this.onSendThemeColors,this)),this.api.asc_registerCallback("asc_onDownloadUrl",_.bind(this.onDownloadUrl,this)),this.api.asc_registerCallback("asc_onDocumentModifiedChanged",_.bind(this.onDocumentModifiedChanged,this));var n=t.getController("Print");n&&this.api&&n.setApi(this.api)}var o=this.getApplication().getController("CellEditor");o&&o.setApi(this.api).setMode(this.appOptions)},applyModeEditorElements:function(t){var e=this.getApplication().getController("Common.Controllers.Comments");if(e&&(e.setMode(this.appOptions),e.setConfig({config:this.editorConfig,sdkviewname:"#ws-canvas-outer",hintmode:!0},this.api)),this.appOptions.isEdit){var i=this,n=this.getApplication(),o=n.getController("Toolbar"),s=n.getController("Statusbar"),a=n.getController("RightMenu"),l=n.getController("Common.Controllers.Fonts"),r=n.getController("Common.Controllers.ReviewChanges");l&&l.setApi(i.api),o&&o.setApi(i.api),a&&a.setApi(i.api),r.setMode(i.appOptions).setConfig({config:i.editorConfig},i.api),i.appOptions.canProtect&&n.getController("Common.Controllers.Protection").setMode(i.appOptions).setConfig({config:i.editorConfig},i.api),s&&s.getView("Statusbar").changeViewMode(!0),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram||i.appOptions.isOffline||n.getController("PivotTable").setMode(i.appOptions).setConfig({config:i.editorConfig},i.api);this.getApplication().getController("Viewport").getView("Viewport").applyEditorMode(),a.getView("RightMenu").setMode(i.appOptions).setApi(i.api),this.toolbarView=o.getView("Toolbar");var c=Common.localStorage.getItem("sse-settings-unit");if(c=null!==c?parseInt(c):Common.Utils.Metric.getDefaultMetric(),Common.Utils.Metric.setCurrentMetric(c),Common.Utils.InternalSettings.set("sse-settings-unit",c),i.appOptions.isEditMailMerge||i.appOptions.isEditDiagram)a.getView("RightMenu").hide();else{var h={};JSON.parse(Common.localStorage.getItem("sse-hidden-formula"))&&(h.formula=!0),n.getController("Toolbar").hideElements(h)}i.api.asc_registerCallback("asc_onAuthParticipantsChanged",_.bind(i.onAuthParticipantsChanged,i)),i.api.asc_registerCallback("asc_onParticipantsChanged",_.bind(i.onAuthParticipantsChanged,i)),i.appOptions.isEditDiagram&&i.api.asc_registerCallback("asc_onSelectionChanged",_.bind(i.onSelectionChanged,i)),i.api.asc_setFilteringMode&&i.api.asc_setFilteringMode(i.appOptions.canModifyFilter),i.stackLongActions.exist({id:-255,type:Asc.c_oAscAsyncActionType.BlockInteraction})?i.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-255):this._isDocReady||(Common.NotificationCenter.trigger("app:face",this.appOptions),i.hidePreloader(),i.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,-256)),window.onbeforeunload=_.bind(i.onBeforeUnload,i),window.onunload=_.bind(i.onUnload,i)}},onExternalMessage:function(t){t&&t.msg&&(t.msg=t.msg.toString(),this.showTips([t.msg.charAt(0).toUpperCase()+t.msg.substring(1)]),Common.component.Analytics.trackEvent("External Error"))},onError:function(t,e,i){if(t==Asc.c_oAscError.ID.LoadingScriptError)return this.showTips([this.scriptLoadError]),void(this.tooltip&&this.tooltip.getBSTip().$tip.css("z-index",1e4));this.hidePreloader(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256);var n={closable:!0};switch(t){case Asc.c_oAscError.ID.Unknown:n.msg=this.unknownErrorText;break;case Asc.c_oAscError.ID.ConvertationTimeout:n.msg=this.convertationTimeoutText;break;case Asc.c_oAscError.ID.ConvertationOpenError:n.msg=this.openErrorText;break;case Asc.c_oAscError.ID.ConvertationSaveError:n.msg=this.saveErrorText;break;case Asc.c_oAscError.ID.DownloadError:n.msg=this.downloadErrorText;break;case Asc.c_oAscError.ID.UplImageSize:n.msg=this.uploadImageSizeMessage;break;case Asc.c_oAscError.ID.UplImageExt:n.msg=this.uploadImageExtMessage;break;case Asc.c_oAscError.ID.UplImageFileCount:n.msg=this.uploadImageFileCountMessage;break;case Asc.c_oAscError.ID.PastInMergeAreaError:n.msg=this.pastInMergeAreaError;break;case Asc.c_oAscError.ID.FrmlWrongCountParentheses:n.msg=this.errorWrongBracketsCount;break;case Asc.c_oAscError.ID.FrmlWrongOperator:n.msg=this.errorWrongOperator;break;case Asc.c_oAscError.ID.FrmlWrongMaxArgument:n.msg=this.errorCountArgExceed;break;case Asc.c_oAscError.ID.FrmlWrongCountArgument:n.msg=this.errorCountArg;break;case Asc.c_oAscError.ID.FrmlWrongFunctionName:n.msg=this.errorFormulaName;break;case Asc.c_oAscError.ID.FrmlAnotherParsingError:n.msg=this.errorFormulaParsing;break;case Asc.c_oAscError.ID.FrmlWrongArgumentRange:n.msg=this.errorArgsRange;break;case Asc.c_oAscError.ID.FrmlOperandExpected:n.msg=this.errorOperandExpected;break;case Asc.c_oAscError.ID.FrmlWrongReferences:n.msg=this.errorFrmlWrongReferences;break;case Asc.c_oAscError.ID.UnexpectedGuid:n.msg=this.errorUnexpectedGuid;break;case Asc.c_oAscError.ID.Database:n.msg=this.errorDatabaseConnection;break;case Asc.c_oAscError.ID.FileRequest:n.msg=this.errorFileRequest;break;case Asc.c_oAscError.ID.FileVKey:n.msg=this.errorFileVKey;break;case Asc.c_oAscError.ID.StockChartError:n.msg=this.errorStockChart;break;case Asc.c_oAscError.ID.DataRangeError:n.msg=this.errorDataRange;break;case Asc.c_oAscError.ID.MaxDataPointsError:n.msg=this.errorMaxPoints;break;case Asc.c_oAscError.ID.VKeyEncrypt:n.msg=this.errorToken;break;case Asc.c_oAscError.ID.KeyExpire:n.msg=this.errorTokenExpire;break;case Asc.c_oAscError.ID.UserCountExceed:n.msg=this.errorUsersExceed;break;case Asc.c_oAscError.ID.CannotMoveRange:n.msg=this.errorMoveRange;break;case Asc.c_oAscError.ID.UplImageUrl:n.msg=this.errorBadImageUrl;break;case Asc.c_oAscError.ID.CoAuthoringDisconnect:n.msg=this.errorViewerDisconnect;break;case Asc.c_oAscError.ID.ConvertationPassword:n.msg=this.errorFilePassProtect;break;case Asc.c_oAscError.ID.AutoFilterDataRangeError:n.msg=this.errorAutoFilterDataRange;break;case Asc.c_oAscError.ID.AutoFilterChangeFormatTableError:n.msg=this.errorAutoFilterChangeFormatTable;break;case Asc.c_oAscError.ID.AutoFilterChangeError:n.msg=this.errorAutoFilterChange;break;case Asc.c_oAscError.ID.AutoFilterMoveToHiddenRangeError:n.msg=this.errorAutoFilterHiddenRange;break;case Asc.c_oAscError.ID.CannotFillRange:n.msg=this.errorFillRange;break;case Asc.c_oAscError.ID.UserDrop:if(this._state.lostEditingRights)return void(this._state.lostEditingRights=!1);this._state.lostEditingRights=!0,n.msg=this.errorUserDrop,Common.NotificationCenter.trigger("collaboration:sharingdeny");break;case Asc.c_oAscError.ID.InvalidReferenceOrName:n.msg=this.errorInvalidRef;break;case Asc.c_oAscError.ID.LockCreateDefName:n.msg=this.errorCreateDefName;break;case Asc.c_oAscError.ID.PasteMaxRangeError:n.msg=this.errorPasteMaxRange;break;case Asc.c_oAscError.ID.LockedAllError:n.msg=this.errorLockedAll;break;case Asc.c_oAscError.ID.Warning:n.msg=this.errorConnectToServer.replace("%1","https://api.onlyoffice.com/editors/callback"),n.closable=!1;break;case Asc.c_oAscError.ID.LockedWorksheetRename:n.msg=this.errorLockedWorksheetRename;break;case Asc.c_oAscError.ID.OpenWarning:n.msg=this.errorOpenWarning;break;case Asc.c_oAscError.ID.CopyMultiselectAreaError:n.msg=this.errorCopyMultiselectArea;break;case Asc.c_oAscError.ID.PrintMaxPagesCount:n.msg=this.errorPrintMaxPagesCount;break;case Asc.c_oAscError.ID.SessionAbsolute:n.msg=this.errorSessionAbsolute;break;case Asc.c_oAscError.ID.SessionIdle:n.msg=this.errorSessionIdle;break;case Asc.c_oAscError.ID.SessionToken:n.msg=this.errorSessionToken;break;case Asc.c_oAscError.ID.AccessDeny:n.msg=this.errorAccessDeny;break;case Asc.c_oAscError.ID.LockedCellPivot:n.msg=this.errorLockedCellPivot;break;case Asc.c_oAscError.ID.ForceSaveButton:n.msg=this.errorForceSave;break;case Asc.c_oAscError.ID.ForceSaveTimeout:n.msg=this.errorForceSave,console.warn(n.msg);break;case Asc.c_oAscError.ID.DataEncrypted:n.msg=this.errorDataEncrypted;break;case Asc.c_oAscError.ID.EditingError:n.msg=this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.errorEditingSaveas:this.errorEditingDownloadas;break;case Asc.c_oAscError.ID.CannotChangeFormulaArray:n.msg=this.errorChangeArray;break;case Asc.c_oAscError.ID.MultiCellsInTablesFormulaArray:n.msg=this.errorMultiCellFormula;break;case Asc.c_oAscError.ID.MailToClientMissing:n.msg=this.errorEmailClient;break;case Asc.c_oAscError.ID.NoDataToParse:n.msg=this.errorNoDataToParse;break;case Asc.c_oAscError.ID.CannotUngroupError:n.msg=this.errorCannotUngroup;break;case Asc.c_oAscError.ID.FrmlMaxTextLength:n.msg=this.errorFrmlMaxTextLength;break;case Asc.c_oAscError.ID.DataValidate:var o=i?i.asc_getErrorStyle():void 0;void 0!==o&&(n.iconCls=o==Asc.c_oAscEDataValidationErrorStyle.Stop?"error":o==Asc.c_oAscEDataValidationErrorStyle.Information?"info":"warn"),i&&i.asc_getErrorTitle()&&(n.title=i.asc_getErrorTitle()),n.buttons=["ok","cancel"],n.msg=i&&i.asc_getError()?i.asc_getError():this.errorDataValidate,n.maxwidth=600;break;default:n.msg="string"==typeof t?t:this.errorDefaultMessage.replace("%1",t)}e==Asc.c_oAscError.Level.Critical?(Common.Gateway.reportError(t,n.msg),n.title=this.criticalErrorTitle,n.iconCls="error",n.closable=!1,this.appOptions.canBackToFolder&&!this.appOptions.isDesktopApp&&"string"!=typeof t&&(n.msg+="

"+this.criticalErrorExtText,n.callback=function(t){"ok"==t&&Common.NotificationCenter.trigger("goback",!0)}),t==Asc.c_oAscError.ID.DataEncrypted&&(this.api.asc_coAuthoringDisconnect(),Common.NotificationCenter.trigger("api:disconnect"))):(Common.Gateway.reportWarning(t,n.msg),n.title=n.title||this.notcriticalErrorTitle,n.iconCls=n.iconCls||"warn",n.buttons=n.buttons||["ok"],n.callback=_.bind(function(e){t==Asc.c_oAscError.ID.Warning&&"ok"==e&&this.appOptions.canDownload?(Common.UI.Menu.Manager.hideAll(),this.appOptions.isDesktopApp&&this.appOptions.isOffline?this.api.asc_DownloadAs():this.getApplication().getController("LeftMenu").leftMenu.showMenu("file:saveas")):t==Asc.c_oAscError.ID.EditingError?(this.disableEditing(!0),Common.NotificationCenter.trigger("api:disconnect",!0)):t==Asc.c_oAscError.ID.DataValidate&&"ok"!==e&&this.api.asc_closeCellEditor(!0),this._state.lostEditingRights=!1,this.onEditComplete()},this)),$(".asc-window.modal.alert:visible").length<1&&t!==Asc.c_oAscError.ID.ForceSaveTimeout&&(Common.UI.alert(n),Common.component.Analytics.trackEvent("Internal Error",t.toString()))},onCoAuthoringDisconnect:function(){this.getApplication().getController("Viewport").getView("Viewport").setMode({isDisconnected:!0}),this.getApplication().getController("Viewport").getView("Common.Views.Header").setCanRename(!1),this.appOptions.canRename=!1,this._state.isDisconnected=!0},showTips:function(t){function e(){var e=t.shift();e&&(e+="\n"+i.textCloseTip,n.setTitle(e),n.show())}var i=this;if(t.length){"object"!=typeof t&&(t=[t]),this.tooltip||(this.tooltip=new Common.UI.Tooltip({owner:this.getApplication().getController("Toolbar").getView("Toolbar"),hideonclick:!0,placement:"bottom",cls:"main-info",offset:30}));var n=this.tooltip;n.on("tooltip:hide",function(){setTimeout(e,300)}),e()}},updateWindowTitle:function(t,e){if(this._state.isDocModified!==t||e){if(this.headerView){var i=this.defaultTitleText;if(_.isEmpty(this.headerView.getDocumentCaption())||(i=this.headerView.getDocumentCaption()+" - "+i),t)clearTimeout(this._state.timerCaption),_.isUndefined(i)||(i="* "+i,this.headerView.setDocumentCaption(this.headerView.getDocumentCaption(),!0));else if(this._state.fastCoauth&&this._state.usersCount>1){var n=this;this._state.timerCaption=setTimeout(function(){n.headerView.setDocumentCaption(n.headerView.getDocumentCaption(),!1)},500)}else this.headerView.setDocumentCaption(this.headerView.getDocumentCaption(),!1);window.document.title!=i&&(window.document.title=i)}Common.Gateway.setDocumentModified(t),this._state.isDocModified=t}},onDocumentChanged:function(){},onDocumentModifiedChanged:function(t){if(this.updateWindowTitle(t),Common.Gateway.setDocumentModified(t),this.toolbarView&&this.toolbarView.btnCollabChanges&&this.api){var e=this.toolbarView.btnCollabChanges.$icon.hasClass("btn-synch"),i=this.appOptions.forcesave,n=this.api.asc_isDocumentCanSave(),o=!n&&!e&&!i||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!i;this.toolbarView.btnSave.setDisabled(o)}},onDocumentCanSaveChanged:function(t){if(this.toolbarView&&this.toolbarView.btnCollabChanges){var e=this.toolbarView.btnCollabChanges.$icon.hasClass("btn-synch"),i=this.appOptions.forcesave,n=!t&&!e&&!i||this._state.isDisconnected||this._state.fastCoauth&&this._state.usersCount>1&&!i;this.toolbarView.btnSave.setDisabled(n)}},onBeforeUnload:function(){if(Common.localStorage.save(),!1!==this.permissions.edit&&"view"!==this.editorConfig.mode&&"editdiagram"!==this.editorConfig.mode&&"editmerge"!==this.editorConfig.mode&&this.api.asc_isDocumentModified()){var t=this;return this.api.asc_stopSaving(),this.continueSavingTimer=window.setTimeout(function(){t.api.asc_continueSaving()},500),this.leavePageText}},onUnload:function(){this.continueSavingTimer&&clearTimeout(this.continueSavingTimer)},hidePreloader:function(){var i;this._state.customizationDone||(this._state.customizationDone=!0,this.appOptions.customization&&(this.appOptions.isDesktopApp?this.appOptions.customization.about=!1:this.appOptions.canBrandingExt||(this.appOptions.customization.about=!0)),Common.Utils.applyCustomization(this.appOptions.customization,t),this.appOptions.canBrandingExt&&(Common.Utils.applyCustomization(this.appOptions.customization,e),i=this.getApplication().getController("Common.Controllers.Plugins").applyUICustomization())),this.stackLongActions.pop({id:-254,type:Asc.c_oAscAsyncActionType.BlockInteraction}),Common.NotificationCenter.trigger("layout:changed","main"),(i||new Promise(function(t,e){t()})).then(function(){$("#loading-mask").hide().remove(),Common.Controllers.Desktop.process("preloader:hide")})},onDownloadUrl:function(t){this._state.isFromGatewayDownloadAs&&Common.Gateway.downloadAs(t),this._state.isFromGatewayDownloadAs=!1},onDownloadCancel:function(){this._state.isFromGatewayDownloadAs=!1},onUpdateVersion:function(t){var e=this;e.needToUpdateVersion=!0,e.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256),Common.UI.error({msg:this.errorUpdateVersion,callback:function(){_.defer(function(){Common.Gateway.updateVersion(),t&&t.call(e),e.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction,-256)})}})},onServerVersion:function(t){return!1},onAdvancedOptions:function(t,e,i,n){if(!this._state.openDlg){var o=this;t==Asc.c_oAscAdvancedOptionsID.CSV?o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitle.replace("%1","CSV"),closable:2==i,type:Common.Utils.importTextType.CSV,preview:e.asc_getData(),codepages:e.asc_getCodePages(),settings:e.asc_getRecommendedSettings(),api:o.api,handler:function(e,s,a,l){o.isShowOpenDialog=!1,"ok"==e&&o&&o.api&&(2==i?(n&&n.asc_setAdvancedOptions(new Asc.asc_CTextOptions(s,a,l)),o.api.asc_DownloadAs(n)):o.api.asc_setAdvancedOptions(t,new Asc.asc_CTextOptions(s,a,l)),o.loadMask&&o.loadMask.show()),o._state.openDlg=null}}):t==Asc.c_oAscAdvancedOptionsID.DRM&&(o._state.openDlg=new Common.Views.OpenDialog({title:Common.Views.OpenDialog.prototype.txtTitleProtected,closeFile:o.appOptions.canRequestClose,type:Common.Utils.importTextType.DRM,warning:!(o.appOptions.isDesktopApp&&o.appOptions.isOffline),validatePwd:!!o._state.isDRM,handler:function(e,i){o.isShowOpenDialog=!1,"ok"==e?o&&o.api&&(o.api.asc_setAdvancedOptions(t,new Asc.asc_CDRMAdvancedOptions(i)),o.loadMask&&o.loadMask.show()):(Common.Gateway.requestClose(),Common.Controllers.Desktop.requestClose()),o._state.openDlg=null}}),o._state.isDRM=!0),o._state.openDlg&&(this.isShowOpenDialog=!0,this.loadMask&&this.loadMask.hide(),this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction,-256),o._state.openDlg.show())}},onActiveSheetChanged:function(t){this.appOptions.isEditMailMerge||this.appOptions.isEditDiagram||!window.editor_elements_prepared||(this.application.getController("Statusbar").selectTab(t),this.appOptions.canViewComments&&!this.dontCloseDummyComment&&Common.NotificationCenter.trigger("comments:updatefilter",["doc","sheet"+this.api.asc_getWorksheetId(t)],!1))},onConfirmAction:function(t,e){var i=this;t==Asc.c_oAscConfirm.ConfirmReplaceRange?Common.UI.warning({title:this.notcriticalErrorTitle,msg:this.confirmMoveCellRange,buttons:["yes","no"],primary:"yes",callback:_.bind(function(t){e&&e("yes"===t),"yes"==t&&i.onEditComplete(i.application.getController("DocumentHolder").getView("DocumentHolder"))},this)}):t==Asc.c_oAscConfirm.ConfirmPutMergeRange&&Common.UI.warning({closable:!1,title:this.notcriticalErrorTitle,msg:this.confirmPutMergeRange,buttons:["ok"],primary:"ok",callback:_.bind(function(t){e&&e(),i.onEditComplete(i.application.getController("DocumentHolder").getView("DocumentHolder"))},this)})},initNames:function(){this.shapeGroupNames=[this.txtBasicShapes,this.txtFiguredArrows,this.txtMath,this.txtCharts,this.txtStarsRibbons,this.txtCallouts,this.txtButtons,this.txtRectangles,this.txtLines]},fillAutoShapes:function(t,e){if(!_.isEmpty(e)&&!_.isEmpty(t)&&e.length==t.length){var i=this,n=[],o=this.getCollection("ShapeGroups");o.reset();t.length;_.each(t,function(t,o){var s=new Backbone.Collection([],{model:SSE.Models.ShapeModel}),a=e[o].length>18?7:6,l=35*Math.ceil(e[o].length/a)+3,r=30*a;_.each(e[o],function(t,e){s.add({data:{shapeType:t.Type},tip:i["txtShape_"+t.Type]||i.textShape+" "+(e+1),allowSelected:!0,selected:!1})}),n.push({groupName:i.shapeGroupNames[o],groupStore:s,groupWidth:r,groupHeight:l})}),o.add(n),setTimeout(function(){i.getApplication().getController("Toolbar").fillAutoShapes()},50)}},fillTextArt:function(t){if(!_.isEmpty(t)){var e=this,i=[],n=this.getCollection("Common.Collections.TextArt");_.each(t,function(t,e){i.push({imageUrl:t,data:e,allowSelected:!0,selected:!1})}),n.reset(i),setTimeout(function(){e.getApplication().getController("Toolbar").fillTextArt()},50),setTimeout(function(){e.getApplication().getController("RightMenu").fillTextArt()},50)}},updateThemeColors:function(){var t=this;setTimeout(function(){t.getApplication().getController("RightMenu").UpdateThemeColors()},50),setTimeout(function(){t.getApplication().getController("Toolbar").updateThemeColors()},50),setTimeout(function(){t.getApplication().getController("Statusbar").updateThemeColors()},50)},onSendThemeColors:function(t,e){if(Common.Utils.ThemeColor.setColors(t,e),window.styles_loaded&&!this.appOptions.isEditMailMerge&&!this.appOptions.isEditDiagram){this.updateThemeColors();var i=this;setTimeout(function(){i.fillTextArt(i.api.asc_getTextArtPreviews())},1)}},loadLanguages:function(t){this.languages=t,window.styles_loaded&&this.setLanguages()},setLanguages:function(){this.getApplication().getController("Spellcheck").setLanguages(this.languages)},onInternalCommand:function(t){if(t)switch(t.command){case"setChartData":this.setChartData(t.data);break;case"getChartData":this.getChartData();break;case"clearChartData":this.clearChartData();break;case"setMergeData":this.setMergeData(t.data);break;case"getMergeData":this.getMergeData();break;case"setAppDisabled":void 0!==this.isAppDisabled||t.data||(Common.NotificationCenter.trigger("layout:changed","main"),this.loadMask&&this.loadMask.isVisible()&&this.loadMask.updatePosition()),this.isAppDisabled=t.data;break;case"queryClose":0===$("body .asc-window:visible").length?(this.isFrameClosed=!0,this.api.asc_closeCellEditor(),Common.UI.Menu.Manager.hideAll(),Common.Gateway.internalMessage("canClose",{mr:t.data.mr,answer:!0})):Common.Gateway.internalMessage("canClose",{answer:!1});break;case"window:drag":this.isDiagramDrag=t.data;break;case"processmouse":this.onProcessMouse(t.data)}},setChartData:function(t){"object"==typeof t&&this.api&&(this.api.asc_addChartDrawingObject(t),this.isFrameClosed=!1)},getChartData:function(){if(this.api){var t=this.api.asc_getWordChartObject();"object"==typeof t&&Common.Gateway.internalMessage("chartData",{data:t})}},clearChartData:function(){this.api&&this.api.asc_closeCellEditor()},setMergeData:function(t){"object"==typeof t&&this.api&&(this.api.asc_setData(t),this.isFrameClosed=!1)},getMergeData:function(){if(this.api){var t=this.api.asc_getData();"object"==typeof t&&Common.Gateway.internalMessage("mergeData",{data:t})}},unitsChanged:function(t){var e=Common.localStorage.getItem("sse-settings-unit");e=null!==e?parseInt(e):Common.Utils.Metric.getDefaultMetric(),Common.Utils.Metric.setCurrentMetric(e),Common.Utils.InternalSettings.set("sse-settings-unit",e),this.getApplication().getController("RightMenu").updateMetricUnit(),this.getApplication().getController("Print").getView("MainSettingsPrint").updateMetricUnit(),this.getApplication().getController("Toolbar").getView("Toolbar").updateMetricUnit()},_compareActionStrong:function(t,e){return t.id===e.id&&t.type===e.type},_compareActionWeak:function(t,e){return t.type===e.type},onContextMenu:function(t){var e=t.target.getAttribute("data-can-copy"),i=t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement;if(i&&"false"===e||!i&&"true"!==e)return t.stopPropagation(),t.preventDefault(),!1},onNamedRangeLocked:function(){$(".asc-window.modal.alert:visible").length<1&&Common.UI.alert({msg:this.errorCreateDefName,title:this.notcriticalErrorTitle,iconCls:"warn",buttons:["ok"],callback:_.bind(function(t){this.onEditComplete()},this)})},onTryUndoInFastCollaborative:function(){return},onAuthParticipantsChanged:function(t){var e=0;_.each(t,function(t){t.asc_getView()||e++}),this._state.usersCount=e},applySettings:function(){if(this.appOptions.isEdit&&!this.appOptions.isOffline&&this.appOptions.canCoAuthoring){var t=Common.localStorage.getItem("sse-settings-coauthmode"),e=this._state.fastCoauth;this._state.fastCoauth=null===t||1==parseInt(t),this._state.fastCoauth&&!e&&this.toolbarView.synchronizeChanges()}this.appOptions.canForcesave&&(this.appOptions.forcesave=Common.localStorage.getBool("sse-settings-forcesave",this.appOptions.canForcesave),Common.Utils.InternalSettings.set("sse-settings-forcesave",this.appOptions.forcesave),this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave))},onDocumentName:function(t){this.headerView.setDocumentCaption(t),this.updateWindowTitle(this.api.asc_isDocumentModified(),!0)},onMeta:function(t){var e=this.getApplication(),i=e.getController("LeftMenu").getView("LeftMenu").getMenu("file");e.getController("Viewport").getView("Common.Views.Header").setDocumentCaption(t.title),this.updateWindowTitle(this.api.asc_isDocumentModified(),!0),this.appOptions.spreadsheet.title=t.title,i.loadDocument({doc:this.appOptions.spreadsheet}),i.panels.info.updateInfo(this.appOptions.spreadsheet),Common.Gateway.metaChange(t)},onPrint:function(){this.appOptions.canPrint&&!this.isModalShowed&&Common.NotificationCenter.trigger("print",this)},onPrintUrl:function(t){if(this.iframePrint&&(this.iframePrint.parentNode.removeChild(this.iframePrint),this.iframePrint=null),!this.iframePrint){var e=this;this.iframePrint=document.createElement("iframe"),this.iframePrint.id="id-print-frame",this.iframePrint.style.display="none",this.iframePrint.style.visibility="hidden",this.iframePrint.style.position="fixed",this.iframePrint.style.right="0",this.iframePrint.style.bottom="0",document.body.appendChild(this.iframePrint),this.iframePrint.onload=function(){try{e.iframePrint.contentWindow.focus(),e.iframePrint.contentWindow.print(),e.iframePrint.contentWindow.blur(),window.focus()}catch(i){var t=new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF);t.asc_setAdvancedOptions(e.getApplication().getController("Print").getPrintParams()),e.api.asc_DownloadAs(t)}}}t&&(this.iframePrint.src=t)},leavePageText:"You have unsaved changes in this document. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.",criticalErrorTitle:"Error",notcriticalErrorTitle:"Warning",errorDefaultMessage:"Error code: %1",criticalErrorExtText:'Press "OK" to to back to document list.',openTitleText:"Opening Document",openTextText:"Opening document...",saveTitleText:"Saving Document",saveTextText:"Saving document...",loadFontsTitleText:"Loading Data",loadFontsTextText:"Loading data...",loadImagesTitleText:"Loading Images",loadImagesTextText:"Loading images...",loadFontTitleText:"Loading Data",loadFontTextText:"Loading data...",loadImageTitleText:"Loading Image",loadImageTextText:"Loading image...",downloadTitleText:"Downloading Document",downloadTextText:"Downloading document...",printTitleText:"Printing Document",printTextText:"Printing document...",uploadImageTitleText:"Uploading Image",uploadImageTextText:"Uploading image...",savePreparingText:"Preparing to save",savePreparingTitle:"Preparing to save. Please wait...",loadingDocumentTitleText:"Loading spreadsheet",uploadImageSizeMessage:"Maximium image size limit exceeded.",uploadImageExtMessage:"Unknown image format.",uploadImageFileCountMessage:"No images uploaded.",reloadButtonText:"Reload Page",unknownErrorText:"Unknown error.",convertationTimeoutText:"Convertation timeout exceeded.",downloadErrorText:"Download failed.",unsupportedBrowserErrorText:"Your browser is not supported.",requestEditFailedTitleText:"Access denied",requestEditFailedMessageText:"Someone is editing this document right now. Please try again later.",warnBrowserZoom:"Your browser's current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.",warnBrowserIE9:"The application has low capabilities on IE9. Use IE10 or higher",pastInMergeAreaError:"Cannot change part of a merged cell",titleRecalcFormulas:"Calculating formulas...",textRecalcFormulas:"Calculating formulas...",textPleaseWait:"It's working hard. Please wait...",errorWrongBracketsCount:"Found an error in the formula entered.
Wrong cout of brackets.",errorWrongOperator:"An error in the entered formula. Wrong operator is used.
Please correct the error or use the Esc button to cancel the formula editing.",errorCountArgExceed:"Found an error in the formula entered.
Count of arguments exceeded.",errorCountArg:"Found an error in the formula entered.
Invalid number of arguments.",errorFormulaName:"Found an error in the formula entered.
Incorrect formula name.",errorFormulaParsing:"Internal error while the formula parsing.",errorArgsRange:"Found an error in the formula entered.
Incorrect arguments range.",errorUnexpectedGuid:"External error.
Unexpected Guid. Please, contact support.",errorDatabaseConnection:"External error.
Database connection error. Please, contact support.",errorFileRequest:"External error.
File Request. Please, contact support.",errorFileVKey:"External error.
Incorrect securety key. Please, contact support.",errorStockChart:"Incorrect row order. To build a stock chart place the data on the sheet in the following order:
opening price, max price, min price, closing price.",errorDataRange:"Incorrect data range.",errorOperandExpected:"The entered function syntax is not correct. Please check if you are missing one of the parentheses - '(' or ')'.",errorKeyEncrypt:"Unknown key descriptor",errorKeyExpire:"Key descriptor expired",errorUsersExceed:"Count of users was exceed",errorMoveRange:"Cann't change a part of merged cell",errorBadImageUrl:"Image url is incorrect",errorCoAuthoringDisconnect:"Server connection lost. You can't edit anymore.",errorFilePassProtect:"The file is password protected and cannot be opened.",errorLockedAll:"The operation could not be done as the sheet has been locked by another user.",txtEditingMode:"Set editing mode...",textLoadingDocument:"Loading spreadsheet",textConfirm:"Confirmation",confirmMoveCellRange:"The destination cell's range can contain data. Continue the operation?",textYes:"Yes",textNo:"No",textAnonymous:"Anonymous",txtBasicShapes:"Basic Shapes",txtFiguredArrows:"Figured Arrows",txtMath:"Math",txtCharts:"Charts",txtStarsRibbons:"Stars & Ribbons",txtCallouts:"Callouts",txtButtons:"Buttons",txtRectangles:"Rectangles",txtLines:"Lines",txtDiagramTitle:"Chart Title",txtXAxis:"X Axis",txtYAxis:"Y Axis",txtSeries:"Seria",warnProcessRightsChange:"You have been denied the right to edit the file.",errorProcessSaveResult:"Saving is failed.",errorAutoFilterDataRange:"The operation could not be done for the selected range of cells.
Select a uniform data range inside or outside the table and try again.",errorAutoFilterChangeFormatTable:"The operation could not be done for the selected cells as you cannot move a part of the table.
Select another data range so that the whole table was shifted and try again.",errorAutoFilterHiddenRange:"The operation cannot be performed because the area contains filtered cells.
Please unhide the filtered elements and try again.",errorAutoFilterChange:"The operation is not allowed, as it is attempting to shift cells in a table on your worksheet.",textCloseTip:"Click to close the tip.",textShape:"Shape",errorFillRange:"Could not fill the selected range of cells.
All the merged cells need to be the same size.",errorUpdateVersion:"The file version has been changed. The page will be reloaded.",errorUserDrop:"The file cannot be accessed right now.",txtArt:"Your text here",errorInvalidRef:"Enter a correct name for the selection or a valid reference to go to.",errorCreateDefName:"The existing named ranges cannot be edited and the new ones cannot be created
at the moment as some of them are being edited.",errorPasteMaxRange:"The copy and paste area does not match. Please select an area with the same size or click the first cell in a row to paste the copied cells.",errorConnectToServer:' The document could not be saved. Please check connection settings or contact your administrator.
When you click the \'OK\' button, you will be prompted to download the document.

Find more information about connecting Document Server here',errorLockedWorksheetRename:"The sheet cannot be renamed at the moment as it is being renamed by another user",textTryUndoRedo:"The Undo/Redo functions are disabled for the Fast co-editing mode.
Click the 'Strict mode' button to switch to the Strict co-editing mode to edit the file without other users interference and send your changes only after you save them. You can switch between the co-editing modes using the editor Advanced settings.",textStrict:"Strict mode",errorOpenWarning:"The length of one of the formulas in the file exceeded
the allowed number of characters and it was removed.",errorFrmlWrongReferences:"The function refers to a sheet that does not exist.
Please check the data and try again.",textBuyNow:"Visit website",textNoLicenseTitle:"%1 open source version",textContactUs:"Contact sales",confirmPutMergeRange:"The source data contains merged cells.
They will be unmerged before they are pasted into the table.",errorViewerDisconnect:"Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.",warnLicenseExp:"Your license has expired.
Please update your license and refresh the page.",titleLicenseExp:"License expired",openErrorText:"An error has occurred while opening the file",saveErrorText:"An error has occurred while saving the file",errorCopyMultiselectArea:"This command cannot be used with multiple selections.
Select a single range and try again.", +errorPrintMaxPagesCount:"Unfortunately, it’s not possible to print more than 1500 pages at once in the current version of the program.
This restriction will be eliminated in upcoming releases.",errorToken:"The document security token is not correctly formed.
Please contact your Document Server administrator.",errorTokenExpire:"The document security token has expired.
Please contact your Document Server administrator.",errorSessionAbsolute:"The document editing session has expired. Please reload the page.",errorSessionIdle:"The document has not been edited for quite a long time. Please reload the page.",errorSessionToken:"The connection to the server has been interrupted. Please reload the page.",errorAccessDeny:"You are trying to perform an action you do not have rights for.
Please contact your Document Server administrator.",titleServerVersion:"Editor updated",errorServerVersion:"The editor version has been updated. The page will be reloaded to apply the changes.",errorLockedCellPivot:"You cannot change data inside a pivot table.",txtAccent:"Accent",txtStyle_Normal:"Normal",txtStyle_Heading_1:"Heading 1",txtStyle_Heading_2:"Heading 2",txtStyle_Heading_3:"Heading 3",txtStyle_Heading_4:"Heading 4",txtStyle_Title:"Title",txtStyle_Neutral:"Neutral",txtStyle_Bad:"Bad",txtStyle_Good:"Good",txtStyle_Input:"Input",txtStyle_Output:"Output",txtStyle_Calculation:"Calculation",txtStyle_Check_Cell:"Check Cell",txtStyle_Explanatory_Text:"Explanatory Text",txtStyle_Note:"Note",txtStyle_Linked_Cell:"Linked Cell",txtStyle_Warning_Text:"Warning Text",txtStyle_Total:"Total",txtStyle_Currency:"Currency",txtStyle_Percent:"Percent",txtStyle_Comma:"Comma",errorForceSave:"An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.",errorMaxPoints:"The maximum number of points in series per chart is 4096.",warnNoLicense:"This version of %1 editors has certain limitations for concurrent connections to the document server.
If you need more please consider purchasing a commercial license.",warnNoLicenseUsers:"This version of %1 Editors has certain limitations for concurrent users.
If you need more please consider purchasing a commercial license.",warnLicenseExceeded:"The number of concurrent connections to the document server has been exceeded and the document will be opened for viewing only.
Please contact your administrator for more information.",warnLicenseUsersExceeded:"The number of concurrent users has been exceeded and the document will be opened for viewing only.
Please contact your administrator for more information.",errorDataEncrypted:"Encrypted changes have been received, they cannot be deciphered.",textClose:"Close",textPaidFeature:"Paid feature",scriptLoadError:"The connection is too slow, some of the components could not be loaded. Please reload the page.",errorEditingSaveas:"An error occurred during the work with the document.
Use the 'Save as...' option to save the file backup copy to your computer hard drive.",errorEditingDownloadas:"An error occurred during the work with the document.
Use the 'Download as...' option to save the file backup copy to your computer hard drive.",txtShape_textRect:"Text Box",txtShape_rect:"Rectangle",txtShape_ellipse:"Ellipse",txtShape_triangle:"Triangle",txtShape_rtTriangle:"Right Triangle",txtShape_parallelogram:"Parallelogram",txtShape_trapezoid:"Trapezoid",txtShape_diamond:"Diamond",txtShape_pentagon:"Pentagon",txtShape_hexagon:"Hexagon",txtShape_heptagon:"Heptagon",txtShape_octagon:"Octagon",txtShape_decagon:"Decagon",txtShape_dodecagon:"Dodecagon",txtShape_pie:"Pie",txtShape_chord:"Chord",txtShape_teardrop:"Teardrop",txtShape_frame:"Frame",txtShape_halfFrame:"Half Frame",txtShape_corner:"Corner",txtShape_diagStripe:"Diagonal Stripe",txtShape_plus:"Plus",txtShape_plaque:"Sign",txtShape_can:"Can",txtShape_cube:"Cube",txtShape_bevel:"Bevel",txtShape_donut:"Donut",txtShape_noSmoking:'"No" Symbol',txtShape_blockArc:"Block Arc",txtShape_foldedCorner:"Folded Corner",txtShape_smileyFace:"Smiley Face",txtShape_heart:"Heart",txtShape_lightningBolt:"Lightning Bolt",txtShape_sun:"Sun",txtShape_moon:"Moon",txtShape_cloud:"Cloud",txtShape_arc:"Arc",txtShape_bracePair:"Double Brace",txtShape_leftBracket:"Left Bracket",txtShape_rightBracket:"Right Bracket",txtShape_leftBrace:"Left Brace",txtShape_rightBrace:"Right Brace",txtShape_rightArrow:"Right Arrow",txtShape_leftArrow:"Left Arrow",txtShape_upArrow:"Up Arrow",txtShape_downArrow:"Down Arrow",txtShape_leftRightArrow:"Left Right Arrow",txtShape_upDownArrow:"Up Down Arrow",txtShape_quadArrow:"Quad Arrow",txtShape_leftRightUpArrow:"Left Right Up Arrow",txtShape_bentArrow:"Bent Arrow",txtShape_uturnArrow:"U-Turn Arrow",txtShape_leftUpArrow:"Left Up Arrow",txtShape_bentUpArrow:"Bent Up Arrow",txtShape_curvedRightArrow:"Curved Right Arrow",txtShape_curvedLeftArrow:"Curved Left Arrow",txtShape_curvedUpArrow:"Curved Up Arrow",txtShape_curvedDownArrow:"Curved Down Arrow",txtShape_stripedRightArrow:"Striped Right Arrow",txtShape_notchedRightArrow:"Notched Right Arrow",txtShape_homePlate:"Pentagon",txtShape_chevron:"Chevron",txtShape_rightArrowCallout:"Right Arrow Callout",txtShape_downArrowCallout:"Down Arrow Callout",txtShape_leftArrowCallout:"Left Arrow Callout",txtShape_upArrowCallout:"Up Arrow Callout",txtShape_leftRightArrowCallout:"Left Right Arrow Callout",txtShape_quadArrowCallout:"Quad Arrow Callout",txtShape_circularArrow:"Circular Arrow",txtShape_mathPlus:"Plus",txtShape_mathMinus:"Minus",txtShape_mathMultiply:"Multiply",txtShape_mathDivide:"Division",txtShape_mathEqual:"Equal",txtShape_mathNotEqual:"Not Equal",txtShape_flowChartProcess:"Flowchart: Process",txtShape_flowChartAlternateProcess:"Flowchart: Alternate Process",txtShape_flowChartDecision:"Flowchart: Decision",txtShape_flowChartInputOutput:"Flowchart: Data",txtShape_flowChartPredefinedProcess:"Flowchart: Predefined Process",txtShape_flowChartInternalStorage:"Flowchart: Internal Storage",txtShape_flowChartDocument:"Flowchart: Document",txtShape_flowChartMultidocument:"Flowchart: Multidocument ",txtShape_flowChartTerminator:"Flowchart: Terminator",txtShape_flowChartPreparation:"Flowchart: Preparation",txtShape_flowChartManualInput:"Flowchart: Manual Input",txtShape_flowChartManualOperation:"Flowchart: Manual Operation",txtShape_flowChartConnector:"Flowchart: Connector",txtShape_flowChartOffpageConnector:"Flowchart: Off-page Connector",txtShape_flowChartPunchedCard:"Flowchart: Card",txtShape_flowChartPunchedTape:"Flowchart: Punched Tape",txtShape_flowChartSummingJunction:"Flowchart: Summing Junction",txtShape_flowChartOr:"Flowchart: Or",txtShape_flowChartCollate:"Flowchart: Collate",txtShape_flowChartSort:"Flowchart: Sort",txtShape_flowChartExtract:"Flowchart: Extract",txtShape_flowChartMerge:"Flowchart: Merge",txtShape_flowChartOnlineStorage:"Flowchart: Stored Data",txtShape_flowChartDelay:"Flowchart: Delay",txtShape_flowChartMagneticTape:"Flowchart: Sequential Access Storage",txtShape_flowChartMagneticDisk:"Flowchart: Magnetic Disk",txtShape_flowChartMagneticDrum:"Flowchart: Direct Access Storage",txtShape_flowChartDisplay:"Flowchart: Display",txtShape_irregularSeal1:"Explosion 1",txtShape_irregularSeal2:"Explosion 2",txtShape_star4:"4-Point Star",txtShape_star5:"5-Point Star",txtShape_star6:"6-Point Star",txtShape_star7:"7-Point Star",txtShape_star8:"8-Point Star",txtShape_star10:"10-Point Star",txtShape_star12:"12-Point Star",txtShape_star16:"16-Point Star",txtShape_star24:"24-Point Star",txtShape_star32:"32-Point Star",txtShape_ribbon2:"Up Ribbon",txtShape_ribbon:"Down Ribbon",txtShape_ellipseRibbon2:"Curved Up Ribbon",txtShape_ellipseRibbon:"Curved Down Ribbon",txtShape_verticalScroll:"Vertical Scroll",txtShape_horizontalScroll:"Horizontal Scroll",txtShape_wave:"Wave",txtShape_doubleWave:"Double Wave",txtShape_wedgeRectCallout:"Rectangular Callout",txtShape_wedgeRoundRectCallout:"Rounded Rectangular Callout",txtShape_wedgeEllipseCallout:"Oval Callout",txtShape_cloudCallout:"Cloud Callout",txtShape_borderCallout1:"Line Callout 1",txtShape_borderCallout2:"Line Callout 2",txtShape_borderCallout3:"Line Callout 3",txtShape_accentCallout1:"Line Callout 1 (Accent Bar)",txtShape_accentCallout2:"Line Callout 2 (Accent Bar)",txtShape_accentCallout3:"Line Callout 3 (Accent Bar)",txtShape_callout1:"Line Callout 1 (No Border)",txtShape_callout2:"Line Callout 2 (No Border)",txtShape_callout3:"Line Callout 3 (No Border)",txtShape_accentBorderCallout1:"Line Callout 1 (Border and Accent Bar)",txtShape_accentBorderCallout2:"Line Callout 2 (Border and Accent Bar)",txtShape_accentBorderCallout3:"Line Callout 3 (Border and Accent Bar)",txtShape_actionButtonBackPrevious:"Back or Previous Button",txtShape_actionButtonForwardNext:"Forward or Next Button",txtShape_actionButtonBeginning:"Beginning Button",txtShape_actionButtonEnd:"End Button",txtShape_actionButtonHome:"Home Button",txtShape_actionButtonInformation:"Information Button",txtShape_actionButtonReturn:"Return Button",txtShape_actionButtonMovie:"Movie Button",txtShape_actionButtonDocument:"Document Button",txtShape_actionButtonSound:"Sound Button",txtShape_actionButtonHelp:"Help Button",txtShape_actionButtonBlank:"Blank Button",txtShape_roundRect:"Round Corner Rectangle",txtShape_snip1Rect:"Snip Single Corner Rectangle",txtShape_snip2SameRect:"Snip Same Side Corner Rectangle",txtShape_snip2DiagRect:"Snip Diagonal Corner Rectangle",txtShape_snipRoundRect:"Snip and Round Single Corner Rectangle",txtShape_round1Rect:"Round Single Corner Rectangle",txtShape_round2SameRect:"Round Same Side Corner Rectangle",txtShape_round2DiagRect:"Round Diagonal Corner Rectangle",txtShape_line:"Line",txtShape_lineWithArrow:"Arrow",txtShape_lineWithTwoArrows:"Double Arrow",txtShape_bentConnector5:"Elbow Connector",txtShape_bentConnector5WithArrow:"Elbow Arrow Connector",txtShape_bentConnector5WithTwoArrows:"Elbow Double-Arrow Connector",txtShape_curvedConnector3:"Curved Connector",txtShape_curvedConnector3WithArrow:"Curved Arrow Connector",txtShape_curvedConnector3WithTwoArrows:"Curved Double-Arrow Connector",txtShape_spline:"Curve",txtShape_polyline1:"Scribble",txtShape_polyline2:"Freeform",errorChangeArray:"You cannot change part of an array.",errorMultiCellFormula:"Multi-cell array formulas are not allowed in tables.",errorEmailClient:"No email client could be found",txtPrintArea:"Print_Area",txtTable:"Table",textCustomLoader:"Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.",errorNoDataToParse:"No data was selected to parse.",errorCannotUngroup:"Cannot ungroup. To start an outline, select the detail rows or columns and group them.",errorFrmlMaxTextLength:"Text values in formulas are limited to 255 characters.
Use the CONCATENATE function or concatenation operator (&)",waitText:"Please, wait...",errorDataValidate:"The value you entered is not valid.
A user has restricted values that can be entered into this cell.",txtConfidential:"Confidential",txtPreparedBy:"Prepared by",txtPage:"Page",txtPageOf:"Page %1 of %2",txtPages:"Pages",txtDate:"Date",txtTime:"Time",txtTab:"Tab",txtFile:"File"}}(),SSE.Controllers.Main||{}))}),define("common/main/lib/view/DocumentAccessDialog",["common/main/lib/component/Window","common/main/lib/component/LoadMask"],function(){"use strict";Common.Views.DocumentAccessDialog=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};_.extend(e,{title:this.textTitle,width:600,height:536,header:!0},t),this.template=['
'].join(""),e.tpl=_.template(this.template)(e),this.settingsurl=t.settingsurl||"",Common.UI.Window.prototype.initialize.call(this,e)},render:function(){Common.UI.Window.prototype.render.call(this),this.$window.find("> .body").css({height:"auto",overflow:"hidden"});var t=document.createElement("iframe");t.width="100%",t.height=500,t.align="top",t.frameBorder=0,t.scrolling="no",t.onload=_.bind(this._onLoad,this),$("#id-sharing-placeholder").append(t),this.loadMask=new Common.UI.LoadMask({owner:$("#id-sharing-placeholder")}),this.loadMask.setTitle(this.textLoading),this.loadMask.show(),t.src=this.settingsurl;var e=this;this._eventfunc=function(t){e._onWindowMessage(t)},this._bindWindowEvents.call(this),this.on("close",function(t){e._unbindWindowEvents()})},_bindWindowEvents:function(){window.addEventListener?window.addEventListener("message",this._eventfunc,!1):window.attachEvent&&window.attachEvent("onmessage",this._eventfunc)},_unbindWindowEvents:function(){window.removeEventListener?window.removeEventListener("message",this._eventfunc):window.detachEvent&&window.detachEvent("onmessage",this._eventfunc)},_onWindowMessage:function(t){if(t&&window.JSON)try{this._onMessage.call(this,window.JSON.parse(t.data))}catch(t){}},_onMessage:function(t){t&&"onlyoffice"==t.Referer&&(t.needUpdate&&this.trigger("accessrights",this,t.sharingSettings),Common.NotificationCenter.trigger("window:close",this))},_onLoad:function(){this.loadMask&&this.loadMask.hide()},textTitle:"Sharing Settings",textLoading:"Loading"},Common.Views.DocumentAccessDialog||{}))}),define("spreadsheeteditor/main/app/view/FileMenuPanels",["common/main/lib/view/DocumentAccessDialog"],function(){"use strict";!SSE.Views.FileMenuPanels&&(SSE.Views.FileMenuPanels={}),SSE.Views.FileMenuPanels.ViewSaveAs=Common.UI.BaseView.extend({el:"#panel-saveas",menu:void 0,formats:[[{name:"XLSX",imgCls:"xlsx",type:Asc.c_oAscFileType.XLSX},{name:"PDF",imgCls:"pdf",type:Asc.c_oAscFileType.PDF},{name:"ODS",imgCls:"ods",type:Asc.c_oAscFileType.ODS},{name:"CSV",imgCls:"csv",type:Asc.c_oAscFileType.CSV}],[{name:"XLTX",imgCls:"xltx",type:Asc.c_oAscFileType.XLTX},{name:"PDFA",imgCls:"pdfa",type:Asc.c_oAscFileType.PDFA},{name:"OTS",imgCls:"ots",type:Asc.c_oAscFileType.OTS}]],template:_.template(["","<% _.each(rows, function(row) { %>","","<% _.each(row, function(item) { %>",'","<% }) %>","","<% }) %>","
','',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({rows:this.formats})),$(".btn-doc-format",this.el).on("click",_.bind(this.onFormatClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onFormatClick:function(t){var e=t.currentTarget.attributes.format;!_.isUndefined(e)&&this.menu&&this.menu.fireEvent("saveas:format",[this.menu,parseInt(e.value)])}}),SSE.Views.FileMenuPanels.ViewSaveCopy=Common.UI.BaseView.extend({el:"#panel-savecopy",menu:void 0,formats:[[{name:"XLSX",imgCls:"xlsx",type:Asc.c_oAscFileType.XLSX,ext:".xlsx"},{name:"PDF",imgCls:"pdf",type:Asc.c_oAscFileType.PDF,ext:".pdf"},{name:"ODS",imgCls:"ods",type:Asc.c_oAscFileType.ODS,ext:".ods"},{name:"CSV",imgCls:"csv",type:Asc.c_oAscFileType.CSV,ext:".csv"}],[{name:"XLTX",imgCls:"xltx",type:Asc.c_oAscFileType.XLTX,ext:".xltx"},{name:"PDFA",imgCls:"pdfa",type:Asc.c_oAscFileType.PDFA,ext:".pdf"},{name:"OTS",imgCls:"ots",type:Asc.c_oAscFileType.OTS,ext:".ots"}]],template:_.template(["","<% _.each(rows, function(row) { %>","","<% _.each(row, function(item) { %>",'","<% }) %>","","<% }) %>","
','',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({rows:this.formats})),$(".btn-doc-format",this.el).on("click",_.bind(this.onFormatClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onFormatClick:function(t){var e=t.currentTarget.attributes.format,i=t.currentTarget.attributes["format-ext"];_.isUndefined(e)||_.isUndefined(i)||!this.menu||this.menu.fireEvent("savecopy:format",[this.menu,parseInt(e.value),i.value])}}),SSE.Views.FileMenuPanels.Settings=Common.UI.BaseView.extend(_.extend({el:"#panel-settings",menu:void 0,template:_.template(['
','
','
','
','
',"
","
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template()),this.generalSettings=new SSE.Views.FileMenuPanels.MainSettingsGeneral({menu:this.menu}),this.generalSettings.options={alias:"MainSettingsGeneral"},this.generalSettings.render(),this.printSettings=SSE.getController("Print").getView("MainSettingsPrint"),this.printSettings.menu=this.menu,this.printSettings.render($("#panel-settings-print")),this.viewSettingsPicker=new Common.UI.DataView({el:$("#id-settings-menu"),store:new Common.UI.DataViewStore([{name:this.txtGeneral,panel:this.generalSettings,iconCls:"mnu-settings-general",selected:!0},{name:this.txtPageSettings,panel:this.printSettings,iconCls:"mnu-print"}]),itemTemplate:_.template(['
','
',"
<%= name %>","
"].join(""))}),this.viewSettingsPicker.on("item:select",_.bind(function(t,e,i){var n=i.get("panel");$("#id-settings-content > div").removeClass("active"),n.$el.addClass("active"),n.show()},this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments);var t=this.viewSettingsPicker.getSelectedRec();t&&t.get("panel").show()},setMode:function(t){this.mode=t,this.mode.canPrint||this.viewSettingsPicker.store.pop(),this.generalSettings&&this.generalSettings.setMode(this.mode)},setApi:function(t){this.generalSettings&&this.generalSettings.setApi(t)},txtGeneral:"General",txtPageSettings:"Page Settings"},SSE.Views.FileMenuPanels.Settings||{})),SSE.Views.MainSettingsPrint=Common.UI.BaseView.extend(_.extend({menu:void 0,template:_.template(['',"",'','',"",'','',"",'','',"",'',"",'','',"",'',"",'','',"",'',"",'','","",'',"",'','","",'','',"",'','',"","
','',"","","","","",'','',"","","","","","",'','',"","
","
','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.spinners=[],this._initSettings=!0},render:function(t){return t&&this.setElement(t,!1),$(this.el).html(this.template({scope:this})),this.cmbSheet=new Common.UI.ComboBox({el:$("#advsettings-print-combo-sheets"),style:"width: 242px;",menuStyle:"min-width: 242px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[]}),this.cmbPaperSize=new Common.UI.ComboBox({el:$("#advsettings-print-combo-pages"),style:"width: 242px;",menuStyle:"max-height: 280px; min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:"215.9|279.4",displayValue:"US Letter (21,59cm x 27,94cm)",caption:"US Letter"},{value:"215.9|355.6",displayValue:"US Legal (21,59cm x 35,56cm)",caption:"US Legal"},{value:"210|297",displayValue:"A4 (21cm x 29,7cm)",caption:"A4"},{value:"148|210",displayValue:"A5 (14,8cm x 21cm)",caption:"A5"},{value:"176|250",displayValue:"B5 (17,6cm x 25cm)",caption:"B5"},{value:"104.8|241.3",displayValue:"Envelope #10 (10,48cm x 24,13cm)",caption:"Envelope #10"},{value:"110|220",displayValue:"Envelope DL (11cm x 22cm)",caption:"Envelope DL"},{value:"279.4|431.8",displayValue:"Tabloid (27,94cm x 43,178m)",caption:"Tabloid"},{value:"297|420",displayValue:"A3 (29,7cm x 42cm)",caption:"A3"},{value:"304.8|457.1",displayValue:"Tabloid Oversize (30,48cm x 45,71cm)",caption:"Tabloid Oversize"},{value:"196.8|273",displayValue:"ROC 16K (19,68cm x 27,3cm)",caption:"ROC 16K"},{value:"119.9|234.9",displayValue:"Envelope Choukei 3 (11,99cm x 23,49cm)",caption:"Envelope Choukei 3"},{value:"330.2|482.5",displayValue:"Super B/A3 (33,02cm x 48,25cm)",caption:"Super B/A3"}]}),this.cmbPaperOrientation=new Common.UI.ComboBox({el:$("#advsettings-print-combo-orient"),style:"width: 132px;",menuStyle:"min-width: 132px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPageOrientation.PagePortrait,displayValue:this.strPortrait},{value:Asc.c_oAscPageOrientation.PageLandscape,displayValue:this.strLandscape}]}),this.cmbLayout=new Common.UI.ComboBox({el:$("#advsettings-print-combo-layout"),style:"width: 242px;",menuStyle:"min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:0,displayValue:this.textActualSize},{value:1,displayValue:this.textFitPage},{value:2,displayValue:this.textFitCols},{value:3,displayValue:this.textFitRows}]}),this.chPrintGrid=new Common.UI.CheckBox({el:$("#advsettings-print-chb-grid"),labelText:this.textPrintGrid}),this.chPrintRows=new Common.UI.CheckBox({el:$("#advsettings-print-chb-rows"),labelText:this.textPrintHeadings}),this.spnMarginTop=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-top"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginTop),this.spnMarginBottom=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-bottom"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginBottom),this.spnMarginLeft=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-left"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginLeft),this.spnMarginRight=new Common.UI.MetricSpinner({el:$("#advsettings-spin-margin-right"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginRight),this.btnOk=new Common.UI.Button({el:"#advsettings-print-button-save"}),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this.fireEvent("render:after",this),this},updateMetricUnit:function(){if(this.spinners)for(var t=0;t','','','
',"",'','','','
',"",'','','','',"",'','','','',"",'',"",'','
',"",'','','','','
','
',"",'',"",'','
',"",'',"",'','',"",'','','','',"",'','','','','
','
',"",'','','','','
','
',"",'',"",'','',"",""].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){$(this.el).html(this.template({scope:this})),this.chLiveComment=new Common.UI.CheckBox({el:$("#fms-chb-live-comment"),labelText:this.strLiveComment}).on("change",_.bind(function(t,e,i,n){this.chResolvedComment.setDisabled("checked"!==t.getValue())},this)),this.chResolvedComment=new Common.UI.CheckBox({el:$("#fms-chb-resolved-comment"),labelText:this.strResolvedComment}),this.chR1C1Style=new Common.UI.CheckBox({el:$("#fms-chb-r1c1-style"),labelText:this.strR1C1}),this.cmbCoAuthMode=new Common.UI.ComboBox({el:$("#fms-cmb-coauth-mode"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:1,displayValue:this.strFast,descValue:this.strCoAuthModeDescFast},{value:0,displayValue:this.strStrict,descValue:this.strCoAuthModeDescStrict}]}).on("selected",_.bind(function(t,e){1==e.value&&"checked"!==this.chAutosave.getValue()&&this.chAutosave.setValue(1),this.lblCoAuthMode.text(e.descValue)},this)),this.lblCoAuthMode=$("#fms-lbl-coauth-mode"),this.cmbZoom=new Common.UI.ComboBox({el:$("#fms-cmb-zoom"),style:"width: 160px;",editable:!1,cls:"input-group-nr",menuStyle:"max-height: 210px;",data:[{value:50,displayValue:"50%"},{value:60,displayValue:"60%"},{value:70,displayValue:"70%"},{value:80,displayValue:"80%"},{value:90,displayValue:"90%"},{value:100,displayValue:"100%"},{value:110,displayValue:"110%"},{value:120,displayValue:"120%"},{value:150,displayValue:"150%"},{value:175,displayValue:"175%"},{value:200,displayValue:"200%"}]}),this.cmbFontRender=new Common.UI.ComboBox({el:$("#fms-cmb-font-render"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscFontRenderingModeType.hintingAndSubpixeling,displayValue:this.txtWin},{value:Asc.c_oAscFontRenderingModeType.noHinting,displayValue:this.txtMac},{value:Asc.c_oAscFontRenderingModeType.hinting,displayValue:this.txtNative}]}),this.chAutosave=new Common.UI.CheckBox({el:$("#fms-chb-autosave"),labelText:this.strAutosave}).on("change",_.bind(function(t,e,i,n){"checked"!==t.getValue()&&this.cmbCoAuthMode.getValue()&&(this.cmbCoAuthMode.setValue(0),this.lblCoAuthMode.text(this.strCoAuthModeDescStrict))},this)),this.lblAutosave=$("#fms-lbl-autosave"),this.chForcesave=new Common.UI.CheckBox({el:$("#fms-chb-forcesave"),labelText:this.strForcesave}),this.cmbUnit=new Common.UI.ComboBox({el:$("#fms-cmb-unit"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:Common.Utils.Metric.c_MetricUnits.cm,displayValue:this.txtCm},{value:Common.Utils.Metric.c_MetricUnits.pt,displayValue:this.txtPt},{value:Common.Utils.Metric.c_MetricUnits.inch,displayValue:this.txtInch}]}),this.cmbFuncLocale=new Common.UI.ComboBox({el:$("#fms-cmb-func-locale"),style:"width: 160px;",editable:!1,cls:"input-group-nr",data:[{value:"en",displayValue:this.txtEn,exampleValue:this.txtExampleEn},{value:"de",displayValue:this.txtDe,exampleValue:this.txtExampleDe},{value:"es",displayValue:this.txtEs,exampleValue:this.txtExampleEs},{value:"fr",displayValue:this.txtFr, +exampleValue:this.txtExampleFr},{value:"it",displayValue:this.txtIt,exampleValue:this.txtExampleIt},{value:"ru",displayValue:this.txtRu,exampleValue:this.txtExampleRu},{value:"pl",displayValue:this.txtPl,exampleValue:this.txtExamplePl}]}).on("selected",_.bind(function(t,e){this.updateFuncExample(e.exampleValue)},this));var t=[{value:1068},{value:1026},{value:1029},{value:1031},{value:2055},{value:1032},{value:3081},{value:2057},{value:1033},{value:3082},{value:2058},{value:1035},{value:1036},{value:1040},{value:1041},{value:1042},{value:1062},{value:1043},{value:1045},{value:1046},{value:2070},{value:1049},{value:1051},{value:1060},{value:2077},{value:1053},{value:1055},{value:1058},{value:1066},{value:2052}];return t.forEach(function(t){var e=Common.util.LanguageInfo.getLocalLanguageName(t.value);t.displayValue=e[1],t.langName=e[0]}),this.cmbRegSettings=new Common.UI.ComboBox({el:$("#fms-cmb-reg-settings"),style:"width: 160px;",menuStyle:"max-height: 185px;",editable:!1,cls:"input-group-nr",data:t,template:_.template(['','','','','",""].join(""))}).on("selected",_.bind(function(t,e){this.updateRegionalExample(e.value)},this)),this.cmbRegSettings.scroller&&this.cmbRegSettings.scroller.update({alwaysVisibleY:!0}),this.btnApply=new Common.UI.Button({el:"#fms-btn-apply"}),this.btnApply.on("click",_.bind(this.applySettings,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateSettings()},setMode:function(t){this.mode=t,$("tr.edit",this.el)[t.isEdit?"show":"hide"](),$("tr.autosave",this.el)[t.isEdit?"show":"hide"](),this.mode.isDesktopApp&&this.mode.isOffline&&(this.chAutosave.setCaption(this.strAutoRecover),this.lblAutosave.text(this.textAutoRecover)),$("tr.forcesave",this.el)[t.canForcesave?"show":"hide"](),$("tr.comments",this.el)[t.canCoAuthoring?"show":"hide"](),$("tr.coauth.changes",this.el)[t.isEdit&&!t.isOffline&&t.canCoAuthoring?"show":"hide"]()},setApi:function(t){this.api=t},updateSettings:function(){var t=Common.Utils.InternalSettings.get("sse-settings-zoom");t=null!==t?parseInt(t):this.mode.customization&&this.mode.customization.zoom?parseInt(this.mode.customization.zoom):100;var e=this.cmbZoom.store.findWhere({value:t});this.cmbZoom.setValue(e?parseInt(e.get("value")):t>0?t+"%":100),this.chLiveComment.setValue(Common.Utils.InternalSettings.get("sse-settings-livecomment")),this.chResolvedComment.setValue(Common.Utils.InternalSettings.get("sse-settings-resolvedcomment")),this.chR1C1Style.setValue(Common.Utils.InternalSettings.get("sse-settings-r1c1"));var i=Common.Utils.InternalSettings.get("sse-settings-coauthmode");e=this.cmbCoAuthMode.store.findWhere({value:i?1:0}),this.cmbCoAuthMode.setValue(e?e.get("value"):1),this.lblCoAuthMode.text(e?e.get("descValue"):this.strCoAuthModeDescFast),t=Common.Utils.InternalSettings.get("sse-settings-fontrender"),e=this.cmbFontRender.store.findWhere({value:parseInt(t)}),this.cmbFontRender.setValue(e?e.get("value"):window.devicePixelRatio>1?Asc.c_oAscFontRenderingModeType.noHinting:Asc.c_oAscFontRenderingModeType.hintingAndSubpixeling),t=Common.Utils.InternalSettings.get("sse-settings-unit"),e=this.cmbUnit.store.findWhere({value:t}),this.cmbUnit.setValue(e?parseInt(e.get("value")):Common.Utils.Metric.getDefaultMetric()),this._oldUnits=this.cmbUnit.getValue(),t=Common.Utils.InternalSettings.get("sse-settings-autosave"),this.chAutosave.setValue(1==t),this.mode.canForcesave&&this.chForcesave.setValue(Common.Utils.InternalSettings.get("sse-settings-forcesave")),t=Common.Utils.InternalSettings.get("sse-settings-func-locale"),e=this.cmbFuncLocale.store.findWhere({value:t}),!e&&t&&(e=this.cmbFuncLocale.store.findWhere({value:t.split(/[\-\_]/)[0]})),this.cmbFuncLocale.setValue(e?e.get("value"):"en"),this.updateFuncExample(e?e.get("exampleValue"):this.txtExampleEn),t=this.api.asc_getLocale(),t?(e=this.cmbRegSettings.store.findWhere({value:t}),this.cmbRegSettings.setValue(e?e.get("value"):Common.util.LanguageInfo.getLocalLanguageName(t)[1]),e&&(t=this.cmbRegSettings.getValue())):(t=this.mode.lang?parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.mode.lang)):1033,this.cmbRegSettings.setValue(Common.util.LanguageInfo.getLocalLanguageName(t)[1])),this.updateRegionalExample(t)},applySettings:function(){Common.localStorage.setItem("sse-settings-zoom",this.cmbZoom.getValue()),Common.Utils.InternalSettings.set("sse-settings-zoom",Common.localStorage.getItem("sse-settings-zoom")),Common.localStorage.setItem("sse-settings-livecomment",this.chLiveComment.isChecked()?1:0),Common.localStorage.setItem("sse-settings-resolvedcomment",this.chResolvedComment.isChecked()?1:0),this.mode.isEdit&&!this.mode.isOffline&&this.mode.canCoAuthoring&&Common.localStorage.setItem("sse-settings-coauthmode",this.cmbCoAuthMode.getValue()),Common.localStorage.setItem("sse-settings-r1c1",this.chR1C1Style.isChecked()?1:0),Common.localStorage.setItem("sse-settings-fontrender",this.cmbFontRender.getValue()),Common.localStorage.setItem("sse-settings-unit",this.cmbUnit.getValue()),Common.localStorage.setItem("sse-settings-autosave",this.chAutosave.isChecked()?1:0),this.mode.canForcesave&&Common.localStorage.setItem("sse-settings-forcesave",this.chForcesave.isChecked()?1:0),Common.localStorage.setItem("sse-settings-func-locale",this.cmbFuncLocale.getValue()),this.cmbRegSettings.getSelectedRecord()&&Common.localStorage.setItem("sse-settings-reg-settings",this.cmbRegSettings.getValue()),Common.localStorage.save(),this.menu&&(this.menu.fireEvent("settings:apply",[this.menu]),this._oldUnits!==this.cmbUnit.getValue()&&Common.NotificationCenter.trigger("settings:unitschanged",this))},updateRegionalExample:function(t){if(this.api){var e="";if(t){var i=new Asc.asc_CFormatCellsInfo;i.asc_setType(Asc.c_oAscNumFormatType.None),i.asc_setSymbol(t);var n=this.api.asc_getFormatCells(i);e=this.api.asc_getLocaleExample(n[4],1000.01,t),e=e+" "+this.api.asc_getLocaleExample(n[5],Asc.cDate().getExcelDateWithTime(),t),e=e+" "+this.api.asc_getLocaleExample(n[6],Asc.cDate().getExcelDateWithTime(),t)}$("#fms-lbl-reg-settings").text(_.isEmpty(e)?"":this.strRegSettingsEx+e)}var o=this.cmbRegSettings.$el.find(".input-icon"),s=o.attr("lang"),a=Common.util.LanguageInfo.getLocalLanguageName(t)[0];s&&o.removeClass(s),o.addClass(a).attr("lang",a)},updateFuncExample:function(t){$("#fms-lbl-func-locale").text(_.isEmpty(t)?"":this.strRegSettingsEx+t)},strLiveComment:"Turn on option",strZoom:"Default Zoom Value",okButtonText:"Apply",txtLiveComment:"Live Commenting",txtWin:"as Windows",txtMac:"as OS X",txtNative:"Native",strFontRender:"Font Hinting",strUnit:"Unit of Measurement",txtCm:"Centimeter",txtPt:"Point",strAutosave:"Turn on autosave",textAutoSave:"Autosave",txtEn:"English",txtDe:"Deutsch",txtRu:"Russian",txtPl:"Polish",txtEs:"Spanish",txtFr:"French",txtIt:"Italian",txtExampleEn:" SUM; MIN; MAX; COUNT",txtExampleDe:" SUMME; MIN; MAX; ANZAHL",txtExampleRu:" СУММ; МИН; МАКС; СЧЁТ",txtExamplePl:" SUMA; MIN; MAX; ILE.LICZB",txtExampleEs:" SUMA; MIN; MAX; CALCULAR",txtExampleFr:" SOMME; MIN; MAX; NB",txtExampleIt:" SOMMA; MIN; MAX; CONTA.NUMERI",strFuncLocale:"Formula Language",strFuncLocaleEx:"Example: SUM; MIN; MAX; COUNT",strRegSettings:"Regional Settings",strRegSettingsEx:"Example: ",strCoAuthMode:"Co-editing mode",strCoAuthModeDescFast:"Other users will see your changes at once",strCoAuthModeDescStrict:"You will need to accept changes before you can see them",strFast:"Fast",strStrict:"Strict",textAutoRecover:"Autorecover",strAutoRecover:"Turn on autorecover",txtInch:"Inch",textForceSave:"Save to Server",strForcesave:"Always save to server (otherwise save to server on document close)",strResolvedComment:"Turn on display of the resolved comments",textRefStyle:"Reference Style",strR1C1:"Turn on R1C1 style"},SSE.Views.FileMenuPanels.MainSettingsGeneral||{})),SSE.Views.FileMenuPanels.RecentFiles=Common.UI.BaseView.extend({el:"#panel-recentfiles",menu:void 0,template:_.template(['
'].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.recent=t.recent},render:function(){return $(this.el).html(this.template()),this.viewRecentPicker=new Common.UI.DataView({el:$("#id-recent-view"),store:new Common.UI.DataViewStore(this.recent),itemTemplate:_.template(['
','
','
<%= Common.Utils.String.htmlEncode(title) %>
','
<%= Common.Utils.String.htmlEncode(folder) %>
',"
"].join(""))}),this.viewRecentPicker.on("item:click",_.bind(this.onRecentFileClick,this)),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},onRecentFileClick:function(t,e,i){this.menu&&this.menu.fireEvent("recent:open",[this.menu,i.get("url")])}}),SSE.Views.FileMenuPanels.CreateNew=Common.UI.BaseView.extend(_.extend({el:"#panel-createnew",menu:void 0,events:function(){return{"click .blank-document-btn":_.bind(this._onBlankDocument,this),"click .thumb-list .thumb-wrap":_.bind(this._onDocumentTemplate,this)}},template:_.template(['

<%= scope.fromBlankText %>


','
','
','','',"","
",'
',"

<%= scope.newDocumentText %>

","<%= scope.newDescriptionText %>","
","
","

<%= scope.fromTemplateText %>


",'
',"<% _.each(docs, function(item) { %>",'
','
\") } else { print(\">\") } %>","
",'
<%= item.name %>
',"
","<% }) %>","
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu},render:function(){return $(this.el).html(this.template({scope:this,docs:this.options[0].docs})),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},_onBlankDocument:function(){this.menu&&this.menu.fireEvent("create:new",[this.menu,"blank"])},_onDocumentTemplate:function(t){this.menu&&this.menu.fireEvent("create:new",[this.menu,t.currentTarget.attributes.template.value])},fromBlankText:"From Blank",newDocumentText:"New Spreadsheet",newDescriptionText:"Create a new blank text document which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a document of a certain type or purpose where some styles have already been pre-applied.",fromTemplateText:"From Template"},SSE.Views.FileMenuPanels.CreateNew||{})),SSE.Views.FileMenuPanels.DocumentInfo=Common.UI.BaseView.extend(_.extend({el:"#panel-info",menu:void 0,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.rendered=!1,this.template=_.template(['',"",'",'',"","",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"",'','',"",'",'',"","",'",'',"","",'",'","","
',"","",'',"","
","
"].join("")),this.menu=t.menu,this.coreProps=null,this.authors=[],this._locked=!1},render:function(){$(this.el).html(this.template());var t=this;this.lblPlacement=$("#id-info-placement"),this.lblOwner=$("#id-info-owner"),this.lblUploaded=$("#id-info-uploaded");var e=function(t,e){if(e.keyCode===Common.UI.Keys.ESC){var i=t._input.val(),n=t.getValue();i!==n&&(t.setValue(n),e.stopPropagation())}};return this.inputTitle=new Common.UI.InputField({el:$("#id-info-title"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putTitle(t.inputTitle.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.inputSubject=new Common.UI.InputField({el:$("#id-info-subject"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putSubject(t.inputSubject.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.inputComment=new Common.UI.InputField({el:$("#id-info-comment"),style:"width: 200px;",placeHolder:this.txtAddText,validateOnBlur:!1}).on("changed:after",function(e,i,n){i!==n&&t.coreProps&&t.api&&(t.coreProps.asc_putDescription(t.inputComment.getValue()),t.api.asc_setCoreProps(t.coreProps))}).on("keydown:before",e),this.lblModifyDate=$("#id-info-modify-date"),this.lblModifyBy=$("#id-info-modify-by"),this.lblDate=$("#id-info-date"),this.lblApplication=$("#id-info-appname"),this.tblAuthor=$("#id-info-author table"),this.trAuthor=$("#id-info-add-author").closest("tr"),this.authorTpl='
',this.tblAuthor.on("click",function(e){var i=$(e.target);if(i.hasClass("close")&&!i.hasClass("disabled")){var n=i.closest("tr"),o=t.tblAuthor.find("tr").index(n);n.remove(),t.authors.splice(o,1),t.coreProps&&t.api&&(t.coreProps.asc_putCreator(t.authors.join(";")),t.api.asc_setCoreProps(t.coreProps))}}),this.inputAuthor=new Common.UI.InputField({el:$("#id-info-add-author"),style:"width: 200px;",validateOnBlur:!1,placeHolder:this.txtAddAuthor}).on("changed:after",function(e,i,n){if(i!=n){var o=i.trim();o&&o!==n.trim()&&(o.split(/\s*[,;]\s*/).forEach(function(e){var i=e.trim();if(i){var n=$(Common.Utils.String.format(t.authorTpl,Common.Utils.String.htmlEncode(i)));t.trAuthor.before(n),t.authors.push(e)}}),t.inputAuthor.setValue(""),t.coreProps&&t.api&&(t.coreProps.asc_putCreator(t.authors.join(";")),t.api.asc_setCoreProps(t.coreProps)))}}).on("keydown:before",e),this.rendered=!0,this.updateInfo(this.doc),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateFileInfo()},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments)},updateInfo:function(t){if(!this.doc&&t&&t.info&&(t.info.author&&console.log("Obsolete: The 'author' parameter of the document 'info' section is deprecated. Please use 'owner' instead."),t.info.created&&console.log("Obsolete: The 'created' parameter of the document 'info' section is deprecated. Please use 'uploaded' instead.")),this.doc=t,this.rendered){var e=!1;if(t=t||{},t.info){t.info.folder&&this.lblPlacement.text(t.info.folder),e=this._ShowHideInfoItem(this.lblPlacement,void 0!==t.info.folder&&null!==t.info.folder)||e;var i=t.info.owner||t.info.author;i&&this.lblOwner.text(i),e=this._ShowHideInfoItem(this.lblOwner,!!i)||e,i=t.info.uploaded||t.info.created,i&&this.lblUploaded.text(i),e=this._ShowHideInfoItem(this.lblUploaded,!!i)||e}else this._ShowHideDocInfo(!1);$("tr.divider.general",this.el)[e?"show":"hide"]();var n=this.api?this.api.asc_getAppProps():null;if(n&&(n=(n.asc_getApplication()||"")+" "+(n.asc_getAppVersion()||""),this.lblApplication.text(n)),this._ShowHideInfoItem(this.lblApplication,!!n),this.coreProps=this.api?this.api.asc_getCoreProps():null,this.coreProps){var i=this.coreProps.asc_getCreated();i&&this.lblDate.text(i.toLocaleString()),this._ShowHideInfoItem(this.lblDate,!!i)}}},updateFileInfo:function(){if(this.rendered){var t,e=this,i=this.api?this.api.asc_getCoreProps():null;if(this.coreProps=i,i){var n=!1;t=i.asc_getModified(),t&&this.lblModifyDate.text(t.toLocaleString()),n=this._ShowHideInfoItem(this.lblModifyDate,!!t)||n,t=i.asc_getLastModifiedBy(),t&&this.lblModifyBy.text(t),n=this._ShowHideInfoItem(this.lblModifyBy,!!t)||n,$("tr.divider.modify",this.el)[n?"show":"hide"](),t=i.asc_getTitle(),this.inputTitle.setValue(t||""),t=i.asc_getSubject(),this.inputSubject.setValue(t||""),t=i.asc_getDescription(),this.inputComment.setValue(t||""),this.tblAuthor.find("tr:not(:last-of-type)").remove(),this.authors=[],t=i.asc_getCreator(),t&&t.split(/\s*[,;]\s*/).forEach(function(t){var i=$(Common.Utils.String.format(e.authorTpl,Common.Utils.String.htmlEncode(t)));e.trAuthor.before(i),e.authors.push(t)}),this.tblAuthor.find(".close").toggleClass("hidden",!this.mode.isEdit)}this.SetDisabled()}},_ShowHideInfoItem:function(t,e){return t.closest("tr")[e?"show":"hide"](),e},_ShowHideDocInfo:function(t){this._ShowHideInfoItem(this.lblPlacement,t),this._ShowHideInfoItem(this.lblOwner,t),this._ShowHideInfoItem(this.lblUploaded,t)},setMode:function(t){return this.mode=t,this.inputAuthor.setVisible(t.isEdit),this.tblAuthor.find(".close").toggleClass("hidden",!t.isEdit),this.SetDisabled(),this},setApi:function(t){return this.api=t,this.api.asc_registerCallback("asc_onLockCore",_.bind(this.onLockCore,this)),this.updateInfo(this.doc),this},onLockCore:function(t){this._locked=t,this.updateFileInfo()},SetDisabled:function(){var t=!this.mode.isEdit||this._locked;this.inputTitle.setDisabled(t),this.inputSubject.setDisabled(t),this.inputComment.setDisabled(t),this.inputAuthor.setDisabled(t),this.tblAuthor.find(".close").toggleClass("disabled",this._locked),this.tblAuthor.toggleClass("disabled",t)},txtPlacement:"Location",txtOwner:"Owner",txtUploaded:"Uploaded",txtAppName:"Application",txtTitle:"Title",txtSubject:"Subject",txtComment:"Comment",txtModifyDate:"Last Modified",txtModifyBy:"Last Modified By",txtCreated:"Created",txtAuthor:"Author",txtAddAuthor:"Add Author",txtAddText:"Add Text",txtMinutes:"min"},SSE.Views.FileMenuPanels.DocumentInfo||{})),SSE.Views.FileMenuPanels.DocumentRights=Common.UI.BaseView.extend(_.extend({el:"#panel-rights",menu:void 0,initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.rendered=!1,this.template=_.template(['','','",'',"",'','","","
"].join("")),this.templateRights=_.template(["","<% _.each(users, function(item) { %>","",'',"","","<% }); %>","
<%= Common.Utils.String.htmlEncode(item.user) %><%= Common.Utils.String.htmlEncode(item.permissions) %>
"].join("")),this.menu=t.menu},render:function(){return $(this.el).html(this.template()),this.cntRights=$("#id-info-rights"),this.btnEditRights=new Common.UI.Button({el:"#id-info-btn-edit"}),this.btnEditRights.on("click",_.bind(this.changeAccessRights,this)),this.rendered=!0,this.updateInfo(this.doc),_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),Common.NotificationCenter.on("collaboration:sharing",_.bind(this.changeAccessRights,this)),Common.NotificationCenter.on("collaboration:sharingdeny",_.bind(this.onLostEditRights,this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments)},hide:function(){Common.UI.BaseView.prototype.hide.call(this,arguments)},updateInfo:function(t){this.doc=t,this.rendered&&(t=t||{},t.info?(t.info.sharingSettings&&this.cntRights.html(this.templateRights({users:t.info.sharingSettings})),this._ShowHideInfoItem("rights",void 0!==t.info.sharingSettings&&null!==t.info.sharingSettings&&t.info.sharingSettings.length>0),this._ShowHideInfoItem("edit-rights",!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&!0!==this._readonlyRights)):this._ShowHideDocInfo(!1))},_ShowHideInfoItem:function(t,e){$("tr."+t,this.el)[e?"show":"hide"]()},_ShowHideDocInfo:function(t){this._ShowHideInfoItem("rights",t),this._ShowHideInfoItem("edit-rights",t)},setMode:function(t){return this.sharingSettingsUrl=t.sharingSettingsUrl,!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&Common.Gateway.on("showsharingsettings",_.bind(this.changeAccessRights,this)),!!this.sharingSettingsUrl&&this.sharingSettingsUrl.length&&Common.Gateway.on("setsharingsettings",_.bind(this.setSharingSettings,this)),this},changeAccessRights:function(t,e,i){if(!this._docAccessDlg&&!this._readonlyRights){var n=this;n._docAccessDlg=new Common.Views.DocumentAccessDialog({settingsurl:this.sharingSettingsUrl}),n._docAccessDlg.on("accessrights",function(t,e){n.updateSharingSettings(e)}).on("close",function(t){n._docAccessDlg=void 0}),n._docAccessDlg.show()}},setSharingSettings:function(t){t&&this.updateSharingSettings(t.sharingSettings)},updateSharingSettings:function(t){this.doc.info.sharingSettings=t,this._ShowHideInfoItem("rights",void 0!==this.doc.info.sharingSettings&&null!==this.doc.info.sharingSettings&&this.doc.info.sharingSettings.length>0),this.cntRights.html(this.templateRights({users:this.doc.info.sharingSettings})),Common.NotificationCenter.trigger("mentions:clearusers",this)},onLostEditRights:function(){this._readonlyRights=!0,this.rendered&&this._ShowHideInfoItem("edit-rights",!1)},txtRights:"Persons who have rights",txtBtnAccessRights:"Change access rights"},SSE.Views.FileMenuPanels.DocumentRights||{})),SSE.Views.FileMenuPanels.Help=Common.UI.BaseView.extend({el:"#panel-help",menu:void 0,template:_.template(['
','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu,this.urlPref="resources/help/en/",this.en_data=[{src:"ProgramInterface/ProgramInterface.htm",name:"Introducing Spreadsheet Editor user interface",headername:"Program Interface"},{src:"ProgramInterface/FileTab.htm",name:"File tab"},{src:"ProgramInterface/HomeTab.htm",name:"Home Tab"},{src:"ProgramInterface/InsertTab.htm",name:"Insert tab"},{src:"ProgramInterface/PluginsTab.htm",name:"Plugins tab"},{src:"UsageInstructions/OpenCreateNew.htm",name:"Create a new spreadsheet or open an existing one",headername:"Basic operations"},{src:"UsageInstructions/CopyPasteData.htm",name:"Cut/copy/paste data"},{src:"UsageInstructions/UndoRedo.htm",name:"Undo/redo your actions"},{src:"UsageInstructions/ManageSheets.htm",name:"Manage sheets",headername:"Operations with sheets"},{src:"UsageInstructions/FontTypeSizeStyle.htm",name:"Set font type, size, style, and colors",headername:"Cell text formatting"},{src:"UsageInstructions/AddHyperlinks.htm",name:"Add hyperlinks"},{src:"UsageInstructions/ClearFormatting.htm",name:"Clear text, format in a cell, copy cell format"},{src:"UsageInstructions/AddBorders.htm",name:"Add borders",headername:"Editing cell properties"},{src:"UsageInstructions/AlignText.htm",name:"Align data in cells"},{src:"UsageInstructions/MergeCells.htm",name:"Merge cells"},{src:"UsageInstructions/ChangeNumberFormat.htm",name:"Change number format"},{src:"UsageInstructions/InsertDeleteCells.htm",name:"Manage cells, rows, and columns",headername:"Editing rows/columns"},{src:"UsageInstructions/SortData.htm",name:"Sort and filter data"},{src:"UsageInstructions/InsertFunction.htm",name:"Insert function",headername:"Work with functions"},{src:"UsageInstructions/UseNamedRanges.htm",name:"Use named ranges"},{src:"UsageInstructions/InsertImages.htm",name:"Insert images",headername:"Operations on objects"},{src:"UsageInstructions/InsertChart.htm",name:"Insert chart"},{src:"UsageInstructions/InsertAutoshapes.htm",name:"Insert and format autoshapes"},{src:"UsageInstructions/InsertTextObjects.htm",name:"Insert text objects"},{src:"UsageInstructions/ManipulateObjects.htm",name:"Manipulate objects"},{src:"UsageInstructions/InsertEquation.htm",name:"Insert equations",headername:"Math equations"},{src:"HelpfulHints/CollaborativeEditing.htm",name:"Collaborative spreadsheet editing",headername:"Spreadsheet co-editing"},{src:"UsageInstructions/ViewDocInfo.htm",name:"View file information",headername:"Tools and settings"},{src:"UsageInstructions/SavePrintDownload.htm",name:"Save/print/download your spreadsheet"},{src:"HelpfulHints/AdvancedSettings.htm",name:"Advanced settings of Spreadsheet Editor"},{src:"HelpfulHints/Navigation.htm",name:"View settings and navigation tools"},{src:"HelpfulHints/Search.htm",name:"Search and replace functions"},{src:"HelpfulHints/About.htm",name:"About Spreadsheet Editor",headername:"Helpful hints"},{src:"HelpfulHints/SupportedFormats.htm",name:"Supported formats of spreadsheets"},{src:"HelpfulHints/KeyboardShortcuts.htm",name:"Keyboard shortcuts"}],Common.Utils.isIE&&(window.onhelp=function(){return!1})},render:function(){var t=this;return $(this.el).html(this.template()),this.viewHelpPicker=new Common.UI.DataView({el:$("#id-help-contents"),store:new Common.UI.DataViewStore([]),keyMoveDirection:"vertical",itemTemplate:_.template(['
','
<%= name %>
',"
"].join(""))}),this.viewHelpPicker.on("item:add",function(t,e,i){i.has("headername")&&$(e.el).before('
'+i.get("headername")+"
")}),this.viewHelpPicker.on("item:select",function(e,i,n){t.iFrame.src=t.urlPref+n.get("src")}),this.iFrame=document.createElement("iframe"),this.iFrame.src="",this.iFrame.align="top",this.iFrame.frameBorder="0",this.iFrame.width="100%",this.iFrame.height="100%",Common.Gateway.on("internalcommand",function(e){if("help:hyperlink"==e.type){var i=e.data,n=t.viewHelpPicker.store.find(function(t){return i.indexOf(t.get("src"))>0});n&&(t.viewHelpPicker.selectRecord(n,!0),t.viewHelpPicker.scrollToRecord(n))}}),$("#id-help-frame").append(this.iFrame),this},setLangConfig:function(t){var e=this,i=this.viewHelpPicker.store;if(t){t=t.split(/[\-\_]/)[0];var n={dataType:"json",error:function(){e.urlPref.indexOf("resources/help/en/")<0?(e.urlPref="resources/help/en/",i.url="resources/help/en/Contents.json",i.fetch(n)):(e.urlPref="resources/help/en/",i.reset(e.en_data))},success:function(){var t=i.at(0);e.viewHelpPicker.selectRecord(t),e.iFrame.src=e.urlPref+t.get("src")}};i.url="resources/help/"+t+"/Contents.json",i.fetch(n),this.urlPref="resources/help/"+t+"/"}},show:function(){Common.UI.BaseView.prototype.show.call(this),this._scrollerInited||(this.viewHelpPicker.scroller.update(),this._scrollerInited=!0)}}),SSE.Views.FileMenuPanels.ProtectDoc=Common.UI.BaseView.extend(_.extend({el:"#panel-protect",menu:void 0,template:_.template(['','
','','
','',"",'',"","",'','',"","
","
",'
','','
','
',"
"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu;var e=this;this.templateSignature=_.template(['',"",'',"","",'",'","","
"].join(""))},render:function(){$(this.el).html(this.template({scope:this}));var t=SSE.getController("Common.Controllers.Protection").getView();return this.btnAddPwd=t.getButton("add-password"),this.btnAddPwd.render(this.$el.find("#fms-btn-add-pwd")),this.btnAddPwd.on("click",_.bind(this.closeMenu,this)),this.btnChangePwd=t.getButton("change-password"),this.btnChangePwd.render(this.$el.find("#fms-btn-change-pwd")),this.btnChangePwd.on("click",_.bind(this.closeMenu,this)),this.btnDeletePwd=t.getButton("del-password"),this.btnDeletePwd.render(this.$el.find("#fms-btn-delete-pwd")),this.btnDeletePwd.on("click",_.bind(this.closeMenu,this)),this.cntPassword=$("#id-fms-password"),this.cntPasswordView=$("#id-fms-view-pwd"),this.btnAddInvisibleSign=t.getButton("signature"),this.btnAddInvisibleSign.render(this.$el.find("#fms-btn-invisible-sign")),this.btnAddInvisibleSign.on("click",_.bind(this.closeMenu,this)),this.cntSignature=$("#id-fms-signature"),this.cntSignatureView=$("#id-fms-signature-view"), +_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:$(this.el),suppressScrollX:!0})),this.$el.on("click",".signature-edit-link",_.bind(this.onEdit,this)),this.$el.on("click",".signature-view-link",_.bind(this.onView,this)),this},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this.updateSignatures(),this.updateEncrypt()},setMode:function(t){this.mode=t,this.cntSignature.toggleClass("hidden",!this.mode.isSignatureSupport),this.cntPassword.toggleClass("hidden",!this.mode.isPasswordSupport)},setApi:function(t){return this.api=t,this},closeMenu:function(){this.menu&&this.menu.hide()},onEdit:function(){this.menu&&this.menu.hide();var t=this;Common.UI.warning({title:this.notcriticalErrorTitle,msg:this.txtEditWarning,buttons:["ok","cancel"],primary:"ok",callback:function(e){"ok"==e&&t.api.asc_RemoveAllSignatures()}})},onView:function(){this.menu&&this.menu.hide(),SSE.getController("RightMenu").rightmenu.SetActivePane(Common.Utils.documentSettingsType.Signature,!0)},updateSignatures:function(){var t=this.api.asc_getRequestSignatures(),e=this.api.asc_getSignatures(),i=t&&t.length>0,n=!1,o=!1;_.each(e,function(t,e){0==t.asc_getValid()?n=!0:o=!0});var s=o?this.txtSignedInvalid:n?this.txtSigned:"";i&&(s=this.txtRequestedSignatures+(""!=s?"

":"")+s),this.cntSignatureView.html(this.templateSignature({tipText:s,hasSigned:n||o,hasRequested:i}))},updateEncrypt:function(){this.cntPasswordView.toggleClass("hidden",this.btnAddPwd.isVisible())},strProtect:"Protect Workbook",strSignature:"With Signature",txtView:"View signatures",txtEdit:"Edit workbook",txtSigned:"Valid signatures has been added to the workbook. The workbook is protected from editing.",txtSignedInvalid:"Some of the digital signatures in workbook are invalid or could not be verified. The workbook is protected from editing.",txtRequestedSignatures:"This workbook needs to be signed.",notcriticalErrorTitle:"Warning",txtEditWarning:"Editing will remove the signatures from the workbook.
Are you sure you want to continue?",strEncrypt:"With Password",txtEncrypted:"This workbook has been protected by password"},SSE.Views.FileMenuPanels.ProtectDoc||{}))}),define("text!spreadsheeteditor/main/app/template/PrintSettings.template",[],function(){return'
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n'}),define("spreadsheeteditor/main/app/view/PrintSettings",["text!spreadsheeteditor/main/app/template/PrintSettings.template","common/main/lib/view/AdvancedSettingsWindow","common/main/lib/component/MetricSpinner","common/main/lib/component/CheckBox","common/main/lib/component/RadioBox","common/main/lib/component/ListView"],function(t){"use strict";SSE.Views.PrintSettings=Common.Views.AdvancedSettingsWindow.extend(_.extend({options:{alias:"PrintSettings",contentWidth:280,height:475},initialize:function(e){this.type=e.type||"print",_.extend(this.options,{title:"print"==this.type?this.textTitle:this.textTitlePDF,template:['
','",'
'+_.template(t)({scope:this})+"
","
",'
','"].join("")},e),Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this,this.options),this.spinners=[]},render:function(){Common.Views.AdvancedSettingsWindow.prototype.render.call(this),this.cmbRange=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-range"),style:"width: 132px;",menuStyle:"min-width: 132px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPrintType.ActiveSheets,displayValue:this.textCurrentSheet},{value:Asc.c_oAscPrintType.EntireWorkbook,displayValue:this.textAllSheets},{value:Asc.c_oAscPrintType.Selection,displayValue:this.textSelection}]}),this.cmbRange.on("selected",_.bind(this.comboRangeChange,this)),this.chIgnorePrintArea=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-ignore"),labelText:this.textIgnore}),this.cmbSheet=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-sheets"),style:"width: 242px;",menuStyle:"min-width: 242px;max-height: 280px;",editable:!1,cls:"input-group-nr",data:[]}),this.cmbPaperSize=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-pages"),style:"width: 242px;",menuStyle:"max-height: 280px; min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:"215.9|279.4",displayValue:"US Letter (21,59cm x 27,94cm)",caption:"US Letter"},{value:"215.9|355.6",displayValue:"US Legal (21,59cm x 35,56cm)",caption:"US Legal"},{value:"210|297",displayValue:"A4 (21cm x 29,7cm)",caption:"A4"},{value:"148|210",displayValue:"A5 (14,8cm x 21cm)",caption:"A5"},{value:"176|250",displayValue:"B5 (17,6cm x 25cm)",caption:"B5"},{value:"104.8|241.3",displayValue:"Envelope #10 (10,48cm x 24,13cm)",caption:"Envelope #10"},{value:"110|220",displayValue:"Envelope DL (11cm x 22cm)",caption:"Envelope DL"},{value:"279.4|431.8",displayValue:"Tabloid (27,94cm x 43,18cm)",caption:"Tabloid"},{value:"297|420",displayValue:"A3 (29,7cm x 42cm)",caption:"A3"},{value:"304.8|457.1",displayValue:"Tabloid Oversize (30,48cm x 45,71cm)",caption:"Tabloid Oversize"},{value:"196.8|273",displayValue:"ROC 16K (19,68cm x 27,3cm)",caption:"ROC 16K"},{value:"119.9|234.9",displayValue:"Envelope Choukei 3 (11,99cm x 23,49cm)",caption:"Envelope Choukei 3"},{value:"330.2|482.5",displayValue:"Super B/A3 (33,02cm x 48,25cm)",caption:"Super B/A3"}]}),this.cmbPaperOrientation=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-orient"),style:"width: 132px;",menuStyle:"min-width: 132px;",editable:!1,cls:"input-group-nr",data:[{value:Asc.c_oAscPageOrientation.PagePortrait,displayValue:this.strPortrait},{value:Asc.c_oAscPageOrientation.PageLandscape,displayValue:this.strLandscape}]}),this.chPrintGrid=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-grid"),labelText:"print"==this.type?this.textPrintGrid:this.textShowGrid}),this.chPrintRows=new Common.UI.CheckBox({el:$("#printadv-dlg-chb-rows"),labelText:"print"==this.type?this.textPrintHeadings:this.textShowHeadings}),this.spnMarginTop=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-top"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginTop),this.spnMarginBottom=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-bottom"),step:.1,width:110,defaultUnit:"cm",value:"0 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginBottom),this.spnMarginLeft=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-left"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginLeft),this.spnMarginRight=new Common.UI.MetricSpinner({el:$("#printadv-dlg-spin-margin-right"),step:.1,width:110,defaultUnit:"cm",value:"0.19 cm",maxValue:48.25,minValue:0}),this.spinners.push(this.spnMarginRight),this.cmbLayout=new Common.UI.ComboBox({el:$("#printadv-dlg-combo-layout"),style:"width: 242px;",menuStyle:"min-width: 242px;",editable:!1,cls:"input-group-nr",data:[{value:0,displayValue:this.textActualSize},{value:1,displayValue:this.textFitPage},{value:2,displayValue:this.textFitCols},{value:3,displayValue:this.textFitRows}]}),this.btnHide=new Common.UI.Button({el:$("#printadv-dlg-btn-hide")}),this.btnHide.on("click",_.bind(this.handlerShowDetails,this)),this.panelDetails=$("#printadv-dlg-content-to-hide"),this.updateMetricUnit(),this.options.afterrender&&this.options.afterrender.call(this);var t=Common.localStorage.getItem("sse-hide-print-settings");this.extended=null!==t&&0==parseInt(t),this.handlerShowDetails(this.btnHide)},setRange:function(t){this.cmbRange.setValue(t)},getRange:function(){return this.cmbRange.getValue()},setIgnorePrintArea:function(t){this.chIgnorePrintArea.setValue(t)},getIgnorePrintArea:function(){return"checked"==this.chIgnorePrintArea.getValue()},comboRangeChange:function(t,e){this.fireEvent("changerange",this)},updateMetricUnit:function(){if(this.spinners)for(var t=0;te?l="left":o>e-n?l="right":s>i?l="top":a>i-s&&(l="bottom"),!l||(Common.UI.warning({title:this.textWarning,msg:this.warnCheckMargings,callback:function(e,i){switch(l){case"left":return void t.spnMarginLeft.$el.focus();case"right":return void t.spnMarginRight.$el.focus();case"top":return void t.spnMarginTop.$el.focus();case"bottom":return void t.spnMarginBottom.$el.focus()}}}),!1)},registerControlEvents:function(t){t.cmbPaperSize.on("selected",_.bind(this.propertyChange,this,t)),t.cmbPaperOrientation.on("selected",_.bind(this.propertyChange,this,t)),t.cmbLayout.on("selected",_.bind(this.propertyChange,this,t)),t.spnMarginTop.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginBottom.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginLeft.on("change",_.bind(this.propertyChange,this,t)),t.spnMarginRight.on("change",_.bind(this.propertyChange,this,t)),t.chPrintGrid.on("change",_.bind(this.propertyChange,this,t)),t.chPrintRows.on("change",_.bind(this.propertyChange,this,t))},propertyChange:function(t){this._changedProps&&(this._changedProps[t.cmbSheet.getValue()]=this.getPageOptions(t))},getPrintParams:function(){return this.adjPrintParams},warnCheckMargings:"Margins are incorrect",strAllSheets:"All Sheets",textWarning:"Warning",txtCustom:"Custom"},SSE.Controllers.Print||{}))}),define("spreadsheeteditor/main/app/view/DataTab",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout"],function(){"use strict";SSE.Views.DataTab=Common.UI.BaseView.extend(_.extend(function(){function t(){var t=this;t.btnUngroup.menu.on("item:click",function(e,i,n){t.fireEvent("data:ungroup",[i.value])}),t.btnUngroup.on("click",function(e,i){t.fireEvent("data:ungroup")}),t.btnGroup.menu.on("item:click",function(e,i,n){t.fireEvent("data:group",[i.value,i.checked])}),t.btnGroup.on("click",function(e,i){t.fireEvent("data:group")}),t.btnGroup.menu.on("show:before",function(e,i){t.fireEvent("data:groupsettings",[e])}),t.btnTextToColumns.on("click",function(e,i){t.fireEvent("data:tocolumns")}),t.btnShow.on("click",function(e,i){t.fireEvent("data:show")}),t.btnHide.on("click",function(e,i){t.fireEvent("data:hide")}),t.btnsSortDown.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:sort",[Asc.c_oAscSortOptions.Ascending])})}),t.btnsSortUp.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:sort",[Asc.c_oAscSortOptions.Descending])})}),t.btnsSetAutofilter.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:setfilter",[Asc.c_oAscSortOptions.Descending])})}),t.btnsClearAutofilter.forEach(function(e){e.on("click",function(e,i){t.fireEvent("data:clearfilter",[Asc.c_oAscSortOptions.Descending])})})}return{options:{},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this),this.toolbar=t.toolbar,this.lockedControls=[];var e=this,i=e.toolbar.$el,n=SSE.enumLock;this.btnGroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-cell-group",caption:this.capBtnGroup,split:!0,menu:!0,disabled:!0,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.sheetLock,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-group"),this.btnGroup),this.lockedControls.push(this.btnGroup),this.btnUngroup=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-cell-ungroup",caption:this.capBtnUngroup,split:!0,menu:!0,disabled:!0,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.sheetLock,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-ungroup"),this.btnUngroup),this.lockedControls.push(this.btnUngroup),this.btnTextToColumns=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-to-columns",caption:this.capBtnTextToCol,split:!1,disabled:!0,lock:[n.multiselect,n.multiselectCols,n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-text-column"),this.btnTextToColumns),this.lockedControls.push(this.btnTextToColumns),this.btnShow=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-show-details",style:"padding-right: 2px;",caption:this.capBtnTextShow,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-show-details"),this.btnShow),this.lockedControls.push(this.btnShow),this.btnHide=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-hide-details",style:"padding-right: 2px;",caption:this.capBtnTextHide,lock:[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth]}),Common.Utils.injectComponent(i.find("#slot-btn-hide-details"),this.btnHide),this.lockedControls.push(this.btnHide),this.btnsSortDown=Common.Utils.injectButtons(i.find(".slot-sortdesc"),"","btn-sort-down","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter]),this.btnsSortUp=Common.Utils.injectButtons(i.find(".slot-sortasc"),"","btn-sort-up","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter]),this.btnsSetAutofilter=Common.Utils.injectButtons(i.find(".slot-btn-setfilter"),"","btn-autofilter","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleFilter,n.editPivot,n.cantModifyFilter],!1,!1,!0),this.btnsClearAutofilter=Common.Utils.injectButtons(i.find(".slot-btn-clear-filter"),"","btn-clear-filter","",[n.editCell,n.selChart,n.selChartText,n.selShape,n.selShapeText,n.selImage,n.lostConnect,n.coAuth,n.ruleDelFilter,n.editPivot]),Array.prototype.push.apply(this.lockedControls,this.btnsSortDown.concat(this.btnsSortUp,this.btnsSetAutofilter,this.btnsClearAutofilter)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this},onAppReady:function(e){var i=this;new Promise(function(t,e){t()}).then(function(){i.btnUngroup.updateHint(i.tipUngroup);var e=new Common.UI.Menu({items:[{caption:i.textRows,value:"rows"},{caption:i.textColumns,value:"columns"},{caption:i.textClear,value:"clear"}]});i.btnUngroup.setMenu(e),i.btnGroup.updateHint(i.tipGroup),e=new Common.UI.Menu({items:[{caption:i.textGroupRows,value:"rows"},{caption:i.textGroupColumns,value:"columns"},{caption:"--"},{caption:i.textBelow,value:"below",checkable:!0},{caption:i.textRightOf,value:"right",checkable:!0}]}),i.btnGroup.setMenu(e),i.btnTextToColumns.updateHint(i.tipToColumns),i.btnsSortDown.forEach(function(t){t.updateHint(i.toolbar.txtSortAZ)}),i.btnsSortUp.forEach(function(t){t.updateHint(i.toolbar.txtSortZA)}),i.btnsSetAutofilter.forEach(function(t){t.updateHint(i.toolbar.txtFilter+" (Ctrl+Shift+L)")}),i.btnsClearAutofilter.forEach(function(t){t.updateHint(i.toolbar.txtClearFilter)}),t.call(i)})},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButtons:function(t){return"sort-down"==t?this.btnsSortDown:"sort-up"==t?this.btnsSortUp:"set-filter"==t?this.btnsSetAutofilter:"clear-filter"==t?this.btnsClearAutofilter:void 0===t?this.lockedControls:[]},SetDisabled:function(t){this.lockedControls&&this.lockedControls.forEach(function(e){e&&e.setDisabled(t)},this)},capBtnGroup:"Group",capBtnUngroup:"Ungroup",textRows:"Ungroup rows",textColumns:"Ungroup columns",textGroupRows:"Group rows",textGroupColumns:"Group columns",textClear:"Clear outline",tipGroup:"Group range of cells",tipUngroup:"Ungroup range of cells",capBtnTextToCol:"Text to Columns",tipToColumns:"Separate cell text into columns",capBtnTextShow:"Show details",capBtnTextHide:"Hide details",textBelow:"Summary rows below detail",textRightOf:"Summary columns to right of detail"}}(),SSE.Views.DataTab||{}))}),define("spreadsheeteditor/main/app/view/GroupDialog",["common/main/lib/component/Window","common/main/lib/component/ComboBox"],function(){"use strict";SSE.Views.GroupDialog=Common.UI.Window.extend(_.extend({options:{width:214,header:!0,style:"min-width: 214px;",cls:"modal-dlg"},initialize:function(t){_.extend(this.options,t||{}),this.template=['
','
','
','"].join(""),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.radioRows=new Common.UI.RadioBox({el:$("#group-radio-rows"),labelText:this.textRows,name:"asc-radio-group-cells",checked:"rows"==this.options.props}),this.radioColumns=new Common.UI.RadioBox({el:$("#group-radio-cols"),labelText:this.textColumns,name:"asc-radio-group-cells",checked:"columns"==this.options.props}),"rows"==this.options.props?this.radioRows.setValue(!0):this.radioColumns.setValue(!0),this.getChild().find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},getSettings:function(){return this.radioRows.getValue()},onPrimary:function(){return this._handleInput("ok"),!1},cancelButtonText:"Cancel",okButtonText:"Ok",textRows:"Rows",textColumns:"Columns"},SSE.Views.GroupDialog||{}))}), +define("spreadsheeteditor/main/app/controller/DataTab",["core","spreadsheeteditor/main/app/view/DataTab","spreadsheeteditor/main/app/view/GroupDialog"],function(){"use strict";SSE.Controllers.DataTab=Backbone.Controller.extend(_.extend({models:[],collections:[],views:["DataTab"],sdkViewName:"#id_main",initialize:function(){this._state={CSVOptions:new Asc.asc_CTextOptions(0,4,"")}},onLaunch:function(){},setApi:function(t){return t&&(this.api=t,this.api.asc_registerCallback("asc_onSelectionChanged",_.bind(this.onSelectionChanged,this)),this.api.asc_registerCallback("asc_onWorksheetLocked",_.bind(this.onWorksheetLocked,this)),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))),this},setConfig:function(t){this.toolbar=t.toolbar,this.view=this.createView("DataTab",{toolbar:this.toolbar.toolbar}),this.addListeners({DataTab:{"data:group":this.onGroup,"data:ungroup":this.onUngroup,"data:tocolumns":this.onTextToColumn,"data:show":this.onShowClick,"data:hide":this.onHideClick,"data:groupsettings":this.onGroupSettings},Statusbar:{"sheet:changed":this.onApiSheetChanged}})},SetDisabled:function(t){this.view&&this.view.SetDisabled(t)},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)},onSelectionChanged:function(t){this.toolbar.editMode&&this.view&&(Common.Utils.lockControls(SSE.enumLock.multiselectCols,t.asc_getSelectedColsCount()>1,{array:[this.view.btnTextToColumns]}),Common.Utils.lockControls(SSE.enumLock.multiselect,t.asc_getFlags().asc_getMultiselect(),{array:[this.view.btnTextToColumns]}))},onUngroup:function(t){var e=this;if("rows"==t)void 0!==e.api.asc_checkAddGroup(!0)&&e.api.asc_ungroup(!0);else if("columns"==t)void 0!==e.api.asc_checkAddGroup(!0)&&e.api.asc_ungroup(!1);else if("clear"==t)e.api.asc_clearOutline();else{var i=e.api.asc_checkAddGroup(!0);null===i?new SSE.Views.GroupDialog({title:e.view.capBtnUngroup,props:"rows",handler:function(t,i){"ok"==i&&e.api.asc_ungroup(t.getSettings()),Common.NotificationCenter.trigger("edit:complete",e.toolbar)}}).show():void 0!==i&&e.api.asc_ungroup(i)}Common.NotificationCenter.trigger("edit:complete",e.toolbar)},onGroup:function(t,e){if("rows"==t)void 0!==this.api.asc_checkAddGroup()&&this.api.asc_group(!0);else if("columns"==t)void 0!==this.api.asc_checkAddGroup()&&this.api.asc_group(!1);else if("below"==t)this.api.asc_setGroupSummary(e,!1);else if("right"==t)this.api.asc_setGroupSummary(e,!0);else{var i=this,n=i.api.asc_checkAddGroup();null===n?new SSE.Views.GroupDialog({title:i.view.capBtnGroup,props:"rows",handler:function(t,e){"ok"==e&&i.api.asc_group(t.getSettings()),Common.NotificationCenter.trigger("edit:complete",i.toolbar)}}).show():void 0!==n&&i.api.asc_group(n)}Common.NotificationCenter.trigger("edit:complete",this.toolbar)},onGroupSettings:function(t){var e=this.api.asc_getGroupSummaryBelow();t.items[3].setChecked(!!e,!0),e=this.api.asc_getGroupSummaryRight(),t.items[4].setChecked(!!e,!0)},onTextToColumn:function(){this.api.asc_TextImport(this._state.CSVOptions,_.bind(this.onTextToColumnCallback,this),!1)},onTextToColumnCallback:function(t){if(t&&t.length){var e=this;new Common.Views.OpenDialog({title:e.textWizard,closable:!0,type:Common.Utils.importTextType.Columns,preview:!0,previewData:t,settings:e._state.CSVOptions,api:e.api,handler:function(t,i,n,o){"ok"==t&&e&&e.api&&e.api.asc_TextToColumns(new Asc.asc_CTextOptions(i,n,o))}}).show()}},onShowClick:function(){this.api.asc_changeGroupDetails(!0)},onHideClick:function(){this.api.asc_changeGroupDetails(!1)},onWorksheetLocked:function(t,e){t==this.api.asc_getActiveWorksheetIndex()&&Common.Utils.lockControls(SSE.enumLock.sheetLock,e,{array:[this.view.btnGroup,this.view.btnUngroup]})},onApiSheetChanged:function(){if(this.toolbar.mode&&this.toolbar.mode.isEdit&&!this.toolbar.mode.isEditDiagram&&!this.toolbar.mode.isEditMailMerge){var t=this.api.asc_getActiveWorksheetIndex();this.onWorksheetLocked(t,this.api.asc_isWorksheetLockedOrDeleted(t))}},textWizard:"Text to Columns Wizard"},SSE.Controllers.DataTab||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Comment",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.Comment=e.Model.extend({defaults:{uid:0,guid:"",userid:0,username:"Guest",usercolor:null,date:void 0,quote:"",comment:"",resolved:!1,lock:!1,lockuserid:"",unattached:!1,id:Common.UI.getId(),time:0,showReply:!1,showReplyInPopover:!1,editText:!1,editTextInPopover:!1,last:void 0,replys:[],hideAddReply:!1,scope:null,hide:!1,hint:!1,dummy:void 0,editable:!0}}),Common.Models.Reply=e.Model.extend({defaults:{time:0,userid:0,username:"Guest",usercolor:null,reply:"",date:void 0,id:Common.UI.getId(),editText:!1,editTextInPopover:!1,scope:null,editable:!0}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Comments",["underscore","backbone","common/main/lib/model/Comment"],function(t,e){"use strict";Common.Collections.Comments=e.Collection.extend({model:Common.Models.Comment,groups:null,clearEditing:function(){this.each(function(t){t.set("editText",!1),t.set("editTextInPopover",!1),t.set("showReply",!1),t.set("showReplyInPopover",!1),t.set("hideAddReply",!1)})},getCommentsReplysCount:function(t){var e=0;return this.each(function(i){i.get("userid")==t&&e++;var n=i.get("replys");n&&n.length>0&&n.forEach(function(i){i.get("userid")==t&&e++})}),e}})}),define("text!common/main/lib/template/CommentsPopover.template",[],function(){return'
\r\n\r\n \x3c!-- comment block --\x3e\r\n\r\n
\r\n
<%= scope.getUserName(username) %>\r\n
\r\n
<%=date%>
\r\n <% if (!editTextInPopover || hint) { %>\r\n
<%=scope.pickLink(comment)%>
\r\n <% } else { %>\r\n
\r\n \r\n <% if (hideAddReply) { %>\r\n \r\n <% } else { %>\r\n \r\n <% } %>\r\n \r\n
\r\n <% } %>\r\n\r\n \x3c!-- replys elements --\x3e\r\n\r\n <% if (replys.length) { %>\r\n
\r\n <% _.each(replys, function (item) { %>\r\n
\r\n
\r\n
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getUserName(item.get("username")) %>\r\n
\r\n
<%=item.get("date")%>
\r\n <% if (!item.get("editTextInPopover")) { %>\r\n
<%=scope.pickLink(item.get("reply"))%>
\r\n <% if (!hint) { %>\r\n
\r\n <% if (item.get("editable")) { %>\r\n
">
\r\n
">
\r\n <%}%>\r\n
\r\n <%}%>\r\n <% } else { %>\r\n
\r\n \r\n \r\n \r\n
\r\n <% } %>\r\n
\r\n <% }); %>\r\n\r\n <% } %>\r\n\r\n \x3c!-- add reply button --\x3e\r\n\r\n <% if (!showReplyInPopover && !hideAddReply && !hint) { %>\r\n <% if (replys.length) { %>\r\n \r\n <% } else { %>\r\n \r\n <% } %>\r\n <% } %>\r\n\r\n \x3c!-- edit buttons --\x3e\r\n\r\n <% if (!editTextInPopover && !lock && !hint) { %>\r\n
\r\n <% if (editable) { %>\r\n
\r\n
\r\n <% } %>\r\n <% if (resolved) { %>\r\n
\r\n <% } else { %>\r\n
\r\n <% } %>\r\n
\r\n <% } %>\r\n\r\n \x3c!-- reply --\x3e\r\n\r\n <% if (showReplyInPopover) { %>\r\n
\r\n \r\n \r\n \r\n
\r\n <% } %>\r\n\r\n \x3c!-- locked user --\x3e\r\n\r\n <% if (lock) { %>\r\n
\r\n
<%=lockuserid%>
\r\n <% } %>\r\n\r\n
'}),define("text!common/main/lib/template/ReviewChangesPopover.template",[],function(){return'
\r\n
\r\n
<%= scope.getUserName(username) %>\r\n
\r\n
<%=date%>
\r\n
<%=changetext%>
\r\n
\r\n <% if (goto) { %>\r\n
\r\n <% } %>\r\n <% if (!hint) { %>\r\n <% if (scope.appConfig.isReviewOnly) { %>\r\n <% if (editable) { %>\r\n
\r\n <% } %>\r\n <% } else { %>\r\n
\r\n
\r\n <% } %>\r\n <% } %>\r\n
\r\n <% if (!hint && lock) { %>\r\n
\r\n
<%=lockuser%>
\r\n <% } %>\r\n
'}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/ReviewPopover",["text!common/main/lib/template/CommentsPopover.template","text!common/main/lib/template/ReviewChangesPopover.template","common/main/lib/util/utils","common/main/lib/component/Button","common/main/lib/component/ComboBox","common/main/lib/component/DataView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(t,e){"use strict";function i(t,e){var i,n,o=t;for(i in e)void 0!==i&&(n=e[i],o=o.replace(new RegExp(i,"g"),n));return o}Common.Views.ReviewPopover=Common.UI.Window.extend(_.extend({initialize:function(t){var e={};return _.extend(e,{closable:!1,width:265,height:120,header:!1,modal:!1,alias:"Common.Views.ReviewPopover"},t),this.template=t.template||['
','
','
','
',"
",'
',"
"].join(""),this.commentsStore=t.commentsStore,this.reviewStore=t.reviewStore,this.canRequestUsers=t.canRequestUsers,this.canRequestSendNotify=t.canRequestSendNotify,this.externalUsers=[],this._state={commentsVisible:!1,reviewVisible:!1},e.tpl=_.template(this.template)(e),this.arrow={margin:20,width:10,height:30},this.sdkBounds={width:0,height:0,padding:10,paddingTop:20},Common.UI.Window.prototype.initialize.call(this,e),this.canRequestUsers&&(Common.Gateway.on("setusers",_.bind(this.setUsers,this)),Common.NotificationCenter.on("mentions:clearusers",_.bind(this.clearUsers,this))),this},render:function(n,o){Common.UI.Window.prototype.render.call(this);var s=this,a=this.$window;a.css({height:"",minHeight:"",overflow:"hidden",position:"absolute",zIndex:"990"});var l=a.find(".body");l&&l.css("position","relative");var r=Common.UI.DataView.extend(function(){var t=s;return{options:{handleSelect:!1,allowScrollbar:!1,template:_.template('
')},getTextBox:function(){var t=$(this.el).find("textarea");return t&&t.length?t:void 0},setFocusToTextBox:function(t){var e=$(this.el).find("textarea");if(t)e.blur();else if(e&&e.length){var i=e.val();e.focus(),e.val(""),e.val(i)}},getActiveTextBoxVal:function(){var t=$(this.el).find("textarea");return t&&t.length?t.val().trim():""},autoHeightTextBox:function(){function e(){l=t.scroller.getScrollTop(),n.scrollHeight>n.clientHeight?(i.css({height:n.scrollHeight+a+"px"}),t.calculateSizeOfContent()):(r=n.clientHeight)>=o&&(i.css({height:o+"px"}),n.scrollHeight>n.clientHeight&&(c=Math.max(n.scrollHeight+a,o),i.css({height:c+"px"})),t.calculateSizeOfContent(),t.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),t.calculateSizeOfContent()),t.scroller.scrollTop(l),t.autoScrollToEditButtons()}var i=this.$el.find("textarea"),n=null,o=50,a=0,l=0,r=0,c=0;i&&i.length&&(n=i.get(0))&&(a=.25*parseInt(i.css("lineHeight"),10),e(),i.bind("input propertychange",e)),this.textBox=i},clearTextBoxBind:function(){this.textBox&&(this.textBox.unbind("input propertychange"),this.textBox=void 0)}}}());if(r)if(this.commentsView)this.commentsView.render($("#id-comments-popover")),this.commentsView.onResetItems();else{this.commentsView=new r({el:$("#id-comments-popover"),store:s.commentsStore,itemTemplate:_.template(i(t,{textAddReply:s.textAddReply,textAdd:s.textAdd,textCancel:s.textCancel,textEdit:s.textEdit,textReply:s.textReply,textClose:s.textClose,maxCommLength:Asc.c_oAscMaxCellOrCommentLength,textMention:s.canRequestSendNotify?s.textMention:""}))});var c=function(t,e,i){e.tipsArray&&e.tipsArray.forEach(function(t){t.remove()});var n=[],o=$(e.el).find(".btn-resolve");o.tooltip({title:s.textResolve,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),o=$(e.el).find(".btn-resolve-check"),o.tooltip({title:s.textOpenAgain,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),e.tipsArray=n,this.autoHeightTextBox()},h=function(){s._isMouseOver=!0},d=function(){s._isMouseOver=!1};this.commentsView.on("item:add",c),this.commentsView.on("item:remove",c),this.commentsView.on("item:change",c),this.commentsView.cmpEl.on("mouseover",h).on("mouseout",d),this.commentsView.on("item:click",function(t,e,i,n){function o(){s.update()}var a,l,r,c,h,d;if(a=$(n.target)){if(l=i.get("editTextInPopover"),r=i.get("showReplyInPopover"),d=i.get("hideAddReply"),c=i.get("uid"),h=a.attr("data-value"),i.get("hint"))return void s.fireEvent("comment:disableHint",[i]);if(a.hasClass("btn-edit"))_.isUndefined(h)?l||(s.fireEvent("comment:closeEditing"),i.set("editTextInPopover",!0),s.fireEvent("comment:show",[c]),this.autoHeightTextBox(),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox()):(s.fireEvent("comment:closeEditing",[c]),s.fireEvent("comment:editReply",[c,h,!0]),this.replyId=h,this.autoHeightTextBox(),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox());else if(a.hasClass("btn-delete"))_.isUndefined(h)?s.fireEvent("comment:remove",[c]):(s.fireEvent("comment:removeReply",[c,h]),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent()),s.fireEvent("comment:closeEditing"),o();else if(a.hasClass("user-reply"))s.fireEvent("comment:closeEditing"),i.set("showReplyInPopover",!0),s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o(),this.autoHeightTextBox(),s.hookTextBox(),s.autoScrollToEditButtons(),this.setFocusToTextBox();else if(a.hasClass("btn-reply",!1))r&&(this.clearTextBoxBind(),s.fireEvent("comment:addReply",[c,this.getActiveTextBoxVal()]),s.fireEvent("comment:closeEditing"),s.calculateSizeOfContent(),o());else if(a.hasClass("btn-close",!1))s.fireEvent("comment:closeEditing",[c]),s.calculateSizeOfContent(),s.fireEvent("comment:show",[c]),o();else if(a.hasClass("btn-inner-edit",!1)){if(i.get("dummy")){var p=this.getActiveTextBoxVal();if(s.clearDummyText(),p.length>0)s.fireEvent("comment:addDummyComment",[p]);else{var m=s.$window.find("textarea:not(.user-message)");m&&m.length&&setTimeout(function(){m.focus()},10)}return}this.clearTextBoxBind(),_.isUndefined(this.replyId)?l&&(s.fireEvent("comment:change",[c,this.getActiveTextBoxVal()]),s.fireEvent("comment:closeEditing"),s.calculateSizeOfContent()):(s.fireEvent("comment:changeReply",[c,this.replyId,this.getActiveTextBoxVal()]),this.replyId=void 0,s.fireEvent("comment:closeEditing")),o()}else if(a.hasClass("btn-inner-close",!1)){if(i.get("dummy"))return s.clearDummyText(),void s.hide();d&&this.getActiveTextBoxVal().length>0?(s.saveText(),i.set("hideAddReply",!1),this.getTextBox().val(s.textVal),this.autoHeightTextBox()):(this.clearTextBoxBind(),s.fireEvent("comment:closeEditing",[c])),this.replyId=void 0,s.calculateSizeOfContent(),s.setLeftTop(s.arrowPosX,s.arrowPosY,s.leftX),s.calculateSizeOfContent(),o()}else if(a.hasClass("btn-resolve",!1)){var u=a.data("bs.tooltip");u&&(u.dontShow=!0),s.fireEvent("comment:resolve",[c]),o()}else if(a.hasClass("btn-resolve-check",!1)){var u=a.data("bs.tooltip");u&&(u.dontShow=!0),s.fireEvent("comment:resolve",[c]),o()}}}),this.emailMenu=new Common.UI.Menu({maxHeight:190,cyclic:!1,items:[]}).on("render:after",function(t){this.scroller=new Common.UI.Scroller({el:$(this.el).find(".dropdown-menu "),useKeyboard:this.enableKeyEvents&&!this.handleSelect,minScrollbarLength:40,alwaysVisibleY:!0})}).on("show:after",function(){this.scroller.update({alwaysVisibleY:!0}),s.$window.css({zIndex:"1001"})}).on("hide:after",function(){s.$window.css({zIndex:"990"})}),s.on({show:function(){s.commentsView.autoHeightTextBox(),s.$window.find("textarea").keydown(function(t){t.keyCode==Common.UI.Keys.ESC&&s.hide(!0)})},"animate:before":function(){var t=s.$window.find("textarea");t&&t.length&&t.focus()}})}var p=Common.UI.DataView.extend(function(){return{options:{handleSelect:!1,scrollable:!0,template:_.template('
')}}}());if(p)if(this.reviewChangesView)this.reviewChangesView.render($("#id-review-popover")),this.reviewChangesView.onResetItems();else{this.reviewChangesView=new p({el:$("#id-review-popover"),store:s.reviewStore,itemTemplate:_.template(e)});var c=function(t,e,i){e.tipsArray&&e.tipsArray.forEach(function(t){t.remove()});var n=[],o=$(e.el).find(".btn-goto");o.tooltip({title:s.textFollowMove,placement:"cursor"}),o.each(function(t,e){n.push($(e).data("bs.tooltip").tip())}),e.tipsArray=n};this.reviewChangesView.on("item:add",c),this.reviewChangesView.on("item:remove",c),this.reviewChangesView.on("item:change",c),this.reviewChangesView.on("item:click",function(t,e,i,n){var o=$(n.target);if(o)if(o.hasClass("btn-accept"))s.fireEvent("reviewchange:accept",[i.get("changedata")]);else if(o.hasClass("btn-reject"))s.fireEvent("reviewchange:reject",[i.get("changedata")]);else if(o.hasClass("btn-delete"))s.fireEvent("reviewchange:delete",[i.get("changedata")]);else if(o.hasClass("btn-goto")){var a=o.data("bs.tooltip");a&&(a.dontShow=!0),s.fireEvent("reviewchange:goto",[i.get("changedata")])}})}_.isUndefined(this.scroller)&&(this.scroller=new Common.UI.Scroller({el:a.find("#id-popover"),minScrollbarLength:40,wheelSpeed:10,alwaysVisibleY:!0}))},showComments:function(t,e,i,n){this.options.animate=t;var o=this.commentsView.getTextBox();e&&this.textVal&&o&&o.val(this.textVal),n&&n.length&&o&&o.val(n),this.show(t),this.hookTextBox(),this._state.commentsVisible=!0},showReview:function(t,e,i){this.show(t),this._state.reviewVisible=!0},show:function(t,e,i,n){this.options.animate=t,Common.UI.Window.prototype.show.call(this),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})},hideComments:function(){this.handlerHide&&this.handlerHide(),this.hideTips(),this._state.commentsVisible=!1,this._state.reviewVisible?this.calculateSizeOfContent():this.hide()},hideReview:function(){this.handlerHide&&this.handlerHide(),this.hideTips(),this._state.reviewVisible=!1,this._state.commentsVisible?this.calculateSizeOfContent():this.hide()},hide:function(){this.handlerHide&&this.handlerHide.apply(this,arguments),this.hideTips(),Common.UI.Window.prototype.hide.call(this),_.isUndefined(this.e)||this.e.keyCode!=Common.UI.Keys.ESC||(this.e.preventDefault(),this.e.stopImmediatePropagation(),this.e=void 0)},update:function(t){this.commentsView&&t&&this.commentsView.onResetItems(),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})},isVisible:function(){return this.$window&&this.$window.is(":visible")},setLeftTop:function(t,e,i,n,o){if(this.$window||this.render(),n&&(t=this.arrowPosX,e=this.arrowPosY,i=this.leftX),!_.isUndefined(t)||!_.isUndefined(e)){this.arrowPosX=t,this.arrowPosY=e,this.leftX=i;var s=$("#id-popover"),a=$("#id-comments-arrow"),l=$("#editor_sdk"),r=null,c=0,h="",d=0,p="",m=0,u="",g=0,b="",f=0,C=0,v=0,y=0,x=0,w=0;s&&a&&l&&l.get(0)&&(r=l.get(0).getBoundingClientRect())&&(c=r.height-2*this.sdkBounds.padding,this.$window.css({maxHeight:c+"px"}),this.sdkBounds.width=r.width,this.sdkBounds.height=r.height,_.isUndefined(t)||(h=$("#id_vertical_scroll"),h.length?d="none"!==h.css("display")?h.width():0:(h=$("#ws-v-scrollbar"),h.length&&(d="none"!==h.css("display")?h.width():0)),this.sdkBounds.width-=d,p=$("#id_panel_left"),p.length&&(m="none"!==p.css("display")?p.width():0),u=$("#id_panel_thumbnails"),u.length&&(g="none"!==u.css("display")?u.width():0,this.sdkBounds.width-=g),C=Math.min(0+t+this.arrow.width,0+this.sdkBounds.width-this.$window.outerWidth()-25),C=Math.max(0+m+this.arrow.width,C),a.removeClass("right").addClass("left"),_.isUndefined(i)||(v=this.$window.outerWidth())&&(t+v>this.sdkBounds.width-this.arrow.width+5&&this.leftX>v?(C=this.leftX-v+0-this.arrow.width,a.removeClass("left").addClass("right")):C=0+t+this.arrow.width),this.$window.css("left",C+"px")),_.isUndefined(e)||(b=$("#id_panel_top"),w=0,b.length?(f="none"!==b.css("display")?b.height():0,w+=this.sdkBounds.paddingTop):(b=$("#ws-h-scrollbar"),b.length&&(f="none"!==b.css("display")?b.height():0)),this.sdkBounds.height-=f,y=this.$window.outerHeight(),x=Math.min(0+c-y,this.arrowPosY+0-this.arrow.height),x=Math.max(x,w),parseInt(a.css("top"))+this.arrow.height>y&&a.css({top:y-this.arrow.height+"px"}),this.$window.css("top",x+"px"))),o||this.calculateSizeOfContent()}},calculateSizeOfContent:function(t){if(!t||this.$window.is(":visible")){this.$window.css({overflow:"hidden"});var e=$("#id-comments-arrow"),i=$("#id-popover"),n=null,o=null,s=null,a=0,l="",r=0,c=0,h=0,d=0,p=0,m=0;if(i&&e&&i.get(0)){var u=this.scroller.getScrollTop();i.css({height:"100%"}),n=i.get(0).getBoundingClientRect(),n&&(o=$("#editor_sdk"))&&o.get(0)&&(s=o.get(0).getBoundingClientRect())&&(a=s.height-2*this.sdkBounds.padding,m=0,h=this.$window.outerHeight(),l=$("#id_panel_top"),l.length?(r="none"!==l.css("display")?l.height():0,m+=this.sdkBounds.paddingTop):(l=$("#ws-h-scrollbar"),l.length&&(r="none"!==l.css("display")?l.height():0)),d=Math.max(i.outerHeight(),this.$window.outerHeight()),a<=d?(this.$window.css({maxHeight:a-r+"px",top:0+r+"px"}),i.css({height:a-r-3+"px"}),c=Math.min(c,a-(r+this.arrow.margin+this.arrow.height)),e.css({top:c+"px"}),this.scroller.scrollTop(u)):(d=h,d>0&&(n.top+d>a+0||0===n.height)&&(p=Math.min(0+a-d,this.arrowPosY+0-this.arrow.height),p=Math.max(p,m),this.$window.css({top:p+"px"})),c=Math.max(this.arrow.margin,this.arrowPosY-(a-d)-this.arrow.height),c=Math.min(c,d-this.arrow.margin-this.arrow.height),e.css({top:c+"px"})))}this.$window.css({overflow:""}),this.scroller&&this.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})}},saveText:function(t){this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1&&(this.textVal=void 0,t?this.commentsView.clearTextBoxBind():this.textVal=this.commentsView.getActiveTextBoxVal())},loadText:function(){if(this.textVal&&this.commentsView){var t=this.commentsView.getTextBox();t&&t.val(this.textVal)}},getEditText:function(){if(this.commentsView)return this.commentsView.getActiveTextBoxVal()},saveDummyText:function(){this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1&&(this.textDummyVal=this.commentsView.getActiveTextBoxVal())},clearDummyText:function(){if(this.commentsView&&this.commentsView.cmpEl.find(".lock-area").length<1){this.textDummyVal=void 0;var t=this.commentsView.getTextBox();t&&t.val(""),this.commentsView.clearTextBoxBind()}},getDummyText:function(){return this.textDummyVal||""},hookTextBox:function(){var t=this,e=this.commentsView.getTextBox();e&&e.keydown(function(e){if(!e.ctrlKey&&!e.metaKey||e.altKey||e.keyCode!==Common.UI.Keys.RETURN){if(e.keyCode===Common.UI.Keys.TAB){var i,n,o;o=this.selectionStart,n=this.selectionEnd,i=$(this),i.val(i.val().substring(0,o)+"\t"+i.val().substring(n)),this.selectionStart=this.selectionEnd=o+1,e.stopImmediatePropagation(),e.preventDefault()}}else{var s=$("#id-comments-change-popover");s&&s.length&&s.click(),e.stopImmediatePropagation()}t.e=e}),this.canRequestUsers&&(e&&e.keydown(function(e){e.keyCode==Common.UI.Keys.SPACE||e.keyCode==Common.UI.Keys.HOME||e.keyCode==Common.UI.Keys.END||e.keyCode==Common.UI.Keys.RIGHT||e.keyCode==Common.UI.Keys.LEFT||e.keyCode==Common.UI.Keys.UP?t.onEmailListMenu():e.keyCode==Common.UI.Keys.DOWN&&t.emailMenu&&t.emailMenu.rendered&&t.emailMenu.isVisible()&&_.delay(function(){var e=t.emailMenu.cmpEl.find("li:not(.divider):first");e=e.find("a"),e.focus()},10),t.e=e}),e&&e.on("input",function(e){for(var i=$(this),n=this.selectionStart,o=i.val().replace(/[\n]$/,""),s=0,a=o.length-1,l=n-1;l>=0;l--)if(32==o.charCodeAt(l)||13==o.charCodeAt(l)||10==o.charCodeAt(l)||9==o.charCodeAt(l)){s=l+1;break}for(var l=n;l<=a;l++)if(32==o.charCodeAt(l)||13==o.charCodeAt(l)||10==o.charCodeAt(l)||9==o.charCodeAt(l)){a=l-1;break}var r=o.substring(s,a+1),c=r.match(/^(?:[@]|[+](?!1))(\S*)/);c&&c.length>1&&(r=c[1],t.onEmailListMenu(r,s,a))}))},hideTips:function(){this.commentsView&&_.each(this.commentsView.dataViewItems,function(t){t.tipsArray&&t.tipsArray.forEach(function(t){t.hide()})},this),this.reviewChangesView&&_.each(this.reviewChangesView.dataViewItems,function(t){t.tipsArray&&t.tipsArray.forEach(function(t){t.hide()})},this)},isCommentsViewMouseOver:function(){return this._isMouseOver},setReviewStore:function(t){this.reviewStore=t,this.reviewChangesView&&this.reviewChangesView.setStore(this.reviewStore)},setCommentsStore:function(t){this.commentsStore=t,this.commentsView&&this.commentsView.setStore(this.commentsStore)},setUsers:function(t){this.externalUsers=t.users||[],this.isUsersLoading=!1,this._state.emailSearch&&this.onEmailListMenu(this._state.emailSearch.str,this._state.emailSearch.left,this._state.emailSearch.right),this._state.emailSearch=null},clearUsers:function(){this.externalUsers=[]},getPopover:function(t){return this.popover||(this.popover=new Common.Views.ReviewPopover(t)),this.popover},autoScrollToEditButtons:function(){var t=$("#id-comments-change-popover"),e=null,i=this.$window[0].getBoundingClientRect(),n=0;t.length&&(e=t.get(0).getBoundingClientRect())&&i&&(n=i.bottom-(e.bottom+7))<0&&this.scroller.scrollTop(this.scroller.getScrollTop()-n)},onEmailListMenu:function(t,e,i,n){var o=this,s=o.externalUsers,a=o.emailMenu;if(s.length<1){if(this._state.emailSearch={str:t,left:e,right:i},this.isUsersLoading)return;return this.isUsersLoading=!0,void Common.Gateway.requestUsers()}if("string"==typeof t){var l=o.$window.find(Common.Utils.String.format("#menu-container-{0}",a.id)),r=this.commentsView.getTextBox(),c=r?r[0]:null,h=c?[c.offsetLeft,c.offsetTop+c.clientHeight+3]:[0,0];a.rendered||(l.length<1&&(l=$(Common.Utils.String.format('',a.id)),o.$window.append(l)),a.render(l),a.cmpEl.css("min-width",c?c.clientWidth:220),a.cmpEl.attr({tabindex:"-1"}),a.on("hide:after",function(){setTimeout(function(){var t=o.commentsView.getTextBox();t&&t.focus()},10)}));for(var d=0;d0){t=t.toLowerCase(),t.length>0&&(s=_.filter(s,function(e){return e.email&&0===e.email.toLowerCase().indexOf(t)||e.name&&0===e.name.toLowerCase().indexOf(t)}));var p=_.template('
<%= Common.Utils.String.htmlEncode(caption) %>
<%= Common.Utils.String.htmlEncode(options.value) %>
'),m=!1;_.each(s,function(t,n){if(m&&!t.hasAccess&&(m=!1,a.addItem(new Common.UI.MenuItem({caption:"--"}))),t.email&&t.name){var s=new Common.UI.MenuItem({caption:t.name,value:t.email,template:p}).on("click",function(t,n){o.insertEmailToTextbox(t.options.value,e,i)});a.addItem(s),t.hasAccess&&(m=!0)}})}a.items.length>0?(l.css({left:h[0],top:h[1]}),a.menuAlignEl=r,a.show(),a.cmpEl.css("display",""),a.alignPosition("bl-tl",-5),a.scroller.update({alwaysVisibleY:!0})):a.rendered&&a.cmpEl.css("display","none")}else a.rendered&&a.cmpEl.css("display","none")},insertEmailToTextbox:function(t,e,i){var n=this.commentsView.getTextBox(),o=n.val();n.val(o.substring(0,e)+"+"+t+o.substring(i+1,o.length)),setTimeout(function(){n[0].selectionStart=n[0].selectionEnd=e+t.length+1},10)},textAddReply:"Add Reply",textAdd:"Add",textCancel:"Cancel",textEdit:"Edit",textReply:"Reply",textClose:"Close",textResolve:"Resolve",textOpenAgain:"Open Again",textFollowMove:"Follow Move",textMention:"+mention will provide access to the document and send an email"},Common.Views.ReviewPopover||{}))}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{}, +define("common/main/lib/controller/Comments",["core","common/main/lib/model/Comment","common/main/lib/collection/Comments","common/main/lib/view/Comments","common/main/lib/view/ReviewPopover"],function(){"use strict";function t(){return void 0!==Asc.asc_CCommentDataWord?new Asc.asc_CCommentDataWord(null):new Asc.asc_CCommentData(null)}Common.Controllers.Comments=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.Comments"],views:["Common.Views.Comments","Common.Views.ReviewPopover"],sdkViewName:"#id_main",subEditStrings:{},filter:void 0,hintmode:!1,viewmode:!1,isSelectedComment:!1,uids:[],oldUids:[],isDummyComment:!1,initialize:function(){this.addListeners({"Common.Views.Comments":{"comment:add":_.bind(this.onCreateComment,this),"comment:change":_.bind(this.onChangeComment,this),"comment:remove":_.bind(this.onRemoveComment,this),"comment:resolve":_.bind(this.onResolveComment,this),"comment:show":_.bind(this.onShowComment,this),"comment:addReply":_.bind(this.onAddReplyComment,this),"comment:changeReply":_.bind(this.onChangeReplyComment,this),"comment:removeReply":_.bind(this.onRemoveReplyComment,this),"comment:editReply":_.bind(this.onShowEditReplyComment,this),"comment:closeEditing":_.bind(this.closeEditing,this)},"Common.Views.ReviewPopover":{"comment:change":_.bind(this.onChangeComment,this),"comment:remove":_.bind(this.onRemoveComment,this),"comment:resolve":_.bind(this.onResolveComment,this),"comment:show":_.bind(this.onShowComment,this),"comment:addReply":_.bind(this.onAddReplyComment,this),"comment:changeReply":_.bind(this.onChangeReplyComment,this),"comment:removeReply":_.bind(this.onRemoveReplyComment,this),"comment:editReply":_.bind(this.onShowEditReplyComment,this),"comment:closeEditing":_.bind(this.closeEditing,this),"comment:disableHint":_.bind(this.disableHint,this),"comment:addDummyComment":_.bind(this.onAddDummyComment,this)}}),Common.NotificationCenter.on("comments:updatefilter",_.bind(this.onUpdateFilter,this)),Common.NotificationCenter.on("app:comment:add",_.bind(this.onAppAddComment,this)),Common.NotificationCenter.on("layout:changed",function(t){Common.Utils.asyncCall(function(t){"toolbar"!=t&&"status"!=t||!this.view.$el.is(":visible")||this.onAfterShow()},this,t)}.bind(this))},onLaunch:function(){this.collection=this.getApplication().getCollection("Common.Collections.Comments"),this.collection&&(this.collection.comparator=function(t){return-t.get("time")}),this.popoverComments=new Common.Collections.Comments,this.popoverComments&&(this.popoverComments.comparator=function(t){return t.get("time")}),this.groupCollection=[],this.view=this.createView("Common.Views.Comments",{store:this.collection}),this.view.render(),this.userCollection=this.getApplication().getCollection("Common.Collections.Users"),this.userCollection.on("reset",_.bind(this.onUpdateUsers,this)),this.userCollection.on("add",_.bind(this.onUpdateUsers,this)),this.bindViewEvents(this.view,this.events)},setConfig:function(t,e){this.setApi(e),t&&(this.currentUserId=t.config.user.id,this.currentUserName=t.config.user.fullname,this.sdkViewName=t.sdkviewname||this.sdkViewName,this.hintmode=t.hintmode||!1,this.viewmode=t.viewmode||!1)},setApi:function(t){t&&(this.api=t,this.api.asc_registerCallback("asc_onAddComment",_.bind(this.onApiAddComment,this)),this.api.asc_registerCallback("asc_onAddComments",_.bind(this.onApiAddComments,this)),this.api.asc_registerCallback("asc_onRemoveComment",_.bind(this.onApiRemoveComment,this)),this.api.asc_registerCallback("asc_onChangeComments",_.bind(this.onChangeComments,this)),this.api.asc_registerCallback("asc_onRemoveComments",_.bind(this.onRemoveComments,this)),this.api.asc_registerCallback("asc_onChangeCommentData",_.bind(this.onApiChangeCommentData,this)),this.api.asc_registerCallback("asc_onLockComment",_.bind(this.onApiLockComment,this)),this.api.asc_registerCallback("asc_onUnLockComment",_.bind(this.onApiUnLockComment,this)),this.api.asc_registerCallback("asc_onShowComment",_.bind(this.onApiShowComment,this)),this.api.asc_registerCallback("asc_onHideComment",_.bind(this.onApiHideComment,this)),this.api.asc_registerCallback("asc_onUpdateCommentPosition",_.bind(this.onApiUpdateCommentPosition,this)),this.api.asc_registerCallback("asc_onDocumentPlaceChanged",_.bind(this.onDocumentPlaceChanged,this)))},setMode:function(t){return this.mode=t,this.isModeChanged=!0,this.view.viewmode=!this.mode.canComments,this.view.changeLayout(t),this},onCreateComment:function(e,i,n,o,s){if(this.api&&i&&i.length>0){var a=t();a&&(this.showPopover=!0,this.editPopover=!!n,this.hidereply=o,this.isSelectedComment=!1,this.uids=[],a.asc_putText(i),a.asc_putTime(this.utcDateToString(new Date)),a.asc_putOnlyOfficeTime(this.ooDateToString(new Date)),a.asc_putUserId(this.currentUserId),a.asc_putUserName(this.currentUserName),a.asc_putSolved(!1),_.isUndefined(a.asc_putDocumentFlag)||a.asc_putDocumentFlag(s),this.api.asc_addComment(a),this.view.showEditContainer(!1))}this.view.txtComment.focus()},onRemoveComment:function(t){this.api&&t&&this.api.asc_removeComment(t)},onResolveComment:function(e){var i=this,n=null,o=null,s=t(),a=i.findComment(e);return _.isUndefined(e)&&(e=a.get("uid")),!(!s||!a)&&(s.asc_putText(a.get("comment")),s.asc_putQuoteText(a.get("quote")),s.asc_putTime(i.utcDateToString(new Date(a.get("time")))),s.asc_putOnlyOfficeTime(i.ooDateToString(new Date(a.get("time")))),s.asc_putUserId(a.get("userid")),s.asc_putUserName(a.get("username")),s.asc_putSolved(!a.get("resolved")),s.asc_putGuid(a.get("guid")),_.isUndefined(s.asc_putDocumentFlag)||s.asc_putDocumentFlag(a.get("unattached")),n=a.get("replys"),n&&n.length&&n.forEach(function(e){(o=t())&&(o.asc_putText(e.get("reply")),o.asc_putTime(i.utcDateToString(new Date(e.get("time")))),o.asc_putOnlyOfficeTime(i.ooDateToString(new Date(e.get("time")))),o.asc_putUserId(e.get("userid")),o.asc_putUserName(e.get("username")),s.asc_addReply(o))}),i.api.asc_changeComment(e,s),!0)},onShowComment:function(t,e){var i=this.findComment(t);if(i)if(null!==i.get("quote")){if(this.api){if(this.hintmode){if(this.animate=!0,i.get("unattached")&&this.getPopover())return void this.getPopover().hideComments()}else{var n=this.popoverComments.findWhere({uid:t});if(n&&!this.getPopover().isVisible())return this.getPopover().showComments(!0),void this.api.asc_selectComment(t)}!_.isUndefined(e)&&this.hintmode&&(this.isSelectedComment=e),this.api.asc_selectComment(t),this._dontScrollToComment=!0,this.api.asc_showComment(t,!1)}}else this.hintmode&&this.api.asc_selectComment(t),this.getPopover()&&this.getPopover().hideComments(),this.isSelectedComment=!1,this.uids=[]},onChangeComment:function(e,i){if(i&&i.length>0){var n=this,o=null,s=null,a=null,l=t(),r=n.findComment(e);if(r&&l)return l.asc_putText(i),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(n.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(n.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(n.currentUserId),l.asc_putUserName(n.currentUserName),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),r.set("editTextInPopover",!1),o=n.findPopupComment(e),o&&o.set("editTextInPopover",!1),n.subEditStrings[e]&&delete n.subEditStrings[e],n.subEditStrings[e+"-R"]&&delete n.subEditStrings[e+"-R"],s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(a.asc_putText(e.get("reply")),a.asc_putTime(n.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username")),l.asc_addReply(a))}),n.api.asc_changeComment(e,l),!0}return!1},onChangeReplyComment:function(e,i,n){if(n&&n.length>0){var o=this,s=null,a=null,l=t(),r=o.findComment(e);if(l&&r)return l.asc_putText(r.get("comment")),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(o.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(o.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(r.get("userid")),l.asc_putUserName(r.get("username")),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(e.get("id")!==i||_.isUndefined(n)?(a.asc_putText(e.get("reply")),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username"))):(a.asc_putText(n),a.asc_putUserId(o.currentUserId),a.asc_putUserName(o.currentUserName)),a.asc_putTime(o.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(o.ooDateToString(new Date(e.get("time")))),l.asc_addReply(a))}),o.api.asc_changeComment(e,l),!0}return!1},onAddReplyComment:function(e,i){if(i.length>0){var n=this,o=null,s=null,a=null,l=t(),r=n.findComment(e);if(l&&r&&(o=r.get("uid"),o&&(n.subEditStrings[o]&&delete n.subEditStrings[o],n.subEditStrings[o+"-R"]&&delete n.subEditStrings[o+"-R"],r.set("showReplyInPopover",!1)),l.asc_putText(r.get("comment")),l.asc_putQuoteText(r.get("quote")),l.asc_putTime(n.utcDateToString(new Date(r.get("time")))),l.asc_putOnlyOfficeTime(n.ooDateToString(new Date(r.get("time")))),l.asc_putUserId(r.get("userid")),l.asc_putUserName(r.get("username")),l.asc_putSolved(r.get("resolved")),l.asc_putGuid(r.get("guid")),_.isUndefined(l.asc_putDocumentFlag)||l.asc_putDocumentFlag(r.get("unattached")),s=r.get("replys"),s&&s.length&&s.forEach(function(e){(a=t())&&(a.asc_putText(e.get("reply")),a.asc_putTime(n.utcDateToString(new Date(e.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),a.asc_putUserId(e.get("userid")),a.asc_putUserName(e.get("username")),l.asc_addReply(a))}),a=t()))return a.asc_putText(i),a.asc_putTime(n.utcDateToString(new Date)),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date)),a.asc_putUserId(n.currentUserId),a.asc_putUserName(n.currentUserName),l.asc_addReply(a),n.api.asc_changeComment(e,l),n.mode&&n.mode.canRequestUsers&&n.view.pickEMail(l.asc_getGuid(),i),!0}return!1},onRemoveReplyComment:function(e,i){if(!_.isUndefined(e)&&!_.isUndefined(i)){var n=this,o=null,s=null,a=t(),l=n.findComment(e);if(a&&l)return a.asc_putText(l.get("comment")),a.asc_putQuoteText(l.get("quote")),a.asc_putTime(n.utcDateToString(new Date(l.get("time")))),a.asc_putOnlyOfficeTime(n.ooDateToString(new Date(l.get("time")))),a.asc_putUserId(l.get("userid")),a.asc_putUserName(l.get("username")),a.asc_putSolved(l.get("resolved")),a.asc_putGuid(l.get("guid")),_.isUndefined(a.asc_putDocumentFlag)||a.asc_putDocumentFlag(l.get("unattached")),o=l.get("replys"),o&&o.length&&o.forEach(function(e){e.get("id")!==i&&(s=t())&&(s.asc_putText(e.get("reply")),s.asc_putTime(n.utcDateToString(new Date(e.get("time")))),s.asc_putOnlyOfficeTime(n.ooDateToString(new Date(e.get("time")))),s.asc_putUserId(e.get("userid")),s.asc_putUserName(e.get("username")),a.asc_addReply(s))}),n.api.asc_changeComment(e,a),!0}return!1},onShowEditReplyComment:function(t,e,i){var n,o,s,a;if(!_.isUndefined(t)&&!_.isUndefined(e))if(i){if((o=this.popoverComments.findWhere({uid:t}))&&(s=o.get("replys"),a=_.clone(o.get("replys"))))for(n=0;n=0;--s)o?this.collection.at(s).set("last",!0,{silent:!0}):this.collection.at(s).get("last")&&this.collection.at(s).set("last",!1,{silent:!0}),o=!1;this.view.render(),this.view.update()}}},onAppAddComment:function(t,e){this.api.can_AddQuotedComment&&!1===this.api.can_AddQuotedComment()||e||this.addDummyComment()},addCommentToGroupCollection:function(t){var e=t.get("groupName");this.groupCollection[e]||(this.groupCollection[e]=new Backbone.Collection([],{model:Common.Models.Comment})),this.groupCollection[e].push(t)},onApiAddComment:function(t,e){var i=this.readSDKComment(t,e);i&&(i.get("groupName")?(this.addCommentToGroupCollection(i),_.indexOf(this.collection.groups,i.get("groupName"))>-1&&this.collection.push(i)):this.collection.push(i),this.updateComments(!0),this.showPopover&&(null!==e.asc_getQuoteText()&&(this.api.asc_selectComment(t),this._dontScrollToComment=!0,this.api.asc_showComment(t,!0)),this.showPopover=void 0,this.editPopover=!1))},onApiAddComments:function(t){for(var e=0;e100&&(clearInterval(n.timerUpdateComments),n.timerUpdateComments=void 0,n.updateCommentsView(t,e,i))},25))},updateCommentsView:function(t,e,i){if(t&&!this.view.isVisible())return this.view.needRender=t,void this.onUpdateFilter(this.filter,!0);var n,o=!0;if(_.isUndefined(e)&&this.collection.sort(),t){for(this.onUpdateFilter(this.filter,!0),n=this.collection.length-1;n>=0;--n)o?this.collection.at(n).set("last",!0,{silent:!0}):this.collection.at(n).get("last")&&this.collection.at(n).set("last",!1,{silent:!0}),o=!1;this.view.render(),this.view.needRender=!1}this.view.update(),i&&this.view.loadText()},findComment:function(t){return this.collection.findWhere({uid:t})},findPopupComment:function(t){return this.popoverComments.findWhere({id:t})},findCommentInGroup:function(t){for(var e in this.groupCollection){var i=this.groupCollection[e],n=i.findWhere({uid:t});if(n)return n}},closeEditing:function(t){if(!_.isUndefined(t)){var e=this.findPopupComment(t);e&&(e.set("editTextInPopover",!1),e.set("showReplyInPopover",!1)),this.subEditStrings[t]&&delete this.subEditStrings[t],this.subEditStrings[t+"-R"]&&delete this.subEditStrings[t+"-R"]}this.collection.clearEditing(),this.collection.each(function(t){var e=_.clone(t.get("replys"));t.get("replys").length=0,e.forEach(function(t){t.get("editText")&&t.set("editText",!1),t.get("editTextInPopover")&&t.set("editTextInPopover",!1)}),t.set("replys",e)}),this.view.showEditContainer(!1),this.view.update()},disableHint:function(t){t&&this.mode.canComments&&(t.set("hint",!1),this.api.asc_showComment(t.get("uid"),!1),this.isSelectedComment=!0)},blockPopover:function(t){this.isSelectedComment=t,t&&this.getPopover().isVisible()&&this.getPopover().hide()},getPopover:function(){return _.isUndefined(this.popover)&&(this.popover=Common.Views.ReviewPopover.prototype.getPopover({commentsStore:this.popoverComments,renderTo:this.sdkViewName,canRequestUsers:this.mode?this.mode.canRequestUsers:void 0,canRequestSendNotify:this.mode?this.mode.canRequestSendNotify:void 0}),this.popover.setCommentsStore(this.popoverComments)),this.popover},onUpdateUsers:function(){var t=this.userCollection,e=!1;for(var i in this.groupCollection)e=!0,this.groupCollection[i].each(function(e){var i=t.findOriginalUser(e.get("userid")),n=i?i.get("color"):null,o=!1;n!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0})),e.get("replys").forEach(function(e){i=t.findOriginalUser(e.get("userid")),(n=i?i.get("color"):null)!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0}))}),o&&e.trigger("change")});!e&&this.collection.each(function(e){var i=t.findOriginalUser(e.get("userid")),n=i?i.get("color"):null,o=!1;n!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0})),e.get("replys").forEach(function(e){i=t.findOriginalUser(e.get("userid")),(n=i?i.get("color"):null)!==e.get("usercolor")&&(o=!0,e.set("usercolor",n,{silent:!0}))}),o&&e.trigger("change")})},readSDKComment:function(t,e){var i=e.asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getOnlyOfficeTime())):""==e.asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getTime())),n=this.userCollection.findOriginalUser(e.asc_getUserId()),o=t.substr(0,t.lastIndexOf("_")+1).match(/^(doc|sheet[0-9_]+)_/),s=new Common.Models.Comment({uid:t,guid:e.asc_getGuid(),userid:e.asc_getUserId(),username:e.asc_getUserName(),usercolor:n?n.get("color"):null,date:this.dateToLocaleTimeString(i),quote:e.asc_getQuoteText(),comment:e.asc_getText(),resolved:e.asc_getSolved(),unattached:!_.isUndefined(e.asc_getDocumentFlag)&&e.asc_getDocumentFlag(),id:Common.UI.getId(),time:i.getTime(),showReply:!1,editText:!1,last:void 0,editTextInPopover:!!this.editPopover,showReplyInPopover:!1,hideAddReply:_.isUndefined(this.hidereply)?!!this.showPopover:this.hidereply,scope:this.view,editable:this.mode.canEditComments||e.asc_getUserId()==this.currentUserId,hint:!this.mode.canComments,groupName:o&&o.length>1?o[1]:null});if(s){var a=this.readSDKReplies(e);a.length&&s.set("replys",a)}return s},readSDKReplies:function(t){var e=0,i=[],n=null,o=t.asc_getRepliesCount();if(o)for(e=0;e0){var i=t();i&&(this.showPopover=!0,this.editPopover=!1,this.hidereply=!1,this.isSelectedComment=!1,this.uids=[],this.popoverComments.reset(),this.getPopover().isVisible()&&this.getPopover().hideComments(),this.isDummyComment=!1,i.asc_putText(e),i.asc_putTime(this.utcDateToString(new Date)),i.asc_putOnlyOfficeTime(this.ooDateToString(new Date)),i.asc_putUserId(this.currentUserId),i.asc_putUserName(this.currentUserName),i.asc_putSolved(!1),_.isUndefined(i.asc_putDocumentFlag)||i.asc_putDocumentFlag(!1),this.api.asc_addComment(i),this.view.showEditContainer(!1),this.mode&&this.mode.canRequestUsers&&this.view.pickEMail(i.asc_getGuid(),e),_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||this.api.asc_SetDocumentPlaceChangedEnabled(!1))}},clearDummyComment:function(t){if(this.isDummyComment){this.isDummyComment=!1,this.showPopover=!0,this.editPopover=!1,this.hidereply=!1,this.isSelectedComment=!1,this.uids=[];var e=this.getPopover();e&&(t&&e.clearDummyText(),e.saveDummyText(),e.handlerHide=function(){},e.isVisible()&&e.hideComments()),this.popoverComments.reset(),_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||this.api.asc_SetDocumentPlaceChangedEnabled(!1),Common.NotificationCenter.trigger("comments:cleardummy")}},onEditComments:function(t){if(this.api){var e=0,i=this,n=null,o=this.api.asc_getAnchorPosition();if(o){for(this.isSelectedComment=!0,this.popoverComments.reset(),e=0;e0&&(this.getPopover().isVisible()&&this.getPopover().hide(),this.getPopover().setLeftTop(o.asc_getX()+o.asc_getWidth(),o.asc_getY(),this.hintmode?o.asc_getX():void 0),this.getPopover().showComments(!0,!1,!0))}}},onAfterShow:function(){if(this.view&&this.api){var t=$(".new-comment-ct",this.view.el);t&&t.length&&"none"!==t.css("display")&&this.view.txtComment.focus(),this.view.needRender?this.updateComments(!0):this.view.needUpdateFilter&&this.onUpdateFilter(this.view.needUpdateFilter),this.view.update()}},onBeforeHide:function(){this.view&&this.view.showEditContainer(!1)},timeZoneOffsetInMs:6e4*(new Date).getTimezoneOffset(),stringOOToLocalDate:function(t){return"string"==typeof t?parseInt(t):0},ooDateToString:function(t){return"[object Date]"===Object.prototype.toString.call(t)?t.getTime().toString():""},stringUtcToLocalDate:function(t){return"string"==typeof t?parseInt(t)+this.timeZoneOffsetInMs:0},utcDateToString:function(t){return"[object Date]"===Object.prototype.toString.call(t)?(t.getTime()-this.timeZoneOffsetInMs).toString():""},dateToLocaleTimeString:function(t){return t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear()+" "+function(t){var e=t.getHours(),i=t.getMinutes(),n=e>=12?"pm":"am";return e%=12,e=e||12,i=i<10?"0"+i:i,e+":"+i+" "+n}(t)},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},setPreviewMode:function(t){this.viewmode!==t&&(this.viewmode=t,t&&(this.prevcanComments=this.mode.canComments),this.mode.canComments=!t&&this.prevcanComments,this.closeEditing(),this.setMode(this.mode),this.updateComments(!0),this.getPopover()&&(t?this.getPopover().hide():this.getPopover().update(!0)))},clearCollections:function(){this.collection.reset(),this.groupCollection=[]}},Common.Controllers.Comments||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/User",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.User=e.Model.extend({defaults:function(){return{iid:Common.UI.getId(),id:void 0,idOriginal:void 0,username:"Guest",color:"#fff",colorval:null,online:!1,view:!1}}})}),define("common/main/lib/collection/Users",["backbone","common/main/lib/model/User"],function(t){"use strict";Common.Collections=Common.Collections||{},Common.Collections.Users=t.Collection.extend({model:Common.Models.User,getOnlineCount:function(){var t=0;return this.each(function(e){e.get("online")&&++t}),t},getEditingCount:function(){return this.filter(function(t){return t.get("online")&&!t.get("view")}).length},getEditingOriginalCount:function(){return this.chain().filter(function(t){return t.get("online")&&!t.get("view")}).groupBy(function(t){return t.get("idOriginal")}).size().value()},findUser:function(t){return this.find(function(e){return e.get("id")==t})},findOriginalUser:function(t){return this.find(function(e){return e.get("idOriginal")==t})}}),Common.Collections.HistoryUsers=t.Collection.extend({model:Common.Models.User,findUser:function(t){return this.find(function(e){return e.get("id")==t})}})}),define("common/main/lib/model/ChatMessage",["backbone"],function(t){"use strict";Common.Models=Common.Models||{},Common.Models.ChatMessage=t.Model.extend({defaults:{type:0,userid:null,username:"",message:""}})}),define("common/main/lib/collection/ChatMessages",["backbone","common/main/lib/model/ChatMessage"],function(t){"use strict";!Common.Collections&&(Common.Collections={}),Common.Collections.ChatMessages=t.Collection.extend({model:Common.Models.ChatMessage})}),define("common/main/lib/controller/Chat",["core","common/main/lib/collection/Users","common/main/lib/collection/ChatMessages","common/main/lib/view/Chat"],function(){"use strict";Common.Controllers.Chat=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.Users","Common.Collections.ChatMessages"],views:["Common.Views.Chat"],initialize:function(){this.addListeners({"Common.Views.Chat":{"message:add":_.bind(this.onSendMessage,this)}});var t=this;Common.NotificationCenter.on("layout:changed",function(e){Common.Utils.asyncCall(function(e){"toolbar"!=e&&"status"!=e||!t.panelChat.$el.is(":visible")||(t.panelChat.updateLayout(!0),t.panelChat.setupAutoSizingTextBox())},this,e)})},events:{},onLaunch:function(){this.panelChat=this.createView("Common.Views.Chat",{storeUsers:this.getApplication().getCollection("Common.Collections.Users"),storeMessages:this.getApplication().getCollection("Common.Collections.ChatMessages")})},setMode:function(t){return this.mode=t,this.api&&(this.mode.canCoAuthoring&&this.mode.canChat&&this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage",_.bind(this.onReceiveMessage,this)),this.mode.isEditDiagram||this.mode.isEditMailMerge||(this.api.asc_registerCallback("asc_onAuthParticipantsChanged",_.bind(this.onUsersChanged,this)),this.api.asc_registerCallback("asc_onConnectionStateChanged",_.bind(this.onUserConnection,this)),this.api.asc_coAuthoringGetUsers()),this.mode.canCoAuthoring&&this.mode.canChat&&this.api.asc_coAuthoringChatGetMessages()),this},setApi:function(t){return this.api=t,this},onUsersChanged:function(t,e){if(!this.mode.canLicense||!this.mode.canCoAuthoring){var i=0;for(o in t)void 0!==o&&i++ +;if(i>1&&void 0==this._isCoAuthoringStopped)return this._isCoAuthoringStopped=!0,this.api.asc_coAuthoringDisconnect(),void Common.NotificationCenter.trigger("api:disconnect")}var n=this.getApplication().getCollection("Common.Collections.Users");if(n){var o,s,a=[];for(o in t)if(void 0!==o&&(s=t[o])){var l=new Common.Models.User({id:s.asc_getId(),idOriginal:s.asc_getIdOriginal(),username:s.asc_getUserName(),online:!0,color:s.asc_getColor(),view:s.asc_getView()});a[s.asc_getId()==e?"unshift":"push"](l)}n[n.size()>0?"add":"reset"](a)}},onUserConnection:function(t){var e=this.getApplication().getCollection("Common.Collections.Users");if(e){var i=e.findUser(t.asc_getId());i?i.set({online:t.asc_getState()}):e.add(new Common.Models.User({id:t.asc_getId(),idOriginal:t.asc_getIdOriginal(),username:t.asc_getUserName(),online:t.asc_getState(),color:t.asc_getColor(),view:t.asc_getView()}))}},onReceiveMessage:function(t,e){var i=this.getApplication().getCollection("Common.Collections.ChatMessages");if(i){var n=[];t.forEach(function(t){n.push(new Common.Models.ChatMessage({userid:t.useridoriginal,message:t.message,username:t.username}))}),i[i.size()<1||e?"reset":"add"](n)}},onSendMessage:function(t,e){if(e.length>0){var i=this;(function(t,e){for(var i=[];t;){if(t.length .group",e.$toolbarPanelPlugins),o=$('').appendTo(n);i.render(o)}},onResetPlugins:function(t){var e=this;if(e.appOptions.canPlugins=!t.isEmpty(),e.$toolbarPanelPlugins){e.$toolbarPanelPlugins.empty();var i=$('
'),n=-1,o=0;t.each(function(t){var s=t.get("groupRank");s!==n&&n>-1&&o>0&&(i.appendTo(e.$toolbarPanelPlugins),$('
').appendTo(e.$toolbarPanelPlugins),i=$('
'),o=0);var a=e.panelPlugins.createPluginButton(t);if(a){var l=$('').appendTo(i);a.render(l),o++}n=s}),i.appendTo(e.$toolbarPanelPlugins)}else console.error("toolbar panel isnot created")},onSelectPlugin:function(t,e,i,n){var o=$(n.target);if(o&&o.hasClass("plugin-caret")){var s=this.panelPlugins.pluginMenu;if(s.isVisible())return void s.hide();var a,l=this,r=$(n.currentTarget),c=$(this.panelPlugins.el),h=r.offset(),d=c.offset();if(a=[h.left-d.left+r.width(),h.top-d.top+r.height()/2],void 0!=i){for(var p=0;p0?u.get("description"):l.panelPlugins.textStart,value:parseInt(u.get("index"))}).on("click",function(t,e){l.api&&l.api.asc_pluginRun(i.get("guid"),t.value,"")});s.addItem(g)}}var b=c.find("#menu-plugin-container");s.rendered||(b.length<1&&(b=$('',s.id),c.append(b)),s.render(b),s.cmpEl.attr({tabindex:"-1"}),s.on({"show:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!0)},"hide:after":function(t){t&&t.menuAlignEl&&t.menuAlignEl.toggleClass("over",!1)}})),b.css({left:a[0],top:a[1]}),s.menuAlignEl=r,s.setOffset(-20,-r.height()/2-3),s.show(),_.delay(function(){s.cmpEl.focus()},10),n.stopPropagation(),n.preventDefault()}else this.api.asc_pluginRun(i.get("guid"),0,"")},onPluginShow:function(t,e,i,n){var o=t.get_Variations()[e];if(o.get_Visual()){var s=o.get_Url();if(s=(0==t.get_BaseUrl().length?s:t.get_BaseUrl())+s,n&&(s+=n),o.get_InsideMode())this.panelPlugins.openInsideMode(t.get_Name(),s,i)||this.api.asc_pluginButtonClick(-1);else{var a=this,l=o.get_CustomWindow(),r=o.get_Buttons(),c={},h=o.get_Size();(!h||h.length<2)&&(h=[800,600]),_.isArray(r)&&_.each(r,function(t,e){t.visible&&(c[e]={text:t.text,cls:"custom"+(t.primary?" primary":"")})}),a.pluginDlg=new Common.Views.PluginDlg({cls:l?"plain":"",header:!l,title:t.get_Name(),width:h[0],height:h[1],url:s,frameId:i,buttons:l?void 0:c,toolcallback:_.bind(this.onToolClose,this)}),a.pluginDlg.on({"render:after":function(t){t.getChild(".footer .dlg-btn").on("click",_.bind(a.onDlgBtnClick,a)),a.pluginContainer=a.pluginDlg.$window.find("#id-plugin-container")},close:function(t){a.pluginDlg=void 0},drag:function(t){a.api.asc_pluginEnableMouseEvents("start"==t[1])},resize:function(t){a.api.asc_pluginEnableMouseEvents("start"==t[1])}}),a.pluginDlg.show()}}this.panelPlugins.openedPluginMode(t.get_Guid())},onPluginClose:function(t){this.pluginDlg?this.pluginDlg.close():this.panelPlugins.iframePlugin&&this.panelPlugins.closeInsideMode(),this.panelPlugins.closedPluginMode(t.get_Guid()),this.runAutoStartPlugins()},onPluginResize:function(t,e,i,n){if(this.pluginDlg){var o=e&&e.length>1&&i&&i.length>1&&(i[0]>e[0]||i[1]>e[1]||0==i[0]||0==i[1]);this.pluginDlg.setResizable(o,e,i),this.pluginDlg.setInnerSize(t[0],t[1]),n&&n.call()}},onDlgBtnClick:function(t){var e=t.currentTarget.attributes.result.value;this.api.asc_pluginButtonClick(parseInt(e))},onToolClose:function(){this.api.asc_pluginButtonClick(-1)},onPluginMouseUp:function(t,e){this.pluginDlg?(this.pluginDlg.binding.dragStop&&this.pluginDlg.binding.dragStop(),this.pluginDlg.binding.resizeStop&&this.pluginDlg.binding.resizeStop()):Common.NotificationCenter.trigger("frame:mouseup",{pageX:t*Common.Utils.zoom()+this._moveOffset.x,pageY:e*Common.Utils.zoom()+this._moveOffset.y})},onPluginMouseMove:function(t,e){if(this.pluginDlg){var i=this.pluginContainer.offset();this.pluginDlg.binding.drag&&this.pluginDlg.binding.drag({pageX:t*Common.Utils.zoom()+i.left,pageY:e*Common.Utils.zoom()+i.top}),this.pluginDlg.binding.resize&&this.pluginDlg.binding.resize({pageX:t*Common.Utils.zoom()+i.left,pageY:e*Common.Utils.zoom()+i.top})}else Common.NotificationCenter.trigger("frame:mousemove",{pageX:t*Common.Utils.zoom()+this._moveOffset.x,pageY:e*Common.Utils.zoom()+this._moveOffset.y})},onPluginsInit:function(t){!(t instanceof Array)&&(t=t.pluginsData),this.parsePlugins(t)},runAutoStartPlugins:function(){this.autostart&&this.autostart.length>0&&this.api.asc_pluginRun(this.autostart.shift(),0,"")},resetPluginsList:function(){this.getApplication().getCollection("Common.Collections.Plugins").reset()},applyUICustomization:function(){var me=this;return new Promise(function(resolve,reject){var timer_sl=setInterval(function(){if(me.customPluginsComplete){clearInterval(timer_sl);try{me.configPlugins.UIplugins&&me.configPlugins.UIplugins.forEach(function(c){c.code&&eval(c.code)})}catch(t){}resolve()}},10)})},parsePlugins:function(t,e){var i=this,n=this.getApplication().getCollection("Common.Collections.Plugins"),o=i.appOptions.isEdit,s=i.editor;if(t instanceof Array){var a=[],l=[],r=i.appOptions.lang.split(/[\-_]/)[0];t.forEach(function(t){if(!(a.some(function(e){return e.get("baseUrl")==t.baseUrl||e.get("guid")==t.guid})||n.findWhere({baseUrl:t.baseUrl})||n.findWhere({guid:t.guid}))){var e=[],i=!1;if(t.variations.forEach(function(n){var a=(o||n.isViewer&&!1!==n.isDisplayedInViewer)&&_.contains(n.EditorsSupport,s)&&!n.isSystem;if(a&&(i=!0),t.isUICustomizer)a&&l.push({url:t.baseUrl+n.url});else{var c=new Common.Models.PluginVariation(n),h=n.description;"object"==typeof n.descriptionLocale&&(h=n.descriptionLocale[r]||n.descriptionLocale.en||h||""),_.each(n.buttons,function(t,e){"object"==typeof t.textLocale&&(t.text=t.textLocale[r]||t.textLocale.en||t.text||""),t.visible=o||!1!==t.isViewer}),c.set({description:h,index:e.length,url:n.url,icons:n.icons,buttons:n.buttons,visible:a}),e.push(c)}}),e.length>0&&!t.isUICustomizer){var c=t.name;"object"==typeof t.nameLocale&&(c=t.nameLocale[r]||t.nameLocale.en||c||""),a.push(new Common.Models.Plugin({name:c,guid:t.guid,baseUrl:t.baseUrl,variations:e,currentVariation:0,visible:i,groupName:t.group?t.group.name:"",groupRank:t.group?t.group.rank:0}))}}}),!1!==e&&(i.configPlugins.UIplugins=l),!e&&n&&(a=n.models.concat(a),a.sort(function(t,e){var i=t.get("groupRank"),n=e.get("groupRank");return in?0==n?-1:1:0}),n.reset(a),this.appOptions.canPlugins=!n.isEmpty())}else e||(this.appOptions.canPlugins=!1);e||this.getApplication().getController("LeftMenu").enablePlugins(),this.appOptions.canPlugins&&(this.refreshPluginsList(),this.runAutoStartPlugins())},getPlugins:function(t,e){if(!t||t.length<1)return Promise.resolve([]);e=e||function(t){return fetch(t).then(function(e){return e.ok?e.json():Promise.reject(t)}).then(function(e){return e.baseUrl=t.substring(0,t.lastIndexOf("config.json")),e})};var i=[];return t.map(e).reduce(function(t,e){return t.then(function(){return e}).then(function(t){return i.push(t),Promise.resolve(t)}).catch(function(t){return Promise.resolve(t)})},Promise.resolve()).then(function(){return Promise.resolve(i)})},mergePlugins:function(){if(void 0!==this.serverPlugins.plugins&&void 0!==this.configPlugins.plugins){var t=[],e=[],i=this.configPlugins,n=!1;if(i.plugins&&i.plugins.length>0){e=i.plugins;var o=i.config.autostart||i.config.autoStartGuid;"string"==typeof o&&(o=[o]),n=!!i.config.autoStartGuid,t=o||[]}if(i=this.serverPlugins,i.plugins&&i.plugins.length>0){e=e.concat(i.plugins);var o=i.config.autostart||i.config.autoStartGuid;"string"==typeof o&&(o=[o]),(n||i.config.autoStartGuid)&&console.warn("Obsolete: The autoStartGuid parameter is deprecated. Please check the documentation for new plugin connection configuration."),t=t.concat(o||[])}this.autostart=t,this.parsePlugins(e,!1)}},getAppCustomPlugins:function(t){var e=this,i=function(){e.customPluginsComplete=!0};t.config?this.getPlugins(t.config.UIpluginsData).then(function(n){e.parsePlugins(n,!0),e.getPlugins(t.UIplugins,function(t){return fetch(t.url).then(function(t){return t.ok?t.text():Promise.reject()}).then(function(e){return t.code=e,e})}).then(i,i)},i):i()}},Common.Controllers.Plugins||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/ReviewChange",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.ReviewChange=e.Model.extend({defaults:{uid:0,userid:0,username:"Guest",usercolor:null,date:void 0,changetext:"",lock:!1,lockuser:"",type:0,changedata:null,hint:!1,editable:!1,id:Common.UI.getId(),scope:null}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/ReviewChanges",["underscore","backbone","common/main/lib/model/ReviewChange"],function(t,e){"use strict";Common.Collections.ReviewChanges=e.Collection.extend({model:Common.Models.ReviewChange})}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/ReviewChanges",["common/main/lib/util/utils","common/main/lib/component/Button","common/main/lib/component/DataView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(){"use strict";Common.Views.ReviewChanges=Common.UI.BaseView.extend(_.extend(function(){function t(t,e){this.appConfig.canReview&&(Common.NotificationCenter.trigger("reviewchanges:turn",t.pressed?"on":"off"),Common.NotificationCenter.trigger("edit:complete"))}function e(){var e=this;e.appConfig.canReview&&(this.btnAccept.on("click",function(t){e.fireEvent("reviewchange:accept",[e.btnAccept,"current"])}),this.btnAccept.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchange:accept",[t,i])}),this.btnReject.on("click",function(t){e.fireEvent("reviewchange:reject",[e.btnReject,"current"])}),this.btnReject.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchange:reject",[t,i])}),this.btnsTurnReview.forEach(function(i){i.on("click",t.bind(e))})),this.appConfig.canViewReview&&(this.btnPrev.on("click",function(t){e.fireEvent("reviewchange:preview",[e.btnPrev,"prev"])}),this.btnNext.on("click",function(t){e.fireEvent("reviewchange:preview",[e.btnNext,"next"])}),this.btnReviewView&&this.btnReviewView.menu.on("item:click",function(t,i,n){e.fireEvent("reviewchanges:view",[t,i])})),this.btnsSpelling.forEach(function(t){t.on("click",function(t,i){Common.NotificationCenter.trigger("spelling:turn",t.pressed?"on":"off"),Common.NotificationCenter.trigger("edit:complete",e)})}),this.btnsDocLang.forEach(function(t){t.on("click",function(t,i){e.fireEvent("lang:document",this)})}),this.btnSharing&&this.btnSharing.on("click",function(t,e){Common.NotificationCenter.trigger("collaboration:sharing")}),this.btnCoAuthMode&&this.btnCoAuthMode.menu.on("item:click",function(t,i,n){e.fireEvent("collaboration:coauthmode",[t,i])}),this.btnHistory&&this.btnHistory.on("click",function(t,e){Common.NotificationCenter.trigger("collaboration:history")}),this.btnChat&&this.btnChat.on("click",function(t,i){e.fireEvent("collaboration:chat",[t.pressed])})}return{options:{},initialize:function(t){if(Common.UI.BaseView.prototype.initialize.call(this,t),this.appConfig=t.mode,this.appConfig.canReview&&(this.btnAccept=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",caption:this.txtAccept,split:!0,iconCls:"review-save"}),this.btnReject=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",caption:this.txtReject,split:!0,iconCls:"review-deny"}),this.btnTurnOn=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-review",caption:this.txtTurnon,enableToggle:!0}),this.btnsTurnReview=[this.btnTurnOn]),this.appConfig.canViewReview&&(this.btnPrev=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"review-prev",caption:this.txtPrev}),this.btnNext=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"review-next",caption:this.txtNext}),!this.appConfig.isRestrictedEdit)){var e=_.template('
<%= caption %>
<% if (options.description !== null) { %><% } %>
');this.btnReviewView=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-reviewview",caption:this.txtView,menu:new Common.UI.Menu({cls:"ppm-toolbar",items:[{caption:this.txtMarkupCap,checkable:!0,toggleGroup:"menuReviewView",checked:!0,value:"markup",template:e,description:this.txtMarkup},{caption:this.txtFinalCap,checkable:!0,toggleGroup:"menuReviewView",checked:!1,template:e,description:this.txtFinal,value:"final"},{caption:this.txtOriginalCap,checkable:!0,toggleGroup:"menuReviewView",checked:!1,template:e,description:this.txtOriginal,value:"original"}]})})}this.appConfig.sharingSettingsUrl&&this.appConfig.sharingSettingsUrl.length&&!0!==this._readonlyRights&&(this.btnSharing=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-sharing",caption:this.txtSharing})),this.appConfig.isEdit&&!this.appConfig.isOffline&&this.appConfig.canCoAuthoring&&(this.btnCoAuthMode=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-coedit",caption:this.txtCoAuthMode,menu:!0})),this.btnsSpelling=[],this.btnsDocLang=[],this.appConfig.canUseHistory&&!this.appConfig.isDisconnected&&(this.btnHistory=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-history",caption:this.txtHistory})),this.appConfig.canCoAuthoring&&this.appConfig.canChat&&(this.btnChat=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-chat",caption:this.txtChat,enableToggle:!0}));var i=Common.localStorage.getKeysFilter();this.appPrefix=i&&i.length?i.split(",")[0]:"",Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this.boxSdk=$("#editor_sdk"),t&&t.html(this.getPanel()),this},onAppReady:function(t){var i=this;new Promise(function(t,e){t()}).then(function(){var n=_.template('
<%= caption %>
<% if (options.description !== null) { %><% } %>
');if(t.canReview&&(i.btnTurnOn.updateHint(i.tipReview),i.btnAccept.setMenu(new Common.UI.Menu({items:[{caption:i.txtAcceptCurrent,value:"current"},{caption:i.txtAcceptAll,value:"all"}]})),i.btnAccept.updateHint([i.tipAcceptCurrent,i.txtAcceptChanges]),i.btnReject.setMenu(new Common.UI.Menu({items:[{caption:i.txtRejectCurrent,value:"current"},{caption:i.txtRejectAll,value:"all"}]})),i.btnReject.updateHint([i.tipRejectCurrent,i.txtRejectChanges]),i.btnAccept.setDisabled(t.isReviewOnly),i.btnReject.setDisabled(t.isReviewOnly)),i.appConfig.canViewReview&&(i.btnPrev.updateHint(i.hintPrev),i.btnNext.updateHint(i.hintNext),i.btnReviewView&&i.btnReviewView.updateHint(i.tipReviewView)),i.btnSharing&&i.btnSharing.updateHint(i.tipSharing),i.btnHistory&&i.btnHistory.updateHint(i.tipHistory),i.btnChat&&i.btnChat.updateHint(i.txtChat+Common.Utils.String.platformKey("Alt+Q")),i.btnCoAuthMode){i.btnCoAuthMode.setMenu(new Common.UI.Menu({cls:"ppm-toolbar",style:"max-width: 220px;",items:[{caption:i.strFast,checkable:!0,toggleGroup:"menuCoauthMode",checked:!0,template:n,description:i.strFastDesc,value:1},{caption:i.strStrict,checkable:!0,toggleGroup:"menuCoauthMode",checked:!1,template:n,description:i.strStrictDesc,value:0}]})),i.btnCoAuthMode.updateHint(i.tipCoAuthMode);var o=Common.localStorage.getItem(i.appPrefix+"settings-coauthmode");null===o&&!Common.localStorage.itemExists(i.appPrefix+"settings-autosave")&&t.customization&&!1===t.customization.autosave&&(o=0),i.turnCoAuthMode((null===o||1==parseInt(o))&&!(t.isDesktopApp&&t.isOffline)&&t.canCoAuthoring)}var s,a=i.btnSharing||i.btnCoAuthMode?".separator.sharing":i.$el.find(".separator.sharing"),l=t.canComments&&t.canCoAuthoring?".separator.comments":i.$el.find(".separator.comments"),r=t.canReview||t.canViewReview?".separator.review":i.$el.find(".separator.review"),c=i.btnChat?".separator.chat":i.$el.find(".separator.chat");"object"==typeof a?a.hide().prev(".group").hide():s=a,"object"==typeof l?l.hide().prev(".group").hide():s=l,"object"==typeof r?r.hide().prevUntil(".separator.comments").hide():s=r,"object"==typeof c?c.hide().prev(".group").hide():s=c,!i.btnHistory&&s&&i.$el.find(s).hide(),Common.NotificationCenter.trigger("tab:visible","review",t.isEdit||t.canViewReview),e.call(i)})},getPanel:function(){return this.$el=$(_.template('
')({})),this.appConfig.canReview&&(this.btnAccept.render(this.$el.find("#btn-change-accept")),this.btnReject.render(this.$el.find("#btn-change-reject")),this.btnTurnOn.render(this.$el.find("#btn-review-on"))),this.btnPrev&&this.btnPrev.render(this.$el.find("#btn-change-prev")),this.btnNext&&this.btnNext.render(this.$el.find("#btn-change-next")),this.btnReviewView&&this.btnReviewView.render(this.$el.find("#btn-review-view")),this.btnSharing&&this.btnSharing.render(this.$el.find("#slot-btn-sharing")),this.btnCoAuthMode&&this.btnCoAuthMode.render(this.$el.find("#slot-btn-coauthmode")),this.btnHistory&&this.btnHistory.render(this.$el.find("#slot-btn-history")),this.btnChat&&this.btnChat.render(this.$el.find("#slot-btn-chat")),this.$el},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButton:function(t,e){if("turn"==t&&"statusbar"==e){var i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-review",hintAnchor:"top",hint:this.tipReview,enableToggle:!0});return this.btnsTurnReview.push(i),i}return"spelling"==t?(i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-docspell",hintAnchor:"top",hint:this.tipSetSpelling,enableToggle:!0}),this.btnsSpelling.push(i),i):"doclang"==t&&"statusbar"==e?(i=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-ic-doclang",hintAnchor:"top",hint:this.tipSetDocLang,disabled:!0}),this.btnsDocLang.push(i),i):void 0},getUserName:function(t){return Common.Utils.String.htmlEncode(t)},turnChanges:function(t){this.btnsTurnReview.forEach(function(e){e&&e.pressed!=t&&e.toggle(t,!0)},this)},markChanges:function(t){this.btnsTurnReview.forEach(function(e){if(e){$(".icon",e.cmpEl)[t?"addClass":"removeClass"]("btn-ic-changes")}},this)},turnSpelling:function(t){this.btnsSpelling.forEach(function(e){e&&e.pressed!=t&&e.toggle(t,!0)},this)},turnCoAuthMode:function(t){this.btnCoAuthMode&&(this.btnCoAuthMode.menu.items[0].setChecked(t,!0),this.btnCoAuthMode.menu.items[1].setChecked(!t,!0))},turnChat:function(t){this.btnChat&&this.btnChat.toggle(t,!0)},turnDisplayMode:function(t){this.btnReviewView&&(this.btnReviewView.menu.items[0].setChecked("markup"==t,!0),this.btnReviewView.menu.items[1].setChecked("final"==t,!0),this.btnReviewView.menu.items[2].setChecked("original"==t,!0))},SetDisabled:function(t,e){this.btnsSpelling&&this.btnsSpelling.forEach(function(e){e&&e.setDisabled(t)},this),this.btnsDocLang&&this.btnsDocLang.forEach(function(i){i&&i.setDisabled(t||e&&e.length<1)},this),this.btnsTurnReview&&this.btnsTurnReview.forEach(function(e){e&&e.setDisabled(t)},this),this.btnChat&&this.btnChat.setDisabled(t)},onLostEditRights:function(){this._readonlyRights=!0,this.rendered&&this.btnSharing&&this.btnSharing.setDisabled(!0)},txtAccept:"Accept",txtAcceptCurrent:"Accept current Changes",txtAcceptAll:"Accept all Changes",txtReject:"Reject",txtRejectCurrent:"Reject current Changes",txtRejectAll:"Reject all Changes",hintNext:"To Next Change",hintPrev:"To Previous Change",txtPrev:"Previous",txtNext:"Next",txtTurnon:"Turn On",txtSpelling:"Spell checking",txtDocLang:"Language",tipSetDocLang:"Set Document Language",tipSetSpelling:"Spell checking",tipReview:"Review",txtAcceptChanges:"Accept Changes",txtRejectChanges:"Reject Changes",txtView:"Display Mode",txtMarkup:"Text with changes (Editing)",txtFinal:"All changes like accept (Preview)",txtOriginal:"Text without changes (Preview)",tipReviewView:"Select the way you want the changes to be displayed",tipAcceptCurrent:"Accept current changes",tipRejectCurrent:"Reject current changes",txtSharing:"Sharing",tipSharing:"Manage document access rights",txtCoAuthMode:"Co-editing Mode",tipCoAuthMode:"Set co-editing mode",strFast:"Fast",strStrict:"Strict",txtHistory:"Version History",tipHistory:"Show version history",txtChat:"Chat",txtMarkupCap:"Markup",txtFinalCap:"Final",txtOriginalCap:"Original",strFastDesc:"Real-time co-editing. All changes are saved automatically.",strStrictDesc:"Use the 'Save' button to sync the changes you and others make."}}(),Common.Views.ReviewChanges||{})),Common.Views.ReviewChangesDialog=Common.UI.Window.extend(_.extend({options:{width:330,height:90,title:"Review Changes",modal:!1,cls:"review-changes modal-dlg",alias:"Common.Views.ReviewChangesDialog"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
','
','
','
','
','
',"
","
"].join(""),this.options.tpl=_.template(this.template)(this.options),this.popoverChanges=this.options.popoverChanges,this.mode=this.options.mode,Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this),this.btnPrev=new Common.UI.Button({cls:"dlg-btn iconic",iconCls:"img-commonctrl prev",hint:this.txtPrev,hintAnchor:"top"}),this.btnPrev.render(this.$window.find("#id-review-button-prev")),this.btnNext=new Common.UI.Button({cls:" dlg-btn iconic",iconCls:"img-commonctrl next",hint:this.txtNext,hintAnchor:"top"}),this.btnNext.render(this.$window.find("#id-review-button-next")),this.btnAccept=new Common.UI.Button({cls:"btn-toolbar",caption:this.txtAccept,split:!0,disabled:this.mode.isReviewOnly,menu:new Common.UI.Menu({items:[this.mnuAcceptCurrent=new Common.UI.MenuItem({caption:this.txtAcceptCurrent,value:"current"}),this.mnuAcceptAll=new Common.UI.MenuItem({caption:this.txtAcceptAll,value:"all"})]})}),this.btnAccept.render(this.$window.find("#id-review-button-accept")),this.btnReject=new Common.UI.Button({cls:"btn-toolbar",caption:this.txtReject,split:!0,disabled:this.mode.isReviewOnly,menu:new Common.UI.Menu({items:[this.mnuRejectCurrent=new Common.UI.MenuItem({caption:this.txtRejectCurrent,value:"current"}),this.mnuRejectAll=new Common.UI.MenuItem({caption:this.txtRejectAll,value:"all"})]})}),this.btnReject.render(this.$window.find("#id-review-button-reject"));var t=this;return this.btnPrev.on("click",function(e){t.fireEvent("reviewchange:preview",[t.btnPrev,"prev"])}),this.btnNext.on("click",function(e){t.fireEvent("reviewchange:preview",[t.btnNext,"next"])}),this.btnAccept.on("click",function(e){t.fireEvent("reviewchange:accept",[t.btnAccept,"current"])}),this.btnAccept.menu.on("item:click",function(e,i,n){t.fireEvent("reviewchange:accept",[e,i])}),this.btnReject.on("click",function(e){t.fireEvent("reviewchange:reject",[t.btnReject,"current"])}), +this.btnReject.menu.on("item:click",function(e,i,n){t.fireEvent("reviewchange:reject",[e,i])}),this},textTitle:"Review Changes",txtPrev:"To previous change",txtNext:"To next change",txtAccept:"Accept",txtAcceptCurrent:"Accept Current Change",txtAcceptAll:"Accept All Changes",txtReject:"Reject",txtRejectCurrent:"Reject Current Change",txtRejectAll:"Reject All Changes"},Common.Views.ReviewChangesDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/LanguageDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.LanguageDialog=Common.UI.Window.extend(_.extend({options:{header:!1,width:350,cls:"modal-dlg"},template:'
',initialize:function(t){_.extend(this.options,t||{},{label:this.labelSelect,btns:{ok:this.btnOk,cancel:this.btnCancel}}),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this.getChild();t.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.cmbLanguage=new Common.UI.ComboBox({el:t.find("#id-document-language"),cls:"input-group-nr",menuStyle:"min-width: 318px; max-height: 285px;",editable:!1,template:_.template(['','','','','",""].join("")),data:this.options.languages,search:!0}),this.cmbLanguage.scroller&&this.cmbLanguage.scroller.update({alwaysVisibleY:!0}),this.cmbLanguage.on("selected",_.bind(this.onLangSelect,this));var e=Common.util.LanguageInfo.getLocalLanguageName(this.options.current);this.cmbLanguage.setValue(e[0],e[1]),this.onLangSelect(this.cmbLanguage,this.cmbLanguage.getSelectedRecord())},close:function(t){this.getChild().find(".combobox.open").length||Common.UI.Window.prototype.close.call(this,arguments)},onBtnClick:function(t){this.options.handler&&this.options.handler.call(this,t.currentTarget.attributes.result.value,this.cmbLanguage.getValue()),this.close()},onLangSelect:function(t,e,i){t.$el.find(".input-icon").toggleClass("spellcheck-lang",e&&e.spellcheck),t._input.css("padding-left",e&&e.spellcheck?25:3)},onPrimary:function(){return this.options.handler&&this.options.handler.call(this,"ok",this.cmbLanguage.getValue()),this.close(),!1},labelSelect:"Select document language",btnCancel:"Cancel",btnOk:"Ok"},Common.Views.LanguageDialog||{}))}),void 0===Common)var Common={};if(Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/ReviewChanges",["core","common/main/lib/model/ReviewChange","common/main/lib/collection/ReviewChanges","common/main/lib/view/ReviewChanges","common/main/lib/view/ReviewPopover","common/main/lib/view/LanguageDialog"],function(){"use strict";Common.Controllers.ReviewChanges=Backbone.Controller.extend(_.extend({models:[],collections:["Common.Collections.ReviewChanges"],views:["Common.Views.ReviewChanges","Common.Views.ReviewPopover"],sdkViewName:"#id_main",initialize:function(){this.addListeners({FileMenu:{"settings:apply":this.applySettings.bind(this)},"Common.Views.ReviewChanges":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:delete":_.bind(this.onDeleteClick,this),"reviewchange:preview":_.bind(this.onBtnPreviewClick,this),"reviewchanges:view":_.bind(this.onReviewViewClick,this),"lang:document":_.bind(this.onDocLanguage,this),"collaboration:coauthmode":_.bind(this.onCoAuthMode,this)},"Common.Views.ReviewChangesDialog":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:preview":_.bind(this.onBtnPreviewClick,this)},"Common.Views.ReviewPopover":{"reviewchange:accept":_.bind(this.onAcceptClick,this),"reviewchange:reject":_.bind(this.onRejectClick,this),"reviewchange:delete":_.bind(this.onDeleteClick,this),"reviewchange:goto":_.bind(this.onGotoClick,this)}})},onLaunch:function(){this.collection=this.getApplication().getCollection("Common.Collections.ReviewChanges"),this.userCollection=this.getApplication().getCollection("Common.Collections.Users"),this._state={posx:-1e3,posy:-1e3,popoverVisible:!1,previewMode:!1},Common.NotificationCenter.on("reviewchanges:turn",this.onTurnPreview.bind(this)),Common.NotificationCenter.on("spelling:turn",this.onTurnSpelling.bind(this)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this)),this.userCollection.on("reset",_.bind(this.onUpdateUsers,this)),this.userCollection.on("add",_.bind(this.onUpdateUsers,this))},setConfig:function(t,e){this.setApi(e),t&&(this.currentUserId=t.config.user.id,this.sdkViewName=t.sdkviewname||this.sdkViewName)},setApi:function(t){t&&(this.api=t,(this.appConfig.canReview||this.appConfig.canViewReview)&&(this.api.asc_registerCallback("asc_onShowRevisionsChange",_.bind(this.onApiShowChange,this)),this.api.asc_registerCallback("asc_onUpdateRevisionsChangesPosition",_.bind(this.onApiUpdateChangePosition,this))),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)))},setMode:function(t){return this.appConfig=t,this.popoverChanges=new Common.Collections.ReviewChanges,this.view=this.createView("Common.Views.ReviewChanges",{mode:t}),this},SetDisabled:function(t){this.dlgChanges&&this.dlgChanges.close(),this.view&&this.view.SetDisabled(t,this.langs),this.setPreviewMode(t)},setPreviewMode:function(t){if(this.viewmode!==t){this.viewmode=t,t&&(this.prevcanReview=this.appConfig.canReview),this.appConfig.canReview=!t&&this.prevcanReview;var e=this;this.popoverChanges&&this.popoverChanges.each(function(t){t.set("hint",!e.appConfig.canReview)})}},onApiShowChange:function(t){if(this.getPopover())if(t&&t.length>0){var e=this.readSDKChange(t),i=t[0].get_X(),n=t[0].get_Y(),o=Math.abs(this._state.posx-i)>.001||Math.abs(this._state.posy-n)>.001||t.length!==this._state.changes_length,s=null!==t[0].get_LockUserId(),a=this.getUserName(t[0].get_LockUserId());this.getPopover().hideTips(),this.popoverChanges.reset(e),o&&(this.getPopover().isVisible()&&this.getPopover().hide(),this.getPopover().setLeftTop(i,n)),this.getPopover().showReview(o,s,a),this.appConfig.canReview&&!this.appConfig.isReviewOnly&&this._state.lock!==s&&(this.view.btnAccept.setDisabled(1==s),this.view.btnReject.setDisabled(1==s),this.dlgChanges&&(this.dlgChanges.btnAccept.setDisabled(1==s),this.dlgChanges.btnReject.setDisabled(1==s)),this._state.lock=s),this._state.posx=i,this._state.posy=n,this._state.changes_length=t.length,this._state.popoverVisible=!0}else this._state.popoverVisible&&(this._state.posx=this._state.posy=-1e3,this._state.changes_length=0,this._state.popoverVisible=!1,this.getPopover().hideTips(),this.popoverChanges.reset(),this.getPopover().hideReview())},onApiUpdateChangePosition:function(t,e){this.getPopover()&&(e<0||this.getPopover().sdkBounds.height0&&(this.getPopover().isVisible()||this.getPopover().show(!1),this.getPopover().setLeftTop(t,e)))},findChange:function(t,e){return _.isUndefined(t)?this.collection.findWhere({id:e}):this.collection.findWhere({uid:t})},getPopover:function(){return(this.appConfig.canReview||this.appConfig.canViewReview)&&_.isUndefined(this.popover)&&(this.popover=Common.Views.ReviewPopover.prototype.getPopover({reviewStore:this.popoverChanges,renderTo:this.sdkViewName}),this.popover.setReviewStore(this.popoverChanges)),this.popover},readSDKChange:function(t){var e=this,i=[];return _.each(t,function(t){var n="",o="",s=t.get_Value(),a=t.get_MoveType();switch(t.get_Type()){case Asc.c_oAscRevisionsChangeType.TextAdd:n=a==Asc.c_oAscRevisionsMove.NoMove?e.textInserted:e.textParaMoveTo,"object"==typeof s?_.each(s,function(t){if("string"==typeof t)n+=" "+Common.Utils.String.htmlEncode(t);else switch(t){case 0:n+=" <"+e.textImage+">";break;case 1:n+=" <"+e.textShape+">";break;case 2:n+=" <"+e.textChart+">";break;case 3:n+=" <"+e.textEquation+">"}}):"string"==typeof s&&(n+=" "+Common.Utils.String.htmlEncode(s));break;case Asc.c_oAscRevisionsChangeType.TextRem:n=a==Asc.c_oAscRevisionsMove.NoMove?e.textDeleted:t.is_MovedDown()?e.textParaMoveFromDown:e.textParaMoveFromUp,"object"==typeof s?_.each(s,function(t){if("string"==typeof t)n+=" "+Common.Utils.String.htmlEncode(t);else switch(t){case 0:n+=" <"+e.textImage+">";break;case 1:n+=" <"+e.textShape+">";break;case 2:n+=" <"+e.textChart+">";break;case 3:n+=" <"+e.textEquation+">"}}):"string"==typeof s&&(n+=" "+Common.Utils.String.htmlEncode(s));break;case Asc.c_oAscRevisionsChangeType.ParaAdd:n=e.textParaInserted;break;case Asc.c_oAscRevisionsChangeType.ParaRem:n=e.textParaDeleted;break;case Asc.c_oAscRevisionsChangeType.TextPr:n=""+e.textFormatted,void 0!==s.Get_Bold()&&(o+=(s.Get_Bold()?"":e.textNot)+e.textBold+", "),void 0!==s.Get_Italic()&&(o+=(s.Get_Italic()?"":e.textNot)+e.textItalic+", "),void 0!==s.Get_Underline()&&(o+=(s.Get_Underline()?"":e.textNot)+e.textUnderline+", "),void 0!==s.Get_Strikeout()&&(o+=(s.Get_Strikeout()?"":e.textNot)+e.textStrikeout+", "),void 0!==s.Get_DStrikeout()&&(o+=(s.Get_DStrikeout()?"":e.textNot)+e.textDStrikeout+", "),void 0!==s.Get_Caps()&&(o+=(s.Get_Caps()?"":e.textNot)+e.textCaps+", "),void 0!==s.Get_SmallCaps()&&(o+=(s.Get_SmallCaps()?"":e.textNot)+e.textSmallCaps+", "),void 0!==s.Get_VertAlign()&&(o+=(1==s.Get_VertAlign()?e.textSuperScript:2==s.Get_VertAlign()?e.textSubScript:e.textBaseline)+", "),void 0!==s.Get_Color()&&(o+=e.textColor+", "),void 0!==s.Get_Highlight()&&(o+=e.textHighlight+", "),void 0!==s.Get_Shd()&&(o+=e.textShd+", "),void 0!==s.Get_FontFamily()&&(o+=s.Get_FontFamily()+", "),void 0!==s.Get_FontSize()&&(o+=s.Get_FontSize()+", "),void 0!==s.Get_Spacing()&&(o+=e.textSpacing+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_Spacing()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Position()&&(o+=e.textPosition+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_Position()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Lang()&&(o+=Common.util.LanguageInfo.getLocalLanguageName(s.Get_Lang())[1]+", "),_.isEmpty(o)||(n+=": ",o=o.substring(0,o.length-2)),n+="",n+=o;break;case Asc.c_oAscRevisionsChangeType.ParaPr:if(n=""+e.textParaFormatted,s.Get_ContextualSpacing()&&(o+=(s.Get_ContextualSpacing()?e.textContextual:e.textNoContextual)+", "),void 0!==s.Get_IndLeft()&&(o+=e.textIndentLeft+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndLeft()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_IndRight()&&(o+=e.textIndentRight+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndRight()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_IndFirstLine()&&(o+=e.textFirstLine+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_IndFirstLine()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),void 0!==s.Get_Jc())switch(s.Get_Jc()){case 0:o+=e.textRight+", ";break;case 1:o+=e.textLeft+", ";break;case 2:o+=e.textCenter+", ";break;case 3:o+=e.textJustify+", "}if(void 0!==s.Get_KeepLines()&&(o+=(s.Get_KeepLines()?e.textKeepLines:e.textNoKeepLines)+", "),s.Get_KeepNext()&&(o+=(s.Get_KeepNext()?e.textKeepNext:e.textNoKeepNext)+", "),s.Get_PageBreakBefore()&&(o+=(s.Get_PageBreakBefore()?e.textBreakBefore:e.textNoBreakBefore)+", "),void 0!==s.Get_SpacingLineRule()&&void 0!==s.Get_SpacingLine()&&(o+=e.textLineSpacing,o+=(s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_LEAST?e.textAtLeast:s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_AUTO?e.textMultiple:e.textExact)+" ",o+=(s.Get_SpacingLineRule()==c_paragraphLinerule.LINERULE_AUTO?s.Get_SpacingLine():Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingLine()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName())+", "),s.Get_SpacingBeforeAutoSpacing()?o+=e.textSpacingBefore+" "+e.textAuto+", ":void 0!==s.Get_SpacingBefore()&&(o+=e.textSpacingBefore+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingBefore()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),s.Get_SpacingAfterAutoSpacing()?o+=e.textSpacingAfter+" "+e.textAuto+", ":void 0!==s.Get_SpacingAfter()&&(o+=e.textSpacingAfter+" "+Common.Utils.Metric.fnRecalcFromMM(s.Get_SpacingAfter()).toFixed(2)+" "+Common.Utils.Metric.getCurrentMetricName()+", "),s.Get_WidowControl()&&(o+=(s.Get_WidowControl()?e.textWidow:e.textNoWidow)+", "),void 0!==s.Get_Tabs()&&(o+=o+=e.textTabs+", "),void 0!==s.Get_NumPr()&&(o+=o+=e.textNum+", "),void 0!==s.Get_PStyle()){var l=e.api.asc_GetStyleNameById(s.Get_PStyle());_.isEmpty(l)||(o+=l+", ")}_.isEmpty(o)||(n+=": ",o=o.substring(0,o.length-2)),n+="",n+=o;break;case Asc.c_oAscRevisionsChangeType.TablePr:n=e.textTableChanged;break;case Asc.c_oAscRevisionsChangeType.RowsAdd:n=e.textTableRowsAdd;break;case Asc.c_oAscRevisionsChangeType.RowsRem:n=e.textTableRowsDel}var r=""==t.get_DateTime()?new Date:new Date(t.get_DateTime()),c=e.userCollection.findOriginalUser(t.get_UserId()),h=new Common.Models.ReviewChange({uid:Common.UI.getId(),userid:t.get_UserId(),username:t.get_UserName(),usercolor:c?c.get("color"):null,date:e.dateToLocaleTimeString(r),changetext:n,id:Common.UI.getId(),lock:null!==t.get_LockUserId(),lockuser:e.getUserName(t.get_LockUserId()),type:t.get_Type(),changedata:t,scope:e.view,hint:!e.appConfig.canReview,goto:t.get_MoveType()==Asc.c_oAscRevisionsMove.MoveTo||t.get_MoveType()==Asc.c_oAscRevisionsMove.MoveFrom,editable:t.get_UserId()==e.currentUserId});i.push(h)}),i},getUserName:function(t){if(this.userCollection&&null!==t){var e=this.userCollection.findUser(t);if(e)return e.get("username")}return""},dateToLocaleTimeString:function(t){return t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear()+" "+function(t){var e=t.getHours(),i=t.getMinutes(),n=e>=12?"pm":"am";return e%=12,e=e||12,i=i<10?"0"+i:i,e+":"+i+" "+n}(t)},onBtnPreviewClick:function(t,e){switch(e){case"prev":this.api.asc_GetPrevRevisionsChange();break;case"next":this.api.asc_GetNextRevisionsChange()}Common.NotificationCenter.trigger("edit:complete",this.view)},onAcceptClick:function(t,e,i){this.api&&(e?"all"===e.value?this.api.asc_AcceptAllChanges():this.api.asc_AcceptChanges():this.api.asc_AcceptChanges(t)),Common.NotificationCenter.trigger("edit:complete",this.view)},onRejectClick:function(t,e,i){this.api&&(e?"all"===e.value?this.api.asc_RejectAllChanges():this.api.asc_RejectChanges():this.api.asc_RejectChanges(t)),Common.NotificationCenter.trigger("edit:complete",this.view)},onDeleteClick:function(t){this.api&&this.api.asc_RejectChanges(t),Common.NotificationCenter.trigger("edit:complete",this.view)},onGotoClick:function(t){this.api&&this.api.asc_FollowRevisionMove(t),Common.NotificationCenter.trigger("edit:complete",this.view)},onTurnPreview:function(t){this.appConfig.isReviewOnly?this.view.turnChanges(!0):this.appConfig.canReview&&(t="on"==t,this.api.asc_SetTrackRevisions(t),Common.localStorage.setItem(this.view.appPrefix+"track-changes-"+(this.appConfig.fileKey||""),t?1:0),this.view.turnChanges(t))},onTurnSpelling:function(t){t="on"==t,this.view.turnSpelling(t),Common.localStorage.setItem(this.view.appPrefix+"settings-spellcheck",t?1:0),this.api.asc_setSpellCheck(t),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-spellcheck",t)},onReviewViewClick:function(t,e,i){this.turnDisplayMode(e.value),!this.appConfig.canReview&&Common.localStorage.setItem(this.view.appPrefix+"review-mode",e.value),Common.NotificationCenter.trigger("edit:complete",this.view)},turnDisplayMode:function(t){this.api&&("final"===t?this.api.asc_BeginViewModeInReview(!0):"original"===t?this.api.asc_BeginViewModeInReview(!1):this.api.asc_EndViewModeInReview()),this.disableEditing("final"==t||"original"==t),this._state.previewMode="final"==t||"original"==t},isPreviewChangesMode:function(){return this._state.previewMode},onCoAuthMode:function(t,e,i){if(Common.localStorage.setItem(this.view.appPrefix+"settings-coauthmode",e.value),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-coauthmode",e.value),this.api){if(this.api.asc_SetFastCollaborative(1==e.value),this.api.SetCollaborativeMarksShowType){var n=Common.localStorage.getItem(e.value?this.view.appPrefix+"settings-showchanges-fast":this.view.appPrefix+"settings-showchanges-strict");null!==n?this.api.SetCollaborativeMarksShowType("all"==n?Asc.c_oAscCollaborativeMarksShowType.All:"none"==n?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges):this.api.SetCollaborativeMarksShowType(e.value?Asc.c_oAscCollaborativeMarksShowType.None:Asc.c_oAscCollaborativeMarksShowType.LastChanges)}n=Common.localStorage.getItem(this.view.appPrefix+"settings-autosave"),null===n&&this.appConfig.customization&&!1===this.appConfig.customization.autosave&&(n=0),n=e.value||null===n?1:parseInt(n),Common.localStorage.setItem(this.view.appPrefix+"settings-autosave",n),Common.Utils.InternalSettings.set(this.view.appPrefix+"settings-autosave",n),this.api.asc_setAutoSaveGap(n)}Common.NotificationCenter.trigger("edit:complete",this.view),this.view.fireEvent("settings:apply",[this])},disableEditing:function(t){var e=this.getApplication();e.getController("Toolbar").DisableToolbar(t,!1,!0),e.getController("DocumentHolder").getView().SetDisabled(t),this.appConfig.canReview&&(e.getController("RightMenu").getView("RightMenu").clearSelection(),e.getController("RightMenu").SetDisabled(t,!1),e.getController("Statusbar").getView("Statusbar").SetDisabled(t),e.getController("Navigation")&&e.getController("Navigation").SetDisabled(t),e.getController("Common.Controllers.Plugins").getView("Common.Views.Plugins").disableControls(t));var i=e.getController("Common.Controllers.Comments");i&&i.setPreviewMode(t);var n=e.getController("LeftMenu");n.leftMenu.getMenu("file").miProtect.setDisabled(t),n.setPreviewMode(t),this.view&&(this.view.$el.find(".no-group-mask").css("opacity",1),this.view.btnsDocLang&&this.view.btnsDocLang.forEach(function(e){e&&e.setDisabled(t||!this.langs||this.langs.length<1)},this))},createToolbarPanel:function(){return this.view.getPanel()},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onAppReady:function(t){var e=this;if(e.view&&Common.localStorage.getBool(e.view.appPrefix+"settings-spellcheck",!0)&&e.view.turnSpelling(!0),t.canReview)new Promise(function(t){t()}).then(function(){var i=t.isReviewOnly||Common.localStorage.getBool(e.view.appPrefix+"track-changes-"+(t.fileKey||""));if(e.api.asc_HaveRevisionsChanges()&&e.view.markChanges(!0),function(t){e.view.turnChanges(t),e.api.asc_SetTrackRevisions(t)}(i),"object"==typeof e.appConfig.customization&&1==e.appConfig.customization.showReviewChanges){e.dlgChanges=new Common.Views.ReviewChangesDialog({popoverChanges:e.popoverChanges,mode:e.appConfig});var n=$("#editor_sdk"),o=n.offset();e.dlgChanges.show(Math.max(10,o.left+n.width()-300),Math.max(10,o.top+n.height()-150))}});else if(t.canViewReview&&(t.canViewReview=t.isEdit||e.api.asc_HaveRevisionsChanges(!0),t.canViewReview)){var i=Common.localStorage.getItem(e.view.appPrefix+"review-mode");null===i&&(i=e.appConfig.customization&&/^(original|final|markup)$/i.test(e.appConfig.customization.reviewDisplay)?e.appConfig.customization.reviewDisplay.toLocaleLowerCase():"original"),e.turnDisplayMode(t.isEdit||t.isRestrictedEdit?"markup":i),e.view.turnDisplayMode(t.isEdit||t.isRestrictedEdit?"markup":i)}e.view&&e.view.btnChat&&e.getApplication().getController("LeftMenu").leftMenu.btnChat.on("toggle",function(t,i){i!==e.view.btnChat.pressed&&e.view.turnChat(i)})},applySettings:function(t){this.view&&this.view.turnSpelling(Common.localStorage.getBool(this.view.appPrefix+"settings-spellcheck",!0)),this.view&&this.view.turnCoAuthMode(Common.localStorage.getBool(this.view.appPrefix+"settings-coauthmode",!0))},synchronizeChanges:function(){this.appConfig&&this.appConfig.canReview&&this.view.markChanges(this.api.asc_HaveRevisionsChanges())},setLanguages:function(t){this.langs=t,this.view&&this.view.btnsDocLang&&this.view.btnsDocLang.forEach(function(t){t&&t.setDisabled(this.langs.length<1)},this)},onDocLanguage:function(){var t=this;new Common.Views.LanguageDialog({languages:t.langs,current:t.api.asc_getDefaultLanguage(),handler:function(e,i){if("ok"==e){var n=_.findWhere(t.langs,{value:i});n&&t.api.asc_setDefaultLanguage(n.code)}}}).show()},onLostEditRights:function(){this.view&&this.view.onLostEditRights()},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)},onUpdateUsers:function(){var t=this.userCollection;this.popoverChanges&&this.popoverChanges.each(function(e){var i=t.findOriginalUser(e.get("userid"));e.set("usercolor",i?i.get("color"):null)})},textInserted:"Inserted:",textDeleted:"Deleted:",textParaInserted:"Paragraph Inserted ",textParaDeleted:"Paragraph Deleted ",textFormatted:"Formatted",textParaFormatted:"Paragraph Formatted",textNot:"Not ",textBold:"Bold",textItalic:"Italic",textStrikeout:"Strikeout",textUnderline:"Underline",textColor:"Font color",textBaseline:"Baseline",textSuperScript:"Superscript",textSubScript:"Subscript",textHighlight:"Highlight color",textSpacing:"Spacing",textDStrikeout:"Double strikeout",textCaps:"All caps",textSmallCaps:"Small caps",textPosition:"Position",textFontSize:"Font size",textShd:"Background color",textContextual:"Don't add interval between paragraphs of the same style",textNoContextual:"Add interval between paragraphs of the same style",textIndentLeft:"Indent left",textIndentRight:"Indent right",textFirstLine:"First line",textRight:"Align right",textLeft:"Align left",textCenter:"Align center",textJustify:"Align justify",textBreakBefore:"Page break before",textKeepNext:"Keep with next",textKeepLines:"Keep lines together",textNoBreakBefore:"No page break before",textNoKeepNext:"Don't keep with next",textNoKeepLines:"Don't keep lines together",textLineSpacing:"Line Spacing: ",textMultiple:"multiple",textAtLeast:"at least",textExact:"exactly",textSpacingBefore:"Spacing before",textSpacingAfter:"Spacing after",textAuto:"auto",textWidow:"Widow control",textNoWidow:"No widow control",textTabs:"Change tabs",textNum:"Change numbering",textEquation:"Equation",textImage:"Image",textChart:"Chart",textShape:"Shape",textTableChanged:"Table Settings Changed",textTableRowsAdd:"Table Rows Added",textTableRowsDel:"Table Rows Deleted",textParaMoveTo:"Moved:",textParaMoveFromUp:"Moved Up:",textParaMoveFromDown:"Moved Down:"},Common.Controllers.ReviewChanges||{}))}),void 0===Common)var Common={};if(Common.Views=Common.Views||{},define("common/main/lib/view/Protection",["common/main/lib/util/utils","common/main/lib/component/BaseView","common/main/lib/component/Layout","common/main/lib/component/Window"],function(t){"use strict";Common.Views.Protection=Common.UI.BaseView.extend(_.extend(function(){function t(){var t=this;t.appConfig.isPasswordSupport&&(this.btnsAddPwd.concat(this.btnsChangePwd).forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:password",[e,"add"])})}),this.btnsDelPwd.forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:password",[e,"delete"])})}),this.btnPwd.menu.on("item:click",function(e,i,n){t.fireEvent("protect:password",[e,i.value])})),t.appConfig.isSignatureSupport&&(this.btnSignature.menu&&this.btnSignature.menu.on("item:click",function(e,i,n){t.fireEvent("protect:signature",[i.value,!1])}),this.btnsInvisibleSignature.forEach(function(e){e.on("click",function(e,i){t.fireEvent("protect:signature",["invisible"])})}))}return{options:{},initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,t),this.appConfig=t.mode,this.btnsInvisibleSignature=[],this.btnsAddPwd=[],this.btnsDelPwd=[],this.btnsChangePwd=[],this._state={disabled:!1,hasPassword:!1,disabledPassword:!1,invisibleSignDisabled:!1};var e=Common.localStorage.getKeysFilter();this.appPrefix=e&&e.length?e.split(",")[0]:"",this.appConfig.isPasswordSupport&&(this.btnAddPwd=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-protect",caption:this.txtEncrypt}),this.btnsAddPwd.push(this.btnAddPwd),this.btnPwd=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-protect",caption:this.txtEncrypt,menu:!0,visible:!1})),this.appConfig.isSignatureSupport&&(this.btnSignature=new Common.UI.Button({cls:"btn-toolbar x-huge icon-top",iconCls:"btn-ic-signature",caption:this.txtSignature,menu:"pe-"!==this.appPrefix}),this.btnSignature.menu||this.btnsInvisibleSignature.push(this.btnSignature)),Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this))},render:function(t){return this.boxSdk=$("#editor_sdk"),t&&t.html(this.getPanel()),this},onAppReady:function(e){var i=this;new Promise(function(t,e){t()}).then(function(){e.canProtect&&(e.isPasswordSupport&&(i.btnAddPwd.updateHint(i.hintAddPwd),i.btnPwd.updateHint(i.hintPwd),i.btnPwd.setMenu(new Common.UI.Menu({items:[{caption:i.txtChangePwd,value:"add"},{caption:i.txtDeletePwd,value:"delete"}]}))),i.btnSignature&&(i.btnSignature.updateHint(i.btnSignature.menu?i.hintSignature:i.txtInvisibleSignature),i.btnSignature.menu&&i.btnSignature.setMenu(new Common.UI.Menu({items:[{caption:i.txtInvisibleSignature,value:"invisible"},{caption:i.txtSignatureLine,value:"visible",disabled:i._state.disabled}]}))),Common.NotificationCenter.trigger("tab:visible","protect",!0)),t.call(i)})},getPanel:function(){return this.$el=$(_.template('
')({})),this.appConfig.canProtect&&(this.btnAddPwd&&this.btnAddPwd.render(this.$el.find("#slot-btn-add-password")),this.btnPwd&&this.btnPwd.render(this.$el.find("#slot-btn-change-password")),this.btnSignature&&this.btnSignature.render(this.$el.find("#slot-btn-signature"))),this.$el},show:function(){Common.UI.BaseView.prototype.show.call(this),this.fireEvent("show",this)},getButton:function(t,e){if("signature"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtInvisibleSignature,disabled:this._state.invisibleSignDisabled});return this.btnsInvisibleSignature.push(i),i}if("add-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtAddPwd,disabled:this._state.disabled||this._state.disabledPassword,visible:!this._state.hasPassword});return this.btnsAddPwd.push(i),i}if("del-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtDeletePwd,disabled:this._state.disabled||this._state.disabledPassword,visible:this._state.hasPassword});return this.btnsDelPwd.push(i),i}if("change-password"==t){var i=new Common.UI.Button({cls:"btn-text-default",style:"width: 100%;",caption:this.txtChangePwd,disabled:this._state.disabled||this._state.disabledPassword,visible:this._state.hasPassword});return this.btnsChangePwd.push(i),i}},SetDisabled:function(t,e){this._state.disabled=t,this._state.invisibleSignDisabled=t&&!e,this.btnsInvisibleSignature&&this.btnsInvisibleSignature.forEach(function(i){i&&i.setDisabled(t&&!e)},this),this.btnSignature&&this.btnSignature.menu&&(this.btnSignature.menu.items&&this.btnSignature.menu.items[1].setDisabled(t),this.btnSignature.setDisabled(t&&!e)),this.btnsAddPwd.concat(this.btnsDelPwd,this.btnsChangePwd).forEach(function(e){e&&e.setDisabled(t||this._state.disabledPassword)},this)},onDocumentPassword:function(t,e){this._state.hasPassword=t,this._state.disabledPassword=!!e;var i=this._state.disabledPassword||this._state.disabled;this.btnsAddPwd&&this.btnsAddPwd.forEach(function(e){e&&(e.setVisible(!t),e.setDisabled(i))},this),this.btnsDelPwd.concat(this.btnsChangePwd).forEach(function(e){e&&(e.setVisible(t),e.setDisabled(i))},this),this.btnPwd.setVisible(t)},txtEncrypt:"Encrypt",txtSignature:"Signature",hintAddPwd:"Encrypt with password",hintPwd:"Change or delete password",hintSignature:"Add digital signature or signature line",txtChangePwd:"Change password",txtDeletePwd:"Delete password",txtAddPwd:"Add password",txtInvisibleSignature:"Add digital signature",txtSignatureLine:"Add Signature line"}}(),Common.Views.Protection||{}))}),define("common/main/lib/view/PasswordDialog",["common/main/lib/component/Window"],function(){"use strict";Common.Views.PasswordDialog=Common.UI.Window.extend(_.extend({applyFunction:void 0,initialize:function(t){var e=this,i={};_.extend(i,{width:350,height:220,header:!0,cls:"modal-dlg",contentTemplate:"",title:e.txtTitle},t),this.template=t.template||['
','
',"","
",'
',"","
",'
','
',"","
",'
',"
",'
','"].join(""),this.handler=t.handler,this.settings=t.settings,i.tpl=_.template(this.template)(i),Common.UI.Window.prototype.initialize.call(this,i)},render:function(){if(Common.UI.Window.prototype.render.call(this),this.$window){var t=this;this.$window.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this)),this.inputPwd=new Common.UI.InputField({el:$("#id-password-txt"),type:"password",allowBlank:!1,style:"width: 100%;",validateOnBlur:!1}),this.repeatPwd=new Common.UI.InputField({el:$("#id-repeat-txt"),type:"password",allowBlank:!1,style:"width: 100%;",validateOnBlur:!1,validation:function(e){return t.txtIncorrectPwd}})}},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;setTimeout(function(){t.inputPwd.cmpEl.find("input").focus()},500)},onPrimary:function(t){return this._handleInput("ok"),!1},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},_handleInput:function(t){if(this.handler){if("ok"==t){if(!0!==this.inputPwd.checkValidate())return void this.inputPwd.cmpEl.find("input").focus();if(this.inputPwd.getValue()!==this.repeatPwd.getValue())return this.repeatPwd.checkValidate(),void this.repeatPwd.cmpEl.find("input").focus()}this.handler.call(this,t,this.inputPwd.getValue())}this.close()},okButtonText:"OK",cancelButtonText:"Cancel",txtTitle:"Set Password",txtPassword:"Password",txtDescription:"A Password is required to open this document", +txtRepeat:"Repeat password",txtIncorrectPwd:"Confirmation password is not identical"},Common.Views.PasswordDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/SignDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/Window","common/main/lib/component/ComboBoxFonts"],function(){"use strict";Common.Views.SignDialog=Common.UI.Window.extend(_.extend({options:{width:370,style:"min-width: 350px;",cls:"modal-dlg"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.api=this.options.api,this.signType=this.options.signType||"invisible",this.signSize=this.options.signSize||{width:0,height:0},this.certificateId=null,this.signObject=null,this.fontStore=this.options.fontStore,this.font={size:11,name:"Arial",bold:!1,italic:!1},this.template=['
','
','
',"","
",'
',"
",'
','
',"","
",'
','
','
','
','
','
',"","
",'",'
','","
",'
',"
",'',"",'","",'',"
","
",'"].join(""),this.templateCertificate=_.template(['',''].join("")),this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputPurpose=new Common.UI.InputField({el:$("#id-dlg-sign-purpose"),style:"width: 100%;"}),t.inputName=new Common.UI.InputField({el:$("#id-dlg-sign-name"),style:"width: 100%;",validateOnChange:!0}).on("changing",_.bind(t.onChangeName,t)),t.cmbFonts=new Common.UI.ComboBoxFonts({el:$("#id-dlg-sign-fonts"),cls:"input-group-nr",style:"width: 234px;",menuCls:"scrollable-menu",menuStyle:"min-width: 234px;max-height: 270px;",store:new Common.Collections.Fonts,recent:0,hint:t.tipFontName}).on("selected",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),i.name,t.font.size,t.font.italic,t.font.bold),t.font.name=i.name}),this.cmbFontSize=new Common.UI.ComboBox({el:$("#id-dlg-sign-font-size"),cls:"input-group-nr",style:"width: 55px;",menuCls:"scrollable-menu",menuStyle:"min-width: 55px;max-height: 270px;",hint:this.tipFontSize,data:[{value:8,displayValue:"8"},{value:9,displayValue:"9"},{value:10,displayValue:"10"},{value:11,displayValue:"11"},{value:12,displayValue:"12"},{value:14,displayValue:"14"},{value:16,displayValue:"16"},{value:18,displayValue:"18"},{value:20,displayValue:"20"},{value:22,displayValue:"22"},{value:24,displayValue:"24"},{value:26,displayValue:"26"},{value:28,displayValue:"28"},{value:36,displayValue:"36"},{value:48,displayValue:"48"},{value:72,displayValue:"72"},{value:96,displayValue:"96"}]}).on("selected",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,i.value,t.font.italic,t.font.bold),t.font.size=i.value}),this.cmbFontSize.setValue(this.font.size),t.btnBold=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-bold",enableToggle:!0,hint:t.textBold}),t.btnBold.render($("#id-dlg-sign-bold")),t.btnBold.on("click",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,t.font.size,t.font.italic,e.pressed),t.font.bold=e.pressed}),t.btnItalic=new Common.UI.Button({cls:"btn-toolbar",iconCls:"btn-italic",enableToggle:!0,hint:t.textItalic}),t.btnItalic.render($("#id-dlg-sign-italic")),t.btnItalic.on("click",function(e,i){t.signObject&&t.signObject.setText(t.inputName.getValue(),t.font.name,t.font.size,e.pressed,t.font.bold),t.font.italic=e.pressed}),t.btnSelectImage=new Common.UI.Button({el:"#id-dlg-sign-image"}),t.btnSelectImage.on("click",_.bind(t.onSelectImage,t)),t.btnChangeCertificate=new Common.UI.Button({el:"#id-dlg-sign-change"}),t.btnChangeCertificate.on("click",_.bind(t.onChangeCertificate,t)),t.btnOk=new Common.UI.Button({el:e.find(".primary"),disabled:!0}),t.cntCertificate=$("#id-dlg-sign-certificate"),t.cntVisibleSign=$("#id-dlg-sign-visible"),t.cntInvisibleSign=$("#id-dlg-sign-invisible"),"visible"==t.signType?t.cntInvisibleSign.addClass("hidden"):t.cntVisibleSign.addClass("hidden"),e.find(".dlg-btn").on("click",_.bind(t.onBtnClick,t)),t.afterRender()},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){("visible"==t.signType?t.inputName:t.inputPurpose).cmpEl.find("input").focus()},500)},close:function(){this.api.asc_unregisterCallback("on_signature_defaultcertificate_ret",this.binding.certificateChanged),this.api.asc_unregisterCallback("on_signature_selectsertificate_ret",this.binding.certificateChanged),Common.UI.Window.prototype.close.apply(this,arguments),this.signObject&&this.signObject.destroy()},afterRender:function(){this.api&&(this.binding||(this.binding={}),this.binding.certificateChanged=_.bind(this.onCertificateChanged,this),this.api.asc_registerCallback("on_signature_defaultcertificate_ret",this.binding.certificateChanged),this.api.asc_registerCallback("on_signature_selectsertificate_ret",this.binding.certificateChanged),this.api.asc_GetDefaultCertificate()),"visible"==this.signType&&(this.cmbFonts.fillFonts(this.fontStore),this.cmbFonts.selectRecord(this.fontStore.findWhere({name:this.font.name})||this.fontStore.at(0)),this.signObject=new AscCommon.CSignatureDrawer("signature-preview-img",this.api,this.signSize.width,this.signSize.height))},getSettings:function(){var t={};return t.certificateId=this.certificateId,"invisible"==this.signType?t.purpose=this.inputPurpose.getValue():t.images=this.signObject?this.signObject.getImages():[null,null],t},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){if(this.options.handler){if("ok"==t&&(this.btnOk.isDisabled()||this.signObject&&!this.signObject.isValid()))return;this.options.handler.call(this,this,t)}this.close()},onChangeCertificate:function(){this.api.asc_SelectCertificate()},onCertificateChanged:function(t){this.certificateId=t.id;var e=t.date,i="string"==typeof e?e.split(" - "):["",""];this.cntCertificate.html(this.templateCertificate({name:t.name,valid:this.textValid.replace("%1",i[0]).replace("%2",i[1])})),this.cntCertificate.toggleClass("hidden",_.isEmpty(this.certificateId)||this.certificateId<0),this.btnChangeCertificate.setCaption(_.isEmpty(this.certificateId)||this.certificateId<0?this.textSelect:this.textChange),this.btnOk.setDisabled(_.isEmpty(this.certificateId)||this.certificateId<0)},onSelectImage:function(){this.signObject&&(this.signObject.selectImage(),this.inputName.setValue(""))},onChangeName:function(t,e){this.signObject&&this.signObject.setText(e,this.font.name,this.font.size,this.font.italic,this.font.bold)},textTitle:"Sign Document",textPurpose:"Purpose for signing this document",textCertificate:"Certificate",textValid:"Valid from %1 to %2",textChange:"Change",cancelButtonText:"Cancel",okButtonText:"Ok",textInputName:"Input signer name",textUseImage:"or click 'Select Image' to use a picture as signature",textSelectImage:"Select Image",textSignature:"Signature looks as",tipFontName:"Font Name",tipFontSize:"Font Size",textBold:"Bold",textItalic:"Italic",textSelect:"Select"},Common.Views.SignDialog||{}))}),void 0===Common)var Common={};if(define("common/main/lib/view/SignSettingsDialog",["common/main/lib/util/utils","common/main/lib/component/InputField","common/main/lib/component/CheckBox","common/main/lib/component/Window"],function(){"use strict";Common.Views.SignSettingsDialog=Common.UI.Window.extend(_.extend({options:{width:350,style:"min-width: 350px;",cls:"modal-dlg",type:"edit"},initialize:function(t){_.extend(this.options,{title:this.textTitle},t||{}),this.template=['
','
',"","
",'
',"","
",'
','
',"","
",'
','
',"","
",'
','
',"","
",'','
',"
",'"].join(""),this.api=this.options.api,this.type=this.options.type||"edit",this.options.tpl=_.template(this.template)(this.options),Common.UI.Window.prototype.initialize.call(this,this.options)},render:function(){Common.UI.Window.prototype.render.call(this);var t=this,e=this.getChild();t.inputName=new Common.UI.InputField({el:$("#id-dlg-sign-settings-name"),style:"width: 100%;",disabled:"view"==this.type}),t.inputTitle=new Common.UI.InputField({el:$("#id-dlg-sign-settings-title"),style:"width: 100%;",disabled:"view"==this.type}),t.inputEmail=new Common.UI.InputField({el:$("#id-dlg-sign-settings-email"),style:"width: 100%;",disabled:"view"==this.type}),t.textareaInstructions=this.$window.find("textarea"),t.textareaInstructions.keydown(function(t){t.keyCode==Common.UI.Keys.RETURN&&t.stopPropagation()}),"view"==this.type?this.textareaInstructions.attr("disabled","disabled"):this.textareaInstructions.removeAttr("disabled"),this.textareaInstructions.toggleClass("disabled","view"==this.type),this.chDate=new Common.UI.CheckBox({el:$("#id-dlg-sign-settings-date"),labelText:this.textShowDate,disabled:"view"==this.type}),e.find(".dlg-btn").on("click",_.bind(this.onBtnClick,this))},show:function(){Common.UI.Window.prototype.show.apply(this,arguments);var t=this;_.delay(function(){t.inputName.cmpEl.find("input").focus()},500)},setSettings:function(t){if(t){var e=this,i=t.asc_getSigner1();e.inputName.setValue(i||""),i=t.asc_getSigner2(),e.inputTitle.setValue(i||""),i=t.asc_getEmail(),e.inputEmail.setValue(i||""),i=t.asc_getInstructions(),e.textareaInstructions.val(i||""),e.chDate.setValue(t.asc_getShowDate())}},getSettings:function(){var t=this,e=new AscCommon.asc_CSignatureLine;return e.asc_setSigner1(t.inputName.getValue()),e.asc_setSigner2(t.inputTitle.getValue()),e.asc_setEmail(t.inputEmail.getValue()),e.asc_setInstructions(t.textareaInstructions.val()),e.asc_setShowDate("checked"==t.chDate.getValue()),e},onBtnClick:function(t){this._handleInput(t.currentTarget.attributes.result.value)},onPrimary:function(t){return this._handleInput("ok"),!1},_handleInput:function(t){this.options.handler&&this.options.handler.call(this,this,t),this.close()},textInfo:"Signer Info",textInfoName:"Name",textInfoTitle:"Signer Title",textInfoEmail:"E-mail",textInstructions:"Instructions for Signer",cancelButtonText:"Cancel",okButtonText:"Ok",txtEmpty:"This field is required",textAllowComment:"Allow signer to add comment in the signature dialog",textShowDate:"Show sign date in signature line",textTitle:"Signature Setup"},Common.Views.SignSettingsDialog||{}))}),void 0===Common)var Common={};Common.Controllers=Common.Controllers||{},define("common/main/lib/controller/Protection",["core","common/main/lib/view/Protection","common/main/lib/view/PasswordDialog","common/main/lib/view/SignDialog","common/main/lib/view/SignSettingsDialog"],function(){"use strict";Common.Controllers.Protection=Backbone.Controller.extend(_.extend({models:[],collections:[],views:["Common.Views.Protection"],sdkViewName:"#id_main",initialize:function(){this.addListeners({"Common.Views.Protection":{"protect:password":_.bind(this.onPasswordClick,this),"protect:signature":_.bind(this.onSignatureClick,this)}})},onLaunch:function(){this._state={},Common.NotificationCenter.on("app:ready",this.onAppReady.bind(this)),Common.NotificationCenter.on("api:disconnect",_.bind(this.onCoAuthoringDisconnect,this))},setConfig:function(t,e){this.setApi(e),t&&(this.sdkViewName=t.sdkviewname||this.sdkViewName)},setApi:function(t){t&&(this.api=t,this.appConfig.isPasswordSupport&&this.api.asc_registerCallback("asc_onDocumentPassword",_.bind(this.onDocumentPassword,this)),this.appConfig.isSignatureSupport&&(Common.NotificationCenter.on("protect:sign",_.bind(this.onSignatureRequest,this)),Common.NotificationCenter.on("protect:signature",_.bind(this.onSignatureClick,this)),this.api.asc_registerCallback("asc_onSignatureClick",_.bind(this.onSignatureSign,this)),this.api.asc_registerCallback("asc_onUpdateSignatures",_.bind(this.onApiUpdateSignatures,this))),this.api.asc_registerCallback("asc_onCoAuthoringDisconnect",_.bind(this.onCoAuthoringDisconnect,this)))},setMode:function(t){return this.appConfig=t,this.view=this.createView("Common.Views.Protection",{mode:t}),this},onDocumentPassword:function(t,e){this.view&&this.view.onDocumentPassword(t,e)},SetDisabled:function(t,e){this.view&&this.view.SetDisabled(t,e)},onPasswordClick:function(t,e){switch(e){case"add":this.addPassword();break;case"delete":this.deletePassword()}Common.NotificationCenter.trigger("edit:complete",this.view)},onSignatureRequest:function(t){this.api.asc_RequestSign(t)},onSignatureClick:function(t,e,i){switch(t){case"invisible":this.onSignatureRequest("unvisibleAdd");break;case"visible":this.addVisibleSignature(e,i)}},createToolbarPanel:function(){return this.view.getPanel()},getView:function(t){return!t&&this.view?this.view:Backbone.Controller.prototype.getView.call(this,t)},onAppReady:function(t){},addPassword:function(){var t=this;new Common.Views.PasswordDialog({api:t.api,signType:"invisible",handler:function(e,i){"ok"==e&&t.api.asc_setCurrentPassword(i),Common.NotificationCenter.trigger("edit:complete")}}).show()},deletePassword:function(){this.api.asc_resetPassword()},addInvisibleSignature:function(){var t=this;new Common.Views.SignDialog({api:t.api,signType:"invisible",handler:function(e,i){if("ok"==i){var n=e.getSettings();t.api.asc_Sign(n.certificateId)}Common.NotificationCenter.trigger("edit:complete")}}).show()},addVisibleSignature:function(t,e){var i=this,n=new Common.Views.SignSettingsDialog({type:t?"view":"edit",handler:function(e,n){t||"ok"!=n||i.api.asc_AddSignatureLine2(e.getSettings()),Common.NotificationCenter.trigger("edit:complete")}});n.show(),e&&n.setSettings(this.api.asc_getSignatureSetup(e))},signVisibleSignature:function(t,e,i){var n=this;if(_.isUndefined(n.fontStore)){n.fontStore=new Common.Collections.Fonts;var o=n.getApplication().getController("Toolbar").getView("Toolbar").cmbFontName.store.toJSON(),s=[];_.each(o,function(t,e){t.cloneid||s.push(_.clone(t))}),n.fontStore.add(s)}new Common.Views.SignDialog({api:n.api,signType:"visible",fontStore:n.fontStore,signSize:{width:e||0,height:i||0},handler:function(e,i){if("ok"==i){var o=e.getSettings();n.api.asc_Sign(o.certificateId,t,o.images[0],o.images[1])}Common.NotificationCenter.trigger("edit:complete")}}).show()},onSignatureSign:function(t,e,i,n){n?this.signVisibleSignature(t,e,i):this.addInvisibleSignature()},onApiUpdateSignatures:function(t,e){this.SetDisabled(t&&t.length>0,!0)},onCoAuthoringDisconnect:function(){this.SetDisabled(!0)}},Common.Controllers.Protection||{}))}),define("common/main/lib/controller/Desktop",["core"],function(){"use strict";var t=function(){var t={},e=window.AscDesktopEditor;return e&&(window.on_native_message=function(i,n){if(/^style:change/.test(i)){var o=JSON.parse(n);if("toolbar"==o.element)"off"==o.action&&"native-color"==o.style&&$(".toolbar").removeClass("editor-native-color");else if("body"==o.element&&"merge"==o.action){var s=document.createElement("style");s.innerHTML=o.style,document.body.appendChild(s)}}else if(/window:features/.test(i)){var o=JSON.parse(n);"true"==o.canUndock&&(t.canUndock||(t.canUndock=!0,_.isEmpty(t)||Common.NotificationCenter.trigger("app:config",{canUndock:!0})))}else if(/window:status/.test(i)){var o=JSON.parse(n);"undocking"==o.action&&Common.NotificationCenter.trigger("undock:status",{status:"undocked"==o.status?"undocked":"docked"})}else/editor:config/.test(i)&&"request"==n&&e.execCommand("editor:config",JSON.stringify({user:t.user,extraleft:$("#box-document-title #slot-btn-dt-save").parent().width()}))},e.execCommand("webapps:events","loading"),e.execCommand("window:features","request")),{init:function(i){_.extend(t,i),t.isDesktopApp&&(Common.NotificationCenter.on("app:ready",function(i){_.extend(t,i),!!e&&e.execCommand("doc:onready",""),$(".toolbar").addClass("editor-native-color")}),Common.NotificationCenter.on("action:undocking",function(t){e.execCommand("editor:event",JSON.stringify({action:"undocking",state:"dock"==t?"dock":"undock"}))}),Common.NotificationCenter.on("app:face",function(e){t.canUndock&&Common.NotificationCenter.trigger("app:config",{canUndock:!0})}))},process:function(i){if(t.isDesktopApp&&e){if("goback"==i)return e.execCommand("go:folder",t.isOffline?"offline":t.customization.goback.url),!0;if("preloader:hide"==i)return e.execCommand("editor:onready",""),!0;if("create:new"==i&&"desktop://create.new"==t.createUrl)return e.LocalFileCreate(window.SSE?2:window.PE?1:0),!0}return!1},requestClose:function(){t.isDesktopApp&&e&&e.execCommand("editor:event",JSON.stringify({action:"close",url:t.customization.goback.url}))}}};Common.Controllers.Desktop=new t});var reqerr;require.config({baseUrl:"../../",paths:{jquery:"../vendor/jquery/jquery",underscore:"../vendor/underscore/underscore",backbone:"../vendor/backbone/backbone",bootstrap:"../vendor/bootstrap/dist/js/bootstrap",text:"../vendor/requirejs-text/text",perfectscrollbar:"common/main/lib/mods/perfect-scrollbar",jmousewheel:"../vendor/perfect-scrollbar/src/jquery.mousewheel",xregexp:"../vendor/xregexp/xregexp-all-min",sockjs:"../vendor/sockjs/sockjs.min",jszip:"../vendor/jszip/jszip.min",jsziputils:"../vendor/jszip-utils/jszip-utils.min",allfonts:"../../sdkjs/common/AllFonts",sdk:"../../sdkjs/cell/sdk-all-min",api:"api/documents/api",core:"common/main/lib/core/application",notification:"common/main/lib/core/NotificationCenter",keymaster:"common/main/lib/core/keymaster",tip:"common/main/lib/util/Tip",localstorage:"common/main/lib/util/LocalStorage",analytics:"common/Analytics",gateway:"common/Gateway",locale:"common/locale",irregularstack:"common/IrregularStack"},shim:{underscore:{exports:"_"},backbone:{deps:["underscore","jquery"],exports:"Backbone"},bootstrap:{deps:["jquery"]},perfectscrollbar:{deps:["jmousewheel"]},notification:{deps:["backbone"]},core:{deps:["backbone","notification","irregularstack"]},sdk:{deps:["jquery","underscore","allfonts","xregexp","sockjs","jszip","jsziputils"]},gateway:{deps:["jquery"]},analytics:{deps:["jquery"]}}}),require(["backbone","bootstrap","core","sdk","api","analytics","gateway","locale"],function(t,e,i){t.history.start();var n=new t.Application({nameSpace:"SSE",autoCreate:!1,controllers:["Viewport","DocumentHolder","CellEditor","FormulaDialog","Print","Toolbar","Statusbar","Spellcheck","RightMenu","LeftMenu","Main","PivotTable","DataTab","Common.Controllers.Fonts","Common.Controllers.Chat","Common.Controllers.Comments","Common.Controllers.Plugins","Common.Controllers.ReviewChanges","Common.Controllers.Protection"]});Common.Locale.apply(function(){require(["spreadsheeteditor/main/app/controller/Viewport","spreadsheeteditor/main/app/controller/DocumentHolder","spreadsheeteditor/main/app/controller/CellEditor","spreadsheeteditor/main/app/controller/Toolbar","spreadsheeteditor/main/app/controller/Statusbar","spreadsheeteditor/main/app/controller/Spellcheck","spreadsheeteditor/main/app/controller/RightMenu","spreadsheeteditor/main/app/controller/LeftMenu","spreadsheeteditor/main/app/controller/Main","spreadsheeteditor/main/app/controller/Print","spreadsheeteditor/main/app/controller/PivotTable","spreadsheeteditor/main/app/controller/DataTab","spreadsheeteditor/main/app/view/FileMenuPanels","spreadsheeteditor/main/app/view/ParagraphSettings","spreadsheeteditor/main/app/view/ImageSettings","spreadsheeteditor/main/app/view/ChartSettings","spreadsheeteditor/main/app/view/ShapeSettings","spreadsheeteditor/main/app/view/TextArtSettings","spreadsheeteditor/main/app/view/PivotSettings","spreadsheeteditor/main/app/view/FieldSettingsDialog","spreadsheeteditor/main/app/view/ValueFieldSettingsDialog","spreadsheeteditor/main/app/view/SignatureSettings","common/main/lib/util/utils","common/main/lib/util/LocalStorage","common/main/lib/controller/Fonts","common/main/lib/controller/Comments","common/main/lib/controller/Chat","common/main/lib/controller/Plugins","common/main/lib/controller/ReviewChanges","common/main/lib/controller/Protection","common/main/lib/controller/Desktop"],function(){n.start()})})},function(t){"timeout"==t.requireType&&!reqerr&&window.requireTimeourError&&(reqerr=window.requireTimeourError(),window.alert(reqerr),window.location.reload())}),define("../apps/spreadsheeteditor/main/app.js",function(){}); \ No newline at end of file