From 78b9c424586b3395b2d07a73cbd52b3c6ffd143c Mon Sep 17 00:00:00 2001 From: yflory <yann.flory@xwiki.com> 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;s<n.length;++s)if(n.at(s).get("userid")!==this.mode.user.id&&(o||!n.at(s).get("resolved"))){this.leftMenu.markCoauthOptions("comments",!0);break}}return this.mode.isEditMailMerge||this.mode.isEditDiagram||this.api.asc_registerCallback("asc_onEditCell",_.bind(this.onApiEditCell,this)),this.leftMenu.getMenu("file").setApi(t),this},setMode:function(t){return this.mode=t,this.leftMenu.setMode(t),this.leftMenu.getMenu("file").setMode(t),t.isEdit||Common.util.Shortcuts.removeShortcuts({shortcuts:{"command+shift+s,ctrl+shift+s":_.bind(this.onShortcut,this,"save"),"alt+f":_.bind(this.onShortcut,this,"file")}}),this},createDelayedElements:function(){return this.mode.canCoAuthoring?(this.leftMenu.btnComments[this.mode.canViewComments&&!this.mode.isLightVersion?"show":"hide"](),this.mode.canViewComments&&this.leftMenu.setOptionsPanel("comment",this.getApplication().getController("Common.Controllers.Comments").getView("Common.Views.Comments")),this.leftMenu.btnChat[this.mode.canChat&&!this.mode.isLightVersion?"show":"hide"](),this.mode.canChat&&this.leftMenu.setOptionsPanel("chat",this.getApplication().getController("Common.Controllers.Chat").getView("Common.Views.Chat"))):(this.leftMenu.btnChat.hide(),this.leftMenu.btnComments.hide()),this.mode.isEdit&&(this.leftMenu.btnSpellcheck.show(),this.leftMenu.setOptionsPanel("spellcheck",this.getApplication().getController("Spellcheck").getView("Spellcheck"))),this.mode.trialMode&&this.leftMenu.setDeveloperMode(this.mode.trialMode),Common.util.Shortcuts.resumeEvents(),this.mode.isEditMailMerge||this.mode.isEditDiagram||Common.NotificationCenter.on("cells:range",_.bind(this.onCellsRange,this)),this},enablePlugins:function(){this.mode.canPlugins?this.leftMenu.setOptionsPanel("plugins",this.getApplication().getController("Common.Controllers.Plugins").getView("Common.Views.Plugins")):this.leftMenu.btnPlugins.hide(),this.mode.trialMode&&this.leftMenu.setDeveloperMode(this.mode.trialMode)},clickMenuFileItem:function(t,e,i){var n=!0;switch(e){case"back":break;case"save":this.api.asc_Save();break;case"save-desktop":this.api.asc_DownloadAs();break;case"print":Common.NotificationCenter.trigger("print",this.leftMenu);break;case"exit":Common.NotificationCenter.trigger("goback");break;case"edit":Common.Gateway.requestEditRights();break;case"new":i?n=!1:this.onCreateNew(void 0,"blank");break;case"rename":var o=this,s=o.api.asc_getDocumentName();new Common.Views.RenameDialog({filename:s,handler:function(t,e){"ok"!=t||_.isEmpty(e.trim())||s===e.trim()||Common.Gateway.requestRename(e),Common.NotificationCenter.trigger("edit:complete",o)}}).show();break;default:n=!1}n&&t.hide()},clickSaveAsFormat:function(t,e){e==Asc.c_oAscFileType.CSV?Common.UI.warning({title:this.textWarning,msg:this.warnDownloadAs,buttons:["ok","cancel"],callback:_.bind(function(i){"ok"==i&&(Common.NotificationCenter.trigger("download:advanced",Asc.c_oAscAdvancedOptionsID.CSV,this.api.asc_getAdvancedOptions(),2,new Asc.asc_CDownloadOptions(e)),t.hide())},this)}):e==Asc.c_oAscFileType.PDF||e==Asc.c_oAscFileType.PDFA?(t.hide(),Common.NotificationCenter.trigger("download:settings",this.leftMenu,e)):(this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(e)),t.hide())},clickSaveCopyAsFormat:function(t,e,i){e==Asc.c_oAscFileType.CSV?Common.UI.warning({title:this.textWarning,msg:this.warnDownloadAs,buttons:["ok","cancel"],callback:_.bind(function(n){"ok"==n&&(this.isFromFileDownloadAs=i,Common.NotificationCenter.trigger("download:advanced",Asc.c_oAscAdvancedOptionsID.CSV,this.api.asc_getAdvancedOptions(),2,new Asc.asc_CDownloadOptions(e,!0)),t.hide())},this)}):e==Asc.c_oAscFileType.PDF||e==Asc.c_oAscFileType.PDFA?(this.isFromFileDownloadAs=i,t.hide(),Common.NotificationCenter.trigger("download:settings",this.leftMenu,e,!0)):(this.isFromFileDownloadAs=i,this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(e,!0)),t.hide())},onDownloadUrl:function(t){if(this.isFromFileDownloadAs){var e=this,i=this.getApplication().getController("Viewport").getView("Common.Views.Header").getDocumentCaption();if(!i&&(i=e.txtUntitled),"string"==typeof this.isFromFileDownloadAs){var n=i.lastIndexOf(".");n>0&&(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<t.length;++i)if(t[i].asc_getUserId()!==this.mode.user.id&&(e||!t[i].asc_getSolved())){this.leftMenu.markCoauthOptions("comments");break}},onAppAddComment:function(t,e){if(e){var i=this;new Promise(function(t,e){t()}).then(function(){Common.UI.Menu.Manager.hideAll(),i.leftMenu.showMenu("comments");var t=SSE.getController("Common.Controllers.Comments");t.getView().showEditContainer(!0),t.onAfterShow()})}},commentsShowHide:function(t){if(this.api){var e=Common.Utils.InternalSettings.get("sse-settings-livecomment"),i=Common.Utils.InternalSettings.get("sse-settings-resolvedcomment");e&&i||(t?this.api.asc_showComments(!0):e?this.api.asc_showComments(i):this.api.asc_hideComments()),t&&this.getApplication().getController("Common.Controllers.Comments").onAfterShow(),t||$(this.leftMenu.btnComments.el).blur()}},fileShowHide:function(t){this.api&&(this.api.asc_closeCellEditor(),this.api.asc_enableKeyEvents(!t))},aboutShowHide:function(t){this.api&&(this.api.asc_closeCellEditor(),this.api.asc_enableKeyEvents(!t),t||$(this.leftMenu.btnAbout.el).blur(),!t&&this.leftMenu._state.pluginIsRunning&&(this.leftMenu.panelPlugins.show(),this.mode.canCoAuthoring&&(this.mode.canViewComments&&this.leftMenu.panelComments.hide(),this.mode.canChat&&this.leftMenu.panelChat.hide())))},menuFilesShowHide:function(t){this.api&&(this.api.asc_closeCellEditor(),this.api.asc_enableKeyEvents(!("show"==t))),this.dlgSearch&&("show"==t?this.dlgSearch.suspendKeyEvents():Common.Utils.asyncCall(this.dlgSearch.resumeKeyEvents,this.dlgSearch))},onShortcut:function(t,e){if(this.mode){if(this.mode.isEditDiagram&&"escape"!=t)return!1;if(this.mode.isEditMailMerge&&"escape"!=t&&"search"!=t)return!1;switch(t){case"replace":case"search":return this.leftMenu.btnSearch.isDisabled()||(Common.UI.Menu.Manager.hideAll(),this.showSearchDlg(!0,t),this.leftMenu.btnSearch.toggle(!0,!0),this.leftMenu.btnAbout.toggle(!1),this.leftMenu.menuFile.hide()),!1;case"save":return this.mode.canDownload&&(this.mode.isDesktopApp&&this.mode.isOffline?this.api.asc_DownloadAs():(Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("file:saveas"))),!1;case"help":return this.mode.isEdit&&this.mode.canHelp&&(Common.UI.Menu.Manager.hideAll(),this.api.asc_closeCellEditor(),this.leftMenu.showMenu("file:help")),!1;case"file":return Common.UI.Menu.Manager.hideAll(),this.leftMenu.showMenu("file"),!1;case"escape":if(this.leftMenu.menuFile.isVisible())return this.leftMenu.menuFile.hide(),!1;var i=SSE.getController("Statusbar"),n=i.statusbar.$el.find('.open > [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.<br>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<a&&(i=t.at(s),i.get("type")==o);)n=i.get("name")==l;return n}function e(e,i){e.showlastused&&t(e.store,i)}function i(t){Common.NotificationCenter.trigger("fonts:change",t)}function n(t,e){var i=[];_.each(t,function(t){var e=t.asc_getFontId();i.push({id:_.isEmpty(e)?Common.UI.getId():e,name:t.asc_getFontName(),imgidx:t.asc_getFontThumbnail(),type:t.asc_getFontType()})});var n=this.getCollection("Common.Collections.Fonts");n&&(n.add(i),n.sort()),Common.NotificationCenter.trigger("fonts:load",n,e)}var o=4;return{models:["Common.Models.Fonts"],collections:["Common.Collections.Fonts"],views:[],initialize:function(){Common.NotificationCenter.on("fonts:select",_.bind(e,this))},onLaunch:function(){},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onInitEditorFonts",_.bind(n,this)),this.api.asc_registerCallback("asc_onFontFamily",_.bind(i,this))}}}())}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/TextArt",["backbone"],function(t){"use strict";Common.Collections.TextArt=t.Collection.extend({model:t.Model.extend({defaults:function(){return{id:Common.UI.getId(),imageUrl:null,data:null}}})})}),void 0===Common)var Common={};if(Common.util=Common.util||{},Common.util.LanguageInfo=new function(){var t={54:["af","Afrikaans"],1078:["af-ZA","Afrikaans (Suid Afrika)","Afrikaans (South Africa)"],28:["sq","Shqipe"],1052:["sq-AL","Shqipe (Shqipëria)","Albanian (Albania)"],132:["gsw","Elsässisch"],1156:["gsw-FR","Elsässisch (Frànkrisch)","Alsatian (France)"],94:["am","አማርኛ"],1118:["am-ET","አማርኛ (ኢትዮጵያ)","Amharic (Ethiopia)"],1:["ar","العربية"],5121:["ar-DZ","العربية (الجزائر)","Arabic (Algeria)"],15361:["ar-BH","العربية (البحرين)","Arabic (Bahrain)"],3073:["ar-EG","العربية (مصر)","Arabic (Egypt)"],2049:["ar-IQ","العربية (العراق)","Arabic (Iraq)"],11265:["ar-JO","العربية (الأردن)","Arabic (Jordan)"],13313:["ar-KW","العربية (الكويت)","Arabic (Kuwait)"],12289:["ar-LB","العربية (لبنان)","Arabic (Lebanon)"],4097:["ar-LY","العربية (ليبيا)","Arabic (Libya)"],6145:["ar-MA","العربية (المملكة المغربية)","Arabic (Morocco)"],8193:["ar-OM","العربية (عمان)","Arabic (Oman)"],16385:["ar-QA","العربية (قطر)","Arabic (Qatar)"],1025:["ar-SA","العربية (المملكة العربية السعودية)","Arabic (Saudi Arabia)"],10241:["ar-SY","العربية (سوريا)","Arabic (Syria)"],7169:["ar-TN","العربية (تونس)","Arabic (Tunisia)"],14337:["ar-AE","العربية (الإمارات العربية المتحدة)","Arabic (U.A.E.)"],9217:["ar-YE","العربية (اليمن)","Arabic (Yemen)"],43:["hy","Հայերեն"],1067:["hy-AM","Հայերեն (Հայաստան)","Armenian (Armenia)"],77:["as","অসমীয়া"],1101:["as-IN","অসমীয়া (ভাৰত)","Assamese (India)"],44:["az","Azərbaycanılı"],29740:["az-Cyrl","Азәрбајҹан дили"],2092:["az-Cyrl-AZ","Азәрбајҹан (Азәрбајҹан)","Azeri (Cyrillic, Azerbaijan)"],30764:["az-Latn","Azərbaycanılı"],1068:["az-Latn-AZ","Azərbaycanılı (Azərbaycan)","Azeri (Latin, Azerbaijan)"],109:["ba","Башҡорт"],1133:["ba-RU","Башҡорт (Россия)","Bashkir (Russia)"],45:["eu","Euskara"],1069:["eu-ES","Euskara (Euskara)","Basque (Basque)"],35:["be","Беларускі"],1059:["be-BY","Беларускі (Беларусь)","Belarusian (Belarus)"],69:["bn","বাংলা"],2117:["bn-BD","বাংলা (বাংলাদেশ)","Bengali (Bangladesh)"],1093:["bn-IN","বাংলা (ভারত)","Bengali (India)"],30746:["bs","bosanski"],25626:["bs-Cyrl","Босански (Ћирилица)"],8218:["bs-Cyrl-BA","Босански (Босна и Херцеговина)","Bosnian (Cyrillic) (Bosnia and Herzegovina)"],26650:["bs-Latn","Bosanski (Latinica)"],5146:["bs-Latn-BA","Bosanski (Bosna i Hercegovina)","Bosnian (Latin) (Bosnia and Herzegovina)"],126:["br","Brezhoneg"],1150:["br-FR","Brezhoneg (Frañs)","Breton (France)"],2:["bg","Български"],1026:["bg-BG","Български (България)","Bulgarian (Bulgaria)"],3:["ca","Català"],1027:["ca-ES","Català (Català)","Catalan (Catalan)"],2051:["ca-ES-valencia","Català (Valencià)","Catalan (Valencia)"],30724:["zh","中文"],4:["zh-Hans","中文(简体)","Chinese (Simplified)"],2052:["zh-CN","中文(中华人民共和国)","Chinese (People's Republic of China)"],4100:["zh-SG","中文(新加坡)","Chinese (Simplified, Singapore)"],31748:["zh-Hant","中文(繁體)","Chinese (Traditional)"],3076:["zh-HK","中文(香港特別行政區)","Chinese (Traditional, Hong Kong S.A.R.)"],5124:["zh-MO","中文(澳門特別行政區)","Chinese (Traditional, Macao S.A.R.)"],1028:["zh-TW","中文(台灣)","Chinese (Traditional, Taiwan)"],131:["co","Corsu"],1155:["co-FR","Corsu (France)","Corsican (France)"],26:["hr","Hrvatski"],1050:["hr-HR","Hrvatski (Hrvatska)","Croatian (Croatia)"],4122:["hr-BA","Hrvatski (Bosna i Hercegovina)","Croatian (Bosnia and Herzegovina)"],5:["cs","Čeština"],1029:["cs-CZ","Čeština (Česká republika)","Czech (Czech Republic)"],6:["da","Dansk"],1030:["da-DK","Dansk (Danmark)","Danish (Denmark)"],140:["prs","درى"],1164:["prs-AF","درى (افغانستان)","Dari (Afghanistan)"],101:["dv","ދިވެހިބަސް"],1125:["dv-MV","ދިވެހިބަސް (ދިވެހި ރާއްޖެ)","Divehi (Maldives)"],19:["nl","Nederlands"],2067:["nl-BE","Nederlands (België)","Dutch (Belgium)"],1043:["nl-NL","Nederlands (Nederland)","Dutch (Netherlands)"],9:["en","English"],3081:["en-AU","English (Australia)","English (Australia)"],10249:["en-BZ","English (Belize)","English (Belize)"],4105:["en-CA","English (Canada)","English (Canada)"],9225:["en-029","English (Caribbean)","English (Caribbean)"],16393:["en-IN","English (India)","English (India)"],6153:["en-IE","English (Ireland)","English (Ireland)"],8201:["en-JM","English (Jamaica)","English (Jamaica)"],17417:["en-MY","English (Malaysia)","English (Malaysia)"],5129:["en-NZ","English (New Zealand)","English (New Zealand)"],13321:["en-PH","English (Philippines)","English (Philippines)"],18441:["en-SG","English (Singapore)","English (Singapore)"],7177:["en-ZA","English (South Africa)","English (South Africa)"],11273:["en-TT","English (Trinidad y Tobago)","English (Trinidad y Tobago)"],2057:["en-GB","English (United Kingdom)","English (United Kingdom)"],1033:["en-US","English (United States)","English (United States)"],12297:["en-ZW","English (Zimbabwe)","English (Zimbabwe)"],15369:["en-HK","English (Hong Kong)","English (Hong Kong)"],14345:["en-ID","English (Indonesia)","English (Indonesia)"],37:["et","Eesti"],1061:["et-EE","Eesti (Eesti)","Estonian (Estonia)"],56:["fo","Føroyskt"],1080:["fo-FO","Føroyskt (Føroyar)","Faroese (Faroe Islands)"],100:["fil","Filipino"],1124:["fil-PH","Filipino (Pilipinas)","Filipino (Philippines)"],11:["fi","Suomi"],1035:["fi-FI","Suomi (Suomi)","Finnish (Finland)"],12:["fr","Français"],2060:["fr-BE","Français (Belgique)","French (Belgium)"],3084:["fr-CA","Français (Canada)","French (Canada)"],1036:["fr-FR","Français (France)","French (France)"],5132:["fr-LU","Français (Luxembourg)","French (Luxembourg)"],6156:["fr-MC","Français (Principauté de Monaco)","French (Principality of Monaco)"],4108:["fr-CH","Français (Suisse)","French (Switzerland)"],15372:["fr-HT","Français (Haïti)","French (Haiti)"],9228:["fr-CG","Français (Congo-Brazzaville)","French (Congo)"],12300:["fr-CI","Français (Côte d’Ivoire)","French (Cote d'Ivoire)"],11276:["fr-CM","Français (Cameroun)","French (Cameroon)"],14348:["fr-MA","Français (Maroc)","French (Morocco)"],13324:["fr-ML","Français (Mali)","French (Mali)"],8204:["fr-RE","Français (La Réunion)","French (Reunion)"],10252:["fr-SN","Français (Sénégal)","French (Senegal)"],7180:["fr-West","French"],98:["fy","Frysk"],1122:["fy-NL","Frysk (Nederlân)","Frisian (Netherlands)"],86:["gl","Galego"],1110:["gl-ES","Galego (Galego)","Galician (Galician)"],55:["ka","ქართული"],1079:["ka-GE","ქართული (საქართველო)","Georgian (Georgia)"],7:["de","Deutsch"],3079:["de-AT","Deutsch (Österreich)","German (Austria)"],1031:["de-DE","Deutsch (Deutschland)","German (Germany)"],5127:["de-LI","Deutsch (Liechtenstein)","German (Liechtenstein)"],4103:["de-LU","Deutsch (Luxemburg)","German (Luxembourg)"],2055:["de-CH","Deutsch (Schweiz)","German (Switzerland)"],8:["el","Ελληνικά"],1032:["el-GR","Ελληνικά (Ελλάδα)","Greek (Greece)"],111:["kl","Kalaallisut"],1135:["kl-GL","Kalaallisut (Kalaallit Nunaat)","Greenlandic (Greenland)"],71:["gu","ગુજરાતી"],1095:["gu-IN","ગુજરાતી (ભારત)","Gujarati (India)"],104:["ha","Hausa"],31848:["ha-Latn","Hausa (Latin)"],1128:["ha-Latn-NG","Hausa (Nigeria)","Hausa (Latin) (Nigeria)"],13:["he","עברית"],1037:["he-IL","עברית (ישראל)","Hebrew (Israel)"],57:["hi","हिंदी"],1081:["hi-IN","हिंदी (भारत)","Hindi (India)"],14:["hu","Magyar"],1038:["hu-HU","Magyar (Magyarország)","Hungarian (Hungary)"],15:["is","Íslenska"],1039:["is-IS","Íslenska (Ísland)","Icelandic (Iceland)"],112:["ig","Igbo"],1136:["ig-NG","Igbo (Nigeria)","Igbo (Nigeria)"],33:["id","Bahasa Indonesia"],1057:["id-ID","Bahasa Indonesia (Indonesia)","Indonesian (Indonesia)"],93:["iu","Inuktitut"],31837:["iu-Latn","Inuktitut (Qaliujaaqpait)"],2141:["iu-Latn-CA","Inuktitut (Kanatami) (kanata)","Inuktitut (Latin) (Canada)"],30813:["iu-Cans","ᐃᓄᒃᑎᑐᑦ (ᖃᓂᐅᔮᖅᐸᐃᑦ)"],1117:["iu-Cans-CA","ᐃᓄᒃᑎᑐᑦ (ᑲᓇᑕᒥ)","Inuktitut (Canada)"],60:["ga","Gaeilge"],2108:["ga-IE","Gaeilge (Éire)","Irish (Ireland)"],52:["xh","isiXhosa"],1076:["xh-ZA","isiXhosa (uMzantsi Afrika)","isiXhosa (South Africa)"],53:["zu","isiZulu"],1077:["zu-ZA","isiZulu (iNingizimu Afrika)","isiZulu (South Africa)"],16:["it","Italiano"],1040:["it-IT","Italiano (Italia)","Italian (Italy)"],2064:["it-CH","Italiano (Svizzera)","Italian (Switzerland)"],17:["ja","日本語"],1041:["ja-JP","日本語 (日本)","Japanese (Japan)"],75:["kn","ಕನ್ನಡ"],1099:["kn-IN","ಕನ್ನಡ (ಭಾರತ)","Kannada (India)"],63:["kk","Қазақ"],1087:["kk-KZ","Қазақ (Қазақстан)","Kazakh (Kazakhstan)"],83:["km","ខ្មែរ"],1107:["km-KH","ខ្មែរ (កម្ពុជា)","Khmer (Cambodia)"],134:["qut","K'iche"],1158:["qut-GT","K'iche (Guatemala)","K'iche (Guatemala)"],135:["rw","Kinyarwanda"],1159:["rw-RW","Kinyarwanda (Rwanda)","Kinyarwanda (Rwanda)"],65:["sw","Kiswahili"],1089:["sw-KE","Kiswahili (Kenya)","Kiswahili (Kenya)"],87:["kok","कोंकणी"],1111:["kok-IN","कोंकणी (भारत)","Konkani (India)"],18:["ko","한국어"],1042:["ko-KR","한국어 (대한민국)","Korean (Korea)"],64:["ky","Кыргыз"],1088:["ky-KG","Кыргыз (Кыргызстан)","Kyrgyz (Kyrgyzstan)"],84:["lo","ລາວ"],1108:["lo-LA","ລາວ (ສ.ປ.ປ. ລາວ)","Lao (Lao P.D.R.)"],38:["lv","Latviešu"],1062:["lv-LV","Latviešu (Latvija)","Latvian (Latvia)"],39:["lt","Lietuvių"],1063:["lt-LT","Lietuvių (Lietuva)","Lithuanian (Lithuania)"],31790:["dsb","Dolnoserbšćina"],2094:["dsb-DE","Dolnoserbšćina (Nimska)","Lower Sorbian (Germany)"],110:["lb","Lëtzebuergesch"],1134:["lb-LU","Lëtzebuergesch (Luxembourg)","Luxembourgish (Luxembourg)"],1071:["mk-MK","Македонски јазик (Македонија)","Macedonian (Former Yugoslav Republic of Macedonia)"],47:["mk","Македонски јазик"],62:["ms","Bahasa Melayu"],2110:["ms-BN","Bahasa Melayu (Brunei Darussalam)","Malay (Brunei Darussalam)"],1086:["ms-MY","Bahasa Melayu (Malaysia)","Malay (Malaysia)"],76:["ml","മലയാളം"],1100:["ml-IN","മലയാളം (ഭാരതം)","Malayalam (India)"],58:["mt","Malti"],1082:["mt-MT","Malti (Malta)","Maltese (Malta)"],129:["mi","Reo Māori"],1153:["mi-NZ","Reo Māori (Aotearoa)","Maori (New Zealand)"],122:["arn","Mapudungun"],1146:["arn-CL","Mapudungun (Chile)","Mapudungun (Chile)"],78:["mr","मराठी"],1102:["mr-IN","मराठी (भारत)","Marathi (India)"],124:["moh","Kanien'kéha"],1148:["moh-CA","Kanien'kéha (Canada)","Mohawk (Canada)"],80:["mn","Монгол хэл"],30800:["mn-Cyrl","Монгол хэл"],1104:["mn-MN","Монгол хэл (Монгол улс)","Mongolian (Cyrillic, Mongolia)"],31824:["mn-Mong","ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ"],2128:["mn-Mong-CN","ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ (ᠪᠦᠭᠦᠳᠡ ᠨᠠᠢᠷᠠᠮᠳᠠᠬᠤ ᠳᠤᠮᠳᠠᠳᠤ ᠠᠷᠠᠳ ᠣᠯᠣᠰ)","Mongolian (Traditional Mongolian) (People's Republic of China)"],97:["ne","नेपाली"],1121:["ne-NP","नेपाली (नेपाल)","Nepali (Nepal)"],2145:["ne-IN","नेपाली (भारत)","Nepali (India)"],20:["no","Norsk"],31764:["nb","Norsk (bokmål)"],1044:["nb-NO","Norsk, bokmål (Norge)","Norwegian, Bokmål (Norway)"],30740:["nn","Norsk (Nynorsk)"],2068:["nn-NO","Norsk, nynorsk (Noreg)","Norwegian, Nynorsk (Norway)"],130:["oc","Occitan"],1154:["oc-FR","Occitan (França)","Occitan (France)"],72:["or","ଓଡ଼ିଆ"],1096:["or-IN","ଓଡ଼ିଆ (ଭାରତ)","Oriya (India)"], 99:["ps","پښتو"],1123:["ps-AF","پښتو (افغانستان)","Pashto (Afghanistan)"],41:["fa","فارسى"],1065:["fa-IR","فارسى (ایران)","Persian (Iran)"],21:["pl","Polski"],1045:["pl-PL","Polski (Polska)","Polish (Poland)"],22:["pt","Português"],1046:["pt-BR","Português (Brasil)","Portuguese (Brazil)"],2070:["pt-PT","Português (Portugal)","Portuguese (Portugal)"],70:["pa","ਪੰਜਾਬੀ"],1094:["pa-IN","ਪੰਜਾਬੀ (ਭਾਰਤ)","Punjabi (India)"],107:["quz","Runasimi"],1131:["quz-BO","Runasimi (Qullasuyu)","Quechua (Bolivia)"],2155:["quz-EC","Runasimi (Ecuador)","Quechua (Ecuador)"],3179:["quz-PE","Runasimi (Piruw)","Quechua (Peru)"],24:["ro","Română"],1048:["ro-RO","Română (România)","Romanian (Romania)"],2072:["ro-MD","Română (Moldova)","Romanian (Republic of Moldova)"],23:["rm","Rumantsch"],1047:["rm-CH","Rumantsch (Svizra)","Romansh (Switzerland)"],25:["ru","Русский"],1049:["ru-RU","Русский (Россия)","Russian (Russia)"],2073:["ru-MD","Русский (Молдавия)","Russian (Republic of Moldova)"],28731:["smn","Sämikielâ"],9275:["smn-FI","Sämikielâ (Suomâ)","Sami (Inari) (Finland)"],31803:["smj","Julevusámegiella"],4155:["smj-NO","Julevusámegiella (Vuodna)","Sami (Lule) (Norway)"],5179:["smj-SE","Julevusámegiella (Svierik)","Sami (Lule) (Sweden)"],59:["se","Davvisámegiella"],3131:["se-FI","Davvisámegiella (Suopma)","Sami (Northern) (Finland)"],1083:["se-NO","Davvisámegiella (Norga)","Sami (Northern) (Norway)"],2107:["se-SE","Davvisámegiella (Ruoŧŧa)","Sami (Northern) (Sweden)"],29755:["sms","Sääm´ǩiõll"],8251:["sms-FI","Sääm´ǩiõll (Lää´ddjânnam)","Sami (Skolt) (Finland)"],30779:["sma","åarjelsaemiengiele"],6203:["sma-NO","åarjelsaemiengiele (Nöörje)","Sami (Southern) (Norway)"],7227:["sma-SE","åarjelsaemiengiele (Sveerje)","Sami (Southern) (Sweden)"],79:["sa","संस्कृत"],1103:["sa-IN","संस्कृत (भारतम्)","Sanskrit (India)"],145:["gd","Gàidhlig"],1169:["gd-GB","Gàidhlig (An Rìoghachd Aonaichte)","Scottish Gaelic (United Kingdom)"],31770:["sr","Srpski"],27674:["sr-Cyrl","Српски (Ћирилица)"],7194:["sr-Cyrl-BA","Српски (Босна и Херцеговина)","Serbian (Cyrillic) (Bosnia and Herzegovina)"],12314:["sr-Cyrl-ME","Српски (Црна Гора)","Serbian (Cyrillic, Montenegro)"],3098:["sr-Cyrl-CS","Српски (Србија и Црна Гора (Претходно))","Serbian (Cyrillic, Serbia and Montenegro (Former))"],10266:["sr-Cyrl-RS","Српски (Србија)","Serbian (Cyrillic, Serbia)"],28698:["sr-Latn","Srpski (Latinica)"],6170:["sr-Latn-BA","Srpski (Bosna i Hercegovina)","Serbian (Latin, Bosnia and Herzegovina)"],11290:["sr-Latn-ME","Srpski (Crna Gora)","Serbian (Latin, Montenegro)"],2074:["sr-Latn-CS","Srpski (Srbija i Crna Gora (Prethodno))","Serbian (Latin, Serbia and Montenegro (Former))"],9242:["sr-Latn-RS","Srpski (Srbija, Latinica)","Serbian (Latin, Serbia)"],108:["nso","Sesotho sa Leboa"],1132:["nso-ZA","Sesotho sa Leboa (Afrika Borwa)","Sesotho sa Leboa (South Africa)"],50:["tn","Setswana"],1074:["tn-ZA","Setswana (Aforika Borwa)","Setswana (South Africa)"],91:["si","සිංහ"],1115:["si-LK","සිංහ (ශ්රී ලංකා)","Sinhala (Sri Lanka)"],27:["sk","Slovenčina"],1051:["sk-SK","Slovenčina (Slovenská republika)","Slovak (Slovakia)"],36:["sl","Slovenski"],1060:["sl-SI","Slovenski (Slovenija)","Slovenian (Slovenia)"],10:["es","Español"],11274:["es-AR","Español (Argentina)","Spanish (Argentina)"],16394:["es-BO","Español (Bolivia)","Spanish (Bolivia)"],13322:["es-CL","Español (Chile)","Spanish (Chile)"],9226:["es-CO","Español (Colombia)","Spanish (Colombia)"],5130:["es-CR","Español (Costa Rica)","Spanish (Costa Rica)"],7178:["es-DO","Español (República Dominicana)","Spanish (Dominican Republic)"],12298:["es-EC","Español (Ecuador)","Spanish (Ecuador)"],17418:["es-SV","Español (El Salvador)","Spanish (El Salvador)"],4106:["es-GT","Español (Guatemala)","Spanish (Guatemala)"],18442:["es-HN","Español (Honduras)","Spanish (Honduras)"],2058:["es-MX","Español (México)","Spanish (Mexico)"],19466:["es-NI","Español (Nicaragua)","Spanish (Nicaragua)"],6154:["es-PA","Español (Panamá)","Spanish (Panama)"],15370:["es-PY","Español (Paraguay)","Spanish (Paraguay)"],10250:["es-PE","Español (Perú)","Spanish (Peru)"],20490:["es-PR","Español (Puerto Rico)","Spanish (Puerto Rico)"],3082:["es-ES","Español (España, alfabetización internacional)","Spanish (Spain)"],21514:["es-US","Español (Estados Unidos)","Spanish (United States)"],14346:["es-UY","Español (Uruguay)","Spanish (Uruguay)"],8202:["es-VE","Español (Republica Bolivariana de Venezuela)","Spanish (Venezuela)"],1034:["es-ES_tradnl","Spanish"],29:["sv","Svenska"],2077:["sv-FI","Svenska (Finland)","Swedish (Finland)"],1053:["sv-SE","Svenska (Sverige)","Swedish (Sweden)"],90:["syr","ܣܘܪܝܝܐ"],1114:["syr-SY","ܣܘܪܝܝܐ (سوريا)","Syriac (Syria)"],40:["tg","Тоҷикӣ"],31784:["tg-Cyrl","Тоҷикӣ"],1064:["tg-Cyrl-TJ","Тоҷикӣ (Тоҷикистон)","Tajik (Cyrillic) (Tajikistan)"],95:["tzm","Tamazight"],31839:["tzm-Latn","Tamazight (Latin)"],2143:["tzm-Latn-DZ","Tamazight (Djazaïr)","Tamazight (Latin) (Algeria)"],73:["ta","தமிழ்"],1097:["ta-IN","தமிழ் (இந்தியா)","Tamil (India)"],68:["tt","Татар"],1092:["tt-RU","Татар (Россия)","Tatar (Russia)"],74:["te","తెలుగు"],1098:["te-IN","తెలుగు (భారత దేశం)","Telugu (India)"],30:["th","ไทย"],1054:["th-TH","ไทย (ไทย)","Thai (Thailand)"],81:["bo","བོད་ཡིག"],1105:["bo-CN","བོད་ཡིག (ཀྲུང་ཧྭ་མི་དམངས་སྤྱི་མཐུན་རྒྱལ་ཁབ།)","Tibetan (People's Republic of China)"],2129:["bo-BT","Tibetan (Bhutan)","Tibetan (Bhutan)"],31:["tr","Türkçe"],1055:["tr-TR","Türkçe (Türkiye)","Turkish (Turkey)"],66:["tk","Türkmençe"],1090:["tk-TM","Türkmençe (Türkmenistan)","Turkmen (Turkmenistan)"],34:["uk","Українська"],1058:["uk-UA","Українська (Україна)","Ukrainian (Ukraine)"],46:["hsb","Hornjoserbšćina"],1070:["hsb-DE","Hornjoserbšćina (Němska)","Upper Sorbian (Germany)"],32:["ur","اُردو"],1056:["ur-PK","اُردو (پاکستان)","Urdu (Islamic Republic of Pakistan)"],2080:["ur-IN","اُردو (بھارت)","Urdu (India)"],128:["ug","ئۇيغۇر يېزىقى"],1152:["ug-CN","(ئۇيغۇر يېزىقى (جۇڭخۇا خەلق جۇمھۇرىيىتى","Uighur (People's Republic of China)"],30787:["uz-Cyrl","Ўзбек"],2115:["uz-Cyrl-UZ","Ўзбек (Ўзбекистон)","Uzbek (Cyrillic, Uzbekistan)"],67:["uz","U'zbek"],31811:["uz-Latn","U'zbek"],1091:["uz-Latn-UZ","U'zbek (U'zbekiston Respublikasi)","Uzbek (Latin, Uzbekistan)"],42:["vi","Tiếng Việt"],1066:["vi-VN","Tiếng Việt (Việt Nam)","Vietnamese (Vietnam)"],82:["cy","Cymraeg"],1106:["cy-GB","Cymraeg (y Deyrnas Unedig)","Welsh (United Kingdom)"],136:["wo","Wolof"],1160:["wo-SN","Wolof (Sénégal)","Wolof (Senegal)"],133:["sah","Саха"],1157:["sah-RU","Саха (Россия)","Yakut (Russia)"],120:["ii","ꆈꌠꁱꂷ"],1144:["ii-CN","ꆈꌠꁱꂷ (ꍏꉸꏓꂱꇭꉼꇩ)","Yi (People's Republic of China)"],106:["yo","Yoruba"],1130:["yo-NG","Yoruba (Nigeria)","Yoruba (Nigeria)"],1126:["bin-NG","Bini (Nigeria)","Bini (Nigeria)"],1116:["chr-US","ᏣᎳᎩ (ᏌᏊ ᎢᏳᎾᎵᏍᏔᏅ ᏍᎦᏚᎩ)","Cherokee (United States)"],1127:["fuv-NG","Nigerian Fulfulde (Nigeria)","Nigerian Fulfulde (Nigeria)"],1138:["gaz-ET","West Central Oromo (Ethiopia)","West Central Oromo (Ethiopia)"],1140:["gn-PY","Guarani (Paraguay)","Guarani (Paraguay)"],1141:["haw-US","ʻŌlelo Hawaiʻi (ʻAmelika Hui Pū ʻIa)","Hawaiian (United States)"],1129:["ibb-NG","Ibibio (Nigeria)","Ibibio (Nigeria)"],1137:["kr-NG","Kanuri (Nigeria)","Kanuri (Nigeria)"],1112:["mni","Manipuri","Manipuri"],1109:["my-MM","Burmese (Myanmar)","Burmese (Myanmar)"],1145:["pap-AN","Papiamento, Netherlands Antilles","Papiamento, Netherlands Antilles"],2118:["pa-PK","Panjabi (Pakistan)","Panjabi (Pakistan)"],1165:["plt-MG","Plateau Malagasy (Madagascar)","Plateau Malagasy (Madagascar)"],1113:["sd-IN","Sindhi (India)","Sindhi (India)"],2137:["sd-PK","Sindhi (Pakistan)","Sindhi (Pakistan)"],1143:["so-SO","Soomaali (Soomaaliya)","Somali (Somalia)"],1072:["st-ZA","Southern Sotho (South Africa)","Southern Sotho (South Africa)"],1139:["ti-ER","ትግርኛ (ኤርትራ)","Tigrinya (Eritrea)"],2163:["ti-ET","ትግርኛ (ኢትዮጵያ)","Tigrinya (Ethiopia)"],1119:["tmz","Tamanaku"],3167:["tmz-MA","Tamaziɣt n laṭlaṣ (Meṛṛuk)","Tamanaku (Morocco)"],1073:["ts-ZA","Tsonga (South Africa)","Tsonga (South Africa)"],1075:["ven-ZA","South Africa","South Africa"]};return{getLocalLanguageName:function(e){return t[e]||["",e]},getLocalLanguageCode:function(e){if(e)for(var i in t)if(t[i][0].toLowerCase()===e.toLowerCase())return i;return null},getLanguages:function(){return t}}},define("common/main/lib/util/LanguageInfo",function(){}),define("common/main/lib/util/LocalStorage",["gateway"],function(){Common.localStorage=new function(){var t,e,i={},n=function(t){"localstorage"==t.type&&(i=t.keys)};Common.Gateway.on("internalcommand",n);var o=function(){d||Common.Gateway.internalMessage("localstorage",{cmd:"get",keys:e})},s=function(){d||Common.Gateway.internalMessage("localstorage",{cmd:"set",keys:i})},a=function(t,e,n){if(d)try{localStorage.setItem(t,e)}catch(t){}else i[t]=e,!0===n&&Common.Gateway.internalMessage("localstorage",{cmd:"set",keys:{name:e}})},l=function(t,e,i){a(t,e?1:0,i)},r=function(t){return d?localStorage.getItem(t):void 0===i[t]?null:i[t]},c=function(t,e){var i=r(t);return e=e||!1,null!==i?0!=parseInt(i):e},h=function(t){return null!==r(t)};try{var d=!!window.localStorage}catch(t){d=!1}return{getId:function(){return t},setId:function(e){t=e},getItem:r,getBool:c,setBool:l,setItem:a,setKeysFilter:function(t){e=t},getKeysFilter:function(){return e},itemExists:h,sync:o,save:s}}}),define("spreadsheeteditor/main/app/model/ShapeGroup",["backbone"],function(t){"use strict";SSE.Models=SSE.Models||{},SSE.Models.ShapeModel=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),imageUrl:null,data:null}}}),SSE.Models.ShapeGroup=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),groupName:null,groupId:null,groupStore:null}}})}),define("spreadsheeteditor/main/app/collection/ShapeGroups",["backbone","spreadsheeteditor/main/app/model/ShapeGroup"],function(t){"use strict";if(void 0===e)var e={};e.Collections=e.Collections||{},SSE.Collections.ShapeGroups=t.Collection.extend({model:SSE.Models.ShapeGroup})}),define("spreadsheeteditor/main/app/model/EquationGroup",["backbone"],function(t){"use strict";SSE.Models=SSE.Models||{},SSE.Models.EquationModel=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),data:null,width:0,height:0,posX:0,posY:0}}}),SSE.Models.EquationGroup=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),groupName:null,groupId:null,groupStore:null}}})}),define("spreadsheeteditor/main/app/collection/EquationGroups",["backbone","spreadsheeteditor/main/app/model/EquationGroup"],function(t){"use strict";if(void 0===e)var e={};e.Collections=e.Collections||{},SSE.Collections.EquationGroups=t.Collection.extend({model:SSE.Models.EquationGroup})}),define("spreadsheeteditor/main/app/model/Formula",["backbone"],function(t){"use strict";SSE.Models=SSE.Models||{},SSE.Models.FormulaModel=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),index:0,group:null,name:null,origin:null,args:null}}}),SSE.Models.FormulaGroup=t.Model.extend({defaults:function(){return{id:Common.UI.getId(),index:0,name:null,store:null,functions:[]}}})}),define("spreadsheeteditor/main/app/collection/FormulaGroups",["backbone","spreadsheeteditor/main/app/model/Formula"],function(t){"use strict";SSE.Collections=SSE.Collections||{},SSE.Collections.FormulaGroups=t.Collection.extend({model:SSE.Models.FormulaGroup})}),define("spreadsheeteditor/main/app/view/FormulaDialog",["common/main/lib/component/Window","spreadsheeteditor/main/app/collection/FormulaGroups"],function(){"use strict";SSE.Views=SSE.Views||{},SSE.Views.FormulaDialog=Common.UI.Window.extend(_.extend({applyFunction:void 0,initialize:function(t){var e=this,i={};_.extend(i,{width:375,height:490,header:!0,cls:"formula-dlg",contentTemplate:"",title:e.txtTitle,items:[]},t),this.template=t.template||['<div class="box" style="height:'+(i.height-85)+'px;">','<div class="content-panel" >','<label class="header">'+e.textGroupDescription+"</label>",'<div id="formula-dlg-combo-group" class="input-group-nr" style="margin-top: 10px"/>','<label class="header" style="margin-top:10px">'+e.textListDescription+"</label>",'<div id="formula-dlg-combo-functions" class="combo-functions"/>','<label id="formula-dlg-args" style="margin-top: 7px"></label>','<label id="formula-dlg-desc" style="margin-top: 4px; display: block;"></label>',"</div>","</div>",'<div class="separator horizontal"/>','<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+e.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+e.cancelButtonText+"</button>","</div>"].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<n;++e){var o=this.formulasGroups.at(e);o.get("functions").length&&i.push({value:o.get("name"),displayValue:o.get("caption")})}this.cmbFuncGroup?this.cmbFuncGroup.setData(i):(this.cmbFuncGroup=new Common.UI.ComboBox({el:$("#formula-dlg-combo-group"),menuStyle:"min-width: 100%;",cls:"input-group-nr",data:i,editable:!1}),this.cmbFuncGroup.on("selected",_.bind(this.onSelectGroup,this))),this.cmbFuncGroup.setValue("Last10"),this.fillFunctions("Last10")}},fillFunctions:function(t){if(this.formulasGroups&&(this.cmbListFunctions||this.functions||(this.functions=new Common.UI.DataViewStore,this.cmbListFunctions=new Common.UI.ListView({el:$("#formula-dlg-combo-functions"),store:this.functions,itemTemplate:_.template('<div id="<%= id %>" class="list-item" style="pointer-events:none;"><%= value %></div>')}),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;e<i;++e)this.functions.push(new Common.UI.DataViewModel({id:n[e].get("index"),selected:e<1,allowSelected:!0,value:n[e].get("name"),args:n[e].get("args"),desc:n[e].get("desc"),origin:n[e].get("origin")}));this.applyFunction={name:n[0].get("name"),origin:n[0].get("origin")},this.syntaxLabel.text(this.applyFunction.name+n[0].get("args")),this.descLabel.text(n[0].get("desc")),this.cmbListFunctions.scroller.update({minScrollbarLength:40,alwaysVisibleY:!0})}}},onKeyDown:function(t,e){function i(t){s.selectRecord(t),s.scrollToRecord(t),c=$(s.el).find(".inner"),s.scroller.scrollTop(c.scrollTop(),0),e.preventDefault(),e.stopPropagation()}var n=0,o=null,s=this,a="",l="",r=null,c=null,h=!1,d=null;if(!this.disabled){if(_.isUndefined(void 0)&&(e=t),a=t.key,t.keyCode>64&&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;n<this.store.length;++n)if(o=this.store.at(n),l=o.get("value"),l[0].toLocaleLowerCase()===a){if(null===r&&(r=o),h){d===o&&(h=!1);continue}if(o.get("selected"))continue;return void i(o)}if(r)return void i(r)}Common.UI.DataView.prototype.onKeyDown.call(this,t,e)}},onScrollToRecordCustom:function(t){var e=$(this.el).find(".inner"),i=e.offset().top,n=e.find("#"+t.get("id")).parent(),o=n.offset().top;(o<i||o+n.height()>i+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('<div id="id-toolbar-formula-menu-'+e+'" style="display: flex;" class="open"></div>')},{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('<div id="id-toolbar-formula-menu-'+t+'" style="display: flex;" class="open"></div>')},{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<Math.min(4,t.length);e++)this.api&&t[e].setCaption(this.api.asc_getFormulaLocaleName(t[e].value));var i=this,n=[];["Cube","Database","Engineering","Information","Statistical"].forEach(function(t){var e=i.setMenuItemMenu(t);e&&n.push(e)});var o=this.btnMore;n.length&&(o.menu&&o.menu.rendered?(o.menu.removeAll(),n.forEach(function(t){o.menu.addItem(t)})):o.setMenu(new Common.UI.Menu({items:n})),o.menu.items.forEach(function(t){var e=t.menu.items[0].cmpEl.children(":first"),i=t.menu._innerMenu;i.render(e),i.cmpEl.css({display:"block",position:"relative",left:0,top:0}),i.cmpEl.attr({tabindex:"-1"})})),o.setDisabled(n.length<1)}},updateRecent:function(){this.formulasGroups&&this.setButtonMenu(this.btnRecent,"Last10")},setApi:function(t){this.api=t},txtRecent:"Recently used",txtAutosum:"Autosum",txtAutosumTip:"Summation",txtAdditional:"Additional",txtFormula:"Function",txtFormulaTip:"Insert function",txtMore:"More functions"}}(),SSE.Views.FormulaTab||{}))}),define("spreadsheeteditor/main/app/controller/FormulaDialog",["core","spreadsheeteditor/main/app/collection/FormulaGroups","spreadsheeteditor/main/app/view/FormulaDialog","spreadsheeteditor/main/app/view/FormulaTab"],function(){"use strict";SSE.Controllers=SSE.Controllers||{},SSE.Controllers.FormulaDialog=Backbone.Controller.extend(_.extend({models:[],views:["FormulaDialog","FormulaTab"],collections:["FormulaGroups"],initialize:function(){var t=this;t.langJson={},t.langDescJson={},this.addListeners({FileMenu:{"settings:apply":function(){if(t.mode&&t.mode.isEdit){t.needUpdateFormula=!0;var e=Common.localStorage.getItem("sse-settings-func-locale");Common.Utils.InternalSettings.set("sse-settings-func-locale",e),t.formulasGroups.reset(),t.reloadTranslations(e)}}},FormulaTab:{"function:apply":this.applyFunction},Toolbar:{"function:apply":this.applyFunction,"tab:active":this.onTabActive}})},applyFunction:function(t,e,i){t&&("more"===t.origin?this.showDialog(i):(this.api.asc_insertFormula(t.name,Asc.c_oAscPopUpSelectorType.Func,!!e),!e&&this.updateLast10Formulas(t.origin)))},setConfig:function(t){return this.toolbar=t.toolbar,this.formulaTab=this.createView("FormulaTab",{toolbar:this.toolbar.toolbar,formulasGroups:this.formulasGroups}),this},setApi:function(t){if(this.api=t,this.formulasGroups&&this.api){Common.Utils.InternalSettings.set("sse-settings-func-last",Common.localStorage.getItem("sse-settings-func-last")),this.reloadTranslations(Common.localStorage.getItem("sse-settings-func-locale")||this.appOptions.lang,!0);var e=this;this.formulas=new SSE.Views.FormulaDialog({api:this.api,toolclose:"hide",formulasGroups:this.formulasGroups,handler:_.bind(this.applyFunction,this)}),this.formulas.on({hide:function(){e.api.asc_enableKeyEvents(!0)}})}return this.formulaTab&&this.formulaTab.setApi(this.api),this},setMode:function(t){return this.mode=t,this},onLaunch:function(){this.formulasGroups=this.getApplication().getCollection("FormulaGroups");Common.Gateway.on("init",this.loadConfig.bind(this))},loadConfig:function(t){this.appOptions={},this.appOptions.lang=t.config.lang},reloadTranslations:function(t,e){var i=this;t=(t||"en").split(/[\-_]/)[0].toLowerCase(),Common.Utils.InternalSettings.set("sse-settings-func-locale",t),i.langJson[t]?(i.api.asc_setLocalization(i.langJson[t]),Common.NotificationCenter.trigger("formula:settings",this)):"en"==t?(i.api.asc_setLocalization(void 0),Common.NotificationCenter.trigger("formula:settings",this)):Common.Utils.loadConfig("resources/formula-lang/"+t+".json",function(e){"error"!=e&&(i.langJson[t]=e,i.api.asc_setLocalization(e),Common.NotificationCenter.trigger("formula:settings",this))}),i.langDescJson[t]?i.loadingFormulas(i.langDescJson[t],e):Common.Utils.loadConfig("resources/formula-lang/"+t+"_desc.json",function(n){"error"!=n?(i.langDescJson[t]=n,i.loadingFormulas(n,e)):Common.Utils.loadConfig("resources/formula-lang/en_desc.json",function(n){i.langDescJson[t]="error"!=n?n:null,i.loadingFormulas(i.langDescJson[t],e)})})},getDescription:function(t){return t?(t=t.toLowerCase(),this.langDescJson[t]?this.langDescJson[t]:null):""},showDialog:function(t){this.formulas&&(this.needUpdateFormula&&(this.needUpdateFormula=!1, this.formulas.$window&&this.formulas.fillFormulasGroups()),this.formulas.show(t))},hideDialog:function(){this.formulas&&this.formulas.isVisible()&&this.formulas.hide()},updateLast10Formulas:function(t){var e=Common.Utils.InternalSettings.get("sse-settings-func-last")||"SUM;AVERAGE;IF;HYPERLINK;COUNT;MAX;SIN;SUMIF;PMT;STDEV";e=e.split(";");var i=_.indexOf(e,t);e.splice(i<0?e.length-1:i,1),e.unshift(t);var n=e.join(";");if(Common.localStorage.setItem("sse-settings-func-last",n),Common.Utils.InternalSettings.set("sse-settings-func-last",n),this.formulasGroups){var o=this.formulasGroups.findWhere({name:"Last10"});o&&o.set("functions",this.loadingLast10Formulas(this.getDescription(Common.Utils.InternalSettings.get("sse-settings-func-locale")))),this.formulaTab&&this.formulaTab.updateRecent()}},loadingLast10Formulas:function(t){for(var e=(Common.Utils.InternalSettings.get("sse-settings-func-last")||"SUM;AVERAGE;IF;HYPERLINK;COUNT;MAX;SIN;SUMIF;PMT;STDEV").split(";"),i=this.api.asc_getFunctionArgumentSeparator(),n=[],o=0;o<e.length;o++){var s=e[o];n.push(new SSE.Models.FormulaModel({index:o,group:"Last10",name:this.api.asc_getFormulaLocaleName(s),origin:s,args:(t&&t[s]?t[s].a:"").replace(/[,;]/g,i),desc:t&&t[s]?t[s].d:""}))}return n},loadingFormulas:function(t,e){var i,n,o,s=0,a=0,l=this.formulasGroups,r=null,c=0,h=0,d=null,p=[],m=null,u=null,g=this.api.asc_getFunctionArgumentSeparator();if(l&&(i="Last10",u=new SSE.Models.FormulaGroup({name:i,index:c,store:l,caption:this["sCategory"+i]||i}),u&&(u.set("functions",this.loadingLast10Formulas(t)),l.push(u),c+=1),i="All",m=new SSE.Models.FormulaGroup({name:i,index:c,store:l,caption:this["sCategory"+i]||i}),m&&(l.push(m),c+=1),m)){for(d=this.api.asc_getFormulasInfo(),s=0;s<d.length;s+=1){for(i=d[s].asc_getGroupName(),n=d[s].asc_getFormulasArray(),r=new SSE.Models.FormulaGroup({name:i,index:c,store:l,caption:this["sCategory"+i]||i}),c+=1,o=[],a=0;a<n.length;a+=1){var b=n[a].asc_getName(),f=new SSE.Models.FormulaModel({index:h,group:i,name:n[a].asc_getLocaleName(),origin:b,args:(t&&t[b]?t[b].a:"").replace(/[,;]/g,g),desc:t&&t[b]?t[b].d:""});h+=1,o.push(f),p.push(f)}r.set("functions",_.sortBy(o,function(t){return t.get("name")})),l.push(r)}m.set("functions",_.sortBy(p,function(t){return t.get("name")}))}(!e||this._formulasInited)&&this.formulaTab&&this.formulaTab.fillFunctions()},onTabActive:function(t){"formula"==t&&!this._formulasInited&&this.formulaTab&&(this.formulaTab.fillFunctions(),this._formulasInited=!0)},sCategoryAll:"All",sCategoryLast10:"10 last used",sCategoryLogical:"Logical",sCategoryCube:"Cube",sCategoryDatabase:"Database",sCategoryDateAndTime:"Date and time",sCategoryEngineering:"Engineering",sCategoryFinancial:"Financial",sCategoryInformation:"Information",sCategoryLookupAndReference:"Lookup and reference",sCategoryMathematic:"Math and trigonometry",sCategoryStatistical:"Statistical",sCategoryTextAndData:"Text and data"},SSE.Controllers.FormulaDialog||{}))}),define("spreadsheeteditor/main/app/controller/Main",["core","irregularstack","common/main/lib/component/Window","common/main/lib/component/LoadMask","common/main/lib/component/Tooltip","common/main/lib/controller/Fonts","common/main/lib/collection/TextArt","common/main/lib/view/OpenDialog","common/main/lib/util/LanguageInfo","common/main/lib/util/LocalStorage","spreadsheeteditor/main/app/collection/ShapeGroups","spreadsheeteditor/main/app/collection/TableTemplates","spreadsheeteditor/main/app/collection/EquationGroups","spreadsheeteditor/main/app/controller/FormulaDialog"],function(){"use strict";SSE.Controllers.Main=Backbone.Controller.extend(_.extend(function(){var t={about:"button#left-btn-about",feedback:"button#left-btn-support",goback:"#fm-btn-back > 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+="<br/><br/>"+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.<br>Wrong cout of brackets.",errorWrongOperator:"An error in the entered formula. Wrong operator is used.<br>Please correct the error or use the Esc button to cancel the formula editing.",errorCountArgExceed:"Found an error in the formula entered.<br>Count of arguments exceeded.",errorCountArg:"Found an error in the formula entered.<br>Invalid number of arguments.",errorFormulaName:"Found an error in the formula entered.<br>Incorrect formula name.",errorFormulaParsing:"Internal error while the formula parsing.",errorArgsRange:"Found an error in the formula entered.<br>Incorrect arguments range.",errorUnexpectedGuid:"External error.<br>Unexpected Guid. Please, contact support.",errorDatabaseConnection:"External error.<br>Database connection error. Please, contact support.",errorFileRequest:"External error.<br>File Request. Please, contact support.",errorFileVKey:"External error.<br>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:<br> 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.<br>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.<br>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.<br>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.<br>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<br>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.<br>When you click the \'OK\' button, you will be prompted to download the document.<br><br>Find more information about connecting Document Server <a href="%1" target="_blank">here</a>',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.<br>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<br>the allowed number of characters and it was removed.",errorFrmlWrongReferences:"The function refers to a sheet that does not exist.<br>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.<br>They will be unmerged before they are pasted into the table.",errorViewerDisconnect:"Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored.",warnLicenseExp:"Your license has expired.<br>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.<br>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.<br>This restriction will be eliminated in upcoming releases.",errorToken:"The document security token is not correctly formed.<br>Please contact your Document Server administrator.",errorTokenExpire:"The document security token has expired.<br>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.<br>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.<br>If you need more please consider purchasing a commercial license.",warnNoLicenseUsers:"This version of %1 Editors has certain limitations for concurrent users.<br>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.<br>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.<br>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.<br>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.<br>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.<br>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.<br>Use the CONCATENATE function or concatenation operator (&)",waitText:"Please, wait...",errorDataValidate:"The value you entered is not valid.<br>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=['<div id="id-sharing-placeholder"></div>'].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(["<table><tbody>","<% _.each(rows, function(row) { %>","<tr>","<% _.each(row, function(item) { %>",'<td><div><svg class="btn-doc-format" format="<%= item.type %>">','<use xlink:href="#svg-format-<%= item.imgCls %>"></use>',"</svg></div></td>","<% }) %>","</tr>","<% }) %>","</tbody></table>"].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(["<table><tbody>","<% _.each(rows, function(row) { %>","<tr>","<% _.each(row, function(item) { %>",'<td><div><svg class="btn-doc-format" format="<%= item.type %>", format-ext="<%= item.ext %>">','<use xlink:href="#svg-format-<%= item.imgCls %>"></use>',"</svg></div></td>","<% }) %>","</tr>","<% }) %>","</tbody></table>"].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(['<div style="width:100%; height:100%; position: relative;">','<div id="id-settings-menu" style="position: absolute; width:200px; top: 0; bottom: 0;" class="no-padding"></div>','<div id="id-settings-content" style="position: absolute; left: 200px; top: 0; right: 0; bottom: 0;" class="no-padding">','<div id="panel-settings-general" style="width:100%; height:100%;" class="no-padding main-settings-panel active"></div>','<div id="panel-settings-print" style="width:100%; height:100%;" class="no-padding main-settings-panel"></div>',"</div>","</div>"].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(['<div id="<%= id %>" class="settings-item-wrap">','<div class="settings-icon <%= iconCls %>" style="display: inline-block;" >',"</div><%= name %>","</div>"].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(['<table class="main"><tbody>',"<tr>",'<td class="left"><label><%= scope.textSettings %></label></td>','<td class="right"><div id="advsettings-print-combo-sheets" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageSize %></label></td>','<td class="right"><div id="advsettings-print-combo-pages" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageOrientation %></label></td>','<td class="right"><span id="advsettings-print-combo-orient" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageScaling %></label></td>','<td class="right"><span id="advsettings-print-combo-layout" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left" style="vertical-align: top;"><label><%= scope.strMargins %></label></td>','<td class="right" style="vertical-align: top;"><div id="advsettings-margins">','<table cols="2" class="no-padding">',"<tr>","<td><label><%= scope.strTop %></label></td>","<td><label><%= scope.strBottom %></label></td>","</tr>","<tr>",'<td><div id="advsettings-spin-margin-top"></div></td>','<td><div id="advsettings-spin-margin-bottom"></div></td>',"</tr>","<tr>","<td><label><%= scope.strLeft %></label></td>","<td><label><%= scope.strRight %></label></td>","</tr>","<tr>",'<td><div id="advsettings-spin-margin-left"></div></td>','<td><div id="advsettings-spin-margin-right"></div></td>',"</tr>","</table>","</div></td>","</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left" style="vertical-align: top;"><label><%= scope.strPrint %></label></td>','<td class="right" style="vertical-align: top;"><div id="advsettings-print">','<div id="advsettings-print-chb-grid" style="margin-bottom: 10px;"/>','<div id="advsettings-print-chb-rows"/>',"</div></td>","</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"></td>','<td class="right"><button id="advsettings-print-button-save" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',"</tr>","</tbody></table>"].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<this.spinners.length;t++){var e=this.spinners[t];e.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName()),e.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt?1:.1)}for(var i=this.cmbPaperSize.store,t=0;t<i.length;t++){var n=i.at(t),o=n.get("value"),s=/^\d{3}\.?\d*/.exec(o),a=/\d{3}\.?\d*$/.exec(o);n.set("displayValue",n.get("caption")+" ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(a).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")")}this.cmbPaperSize.onResetItems()},applySettings:function(){this.menu&&this.menu.fireEvent("settings:apply",[this.menu])},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this._initSettings&&(this.updateMetricUnit(),this._initSettings=!1),this.fireEvent("show",this)},okButtonText:"Save",strPortrait:"Portrait",strLandscape:"Landscape",textPrintGrid:"Print Gridlines",textPrintHeadings:"Print Rows and Columns Headings",strLeft:"Left",strRight:"Right",strTop:"Top",strBottom:"Bottom",strMargins:"Margins",textPageSize:"Page Size",textPageOrientation:"Page Orientation",strPrint:"Print",textSettings:"Settings for",textPageScaling:"Scaling",textActualSize:"Actual Size",textFitPage:"Fit Sheet on One Page",textFitCols:"Fit All Columns on One Page",textFitRows:"Fit All Rows on One Page"},SSE.Views.MainSettingsPrint||{})),SSE.Views.FileMenuPanels.MainSettingsGeneral=Common.UI.BaseView.extend(_.extend({el:"#panel-settings-general",menu:void 0,template:_.template(['<table class="main"><tbody>','<tr class="comments">','<td class="left"><label><%= scope.txtLiveComment %></label></td>','<td class="right"><div id="fms-chb-live-comment"/></td>',"</tr>",'<tr class="divider comments"></tr>','<tr class="comments">','<td class="left"></td>','<td class="right"><div id="fms-chb-resolved-comment"/></td>',"</tr>",'<tr class="divider comments"></tr>','<tr class="autosave">','<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>','<td class="right"><span id="fms-chb-autosave" /></td>',"</tr>",'<tr class="divider autosave"></tr>','<tr class="forcesave">','<td class="left"><label id="fms-lbl-forcesave"><%= scope.textForceSave %></label></td>','<td class="right"><span id="fms-chb-forcesave" /></td>',"</tr>",'<tr class="divider forcesave"></tr>',"<tr>",'<td class="left"><label><%= scope.textRefStyle %></label></td>','<td class="right"><div id="fms-chb-r1c1-style"/></td>',"</tr>",'<tr class="divider"></tr>','<tr class="coauth changes">','<td class="left"><label><%= scope.strCoAuthMode %></label></td>','<td class="right">','<div><div id="fms-cmb-coauth-mode" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-coauth-mode" style="vertical-align: middle;"><%= scope.strCoAuthModeDescFast %></label></div></td>',"</tr>",'<tr class="divider coauth changes"></tr>',"<tr>",'<td class="left"><label><%= scope.strZoom %></label></td>','<td class="right"><div id="fms-cmb-zoom" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.strFontRender %></label></td>','<td class="right"><span id="fms-cmb-font-render" /></td>',"</tr>",'<tr class="divider"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strUnit %></label></td>','<td class="right"><span id="fms-cmb-unit" /></td>',"</tr>",'<tr class="divider edit"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strFuncLocale %></label></td>','<td class="right">','<div><div id="fms-cmb-func-locale" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-func-locale" style="vertical-align: middle;"><%= scope.strFuncLocaleEx %></label></div></td>',"</tr>",'<tr class="divider edit"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strRegSettings %></label></td>','<td class="right">','<div><div id="fms-cmb-reg-settings" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-reg-settings" style="vertical-align: middle;"></label></div></td>',"</tr>",'<tr class="divider edit"></tr>',"<tr>",'<td class="left"></td>','<td class="right"><button id="fms-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',"</tr>","</tbody></table>"].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(['<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">','<input type="text" class="form-control" style="padding-left: 25px !important;">','<span class="icon input-icon lang-flag"></span>','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret img-commonctrl"></span></button>','<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',"<% _.each(items, function(item) { %>",'<li id="<%= item.id %>" data-value="<%= item.value %>">','<a tabindex="-1" type="menuitem" style="padding-left: 26px !important;">','<i class="icon lang-flag <%= item.langName %>" style="position: absolute;margin-left:-21px;"></i>',"<%= scope.getDisplayValue(item) %>","</a>","</li>","<% }); %>","</ul>","</span>"].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(['<div id="id-recent-view" style="margin: 20px 0;"></div>'].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(['<div class="recent-wrap">','<div class="recent-icon"></div>','<div class="file-name"><%= Common.Utils.String.htmlEncode(title) %></div>','<div class="file-info"><%= Common.Utils.String.htmlEncode(folder) %></div>',"</div>"].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(['<h3 style="margin-top: 20px;"><%= scope.fromBlankText %></h3><hr noshade />','<div class="blank-document">','<div class="blank-document-btn">','<svg class="btn-doc-format">','<use xlink:href="#svg-format-xlsx"></use>',"</svg>","</div>",'<div class="blank-document-info">',"<h3><%= scope.newDocumentText %></h3>","<%= scope.newDescriptionText %>","</div>","</div>","<h3><%= scope.fromTemplateText %></h3><hr noshade />",'<div class="thumb-list">',"<% _.each(docs, function(item) { %>",'<div class="thumb-wrap" template="<%= item.url %>">','<div class="thumb"',"<% if (!_.isEmpty(item.icon)) { print(\" style='background-image: url(item.icon);'>\") } else { print(\"><svg class='btn-doc-format'><use xlink:href='#svg-format-blank'></use></svg>\") } %>","</div>",'<div class="title"><%= item.name %></div>',"</div>","<% }) %>","</div>"].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(['<table class="main">',"<tr>",'<td class="left"><label>'+this.txtPlacement+"</label></td>",'<td class="right"><label id="id-info-placement">-</label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtOwner+"</label></td>",'<td class="right"><label id="id-info-owner">-</label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtUploaded+"</label></td>",'<td class="right"><label id="id-info-uploaded">-</label></td>',"</tr>",'<tr class="divider general"></tr>','<tr class="divider general"></tr>',"<tr>",'<td class="left"><label>'+this.txtTitle+"</label></td>",'<td class="right"><div id="id-info-title"></div></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtSubject+"</label></td>",'<td class="right"><div id="id-info-subject"></div></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtComment+"</label></td>",'<td class="right"><div id="id-info-comment"></div></td>',"</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"><label>'+this.txtModifyDate+"</label></td>",'<td class="right"><label id="id-info-modify-date"></label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtModifyBy+"</label></td>",'<td class="right"><label id="id-info-modify-by"></label></td>',"</tr>",'<tr class="divider modify">','<tr class="divider modify">',"<tr>",'<td class="left"><label>'+this.txtCreated+"</label></td>",'<td class="right"><label id="id-info-date"></label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtAppName+"</label></td>",'<td class="right"><label id="id-info-appname"></label></td>',"</tr>","<tr>",'<td class="left" style="vertical-align: top;"><label style="margin-top: 3px;">'+this.txtAuthor+"</label></td>",'<td class="right" style="vertical-align: top;"><div id="id-info-author">',"<table>","<tr>",'<td><div id="id-info-add-author"><input type="text" spellcheck="false" class="form-control" placeholder="'+this.txtAddAuthor+'"></div></td>',"</tr>","</table>","</div></td>","</tr>","</table>"].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='<tr><td><div style="display: inline-block;width: 200px;"><input type="text" spellcheck="false" class="form-control" readonly="true" value="{0}" ></div><div class="close img-commonctrl"></div></td></tr>',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(['<table class="main">','<tr class="rights">','<td class="left" style="vertical-align: top;"><label>'+this.txtRights+"</label></td>",'<td class="right"><div id="id-info-rights"></div></td>',"</tr>",'<tr class="edit-rights">','<td class="left"></td><td class="right"><button id="id-info-btn-edit" class="btn normal dlg-btn primary custom" style="margin-right: 10px;">'+this.txtBtnAccessRights+"</button></td>","</tr>","</table>"].join("")),this.templateRights=_.template(["<table>","<% _.each(users, function(item) { %>","<tr>",'<td><span class="userLink <% if (item.isLink) { %>sharedLink<% } %>"></span><span><%= Common.Utils.String.htmlEncode(item.user) %></span></td>',"<td><%= Common.Utils.String.htmlEncode(item.permissions) %></td>","</tr>","<% }); %>","</table>"].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(['<div style="width:100%; height:100%; position: relative;">','<div id="id-help-contents" style="position: absolute; width:220px; top: 0; bottom: 0;" class="no-padding"></div>','<div id="id-help-frame" style="position: absolute; left: 220px; top: 0; right: 0; bottom: 0;" class="no-padding"></div>',"</div>"].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(['<div id="<%= id %>" class="help-item-wrap">','<div class="caption"><%= name %></div>',"</div>"].join(""))}),this.viewHelpPicker.on("item:add",function(t,e,i){i.has("headername")&&$(e.el).before('<div class="header-name">'+i.get("headername")+"</div>")}),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(['<label id="id-fms-lbl-protect-header" style="font-size: 18px;"><%= scope.strProtect %></label>','<div id="id-fms-password">','<label class="header"><%= scope.strEncrypt %></label>','<div id="fms-btn-add-pwd" style="width:190px;"></div>','<table id="id-fms-view-pwd" cols="2" width="300">',"<tr>",'<td colspan="2"><label style="cursor: default;"><%= scope.txtEncrypted %></label></td>',"</tr>","<tr>",'<td><div id="fms-btn-change-pwd" style="width:190px;"></div></td>','<td align="right"><div id="fms-btn-delete-pwd" style="width:190px; margin-left:20px;"></div></td>',"</tr>","</table>","</div>",'<div id="id-fms-signature">','<label class="header"><%= scope.strSignature %></label>','<div id="fms-btn-invisible-sign" style="width:190px; margin-bottom: 20px;"></div>','<div id="id-fms-signature-view"></div>',"</div>"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu;var e=this;this.templateSignature=_.template(['<table cols="2" width="300" class="<% if (!hasRequested && !hasSigned) { %>hidden<% } %>"">',"<tr>",'<td colspan="2"><label style="cursor: default;"><%= tipText %></label></td>',"</tr>","<tr>",'<td><label class="link signature-view-link">'+e.txtView+"</label></td>",'<td align="right"><label class="link signature-edit-link <% if (!hasSigned) { %>hidden<% } %>">'+e.txtEdit+"</label></td>","</tr>","</table>"].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?"<br><br>":"")+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.<br>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'<div class="settings-panel active">\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-range" class="input-group-nr" />\r\n <div id="printadv-dlg-chb-ignore" style="margin-top: 5px;"/>\r\n </div>\r\n <div class="padding-small"/>\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-sheets" class="input-group-nr" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-pages" class="input-group-nr" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <span id="printadv-dlg-combo-orient" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <span id="printadv-dlg-combo-layout" />\r\n </div>\r\n <div id="printadv-dlg-content-to-hide">\r\n <div class="padding-large inner-content" >\r\n <table cols="2" class="no-padding">\r\n <tr>\r\n <td><label><%= scope.strTop %></label></td>\r\n <td><label><%= scope.strBottom %></label></td>\r\n </tr>\r\n <tr>\r\n <td class="padding-small"><div id="printadv-dlg-spin-margin-top" style="margin-right: 19px;"></div></td>\r\n <td class="padding-small"><div id="printadv-dlg-spin-margin-bottom"></div></td>\r\n </tr>\r\n <tr>\r\n <td><label><%= scope.strLeft %></label></td>\r\n <td><label><%= scope.strRight %></label></td>\r\n </tr>\r\n <tr>\r\n <td><div id="printadv-dlg-spin-margin-left" style="margin-right: 15px;"></div></td>\r\n <td><div id="printadv-dlg-spin-margin-right"></div></td>\r\n </tr>\r\n </table>\r\n </div>\r\n <div class="padding-small"/>\r\n <div class="inner-content">\r\n <div id="printadv-dlg-chb-grid" style="margin-bottom: 10px;"/>\r\n <div id="printadv-dlg-chb-rows"/>\r\n </div>\r\n </div>\r\n</div>\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:['<div class="box" style="height:'+(this.options.height-85)+'px;">','<div class="menu-panel" style="overflow: hidden;">','<div style="height: 54px; line-height: 42px;" class="div-category">'+("print"==this.type?this.textPrintRange:this.textRange)+"</div>",'<div style="height: 52px; line-height: 66px;" class="div-category">'+this.textSettings+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageSize+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageOrientation+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageScaling+"</div>",'<div style="height: 108px; line-height: 33px;" class="div-category">'+this.strMargins+"</div>",'<div style="height: 58px; line-height: 40px;" class="div-category">'+("print"==this.type?this.strPrint:this.strShow)+"</div>","</div>",'<div class="content-panel">'+_.template(t)({scope:this})+"</div>","</div>",'<div class="separator horizontal"/>','<div class="footer justify">','<button id="printadv-dlg-btn-hide" class="btn btn-text-default" style="margin-right: 55px; width: 100px;">'+this.textHideDetails+"</button>",'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px; width: 150px;">'+("print"==this.type?this.btnPrint:this.btnDownload)+"</button>",'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">'+this.cancelButtonText+"</button>","</div>"].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;t<this.spinners.length;t++){var e=this.spinners[t];e.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName()),e.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt?1:.1)}for(var i=this.cmbPaperSize.store,t=0;t<i.length;t++){var n=i.at(t),o=n.get("value"),s=/^\d{3}\.?\d*/.exec(o),a=/\d{3}\.?\d*$/.exec(o);n.set("displayValue",n.get("caption")+" ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(a).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")")}this.cmbPaperSize.onResetItems()},handlerShowDetails:function(t){this.extended?(this.extended=!1,this.panelDetails.css({display:"block"}),this.setHeight(475),t.setCaption(this.textHideDetails),Common.localStorage.setItem("sse-hide-print-settings",0)):(this.extended=!0,this.panelDetails.css({display:"none"}),this.setHeight(314),t.setCaption(this.textShowDetails),Common.localStorage.setItem("sse-hide-print-settings",1))},textTitle:"Print Settings",strLeft:"Left",strRight:"Right",strTop:"Top",strBottom:"Bottom",strPortrait:"Portrait",strLandscape:"Landscape",textPrintGrid:"Print Gridlines",textPrintHeadings:"Print Rows and Columns Headings",textPageSize:"Page Size",textPageOrientation:"Page Orientation",strMargins:"Margins",strPrint:"Print",btnPrint:"Save & Print",textPrintRange:"Print Range",textLayout:"Layout",textCurrentSheet:"Current Sheet",textAllSheets:"All Sheets",textSelection:"Selection",textActualSize:"Actual Size",textFitPage:"Fit Sheet on One Page",textFitCols:"Fit All Columns on One Page",textFitRows:"Fit All Rows on One Page",textShowDetails:"Show Details",cancelButtonText:"Cancel",textHideDetails:"Hide Details",textPageScaling:"Scaling",textSettings:"Sheet Settings",textTitlePDF:"PDF Settings",textShowGrid:"Show Gridlines",textShowHeadings:"Show Rows and Columns Headings",strShow:"Show",btnDownload:"Save & Download",textRange:"Range",textIgnore:"Ignore Print Area"},SSE.Views.PrintSettings||{}))}),define("spreadsheeteditor/main/app/controller/Print",["core","spreadsheeteditor/main/app/view/FileMenuPanels","spreadsheeteditor/main/app/view/PrintSettings"],function(){"use strict";SSE.Controllers.Print=Backbone.Controller.extend(_.extend({views:["MainSettingsPrint"],initialize:function(){var t=Common.localStorage.getItem("sse-print-settings-range");t=null!==t?parseInt(t):Asc.c_oAscPrintType.ActiveSheets,this.adjPrintParams=new Asc.asc_CAdjustPrint,this.adjPrintParams.asc_setPrintType(t),this._changedProps=null,this._originalPageSettings=null,this.addListeners({MainSettingsPrint:{show:_.bind(this.onShowMainSettingsPrint,this),"render:after":_.bind(this.onAfterRender,this)},PrintSettings:{changerange:_.bind(this.onChangeRange,this)}})},onLaunch:function(){this.printSettings=this.createView("MainSettingsPrint")},onAfterRender:function(t){this.printSettings.cmbSheet.on("selected",_.bind(this.comboSheetsChange,this,this.printSettings)),this.printSettings.btnOk.on("click",_.bind(this.querySavePrintSettings,this)),Common.NotificationCenter.on("print",_.bind(this.openPrintSettings,this,"print")),Common.NotificationCenter.on("download:settings",_.bind(this.openPrintSettings,this,"download")),this.registerControlEvents(this.printSettings)},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onSheetsChanged",_.bind(this.updateSheetsInfo,this))},updateSheetsInfo:function(){this.printSettings.isVisible()?this.updateSettings(this.printSettings):this.isFillSheets=!1},updateSettings:function(t){for(var e=this.api.asc_getWorksheetsCount(),i=-1,n=[];++i<e;)this.api.asc_isWorksheetHidden(i)||n.push({displayValue:this.api.asc_getWorksheetName(i),value:i});t.cmbSheet.store.reset(n);var o=t.cmbSheet.store.findWhere({value:t.cmbSheet.getValue()})||t.cmbSheet.store.findWhere({value:this.api.asc_getActiveWorksheetIndex()});o&&t.cmbSheet.setValue(o.get("value"))},comboSheetsChange:function(t,e,i){this.fillPageOptions(t,this._changedProps[i.value]?this._changedProps[i.value]:this.api.asc_getPageOptions(i.value))},fillPageOptions:function(t,e){var i=e.asc_getPageSetup();this._originalPageSettings=i;var n=t.cmbPaperOrientation.store.findWhere({value:i.asc_getOrientation()});n&&t.cmbPaperOrientation.setValue(n.get("value"));var o=i.asc_getWidth(),s=i.asc_getHeight(),a=t.cmbPaperSize.store;n=null;for(var l=0;l<a.length;l++){var r=a.at(l),c=r.get("value"),h=parseFloat(/^\d{3}\.?\d*/.exec(c)),d=parseFloat(/\d{3}\.?\d*$/.exec(c));if(Math.abs(h-o)<.1&&Math.abs(d-s)<.1){n=r;break}}n?t.cmbPaperSize.setValue(n.get("value")):t.cmbPaperSize.setValue("Custom ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(o).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")");var p=i.asc_getFitToWidth(),m=i.asc_getFitToHeight();p||m?p&&m?t.cmbLayout.setValue(1):p&&!m?t.cmbLayout.setValue(2):t.cmbLayout.setValue(3):t.cmbLayout.setValue(0),n=t.cmbPaperOrientation.store.findWhere({value:i.asc_getOrientation()}),n&&t.cmbPaperOrientation.setValue(n.get("value")),i=e.asc_getPageMargins(),t.spnMarginLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getLeft()),!0),t.spnMarginTop.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getTop()),!0),t.spnMarginRight.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getRight()),!0),t.spnMarginBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getBottom()),!0),t.chPrintGrid.setValue(e.asc_getGridLines(),!0),t.chPrintRows.setValue(e.asc_getHeadings(),!0)},fillPrintOptions:function(t){this.printSettingsDlg.setRange(t.asc_getPrintType()),this.printSettingsDlg.setIgnorePrintArea(!!t.asc_getIgnorePrintArea()),this.onChangeRange()},onChangeRange:function(){var t=this.printSettingsDlg.getRange(),e=this.printSettingsDlg.cmbSheet.store,i=t!==Asc.c_oAscPrintType.EntireWorkbook?e.findWhere({value:this.api.asc_getActiveWorksheetIndex()}):e.at(0);i&&(this.printSettingsDlg.cmbSheet.setValue(i.get("value")),this.comboSheetsChange(this.printSettingsDlg,this.printSettingsDlg.cmbSheet,i.toJSON())),this.printSettingsDlg.cmbSheet.setDisabled(t!==Asc.c_oAscPrintType.EntireWorkbook),this.printSettingsDlg.chIgnorePrintArea.setDisabled(t==Asc.c_oAscPrintType.Selection)},getPageOptions:function(t){var e=new Asc.asc_CPageOptions;e.asc_setGridLines("indeterminate"==t.chPrintGrid.getValue()?void 0:"checked"==t.chPrintGrid.getValue()?1:0),e.asc_setHeadings("indeterminate"==t.chPrintRows.getValue()?void 0:"checked"==t.chPrintRows.getValue()?1:0);var i=new Asc.asc_CPageSetup;i.asc_setOrientation("-"==t.cmbPaperOrientation.getValue()?void 0:t.cmbPaperOrientation.getValue());var n=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),o=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());i.asc_setWidth(n?parseFloat(n[0]):this._originalPageSettings?this._originalPageSettings.asc_getWidth():void 0),i.asc_setHeight(o?parseFloat(o[0]):this._originalPageSettings?this._originalPageSettings.asc_getHeight():void 0);var s=t.cmbLayout.getValue();return i.asc_setFitToWidth(1==s||2==s),i.asc_setFitToHeight(1==s||3==s),e.asc_setPageSetup(i),i=new Asc.asc_CPageMargins,i.asc_setLeft("-"==t.spnMarginLeft.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginLeft.getNumberValue())),i.asc_setTop("-"==t.spnMarginTop.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginTop.getNumberValue())),i.asc_setRight("-"==t.spnMarginRight.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginRight.getNumberValue())),i.asc_setBottom("-"==t.spnMarginBottom.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginBottom.getNumberValue())),e.asc_setPageMargins(i),e},savePageOptions:function(t){this.api.asc_savePagePrintOptions(this._changedProps),Common.NotificationCenter.trigger("page:settings")},onShowMainSettingsPrint:function(){this._changedProps=[],this.isFillSheets||(this.isFillSheets=!0,this.updateSettings(this.printSettings));var t=this.printSettings.cmbSheet.store.findWhere({value:this.api.asc_getActiveWorksheetIndex()});t&&(this.printSettings.cmbSheet.setValue(t.get("value")),this.comboSheetsChange(this.printSettings,this.printSettings.cmbSheet,t.toJSON()))},openPrintSettings:function(t,e,i,n){if(this.printSettingsDlg&&this.printSettingsDlg.isVisible())return void(n&&Common.NotificationCenter.trigger("download:cancel"));this.api&&(this.asUrl=n,this.downloadFormat=i,this.printSettingsDlg=new SSE.Views.PrintSettings({type:t,handler:_.bind(this.resultPrintSettings,this),afterrender:_.bind(function(){this._changedProps=[],this.updateSettings(this.printSettingsDlg),this.printSettingsDlg.cmbSheet.on("selected",_.bind(this.comboSheetsChange,this,this.printSettingsDlg)),this.fillPrintOptions(this.adjPrintParams),this.registerControlEvents(this.printSettingsDlg)},this)}),this.printSettingsDlg.show())},resultPrintSettings:function(t,e){var i=SSE.getController("Toolbar").getView("Toolbar");if("ok"==t){if(!this.checkMargins(this.printSettingsDlg))return!0;this.savePageOptions(this.printSettingsDlg);var n=this.printSettingsDlg.getRange();if(this.adjPrintParams.asc_setPrintType(n),this.adjPrintParams.asc_setPageOptionsMap(this._changedProps),this.adjPrintParams.asc_setIgnorePrintArea(this.printSettingsDlg.getIgnorePrintArea()),Common.localStorage.setItem("sse-print-settings-range",n),"print"==this.printSettingsDlg.type){var o=new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera);o.asc_setAdvancedOptions(this.adjPrintParams),this.api.asc_Print(o)}else{var o=new Asc.asc_CDownloadOptions(this.downloadFormat,this.asUrl);o.asc_setAdvancedOptions(this.adjPrintParams),this.api.asc_DownloadAs(o)}Common.component.Analytics.trackEvent("print"==this.printSettingsDlg.type?"Print":"DownloadAs"),Common.component.Analytics.trackEvent("ToolBar","print"==this.printSettingsDlg.type?"Print":"DownloadAs"),Common.NotificationCenter.trigger("edit:complete",i)}else this.asUrl&&Common.NotificationCenter.trigger("download:cancel"),Common.NotificationCenter.trigger("edit:complete",i);this.printSettingsDlg=null},querySavePrintSettings:function(){this.checkMargins(this.printSettings)&&(this.savePageOptions(this.printSettings),this.printSettings.applySettings())},checkMargins:function(t){if(t.cmbPaperOrientation.getValue()==Asc.c_oAscPageOrientation.PagePortrait)var e=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),i=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());else i=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),e=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());e=e?parseFloat(e[0]):this._originalPageSettings?this._originalPageSettings.asc_getWidth():0,i=i?parseFloat(i[0]):this._originalPageSettings?this._originalPageSettings.asc_getHeight():0;var n=Common.Utils.Metric.fnRecalcToMM(t.spnMarginLeft.getNumberValue()),o=Common.Utils.Metric.fnRecalcToMM(t.spnMarginRight.getNumberValue()),s=Common.Utils.Metric.fnRecalcToMM(t.spnMarginTop.getNumberValue()),a=Common.Utils.Metric.fnRecalcToMM(t.spnMarginBottom.getNumberValue()),l=!1;return n>e?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=['<div class="box">','<div id="group-radio-rows" style="margin-bottom: 5px;"></div>','<div id="group-radio-cols"></div>','<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","</div>"].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'<div id="<%=id%>" class="user-comment-item">\r\n\r\n \x3c!-- comment block --\x3e\r\n\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (usercolor!==null) { %><%=usercolor%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(username) %>\r\n </div>\r\n <div class="user-date"><%=date%></div>\r\n <% if (!editTextInPopover || hint) { %>\r\n <div oo_editor_input="true" tabindex="-1" class="user-message user-select"><%=scope.pickLink(comment)%></div>\r\n <% } else { %>\r\n <div class="inner-edit-ct">\r\n <textarea class="msg-reply user-select" maxlength="maxCommLength" spellcheck="false" <% if (!!dummy) { %> placeholder="textMention"<% } %>><%=comment%></textarea>\r\n <% if (hideAddReply) { %>\r\n <button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textAdd</button>\r\n <% } else { %>\r\n <button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textEdit</button>\r\n <% } %>\r\n <button class="btn normal dlg-btn btn-inner-close">textCancel</button>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- replys elements --\x3e\r\n\r\n <% if (replys.length) { %>\r\n <div class="reply-arrow img-commonctrl"></div>\r\n <% _.each(replys, function (item) { %>\r\n <div class="reply-item-ct">\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %>\r\n </div>\r\n <div class="user-date"><%=item.get("date")%></div>\r\n <% if (!item.get("editTextInPopover")) { %>\r\n <div oo_editor_input="true" tabindex="-1" class="user-message user-select"><%=scope.pickLink(item.get("reply"))%></div>\r\n <% if (!hint) { %>\r\n <div class="btns-reply-ct">\r\n <% if (item.get("editable")) { %>\r\n <div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>\r\n <div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>\r\n <%}%>\r\n </div>\r\n <%}%>\r\n <% } else { %>\r\n <div class="inner-edit-ct">\r\n <textarea class="msg-reply textarea-fix user-select" maxlength="maxCommLength" spellcheck="false"><%=item.get("reply")%></textarea>\r\n <button class="btn normal dlg-btn primary btn-inner-edit btn-fix" id="id-comments-change-popover">textEdit</button>\r\n <button class="btn normal dlg-btn btn-inner-close">textClose</button>\r\n </div>\r\n <% } %>\r\n </div>\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 <label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>\r\n <% } else { %>\r\n <label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>\r\n <% } %>\r\n <% } %>\r\n\r\n \x3c!-- edit buttons --\x3e\r\n\r\n <% if (!editTextInPopover && !lock && !hint) { %>\r\n <div class="edit-ct">\r\n <% if (editable) { %>\r\n <div class="btn-edit img-commonctrl"></div>\r\n <div class="btn-delete img-commonctrl"></div>\r\n <% } %>\r\n <% if (resolved) { %>\r\n <div class="btn-resolve-check img-commonctrl" data-toggle="tooltip"></div>\r\n <% } else { %>\r\n <div class="btn-resolve img-commonctrl" data-toggle="tooltip"></div>\r\n <% } %>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- reply --\x3e\r\n\r\n <% if (showReplyInPopover) { %>\r\n <div class="reply-ct">\r\n <textarea class="msg-reply user-select" placeholder="textAddReply" maxlength="maxCommLength" spellcheck="false"></textarea>\r\n <button class="btn normal dlg-btn primary btn-reply" id="id-comments-change-popover">textReply</button>\r\n <button class="btn normal dlg-btn btn-close">textClose</button>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- locked user --\x3e\r\n\r\n <% if (lock) { %>\r\n <div class="lock-area" style="cursor: default;"></div>\r\n <div class="lock-author" style="cursor: default;"><%=lockuserid%></div>\r\n <% } %>\r\n\r\n</div>'}),define("text!common/main/lib/template/ReviewChangesPopover.template",[],function(){return'<div id="<%=id%>" class="user-comment-item">\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (usercolor!==null) { %><%=usercolor%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(username) %>\r\n </div>\r\n <div class="user-date"><%=date%></div>\r\n <div class="user-message limit-height"><%=changetext%></div>\r\n <div class="edit-ct">\r\n <% if (goto) { %>\r\n <div class="btn-goto img-commonctrl"></div>\r\n <% } %>\r\n <% if (!hint) { %>\r\n <% if (scope.appConfig.isReviewOnly) { %>\r\n <% if (editable) { %>\r\n <div class="btn-delete img-commonctrl"></div>\r\n <% } %>\r\n <% } else { %>\r\n <div class="btn-accept img-commonctrl"></div>\r\n <div class="btn-reject img-commonctrl"></div>\r\n <% } %>\r\n <% } %>\r\n </div>\r\n <% if (!hint && lock) { %>\r\n <div class="lock-area" style="cursor: default;"></div>\r\n <div class="lock-author" style="cursor: default;"><%=lockuser%></div>\r\n <% } %>\r\n</div>'}),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||['<div class="box">','<div id="id-popover" class="comments-popover" style="overflow-y: hidden;position: relative;">','<div id="id-review-popover"></div>','<div id="id-comments-popover"></div>',"</div>",'<div id="id-comments-arrow" class="comments-arrow"></div>',"</div>"].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('<div class="dataview-ct inner" style="overflow-y: visible;"></div>')},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('<div class="dataview-ct inner" style="overflow-y: visible;"></div>')}}}());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('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',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;d<a.items.length;d++)a.removeItem(a.items[d]),d--;if(s.length>0){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('<a id="<%= id %>" tabindex="-1" type="menuitem" style="font-size: 12px;"><div><%= Common.Utils.String.htmlEncode(caption) %></div><div style="color: #909090;"><%= Common.Utils.String.htmlEncode(options.value) %></div></a>'),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<a.length;++n)if(e===a[n].get("id"))return a[n].set("editTextInPopover",!0),s.length=0,o.set("replys",a),!0}else if((o=this.collection.findWhere({uid:t}))&&(s=o.get("replys"),a=_.clone(o.get("replys"))))for(n=0;n<a.length;++n)if(e===a[n].get("id"))return a[n].set("editText",!0),s.length=0,o.set("replys",a),!0;return!1},onUpdateFilter:function(t,e){if(t){this.view.isVisible()||(this.view.needUpdateFilter=t,e=!0),this.filter=t;var i=this,n=[];if(this.filter.forEach(function(t){i.groupCollection[t]||(i.groupCollection[t]=new Backbone.Collection([],{model:Common.Models.Comment})),n=n.concat(i.groupCollection[t].models)}),this.collection.reset(n),this.collection.groups=this.filter,!e){this.getPopover()&&this.getPopover().hide(),this.view.needUpdateFilter=!1;for(var o=!0,s=this.collection.length-1;s>=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;e<t.length;++e){var i=this.readSDKComment(t[e].asc_getId(),t[e]);i.get("groupName")?this.addCommentToGroupCollection(i):this.collection.push(i)}this.updateComments(!0)},onApiRemoveComment:function(t,e){for(var i in this.groupCollection){var n=this.groupCollection[i],o=n.findWhere({uid:t});if(o){n.remove(o);break}}if(this.collection.length){var o=this.collection.findWhere({uid:t});o&&(this.collection.remove(o),e||this.updateComments(!0)),this.popoverComments.length&&(o=this.popoverComments.findWhere({uid:t}))&&(this.popoverComments.remove(o),0===this.popoverComments.length&&this.getPopover()&&this.getPopover().hideComments())}},onChangeComments:function(t){for(var e=0;e<t.length;++e)this.onApiChangeCommentData(t[e].Comment.Id,t[e].Comment,!0);this.updateComments(!0)},onRemoveComments:function(t){for(var e=0;e<t.length;++e)this.onApiRemoveComment(t[e],!0);this.updateComments(!0)},onApiChangeCommentData:function(t,e,i){var n=this,o=0,s=null,a=null,l=0,r=null,c=this.findComment(t)||this.findCommentInGroup(t);if(c){n=this,s=e.asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getOnlyOfficeTime())):""==e.asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getTime()));var h=this.userCollection.findOriginalUser(e.asc_getUserId());for(c.set("comment",e.asc_getText()),c.set("userid",e.asc_getUserId()),c.set("username",e.asc_getUserName()),c.set("usercolor",h?h.get("color"):null),c.set("resolved",e.asc_getSolved()),c.set("quote",e.asc_getQuoteText()),c.set("time",s.getTime()),c.set("date",n.dateToLocaleTimeString(s)),a=_.clone(c.get("replys")),a.length=0,l=e.asc_getRepliesCount(),o=0;o<l;++o)r=e.asc_getReply(o).asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getReply(o).asc_getOnlyOfficeTime())):""==e.asc_getReply(o).asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getReply(o).asc_getTime())),h=this.userCollection.findOriginalUser(e.asc_getReply(o).asc_getUserId()),a.push(new Common.Models.Reply({id:Common.UI.getId(),userid:e.asc_getReply(o).asc_getUserId(),username:e.asc_getReply(o).asc_getUserName(),usercolor:h?h.get("color"):null,date:n.dateToLocaleTimeString(r),reply:e.asc_getReply(o).asc_getText(),time:r.getTime(),editText:!1,editTextInPopover:!1,showReplyInPopover:!1,scope:n.view,editable:n.mode.canEditComments||e.asc_getReply(o).asc_getUserId()==n.currentUserId}));c.set("replys",a),i||this.updateComments(!1,!0)}},onApiLockComment:function(t,e){var i=this.findComment(t)||this.findCommentInGroup(t),n=null;i&&this.userCollection&&(n=this.userCollection.findUser(e))&&(this.getPopover()&&this.getPopover().saveText(),this.view.saveText(),i.set("lock",!0),i.set("lockuserid",this.view.getUserName(n.get("username"))))},onApiUnLockComment:function(t){var e=this.findComment(t)||this.findCommentInGroup(t);e&&(e.set("lock",!1),this.getPopover()&&this.getPopover().loadText(),this.view.loadText())},onApiShowComment:function(t,e,i,n,o,s){var a=0===_.difference(this.uids,t).length&&0===_.difference(t,this.uids).length;if(!(s&&this.isSelectedComment&&a)||this.isModeChanged){this.mode&&!this.mode.canComments&&(s=!0);var l=this.getPopover();if(l){if(this.clearDummyComment(),this.isSelectedComment&&a&&!this.isModeChanged)return void(this.api&&(l.commentsView&&l.commentsView.setFocusToTextBox(!0),this.api.asc_enableKeyEvents(!0)));var r=0,c="",h="",d=null,p="",m=!0,u=[];for(r=0;r<t.length;++r)c=t[r],h=t[r]+"-R",(d=this.findComment(c))&&(this.subEditStrings[c]&&!s?(d.set("editTextInPopover",!0),p=this.subEditStrings[c]):this.subEditStrings[h]&&!s&&(d.set("showReplyInPopover",!0),p=this.subEditStrings[h]),d.set("hint",!_.isUndefined(s)&&s),!s&&this.hintmode&&(a&&0===this.uids.length&&(m=!1),this.oldUids.length&&0===_.difference(this.oldUids,t).length&&0===_.difference(t,this.oldUids).length&&(m=!1,this.oldUids=[])),this.animate&&(m=this.animate,this.animate=!1),this.isSelectedComment=!s||!this.hintmode,this.uids=_.clone(t),u.push(d),this._dontScrollToComment||this.view.commentsView.scrollToRecord(d),this._dontScrollToComment=!1);u.sort(function(t,e){return t.get("time")-e.get("time")}),this.popoverComments.reset(u),l.isVisible()&&l.hide(),l.setLeftTop(e,i,n),l.showComments(m,!1,!0,p)}this.isModeChanged=!1}},onApiHideComment:function(t){var e=this;if(this.getPopover()){if(this.isSelectedComment&&t)return;if(t&&this.getPopover().isCommentsViewMouseOver())return;this.popoverComments.each(function(t){t.get("editTextInPopover")&&(e.subEditStrings[t.get("uid")]=e.getPopover().getEditText()),t.get("showReplyInPopover")&&(e.subEditStrings[t.get("uid")+"-R"]=e.getPopover().getEditText())}),this.getPopover().saveText(!0),this.getPopover().hideComments(),this.collection.clearEditing(),this.popoverComments.clearEditing(),this.oldUids=_.clone(this.uids),this.isSelectedComment=!1,this.uids=[],this.popoverComments.reset()}},onApiUpdateCommentPosition:function(t,e,i,n){var o,s=!1,a=null,l=void 0,r="",c="";if(this.getPopover())if(this.getPopover().saveText(),this.getPopover().hideTips(),i<0||this.getPopover().sdkBounds.height<i||!_.isUndefined(n)&&this.getPopover().sdkBounds.width<n)this.getPopover().hide();else{if(this.isModeChanged&&this.onApiShowComment(t,e,i,n),0===this.popoverComments.length){var h=[];for(o=0;o<t.length;++o)r=t[o],c=t[o]+"-R",(a=this.findComment(r))&&(this.subEditStrings[r]?(a.set("editTextInPopover",!0),l=this.subEditStrings[r]):this.subEditStrings[c]&&(a.set("showReplyInPopover",!0),l=this.subEditStrings[c]),h.push(a));h.sort(function(t,e){return t.get("time")-e.get("time")}),this.popoverComments.reset(h),s=!0,this.getPopover().showComments(s,void 0,void 0,l)}else this.getPopover().isVisible()||this.getPopover().showComments(!1,void 0,void 0,l);this.getPopover().setLeftTop(e,i,n,void 0,!0)}},onDocumentPlaceChanged:function(){if(this.isDummyComment&&this.getPopover()&&this.getPopover().isVisible()){var t=this.api.asc_getAnchorPosition();t&&this.getPopover().setLeftTop(t.asc_getX()+t.asc_getWidth(),t.asc_getY(),this.hintmode?t.asc_getX():void 0)}},updateComments:function(t,e,i){var n=this;n.updateCommentsTime=new Date,void 0===n.timerUpdateComments&&(n.timerUpdateComments=setInterval(function(){new Date-n.updateCommentsTime>100&&(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;e<o;++e){n=t.asc_getReply(e).asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(t.asc_getReply(e).asc_getOnlyOfficeTime())):""==t.asc_getReply(e).asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(t.asc_getReply(e).asc_getTime()));var s=this.userCollection.findOriginalUser(t.asc_getReply(e).asc_getUserId());i.push(new Common.Models.Reply({id:Common.UI.getId(),userid:t.asc_getReply(e).asc_getUserId(),username:t.asc_getReply(e).asc_getUserName(),usercolor:s?s.get("color"):null,date:this.dateToLocaleTimeString(n),reply:t.asc_getReply(e).asc_getText(),time:n.getTime(),editText:!1,editTextInPopover:!1,showReplyInPopover:!1,scope:this.view,editable:this.mode.canEditComments||t.asc_getReply(e).asc_getUserId()==this.currentUserId}))}return i},addDummyComment:function(){if(this.api){var t=this,e=null,i=new Date,n=this.getPopover();if(n){if(this.popoverComments.length){if(this.isDummyComment)return void _.delay(function(){n.commentsView.setFocusToTextBox()},200);this.closeEditing()}var o=this.userCollection.findOriginalUser(this.currentUserId),s=new Common.Models.Comment({id:-1,time:i.getTime(),date:this.dateToLocaleTimeString(i),userid:this.currentUserId,username:this.currentUserName,usercolor:o?o.get("color"):null,editTextInPopover:!0,showReplyInPopover:!1,hideAddReply:!0,scope:this.view,dummy:!0});this.popoverComments.reset(),this.popoverComments.push(s),this.uids=[],this.isSelectedComment=!0,this.isDummyComment=!0,_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||t.api.asc_SetDocumentPlaceChangedEnabled(!0),n.handlerHide=function(){},n.isVisible()&&n.hide(),n.handlerHide=function(e){t.clearDummyComment(e)},e=this.api.asc_getAnchorPosition(),e&&(n.setLeftTop(e.asc_getX()+e.asc_getWidth(),e.asc_getY(),this.hintmode?e.asc_getX():void 0),Common.NotificationCenter.trigger("comments:showdummy"),n.showComments(!0,!1,!0,n.getDummyText()))}}},onAddDummyComment:function(e){if(this.api&&e&&e.length>0){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;e<t.length;++e)(n=this.findComment(t[e].asc_getId()))&&(n.set("editTextInPopover",i.mode.canEditComments),n.set("hint",!1),this.popoverComments.push(n));this.getPopover()&&this.popoverComments.length>0&&(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<e){i.push(t);break}i.push(t.substr(0,e)),t=t.substr(e)}return i})(e,2048).forEach(function(t){i.api.asc_coAuthoringChatSendMessage(t)})}},notcriticalErrorTitle:"Warning"},Common.Controllers.Chat||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Plugin",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.PluginVariation=e.Model.extend({defaults:function(){return{description:"",url:"",index:0,icons:void 0,isSystem:!1,isViewer:!1,isDisplayedInViewer:!0,EditorsSupport:["word","cell","slide"],isVisual:!1,isCustomWindow:!1,isModal:!1,isInsideMode:!1,initDataType:0,initData:"",isUpdateOleOnResize:!1,buttons:[],size:[800,600],initOnSelectionChanged:!1,visible:!0}}}),Common.Models.Plugin=e.Model.extend({defaults:function(){return{id:Common.UI.getId(),name:"",baseUrl:"",guid:Common.UI.getId(),variations:[],currentVariation:0,pluginObj:void 0,allowSelected:!1,selected:!1,visible:!0,groupName:"",groupRank:0}}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Plugins",["underscore","backbone","common/main/lib/model/Plugin"],function(t,e){"use strict";Common.Collections.Plugins=e.Collection.extend({model:Common.Models.Plugin,hasVisible:function(){return!!this.findWhere({visible:!0})}})}),define("common/main/lib/controller/Plugins",["core","common/main/lib/collection/Plugins","common/main/lib/view/Plugins"],function(){"use strict";Common.Controllers.Plugins=Backbone.Controller.extend(_.extend({models:[],appOptions:{},configPlugins:{autostart:[]},serverPlugins:{autostart:[]},collections:["Common.Collections.Plugins"],views:["Common.Views.Plugins"],initialize:function(){var t=this;this.addListeners({Toolbar:{"render:before":function(e){var i=t.getApplication().getController("Main").appOptions;if(!i.isEditMailMerge&&!i.isEditDiagram){var n={action:"plugins",caption:t.panelPlugins.groupCaption};t.$toolbarPanelPlugins=t.panelPlugins.getPanel(),e.addTab(n,t.$toolbarPanelPlugins,10)}}},"Common.Views.Plugins":{"plugin:select":function(e,i){t.api.asc_pluginRun(e,i,"")}}})},events:function(){return{"click #id-plugin-close":_.bind(this.onToolClose,this)}},onLaunch:function(){var t=this.getApplication().getCollection("Common.Collections.Plugins");this.panelPlugins=this.createView("Common.Views.Plugins",{storePlugins:t}),this.panelPlugins.on("render:after",_.bind(this.onAfterRender,this)),t.on({add:this.onAddPlugin.bind(this),reset:this.onResetPlugins.bind(this)}),this._moveOffset={x:0,y:0},this.autostart=[],Common.Gateway.on("init",this.loadConfig.bind(this)),Common.NotificationCenter.on("app:face",this.onAppShowed.bind(this))},loadConfig:function(t){var e=this;e.configPlugins.config=t.config.plugins,e.editor=window.DE?"word":window.PE?"slide":"cell"},loadPlugins:function(){this.configPlugins.config?this.getPlugins(this.configPlugins.config.pluginsData).then(function(e){t.configPlugins.plugins=e,t.mergePlugins()}).catch(function(e){t.configPlugins.plugins=!1}):this.configPlugins.plugins=!1;var t=this;Common.Utils.loadConfig("../../../../plugins.json",function(e){"error"!=e?(t.serverPlugins.config=e,t.getPlugins(t.serverPlugins.config.pluginsData).then(function(e){t.serverPlugins.plugins=e,t.mergePlugins()}).catch(function(e){t.serverPlugins.plugins=!1})):t.serverPlugins.plugins=!1})},onAppShowed:function(t){},setApi:function(t){return this.api=t,this.api.asc_registerCallback("asc_onPluginShow",_.bind(this.onPluginShow,this)),this.api.asc_registerCallback("asc_onPluginClose",_.bind(this.onPluginClose,this)),this.api.asc_registerCallback("asc_onPluginResize",_.bind(this.onPluginResize,this)),this.api.asc_registerCallback("asc_onPluginMouseUp",_.bind(this.onPluginMouseUp,this)),this.api.asc_registerCallback("asc_onPluginMouseMove",_.bind(this.onPluginMouseMove,this)),this.api.asc_registerCallback("asc_onPluginsReset",_.bind(this.resetPluginsList,this)),this.api.asc_registerCallback("asc_onPluginsInit",_.bind(this.onPluginsInit,this)),this.loadPlugins(),this},setMode:function(t){return this.appOptions=t,this.customPluginsComplete=!this.appOptions.canBrandingExt,this.appOptions.canBrandingExt&&this.getAppCustomPlugins(this.configPlugins),this},onAfterRender:function(t){t.viewPluginsList.on("item:click",_.bind(this.onSelectPlugin,this)),this.bindViewEvents(this.panelPlugins,this.events);var e=this;Common.NotificationCenter.on({"layout:resizestart":function(t){if(e.panelPlugins.isVisible()){var i=e.panelPlugins.currentPluginFrame.offset();e._moveOffset={x:i.left+parseInt(e.panelPlugins.currentPluginFrame.css("padding-left")),y:i.top+parseInt(e.panelPlugins.currentPluginFrame.css("padding-top"))},e.api.asc_pluginEnableMouseEvents(!0)}},"layout:resizestop":function(t){e.panelPlugins.isVisible()&&e.api.asc_pluginEnableMouseEvents(!1)}})},refreshPluginsList:function(){var t=this.getApplication().getCollection("Common.Collections.Plugins"),e=[];t.each(function(t){var i=new Asc.CPlugin;i.set_Name(t.get("name")),i.set_Guid(t.get("guid")),i.set_BaseUrl(t.get("baseUrl"));var n=t.get("variations"),o=[];n.forEach(function(t){var e=new Asc.CPluginVariation;e.set_Description(t.get("description")),e.set_Url(t.get("url")),e.set_Icons(t.get("icons")),e.set_Visual(t.get("isVisual")),e.set_CustomWindow(t.get("isCustomWindow")),e.set_System(t.get("isSystem")),e.set_Viewer(t.get("isViewer")),e.set_EditorsSupport(t.get("EditorsSupport")),e.set_Modal(t.get("isModal")),e.set_InsideMode(t.get("isInsideMode")),e.set_InitDataType(t.get("initDataType")),e.set_InitData(t.get("initData")),e.set_UpdateOleOnResize(t.get("isUpdateOleOnResize")),e.set_Buttons(t.get("buttons")),e.set_Size(t.get("size")),e.set_InitOnSelectionChanged(t.get("initOnSelectionChanged")),e.set_Events(t.get("events")),o.push(e)}),i.set_Variations(o),t.set("pluginObj",i),e.push(i)}),this.api.asc_pluginsRegister("",e),t.hasVisible()&&Common.NotificationCenter.trigger("tab:visible","plugins",!0)},onAddPlugin:function(t){var e=this;if(e.$toolbarPanelPlugins){var i=e.panelPlugins.createPluginButton(t);if(!i)return;var n=$("> .group",e.$toolbarPanelPlugins),o=$('<span class="slot"></span>').appendTo(n);i.render(o)}},onResetPlugins:function(t){var e=this;if(e.appOptions.canPlugins=!t.isEmpty(),e.$toolbarPanelPlugins){e.$toolbarPanelPlugins.empty();var i=$('<div class="group"></div>'),n=-1,o=0;t.each(function(t){var s=t.get("groupRank");s!==n&&n>-1&&o>0&&(i.appendTo(e.$toolbarPanelPlugins),$('<div class="separator long"></div>').appendTo(e.$toolbarPanelPlugins),i=$('<div class="group"></div>'),o=0);var a=e.panelPlugins.createPluginButton(t);if(a){var l=$('<span class="slot"></span>').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;p<s.items.length;p++)s.removeItem(s.items[p]),p--;s.removeAll();for(var m=i.get("variations"),p=0;p<m.length;p++){var u=m[p],g=new Common.UI.MenuItem({caption:p>0?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=$('<div id="menu-plugin-container" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',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 i<n?0==i?1:-1:i>n?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('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div><% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label><% } %></a>');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('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div><% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label><% } %></a>');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('<section id="review-changes-panel" class="panel" data-tab="review"><div class="group no-group-mask"><span id="slot-btn-sharing" class="btn-slot text x-huge"></span><span id="slot-btn-coauthmode" class="btn-slot text x-huge"></span></div><div class="separator long sharing"/><div class="group"><span class="btn-slot text x-huge slot-comment"></span></div><div class="separator long comments"/><div class="group"><span id="btn-review-on" class="btn-slot text x-huge"></span></div><div class="group no-group-mask" style="padding-left: 0;"><span id="btn-review-view" class="btn-slot text x-huge"></span></div><div class="group move-changes" style="padding-left: 0;"><span id="btn-change-prev" class="btn-slot text x-huge"></span><span id="btn-change-next" class="btn-slot text x-huge"></span><span id="btn-change-accept" class="btn-slot text x-huge"></span><span id="btn-change-reject" class="btn-slot text x-huge"></span></div><div class="separator long review"/><div class="group no-group-mask"><span id="slot-btn-chat" class="btn-slot text x-huge"></span></div><div class="separator long chat"/><div class="group no-group-mask"><span id="slot-btn-history" class="btn-slot text x-huge"></span></div></section>')({})),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=['<div class="box">','<div class="input-row">','<div id="id-review-button-prev" style=""></div>','<div id="id-review-button-next" style=""></div>','<div id="id-review-button-accept" style=""></div>','<div id="id-review-button-reject" style="margin-right: 0;"></div>',"</div>","</div>"].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:'<div class="box"><div class="input-row"><label><%= label %></label></div><div class="input-row" id="id-document-language"></div></div><div class="footer right"><button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button><button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button></div>',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(['<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">','<input type="text" class="form-control">','<span class="icon input-icon spellcheck-lang img-toolbarmenu"></span>','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret img-commonctrl"></span></button>','<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',"<% _.each(items, function(item) { %>",'<li id="<%= item.id %>" data-value="<%= item.value %>">','<a tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= item.value %>">','<i class="icon <% if (item.spellcheck) { %> img-toolbarmenu spellcheck-lang <% } %>"></i>',"<%= scope.getDisplayValue(item) %>","</a>","</li>","<% }); %>","</ul>","</span>"].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.height<e?this.getPopover().hide():this.popoverChanges.length>0&&(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="<b>"+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+="</b>",n+=o;break;case Asc.c_oAscRevisionsChangeType.ParaPr:if(n="<b>"+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+="</b>",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:"<b>Inserted:</b>",textDeleted:"<b>Deleted:</b>",textParaInserted:"<b>Paragraph Inserted</b> ",textParaDeleted:"<b>Paragraph Deleted</b> ",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:"<b>Table Settings Changed</b>",textTableRowsAdd:"<b>Table Rows Added<b/>",textTableRowsDel:"<b>Table Rows Deleted<b/>",textParaMoveTo:"<b>Moved:</b>",textParaMoveFromUp:"<b>Moved Up:</b>",textParaMoveFromDown:"<b>Moved Down:</b>"},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('<section id="protection-panel" class="panel" data-tab="protect"><div class="group"><span id="slot-btn-add-password" class="btn-slot text x-huge"></span><span id="slot-btn-change-password" class="btn-slot text x-huge"></span><span id="slot-btn-signature" class="btn-slot text x-huge"></span></div></section>')({})),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||['<div class="box" style="height:'+(i.height-85)+'px;">','<div class="input-row" style="margin-bottom: 10px;">',"<label>"+e.txtDescription+"</label>","</div>",'<div class="input-row">',"<label>"+e.txtPassword+"</label>","</div>",'<div id="id-password-txt" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+e.txtRepeat+"</label>","</div>",'<div id="id-repeat-txt" class="input-row"></div>',"</div>",'<div class="separator horizontal"/>','<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">'+e.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+e.cancelButtonText+"</button>","</div>"].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=['<div class="box" style="height: '+("invisible"==this.signType?"132px;":"300px;")+'">','<div id="id-dlg-sign-invisible">','<div class="input-row">',"<label>"+this.textPurpose+"</label>","</div>",'<div id="id-dlg-sign-purpose" class="input-row"></div>',"</div>",'<div id="id-dlg-sign-visible">','<div class="input-row">',"<label>"+this.textInputName+"</label>","</div>",'<div id="id-dlg-sign-name" class="input-row" style="margin-bottom: 5px;"></div>','<div id="id-dlg-sign-fonts" class="input-row" style="display: inline-block;"></div>','<div id="id-dlg-sign-font-size" class="input-row" style="display: inline-block;margin-left: 3px;"></div>','<div id="id-dlg-sign-bold" style="display: inline-block;margin-left: 3px;"></div>','<div id="id-dlg-sign-italic" style="display: inline-block;margin-left: 3px;"></div>','<div style="margin: 10px 0 5px 0;">',"<label>"+this.textUseImage+"</label>","</div>",'<button id="id-dlg-sign-image" class="btn btn-text-default auto">'+this.textSelectImage+"</button>",'<div class="input-row" style="margin-top: 10px;">','<label style="font-weight: bold;">'+this.textSignature+"</label>","</div>",'<div style="border: 1px solid #cbcbcb;"><div id="signature-preview-img" style="width: 100%; height: 50px;position: relative;"></div></div>',"</div>",'<table style="margin-top: 30px;">',"<tr>",'<td><label style="font-weight: bold;margin-bottom: 3px;">'+this.textCertificate+'</label></td><td rowspan="2" style="vertical-align: top; padding-left: 30px;"><button id="id-dlg-sign-change" class="btn btn-text-default" style="">'+this.textSelect+"</button></td>","</tr>",'<tr><td><div id="id-dlg-sign-certificate" class="hidden" style="max-width: 212px;overflow: hidden;"></td></tr>',"</table>","</div>",'<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","</div>"].join(""),this.templateCertificate=_.template(['<label style="display: block;margin-bottom: 3px;"><%= Common.Utils.String.htmlEncode(name) %></label>','<label style="display: block;"><%= Common.Utils.String.htmlEncode(valid) %></label>'].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=['<div class="box" style="height: 260px;">','<div class="input-row">',"<label>"+this.textInfo+"</label>","</div>",'<div class="input-row">',"<label>"+this.textInfoName+"</label>","</div>",'<div id="id-dlg-sign-settings-name" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+this.textInfoTitle+"</label>","</div>",'<div id="id-dlg-sign-settings-title" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+this.textInfoEmail+"</label>","</div>",'<div id="id-dlg-sign-settings-email" class="input-row" style="margin-bottom: 10px;"></div>','<div class="input-row">',"<label>"+this.textInstructions+"</label>","</div>",'<textarea id="id-dlg-sign-settings-instructions" class="form-control" style="width: 100%;height: 35px;margin-bottom: 10px;resize: none;"></textarea>','<div id="id-dlg-sign-settings-date"></div>',"</div>",'<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<% if (type == "edit") { %>','<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","<% } %>","</div>"].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+="<br/><br/>"+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.<br>Wrong cout of brackets.",errorWrongOperator:"An error in the entered formula. Wrong operator is used.<br>Please correct the error or use the Esc button to cancel the formula editing.",errorCountArgExceed:"Found an error in the formula entered.<br>Count of arguments exceeded.",errorCountArg:"Found an error in the formula entered.<br>Invalid number of arguments.",errorFormulaName:"Found an error in the formula entered.<br>Incorrect formula name.",errorFormulaParsing:"Internal error while the formula parsing.",errorArgsRange:"Found an error in the formula entered.<br>Incorrect arguments range.",errorUnexpectedGuid:"External error.<br>Unexpected Guid. Please, contact support.",errorDatabaseConnection:"External error.<br>Database connection error. Please, contact support.",errorFileRequest:"External error.<br>File Request. Please, contact support.",errorFileVKey:"External error.<br>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:<br> 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.<br>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.<br>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.<br>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.<br>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<br>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.<br>When you click the \'OK\' button, you will be prompted to download the document.<br><br>Find more information about connecting Document Server <a href="%1" target="_blank">here</a>',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.<br>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<br>the allowed number of characters and it was removed.",errorFrmlWrongReferences:"The function refers to a sheet that does not exist.<br>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.<br>They will be unmerged before they are pasted into the table.",errorViewerDisconnect:"Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored.",warnLicenseExp:"Your license has expired.<br>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.<br>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.<br>This restriction will be eliminated in upcoming releases.",errorToken:"The document security token is not correctly formed.<br>Please contact your Document Server administrator.",errorTokenExpire:"The document security token has expired.<br>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.<br>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.<br>If you need more please consider purchasing a commercial license.",warnNoLicenseUsers:"This version of %1 Editors has certain limitations for concurrent users.<br>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.<br>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.<br>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.<br>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.<br>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.<br>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.<br>Use the CONCATENATE function or concatenation operator (&)",waitText:"Please, wait...",errorDataValidate:"The value you entered is not valid.<br>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=['<div id="id-sharing-placeholder"></div>'].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(["<table><tbody>","<% _.each(rows, function(row) { %>","<tr>","<% _.each(row, function(item) { %>",'<td><div><svg class="btn-doc-format" format="<%= item.type %>">','<use xlink:href="#svg-format-<%= item.imgCls %>"></use>',"</svg></div></td>","<% }) %>","</tr>","<% }) %>","</tbody></table>"].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(["<table><tbody>","<% _.each(rows, function(row) { %>","<tr>","<% _.each(row, function(item) { %>",'<td><div><svg class="btn-doc-format" format="<%= item.type %>", format-ext="<%= item.ext %>">','<use xlink:href="#svg-format-<%= item.imgCls %>"></use>',"</svg></div></td>","<% }) %>","</tr>","<% }) %>","</tbody></table>"].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(['<div style="width:100%; height:100%; position: relative;">','<div id="id-settings-menu" style="position: absolute; width:200px; top: 0; bottom: 0;" class="no-padding"></div>','<div id="id-settings-content" style="position: absolute; left: 200px; top: 0; right: 0; bottom: 0;" class="no-padding">','<div id="panel-settings-general" style="width:100%; height:100%;" class="no-padding main-settings-panel active"></div>','<div id="panel-settings-print" style="width:100%; height:100%;" class="no-padding main-settings-panel"></div>',"</div>","</div>"].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(['<div id="<%= id %>" class="settings-item-wrap">','<div class="settings-icon <%= iconCls %>" style="display: inline-block;" >',"</div><%= name %>","</div>"].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(['<table class="main"><tbody>',"<tr>",'<td class="left"><label><%= scope.textSettings %></label></td>','<td class="right"><div id="advsettings-print-combo-sheets" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageSize %></label></td>','<td class="right"><div id="advsettings-print-combo-pages" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageOrientation %></label></td>','<td class="right"><span id="advsettings-print-combo-orient" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.textPageScaling %></label></td>','<td class="right"><span id="advsettings-print-combo-layout" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left" style="vertical-align: top;"><label><%= scope.strMargins %></label></td>','<td class="right" style="vertical-align: top;"><div id="advsettings-margins">','<table cols="2" class="no-padding">',"<tr>","<td><label><%= scope.strTop %></label></td>","<td><label><%= scope.strBottom %></label></td>","</tr>","<tr>",'<td><div id="advsettings-spin-margin-top"></div></td>','<td><div id="advsettings-spin-margin-bottom"></div></td>',"</tr>","<tr>","<td><label><%= scope.strLeft %></label></td>","<td><label><%= scope.strRight %></label></td>","</tr>","<tr>",'<td><div id="advsettings-spin-margin-left"></div></td>','<td><div id="advsettings-spin-margin-right"></div></td>',"</tr>","</table>","</div></td>","</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left" style="vertical-align: top;"><label><%= scope.strPrint %></label></td>','<td class="right" style="vertical-align: top;"><div id="advsettings-print">','<div id="advsettings-print-chb-grid" style="margin-bottom: 10px;"/>','<div id="advsettings-print-chb-rows"/>',"</div></td>","</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"></td>','<td class="right"><button id="advsettings-print-button-save" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',"</tr>","</tbody></table>"].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<this.spinners.length;t++){var e=this.spinners[t];e.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName()),e.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt?1:.1)}for(var i=this.cmbPaperSize.store,t=0;t<i.length;t++){var n=i.at(t),o=n.get("value"),s=/^\d{3}\.?\d*/.exec(o),a=/\d{3}\.?\d*$/.exec(o);n.set("displayValue",n.get("caption")+" ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(a).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")")}this.cmbPaperSize.onResetItems()},applySettings:function(){this.menu&&this.menu.fireEvent("settings:apply",[this.menu])},show:function(){Common.UI.BaseView.prototype.show.call(this,arguments),this._initSettings&&(this.updateMetricUnit(),this._initSettings=!1),this.fireEvent("show",this)},okButtonText:"Save",strPortrait:"Portrait",strLandscape:"Landscape",textPrintGrid:"Print Gridlines",textPrintHeadings:"Print Rows and Columns Headings",strLeft:"Left",strRight:"Right",strTop:"Top",strBottom:"Bottom",strMargins:"Margins",textPageSize:"Page Size",textPageOrientation:"Page Orientation",strPrint:"Print",textSettings:"Settings for",textPageScaling:"Scaling",textActualSize:"Actual Size",textFitPage:"Fit Sheet on One Page",textFitCols:"Fit All Columns on One Page",textFitRows:"Fit All Rows on One Page"},SSE.Views.MainSettingsPrint||{})),SSE.Views.FileMenuPanels.MainSettingsGeneral=Common.UI.BaseView.extend(_.extend({el:"#panel-settings-general",menu:void 0,template:_.template(['<table class="main"><tbody>','<tr class="comments">','<td class="left"><label><%= scope.txtLiveComment %></label></td>','<td class="right"><div id="fms-chb-live-comment"/></td>',"</tr>",'<tr class="divider comments"></tr>','<tr class="comments">','<td class="left"></td>','<td class="right"><div id="fms-chb-resolved-comment"/></td>',"</tr>",'<tr class="divider comments"></tr>','<tr class="autosave">','<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>','<td class="right"><span id="fms-chb-autosave" /></td>',"</tr>",'<tr class="divider autosave"></tr>','<tr class="forcesave">','<td class="left"><label id="fms-lbl-forcesave"><%= scope.textForceSave %></label></td>','<td class="right"><span id="fms-chb-forcesave" /></td>',"</tr>",'<tr class="divider forcesave"></tr>',"<tr>",'<td class="left"><label><%= scope.textRefStyle %></label></td>','<td class="right"><div id="fms-chb-r1c1-style"/></td>',"</tr>",'<tr class="divider"></tr>','<tr class="coauth changes">','<td class="left"><label><%= scope.strCoAuthMode %></label></td>','<td class="right">','<div><div id="fms-cmb-coauth-mode" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-coauth-mode" style="vertical-align: middle;"><%= scope.strCoAuthModeDescFast %></label></div></td>',"</tr>",'<tr class="divider coauth changes"></tr>',"<tr>",'<td class="left"><label><%= scope.strZoom %></label></td>','<td class="right"><div id="fms-cmb-zoom" class="input-group-nr" /></td>',"</tr>",'<tr class="divider"></tr>',"<tr>",'<td class="left"><label><%= scope.strFontRender %></label></td>','<td class="right"><span id="fms-cmb-font-render" /></td>',"</tr>",'<tr class="divider"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strUnit %></label></td>','<td class="right"><span id="fms-cmb-unit" /></td>',"</tr>",'<tr class="divider edit"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strFuncLocale %></label></td>','<td class="right">','<div><div id="fms-cmb-func-locale" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-func-locale" style="vertical-align: middle;"><%= scope.strFuncLocaleEx %></label></div></td>',"</tr>",'<tr class="divider edit"></tr>','<tr class="edit">','<td class="left"><label><%= scope.strRegSettings %></label></td>','<td class="right">','<div><div id="fms-cmb-reg-settings" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>','<label id="fms-lbl-reg-settings" style="vertical-align: middle;"></label></div></td>',"</tr>",'<tr class="divider edit"></tr>',"<tr>",'<td class="left"></td>','<td class="right"><button id="fms-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',"</tr>","</tbody></table>"].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(['<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">','<input type="text" class="form-control" style="padding-left: 25px !important;">','<span class="icon input-icon lang-flag"></span>','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret img-commonctrl"></span></button>','<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',"<% _.each(items, function(item) { %>",'<li id="<%= item.id %>" data-value="<%= item.value %>">','<a tabindex="-1" type="menuitem" style="padding-left: 26px !important;">','<i class="icon lang-flag <%= item.langName %>" style="position: absolute;margin-left:-21px;"></i>',"<%= scope.getDisplayValue(item) %>","</a>","</li>","<% }); %>","</ul>","</span>"].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(['<div id="id-recent-view" style="margin: 20px 0;"></div>'].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(['<div class="recent-wrap">','<div class="recent-icon"></div>','<div class="file-name"><%= Common.Utils.String.htmlEncode(title) %></div>','<div class="file-info"><%= Common.Utils.String.htmlEncode(folder) %></div>',"</div>"].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(['<h3 style="margin-top: 20px;"><%= scope.fromBlankText %></h3><hr noshade />','<div class="blank-document">','<div class="blank-document-btn">','<svg class="btn-doc-format">','<use xlink:href="#svg-format-xlsx"></use>',"</svg>","</div>",'<div class="blank-document-info">',"<h3><%= scope.newDocumentText %></h3>","<%= scope.newDescriptionText %>","</div>","</div>","<h3><%= scope.fromTemplateText %></h3><hr noshade />",'<div class="thumb-list">',"<% _.each(docs, function(item) { %>",'<div class="thumb-wrap" template="<%= item.url %>">','<div class="thumb"',"<% if (!_.isEmpty(item.icon)) { print(\" style='background-image: url(item.icon);'>\") } else { print(\"><svg class='btn-doc-format'><use xlink:href='#svg-format-blank'></use></svg>\") } %>","</div>",'<div class="title"><%= item.name %></div>',"</div>","<% }) %>","</div>"].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(['<table class="main">',"<tr>",'<td class="left"><label>'+this.txtPlacement+"</label></td>",'<td class="right"><label id="id-info-placement">-</label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtOwner+"</label></td>",'<td class="right"><label id="id-info-owner">-</label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtUploaded+"</label></td>",'<td class="right"><label id="id-info-uploaded">-</label></td>',"</tr>",'<tr class="divider general"></tr>','<tr class="divider general"></tr>',"<tr>",'<td class="left"><label>'+this.txtTitle+"</label></td>",'<td class="right"><div id="id-info-title"></div></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtSubject+"</label></td>",'<td class="right"><div id="id-info-subject"></div></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtComment+"</label></td>",'<td class="right"><div id="id-info-comment"></div></td>',"</tr>",'<tr class="divider"></tr>','<tr class="divider"></tr>',"<tr>",'<td class="left"><label>'+this.txtModifyDate+"</label></td>",'<td class="right"><label id="id-info-modify-date"></label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtModifyBy+"</label></td>",'<td class="right"><label id="id-info-modify-by"></label></td>',"</tr>",'<tr class="divider modify">','<tr class="divider modify">',"<tr>",'<td class="left"><label>'+this.txtCreated+"</label></td>",'<td class="right"><label id="id-info-date"></label></td>',"</tr>","<tr>",'<td class="left"><label>'+this.txtAppName+"</label></td>",'<td class="right"><label id="id-info-appname"></label></td>',"</tr>","<tr>",'<td class="left" style="vertical-align: top;"><label style="margin-top: 3px;">'+this.txtAuthor+"</label></td>",'<td class="right" style="vertical-align: top;"><div id="id-info-author">',"<table>","<tr>",'<td><div id="id-info-add-author"><input type="text" spellcheck="false" class="form-control" placeholder="'+this.txtAddAuthor+'"></div></td>',"</tr>","</table>","</div></td>","</tr>","</table>"].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='<tr><td><div style="display: inline-block;width: 200px;"><input type="text" spellcheck="false" class="form-control" readonly="true" value="{0}" ></div><div class="close img-commonctrl"></div></td></tr>',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(['<table class="main">','<tr class="rights">','<td class="left" style="vertical-align: top;"><label>'+this.txtRights+"</label></td>",'<td class="right"><div id="id-info-rights"></div></td>',"</tr>",'<tr class="edit-rights">','<td class="left"></td><td class="right"><button id="id-info-btn-edit" class="btn normal dlg-btn primary custom" style="margin-right: 10px;">'+this.txtBtnAccessRights+"</button></td>","</tr>","</table>"].join("")),this.templateRights=_.template(["<table>","<% _.each(users, function(item) { %>","<tr>",'<td><span class="userLink <% if (item.isLink) { %>sharedLink<% } %>"></span><span><%= Common.Utils.String.htmlEncode(item.user) %></span></td>',"<td><%= Common.Utils.String.htmlEncode(item.permissions) %></td>","</tr>","<% }); %>","</table>"].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(['<div style="width:100%; height:100%; position: relative;">','<div id="id-help-contents" style="position: absolute; width:220px; top: 0; bottom: 0;" class="no-padding"></div>','<div id="id-help-frame" style="position: absolute; left: 220px; top: 0; right: 0; bottom: 0;" class="no-padding"></div>',"</div>"].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(['<div id="<%= id %>" class="help-item-wrap">','<div class="caption"><%= name %></div>',"</div>"].join(""))}),this.viewHelpPicker.on("item:add",function(t,e,i){i.has("headername")&&$(e.el).before('<div class="header-name">'+i.get("headername")+"</div>")}),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(['<label id="id-fms-lbl-protect-header" style="font-size: 18px;"><%= scope.strProtect %></label>','<div id="id-fms-password">','<label class="header"><%= scope.strEncrypt %></label>','<div id="fms-btn-add-pwd" style="width:190px;"></div>','<table id="id-fms-view-pwd" cols="2" width="300">',"<tr>",'<td colspan="2"><label style="cursor: default;"><%= scope.txtEncrypted %></label></td>',"</tr>","<tr>",'<td><div id="fms-btn-change-pwd" style="width:190px;"></div></td>','<td align="right"><div id="fms-btn-delete-pwd" style="width:190px; margin-left:20px;"></div></td>',"</tr>","</table>","</div>",'<div id="id-fms-signature">','<label class="header"><%= scope.strSignature %></label>','<div id="fms-btn-invisible-sign" style="width:190px; margin-bottom: 20px;"></div>','<div id="id-fms-signature-view"></div>',"</div>"].join("")),initialize:function(t){Common.UI.BaseView.prototype.initialize.call(this,arguments),this.menu=t.menu;var e=this;this.templateSignature=_.template(['<table cols="2" width="300" class="<% if (!hasRequested && !hasSigned) { %>hidden<% } %>"">',"<tr>",'<td colspan="2"><label style="cursor: default;"><%= tipText %></label></td>',"</tr>","<tr>",'<td><label class="link signature-view-link">'+e.txtView+"</label></td>",'<td align="right"><label class="link signature-edit-link <% if (!hasSigned) { %>hidden<% } %>">'+e.txtEdit+"</label></td>","</tr>","</table>"].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?"<br><br>":"")+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.<br>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'<div class="settings-panel active">\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-range" class="input-group-nr" />\r\n <div id="printadv-dlg-chb-ignore" style="margin-top: 5px;"/>\r\n </div>\r\n <div class="padding-small"/>\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-sheets" class="input-group-nr" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <div id="printadv-dlg-combo-pages" class="input-group-nr" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <span id="printadv-dlg-combo-orient" />\r\n </div>\r\n <div class="padding-large inner-content" >\r\n <span id="printadv-dlg-combo-layout" />\r\n </div>\r\n <div id="printadv-dlg-content-to-hide">\r\n <div class="padding-large inner-content" >\r\n <table cols="2" class="no-padding">\r\n <tr>\r\n <td><label><%= scope.strTop %></label></td>\r\n <td><label><%= scope.strBottom %></label></td>\r\n </tr>\r\n <tr>\r\n <td class="padding-small"><div id="printadv-dlg-spin-margin-top" style="margin-right: 19px;"></div></td>\r\n <td class="padding-small"><div id="printadv-dlg-spin-margin-bottom"></div></td>\r\n </tr>\r\n <tr>\r\n <td><label><%= scope.strLeft %></label></td>\r\n <td><label><%= scope.strRight %></label></td>\r\n </tr>\r\n <tr>\r\n <td><div id="printadv-dlg-spin-margin-left" style="margin-right: 15px;"></div></td>\r\n <td><div id="printadv-dlg-spin-margin-right"></div></td>\r\n </tr>\r\n </table>\r\n </div>\r\n <div class="padding-small"/>\r\n <div class="inner-content">\r\n <div id="printadv-dlg-chb-grid" style="margin-bottom: 10px;"/>\r\n <div id="printadv-dlg-chb-rows"/>\r\n </div>\r\n </div>\r\n</div>\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:['<div class="box" style="height:'+(this.options.height-85)+'px;">','<div class="menu-panel" style="overflow: hidden;">','<div style="height: 54px; line-height: 42px;" class="div-category">'+("print"==this.type?this.textPrintRange:this.textRange)+"</div>",'<div style="height: 52px; line-height: 66px;" class="div-category">'+this.textSettings+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageSize+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageOrientation+"</div>",'<div style="height: 38px; line-height: 38px;" class="div-category">'+this.textPageScaling+"</div>",'<div style="height: 108px; line-height: 33px;" class="div-category">'+this.strMargins+"</div>",'<div style="height: 58px; line-height: 40px;" class="div-category">'+("print"==this.type?this.strPrint:this.strShow)+"</div>","</div>",'<div class="content-panel">'+_.template(t)({scope:this})+"</div>","</div>",'<div class="separator horizontal"/>','<div class="footer justify">','<button id="printadv-dlg-btn-hide" class="btn btn-text-default" style="margin-right: 55px; width: 100px;">'+this.textHideDetails+"</button>",'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px; width: 150px;">'+("print"==this.type?this.btnPrint:this.btnDownload)+"</button>",'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">'+this.cancelButtonText+"</button>","</div>"].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;t<this.spinners.length;t++){var e=this.spinners[t];e.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName()),e.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt?1:.1)}for(var i=this.cmbPaperSize.store,t=0;t<i.length;t++){var n=i.at(t),o=n.get("value"),s=/^\d{3}\.?\d*/.exec(o),a=/\d{3}\.?\d*$/.exec(o);n.set("displayValue",n.get("caption")+" ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(a).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")")}this.cmbPaperSize.onResetItems()},handlerShowDetails:function(t){this.extended?(this.extended=!1,this.panelDetails.css({display:"block"}),this.setHeight(475),t.setCaption(this.textHideDetails),Common.localStorage.setItem("sse-hide-print-settings",0)):(this.extended=!0,this.panelDetails.css({display:"none"}),this.setHeight(314),t.setCaption(this.textShowDetails),Common.localStorage.setItem("sse-hide-print-settings",1))},textTitle:"Print Settings",strLeft:"Left",strRight:"Right",strTop:"Top",strBottom:"Bottom",strPortrait:"Portrait",strLandscape:"Landscape",textPrintGrid:"Print Gridlines",textPrintHeadings:"Print Rows and Columns Headings",textPageSize:"Page Size",textPageOrientation:"Page Orientation",strMargins:"Margins",strPrint:"Print",btnPrint:"Save & Print",textPrintRange:"Print Range",textLayout:"Layout",textCurrentSheet:"Current Sheet",textAllSheets:"All Sheets",textSelection:"Selection",textActualSize:"Actual Size",textFitPage:"Fit Sheet on One Page",textFitCols:"Fit All Columns on One Page",textFitRows:"Fit All Rows on One Page",textShowDetails:"Show Details",cancelButtonText:"Cancel",textHideDetails:"Hide Details",textPageScaling:"Scaling",textSettings:"Sheet Settings",textTitlePDF:"PDF Settings",textShowGrid:"Show Gridlines",textShowHeadings:"Show Rows and Columns Headings",strShow:"Show",btnDownload:"Save & Download",textRange:"Range",textIgnore:"Ignore Print Area"},SSE.Views.PrintSettings||{}))}),define("spreadsheeteditor/main/app/controller/Print",["core","spreadsheeteditor/main/app/view/FileMenuPanels","spreadsheeteditor/main/app/view/PrintSettings"],function(){"use strict";SSE.Controllers.Print=Backbone.Controller.extend(_.extend({views:["MainSettingsPrint"],initialize:function(){var t=Common.localStorage.getItem("sse-print-settings-range");t=null!==t?parseInt(t):Asc.c_oAscPrintType.ActiveSheets,this.adjPrintParams=new Asc.asc_CAdjustPrint,this.adjPrintParams.asc_setPrintType(t),this._changedProps=null,this._originalPageSettings=null,this.addListeners({MainSettingsPrint:{show:_.bind(this.onShowMainSettingsPrint,this),"render:after":_.bind(this.onAfterRender,this)},PrintSettings:{changerange:_.bind(this.onChangeRange,this)}})},onLaunch:function(){this.printSettings=this.createView("MainSettingsPrint")},onAfterRender:function(t){this.printSettings.cmbSheet.on("selected",_.bind(this.comboSheetsChange,this,this.printSettings)),this.printSettings.btnOk.on("click",_.bind(this.querySavePrintSettings,this)),Common.NotificationCenter.on("print",_.bind(this.openPrintSettings,this,"print")),Common.NotificationCenter.on("download:settings",_.bind(this.openPrintSettings,this,"download")),this.registerControlEvents(this.printSettings)},setApi:function(t){this.api=t,this.api.asc_registerCallback("asc_onSheetsChanged",_.bind(this.updateSheetsInfo,this))},updateSheetsInfo:function(){this.printSettings.isVisible()?this.updateSettings(this.printSettings):this.isFillSheets=!1},updateSettings:function(t){for(var e=this.api.asc_getWorksheetsCount(),i=-1,n=[];++i<e;)this.api.asc_isWorksheetHidden(i)||n.push({displayValue:this.api.asc_getWorksheetName(i),value:i});t.cmbSheet.store.reset(n);var o=t.cmbSheet.store.findWhere({value:t.cmbSheet.getValue()})||t.cmbSheet.store.findWhere({value:this.api.asc_getActiveWorksheetIndex()});o&&t.cmbSheet.setValue(o.get("value"))},comboSheetsChange:function(t,e,i){this.fillPageOptions(t,this._changedProps[i.value]?this._changedProps[i.value]:this.api.asc_getPageOptions(i.value))},fillPageOptions:function(t,e){var i=e.asc_getPageSetup();this._originalPageSettings=i;var n=t.cmbPaperOrientation.store.findWhere({value:i.asc_getOrientation()});n&&t.cmbPaperOrientation.setValue(n.get("value"));var o=i.asc_getWidth(),s=i.asc_getHeight(),a=t.cmbPaperSize.store;n=null;for(var l=0;l<a.length;l++){var r=a.at(l),c=r.get("value"),h=parseFloat(/^\d{3}\.?\d*/.exec(c)),d=parseFloat(/\d{3}\.?\d*$/.exec(c));if(Math.abs(h-o)<.1&&Math.abs(d-s)<.1){n=r;break}}n?t.cmbPaperSize.setValue(n.get("value")):t.cmbPaperSize.setValue("Custom ("+parseFloat(Common.Utils.Metric.fnRecalcFromMM(o).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+" x "+parseFloat(Common.Utils.Metric.fnRecalcFromMM(s).toFixed(2))+Common.Utils.Metric.getCurrentMetricName()+")");var p=i.asc_getFitToWidth(),m=i.asc_getFitToHeight();p||m?p&&m?t.cmbLayout.setValue(1):p&&!m?t.cmbLayout.setValue(2):t.cmbLayout.setValue(3):t.cmbLayout.setValue(0),n=t.cmbPaperOrientation.store.findWhere({value:i.asc_getOrientation()}),n&&t.cmbPaperOrientation.setValue(n.get("value")),i=e.asc_getPageMargins(),t.spnMarginLeft.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getLeft()),!0),t.spnMarginTop.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getTop()),!0),t.spnMarginRight.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getRight()),!0),t.spnMarginBottom.setValue(Common.Utils.Metric.fnRecalcFromMM(i.asc_getBottom()),!0),t.chPrintGrid.setValue(e.asc_getGridLines(),!0),t.chPrintRows.setValue(e.asc_getHeadings(),!0)},fillPrintOptions:function(t){this.printSettingsDlg.setRange(t.asc_getPrintType()),this.printSettingsDlg.setIgnorePrintArea(!!t.asc_getIgnorePrintArea()),this.onChangeRange()},onChangeRange:function(){var t=this.printSettingsDlg.getRange(),e=this.printSettingsDlg.cmbSheet.store,i=t!==Asc.c_oAscPrintType.EntireWorkbook?e.findWhere({value:this.api.asc_getActiveWorksheetIndex()}):e.at(0);i&&(this.printSettingsDlg.cmbSheet.setValue(i.get("value")),this.comboSheetsChange(this.printSettingsDlg,this.printSettingsDlg.cmbSheet,i.toJSON())),this.printSettingsDlg.cmbSheet.setDisabled(t!==Asc.c_oAscPrintType.EntireWorkbook),this.printSettingsDlg.chIgnorePrintArea.setDisabled(t==Asc.c_oAscPrintType.Selection)},getPageOptions:function(t){var e=new Asc.asc_CPageOptions;e.asc_setGridLines("indeterminate"==t.chPrintGrid.getValue()?void 0:"checked"==t.chPrintGrid.getValue()?1:0),e.asc_setHeadings("indeterminate"==t.chPrintRows.getValue()?void 0:"checked"==t.chPrintRows.getValue()?1:0);var i=new Asc.asc_CPageSetup;i.asc_setOrientation("-"==t.cmbPaperOrientation.getValue()?void 0:t.cmbPaperOrientation.getValue());var n=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),o=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());i.asc_setWidth(n?parseFloat(n[0]):this._originalPageSettings?this._originalPageSettings.asc_getWidth():void 0),i.asc_setHeight(o?parseFloat(o[0]):this._originalPageSettings?this._originalPageSettings.asc_getHeight():void 0);var s=t.cmbLayout.getValue();return i.asc_setFitToWidth(1==s||2==s),i.asc_setFitToHeight(1==s||3==s),e.asc_setPageSetup(i),i=new Asc.asc_CPageMargins,i.asc_setLeft("-"==t.spnMarginLeft.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginLeft.getNumberValue())),i.asc_setTop("-"==t.spnMarginTop.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginTop.getNumberValue())),i.asc_setRight("-"==t.spnMarginRight.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginRight.getNumberValue())),i.asc_setBottom("-"==t.spnMarginBottom.getValue()?void 0:Common.Utils.Metric.fnRecalcToMM(t.spnMarginBottom.getNumberValue())),e.asc_setPageMargins(i),e},savePageOptions:function(t){this.api.asc_savePagePrintOptions(this._changedProps),Common.NotificationCenter.trigger("page:settings")},onShowMainSettingsPrint:function(){this._changedProps=[],this.isFillSheets||(this.isFillSheets=!0,this.updateSettings(this.printSettings));var t=this.printSettings.cmbSheet.store.findWhere({value:this.api.asc_getActiveWorksheetIndex()});t&&(this.printSettings.cmbSheet.setValue(t.get("value")),this.comboSheetsChange(this.printSettings,this.printSettings.cmbSheet,t.toJSON()))},openPrintSettings:function(t,e,i,n){if(this.printSettingsDlg&&this.printSettingsDlg.isVisible())return void(n&&Common.NotificationCenter.trigger("download:cancel"));this.api&&(this.asUrl=n,this.downloadFormat=i,this.printSettingsDlg=new SSE.Views.PrintSettings({type:t,handler:_.bind(this.resultPrintSettings,this),afterrender:_.bind(function(){this._changedProps=[],this.updateSettings(this.printSettingsDlg),this.printSettingsDlg.cmbSheet.on("selected",_.bind(this.comboSheetsChange,this,this.printSettingsDlg)),this.fillPrintOptions(this.adjPrintParams),this.registerControlEvents(this.printSettingsDlg)},this)}),this.printSettingsDlg.show())},resultPrintSettings:function(t,e){var i=SSE.getController("Toolbar").getView("Toolbar");if("ok"==t){if(!this.checkMargins(this.printSettingsDlg))return!0;this.savePageOptions(this.printSettingsDlg);var n=this.printSettingsDlg.getRange();if(this.adjPrintParams.asc_setPrintType(n),this.adjPrintParams.asc_setPageOptionsMap(this._changedProps),this.adjPrintParams.asc_setIgnorePrintArea(this.printSettingsDlg.getIgnorePrintArea()),Common.localStorage.setItem("sse-print-settings-range",n),"print"==this.printSettingsDlg.type){var o=new Asc.asc_CDownloadOptions(null,Common.Utils.isChrome||Common.Utils.isSafari||Common.Utils.isOpera);o.asc_setAdvancedOptions(this.adjPrintParams),this.api.asc_Print(o)}else{var o=new Asc.asc_CDownloadOptions(this.downloadFormat,this.asUrl);o.asc_setAdvancedOptions(this.adjPrintParams),this.api.asc_DownloadAs(o)}Common.component.Analytics.trackEvent("print"==this.printSettingsDlg.type?"Print":"DownloadAs"),Common.component.Analytics.trackEvent("ToolBar","print"==this.printSettingsDlg.type?"Print":"DownloadAs"),Common.NotificationCenter.trigger("edit:complete",i)}else this.asUrl&&Common.NotificationCenter.trigger("download:cancel"),Common.NotificationCenter.trigger("edit:complete",i);this.printSettingsDlg=null},querySavePrintSettings:function(){this.checkMargins(this.printSettings)&&(this.savePageOptions(this.printSettings),this.printSettings.applySettings())},checkMargins:function(t){if(t.cmbPaperOrientation.getValue()==Asc.c_oAscPageOrientation.PagePortrait)var e=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),i=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());else i=/^\d{3}\.?\d*/.exec(t.cmbPaperSize.getValue()),e=/\d{3}\.?\d*$/.exec(t.cmbPaperSize.getValue());e=e?parseFloat(e[0]):this._originalPageSettings?this._originalPageSettings.asc_getWidth():0,i=i?parseFloat(i[0]):this._originalPageSettings?this._originalPageSettings.asc_getHeight():0;var n=Common.Utils.Metric.fnRecalcToMM(t.spnMarginLeft.getNumberValue()),o=Common.Utils.Metric.fnRecalcToMM(t.spnMarginRight.getNumberValue()),s=Common.Utils.Metric.fnRecalcToMM(t.spnMarginTop.getNumberValue()),a=Common.Utils.Metric.fnRecalcToMM(t.spnMarginBottom.getNumberValue()),l=!1;return n>e?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=['<div class="box">','<div id="group-radio-rows" style="margin-bottom: 5px;"></div>','<div id="group-radio-cols"></div>','<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","</div>"].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'<div id="<%=id%>" class="user-comment-item">\r\n\r\n \x3c!-- comment block --\x3e\r\n\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (usercolor!==null) { %><%=usercolor%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(username) %>\r\n </div>\r\n <div class="user-date"><%=date%></div>\r\n <% if (!editTextInPopover || hint) { %>\r\n <div oo_editor_input="true" tabindex="-1" class="user-message user-select"><%=scope.pickLink(comment)%></div>\r\n <% } else { %>\r\n <div class="inner-edit-ct">\r\n <textarea class="msg-reply user-select" maxlength="maxCommLength" spellcheck="false" <% if (!!dummy) { %> placeholder="textMention"<% } %>><%=comment%></textarea>\r\n <% if (hideAddReply) { %>\r\n <button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textAdd</button>\r\n <% } else { %>\r\n <button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textEdit</button>\r\n <% } %>\r\n <button class="btn normal dlg-btn btn-inner-close">textCancel</button>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- replys elements --\x3e\r\n\r\n <% if (replys.length) { %>\r\n <div class="reply-arrow img-commonctrl"></div>\r\n <% _.each(replys, function (item) { %>\r\n <div class="reply-item-ct">\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %>\r\n </div>\r\n <div class="user-date"><%=item.get("date")%></div>\r\n <% if (!item.get("editTextInPopover")) { %>\r\n <div oo_editor_input="true" tabindex="-1" class="user-message user-select"><%=scope.pickLink(item.get("reply"))%></div>\r\n <% if (!hint) { %>\r\n <div class="btns-reply-ct">\r\n <% if (item.get("editable")) { %>\r\n <div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>\r\n <div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>\r\n <%}%>\r\n </div>\r\n <%}%>\r\n <% } else { %>\r\n <div class="inner-edit-ct">\r\n <textarea class="msg-reply textarea-fix user-select" maxlength="maxCommLength" spellcheck="false"><%=item.get("reply")%></textarea>\r\n <button class="btn normal dlg-btn primary btn-inner-edit btn-fix" id="id-comments-change-popover">textEdit</button>\r\n <button class="btn normal dlg-btn btn-inner-close">textClose</button>\r\n </div>\r\n <% } %>\r\n </div>\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 <label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>\r\n <% } else { %>\r\n <label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>\r\n <% } %>\r\n <% } %>\r\n\r\n \x3c!-- edit buttons --\x3e\r\n\r\n <% if (!editTextInPopover && !lock && !hint) { %>\r\n <div class="edit-ct">\r\n <% if (editable) { %>\r\n <div class="btn-edit img-commonctrl"></div>\r\n <div class="btn-delete img-commonctrl"></div>\r\n <% } %>\r\n <% if (resolved) { %>\r\n <div class="btn-resolve-check img-commonctrl" data-toggle="tooltip"></div>\r\n <% } else { %>\r\n <div class="btn-resolve img-commonctrl" data-toggle="tooltip"></div>\r\n <% } %>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- reply --\x3e\r\n\r\n <% if (showReplyInPopover) { %>\r\n <div class="reply-ct">\r\n <textarea class="msg-reply user-select" placeholder="textAddReply" maxlength="maxCommLength" spellcheck="false"></textarea>\r\n <button class="btn normal dlg-btn primary btn-reply" id="id-comments-change-popover">textReply</button>\r\n <button class="btn normal dlg-btn btn-close">textClose</button>\r\n </div>\r\n <% } %>\r\n\r\n \x3c!-- locked user --\x3e\r\n\r\n <% if (lock) { %>\r\n <div class="lock-area" style="cursor: default;"></div>\r\n <div class="lock-author" style="cursor: default;"><%=lockuserid%></div>\r\n <% } %>\r\n\r\n</div>'}),define("text!common/main/lib/template/ReviewChangesPopover.template",[],function(){return'<div id="<%=id%>" class="user-comment-item">\r\n <div class="user-name">\r\n <div class="color" style="display: inline-block; background-color: <% if (usercolor!==null) { %><%=usercolor%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(username) %>\r\n </div>\r\n <div class="user-date"><%=date%></div>\r\n <div class="user-message limit-height"><%=changetext%></div>\r\n <div class="edit-ct">\r\n <% if (goto) { %>\r\n <div class="btn-goto img-commonctrl"></div>\r\n <% } %>\r\n <% if (!hint) { %>\r\n <% if (scope.appConfig.isReviewOnly) { %>\r\n <% if (editable) { %>\r\n <div class="btn-delete img-commonctrl"></div>\r\n <% } %>\r\n <% } else { %>\r\n <div class="btn-accept img-commonctrl"></div>\r\n <div class="btn-reject img-commonctrl"></div>\r\n <% } %>\r\n <% } %>\r\n </div>\r\n <% if (!hint && lock) { %>\r\n <div class="lock-area" style="cursor: default;"></div>\r\n <div class="lock-author" style="cursor: default;"><%=lockuser%></div>\r\n <% } %>\r\n</div>'}),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||['<div class="box">','<div id="id-popover" class="comments-popover" style="overflow-y: hidden;position: relative;">','<div id="id-review-popover"></div>','<div id="id-comments-popover"></div>',"</div>",'<div id="id-comments-arrow" class="comments-arrow"></div>',"</div>"].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('<div class="dataview-ct inner" style="overflow-y: visible;"></div>')},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('<div class="dataview-ct inner" style="overflow-y: visible;"></div>')}}}());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('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',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;d<a.items.length;d++)a.removeItem(a.items[d]),d--;if(s.length>0){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('<a id="<%= id %>" tabindex="-1" type="menuitem" style="font-size: 12px;"><div><%= Common.Utils.String.htmlEncode(caption) %></div><div style="color: #909090;"><%= Common.Utils.String.htmlEncode(options.value) %></div></a>'),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<a.length;++n)if(e===a[n].get("id"))return a[n].set("editTextInPopover",!0),s.length=0,o.set("replys",a),!0}else if((o=this.collection.findWhere({uid:t}))&&(s=o.get("replys"),a=_.clone(o.get("replys"))))for(n=0;n<a.length;++n)if(e===a[n].get("id"))return a[n].set("editText",!0),s.length=0,o.set("replys",a),!0;return!1},onUpdateFilter:function(t,e){if(t){this.view.isVisible()||(this.view.needUpdateFilter=t,e=!0),this.filter=t;var i=this,n=[];if(this.filter.forEach(function(t){i.groupCollection[t]||(i.groupCollection[t]=new Backbone.Collection([],{model:Common.Models.Comment})),n=n.concat(i.groupCollection[t].models)}),this.collection.reset(n),this.collection.groups=this.filter,!e){this.getPopover()&&this.getPopover().hide(),this.view.needUpdateFilter=!1;for(var o=!0,s=this.collection.length-1;s>=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;e<t.length;++e){var i=this.readSDKComment(t[e].asc_getId(),t[e]);i.get("groupName")?this.addCommentToGroupCollection(i):this.collection.push(i)}this.updateComments(!0)},onApiRemoveComment:function(t,e){for(var i in this.groupCollection){var n=this.groupCollection[i],o=n.findWhere({uid:t});if(o){n.remove(o);break}}if(this.collection.length){var o=this.collection.findWhere({uid:t});o&&(this.collection.remove(o),e||this.updateComments(!0)),this.popoverComments.length&&(o=this.popoverComments.findWhere({uid:t}))&&(this.popoverComments.remove(o),0===this.popoverComments.length&&this.getPopover()&&this.getPopover().hideComments())}},onChangeComments:function(t){for(var e=0;e<t.length;++e)this.onApiChangeCommentData(t[e].Comment.Id,t[e].Comment,!0);this.updateComments(!0)},onRemoveComments:function(t){for(var e=0;e<t.length;++e)this.onApiRemoveComment(t[e],!0);this.updateComments(!0)},onApiChangeCommentData:function(t,e,i){var n=this,o=0,s=null,a=null,l=0,r=null,c=this.findComment(t)||this.findCommentInGroup(t);if(c){n=this,s=e.asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getOnlyOfficeTime())):""==e.asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getTime()));var h=this.userCollection.findOriginalUser(e.asc_getUserId());for(c.set("comment",e.asc_getText()),c.set("userid",e.asc_getUserId()),c.set("username",e.asc_getUserName()),c.set("usercolor",h?h.get("color"):null),c.set("resolved",e.asc_getSolved()),c.set("quote",e.asc_getQuoteText()),c.set("time",s.getTime()),c.set("date",n.dateToLocaleTimeString(s)),a=_.clone(c.get("replys")),a.length=0,l=e.asc_getRepliesCount(),o=0;o<l;++o)r=e.asc_getReply(o).asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(e.asc_getReply(o).asc_getOnlyOfficeTime())):""==e.asc_getReply(o).asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(e.asc_getReply(o).asc_getTime())),h=this.userCollection.findOriginalUser(e.asc_getReply(o).asc_getUserId()),a.push(new Common.Models.Reply({id:Common.UI.getId(),userid:e.asc_getReply(o).asc_getUserId(),username:e.asc_getReply(o).asc_getUserName(),usercolor:h?h.get("color"):null,date:n.dateToLocaleTimeString(r),reply:e.asc_getReply(o).asc_getText(),time:r.getTime(),editText:!1,editTextInPopover:!1,showReplyInPopover:!1,scope:n.view,editable:n.mode.canEditComments||e.asc_getReply(o).asc_getUserId()==n.currentUserId}));c.set("replys",a),i||this.updateComments(!1,!0)}},onApiLockComment:function(t,e){var i=this.findComment(t)||this.findCommentInGroup(t),n=null;i&&this.userCollection&&(n=this.userCollection.findUser(e))&&(this.getPopover()&&this.getPopover().saveText(),this.view.saveText(),i.set("lock",!0),i.set("lockuserid",this.view.getUserName(n.get("username"))))},onApiUnLockComment:function(t){var e=this.findComment(t)||this.findCommentInGroup(t);e&&(e.set("lock",!1),this.getPopover()&&this.getPopover().loadText(),this.view.loadText())},onApiShowComment:function(t,e,i,n,o,s){var a=0===_.difference(this.uids,t).length&&0===_.difference(t,this.uids).length;if(!(s&&this.isSelectedComment&&a)||this.isModeChanged){this.mode&&!this.mode.canComments&&(s=!0);var l=this.getPopover();if(l){if(this.clearDummyComment(),this.isSelectedComment&&a&&!this.isModeChanged)return void(this.api&&(l.commentsView&&l.commentsView.setFocusToTextBox(!0),this.api.asc_enableKeyEvents(!0)));var r=0,c="",h="",d=null,p="",m=!0,u=[];for(r=0;r<t.length;++r)c=t[r],h=t[r]+"-R",(d=this.findComment(c))&&(this.subEditStrings[c]&&!s?(d.set("editTextInPopover",!0),p=this.subEditStrings[c]):this.subEditStrings[h]&&!s&&(d.set("showReplyInPopover",!0),p=this.subEditStrings[h]),d.set("hint",!_.isUndefined(s)&&s),!s&&this.hintmode&&(a&&0===this.uids.length&&(m=!1),this.oldUids.length&&0===_.difference(this.oldUids,t).length&&0===_.difference(t,this.oldUids).length&&(m=!1,this.oldUids=[])),this.animate&&(m=this.animate,this.animate=!1),this.isSelectedComment=!s||!this.hintmode,this.uids=_.clone(t),u.push(d),this._dontScrollToComment||this.view.commentsView.scrollToRecord(d),this._dontScrollToComment=!1);u.sort(function(t,e){return t.get("time")-e.get("time")}),this.popoverComments.reset(u),l.isVisible()&&l.hide(),l.setLeftTop(e,i,n),l.showComments(m,!1,!0,p)}this.isModeChanged=!1}},onApiHideComment:function(t){var e=this;if(this.getPopover()){if(this.isSelectedComment&&t)return;if(t&&this.getPopover().isCommentsViewMouseOver())return;this.popoverComments.each(function(t){t.get("editTextInPopover")&&(e.subEditStrings[t.get("uid")]=e.getPopover().getEditText()),t.get("showReplyInPopover")&&(e.subEditStrings[t.get("uid")+"-R"]=e.getPopover().getEditText())}),this.getPopover().saveText(!0),this.getPopover().hideComments(),this.collection.clearEditing(),this.popoverComments.clearEditing(),this.oldUids=_.clone(this.uids),this.isSelectedComment=!1,this.uids=[],this.popoverComments.reset()}},onApiUpdateCommentPosition:function(t,e,i,n){var o,s=!1,a=null,l=void 0,r="",c="";if(this.getPopover())if(this.getPopover().saveText(),this.getPopover().hideTips(),i<0||this.getPopover().sdkBounds.height<i||!_.isUndefined(n)&&this.getPopover().sdkBounds.width<n)this.getPopover().hide();else{if(this.isModeChanged&&this.onApiShowComment(t,e,i,n),0===this.popoverComments.length){var h=[];for(o=0;o<t.length;++o)r=t[o],c=t[o]+"-R",(a=this.findComment(r))&&(this.subEditStrings[r]?(a.set("editTextInPopover",!0),l=this.subEditStrings[r]):this.subEditStrings[c]&&(a.set("showReplyInPopover",!0),l=this.subEditStrings[c]),h.push(a));h.sort(function(t,e){return t.get("time")-e.get("time")}),this.popoverComments.reset(h),s=!0,this.getPopover().showComments(s,void 0,void 0,l)}else this.getPopover().isVisible()||this.getPopover().showComments(!1,void 0,void 0,l);this.getPopover().setLeftTop(e,i,n,void 0,!0)}},onDocumentPlaceChanged:function(){if(this.isDummyComment&&this.getPopover()&&this.getPopover().isVisible()){var t=this.api.asc_getAnchorPosition();t&&this.getPopover().setLeftTop(t.asc_getX()+t.asc_getWidth(),t.asc_getY(),this.hintmode?t.asc_getX():void 0)}},updateComments:function(t,e,i){var n=this;n.updateCommentsTime=new Date,void 0===n.timerUpdateComments&&(n.timerUpdateComments=setInterval(function(){new Date-n.updateCommentsTime>100&&(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;e<o;++e){n=t.asc_getReply(e).asc_getOnlyOfficeTime()?new Date(this.stringOOToLocalDate(t.asc_getReply(e).asc_getOnlyOfficeTime())):""==t.asc_getReply(e).asc_getTime()?new Date:new Date(this.stringUtcToLocalDate(t.asc_getReply(e).asc_getTime()));var s=this.userCollection.findOriginalUser(t.asc_getReply(e).asc_getUserId());i.push(new Common.Models.Reply({id:Common.UI.getId(),userid:t.asc_getReply(e).asc_getUserId(),username:t.asc_getReply(e).asc_getUserName(),usercolor:s?s.get("color"):null,date:this.dateToLocaleTimeString(n),reply:t.asc_getReply(e).asc_getText(),time:n.getTime(),editText:!1,editTextInPopover:!1,showReplyInPopover:!1,scope:this.view,editable:this.mode.canEditComments||t.asc_getReply(e).asc_getUserId()==this.currentUserId}))}return i},addDummyComment:function(){if(this.api){var t=this,e=null,i=new Date,n=this.getPopover();if(n){if(this.popoverComments.length){if(this.isDummyComment)return void _.delay(function(){n.commentsView.setFocusToTextBox()},200);this.closeEditing()}var o=this.userCollection.findOriginalUser(this.currentUserId),s=new Common.Models.Comment({id:-1,time:i.getTime(),date:this.dateToLocaleTimeString(i),userid:this.currentUserId,username:this.currentUserName,usercolor:o?o.get("color"):null,editTextInPopover:!0,showReplyInPopover:!1,hideAddReply:!0,scope:this.view,dummy:!0});this.popoverComments.reset(),this.popoverComments.push(s),this.uids=[],this.isSelectedComment=!0,this.isDummyComment=!0,_.isUndefined(this.api.asc_SetDocumentPlaceChangedEnabled)||t.api.asc_SetDocumentPlaceChangedEnabled(!0),n.handlerHide=function(){},n.isVisible()&&n.hide(),n.handlerHide=function(e){t.clearDummyComment(e)},e=this.api.asc_getAnchorPosition(),e&&(n.setLeftTop(e.asc_getX()+e.asc_getWidth(),e.asc_getY(),this.hintmode?e.asc_getX():void 0),Common.NotificationCenter.trigger("comments:showdummy"),n.showComments(!0,!1,!0,n.getDummyText()))}}},onAddDummyComment:function(e){if(this.api&&e&&e.length>0){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;e<t.length;++e)(n=this.findComment(t[e].asc_getId()))&&(n.set("editTextInPopover",i.mode.canEditComments),n.set("hint",!1),this.popoverComments.push(n));this.getPopover()&&this.popoverComments.length>0&&(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<e){i.push(t);break}i.push(t.substr(0,e)),t=t.substr(e)}return i})(e,2048).forEach(function(t){i.api.asc_coAuthoringChatSendMessage(t)})}},notcriticalErrorTitle:"Warning"},Common.Controllers.Chat||{}))}),void 0===Common)var Common={};if(Common.Models=Common.Models||{},define("common/main/lib/model/Plugin",["underscore","backbone","common/main/lib/component/BaseView"],function(t,e){"use strict";Common.Models.PluginVariation=e.Model.extend({defaults:function(){return{description:"",url:"",index:0,icons:void 0,isSystem:!1,isViewer:!1,isDisplayedInViewer:!0,EditorsSupport:["word","cell","slide"],isVisual:!1,isCustomWindow:!1,isModal:!1,isInsideMode:!1,initDataType:0,initData:"",isUpdateOleOnResize:!1,buttons:[],size:[800,600],initOnSelectionChanged:!1,visible:!0}}}),Common.Models.Plugin=e.Model.extend({defaults:function(){return{id:Common.UI.getId(),name:"",baseUrl:"",guid:Common.UI.getId(),variations:[],currentVariation:0,pluginObj:void 0,allowSelected:!1,selected:!1,visible:!0,groupName:"",groupRank:0}}})}),void 0===Common)var Common={};if(Common.Collections=Common.Collections||{},define("common/main/lib/collection/Plugins",["underscore","backbone","common/main/lib/model/Plugin"],function(t,e){"use strict";Common.Collections.Plugins=e.Collection.extend({model:Common.Models.Plugin,hasVisible:function(){return!!this.findWhere({visible:!0})}})}),define("common/main/lib/controller/Plugins",["core","common/main/lib/collection/Plugins","common/main/lib/view/Plugins"],function(){"use strict";Common.Controllers.Plugins=Backbone.Controller.extend(_.extend({models:[],appOptions:{},configPlugins:{autostart:[]},serverPlugins:{autostart:[]},collections:["Common.Collections.Plugins"],views:["Common.Views.Plugins"],initialize:function(){var t=this;this.addListeners({Toolbar:{"render:before":function(e){var i=t.getApplication().getController("Main").appOptions;if(!i.isEditMailMerge&&!i.isEditDiagram){var n={action:"plugins",caption:t.panelPlugins.groupCaption};t.$toolbarPanelPlugins=t.panelPlugins.getPanel(),e.addTab(n,t.$toolbarPanelPlugins,10)}}},"Common.Views.Plugins":{"plugin:select":function(e,i){t.api.asc_pluginRun(e,i,"")}}})},events:function(){return{"click #id-plugin-close":_.bind(this.onToolClose,this)}},onLaunch:function(){var t=this.getApplication().getCollection("Common.Collections.Plugins");this.panelPlugins=this.createView("Common.Views.Plugins",{storePlugins:t}),this.panelPlugins.on("render:after",_.bind(this.onAfterRender,this)),t.on({add:this.onAddPlugin.bind(this),reset:this.onResetPlugins.bind(this)}),this._moveOffset={x:0,y:0},this.autostart=[],Common.Gateway.on("init",this.loadConfig.bind(this)),Common.NotificationCenter.on("app:face",this.onAppShowed.bind(this))},loadConfig:function(t){var e=this;e.configPlugins.config=t.config.plugins,e.editor=window.DE?"word":window.PE?"slide":"cell"},loadPlugins:function(){this.configPlugins.config?this.getPlugins(this.configPlugins.config.pluginsData).then(function(e){t.configPlugins.plugins=e,t.mergePlugins()}).catch(function(e){t.configPlugins.plugins=!1}):this.configPlugins.plugins=!1;var t=this;Common.Utils.loadConfig("../../../../plugins.json",function(e){"error"!=e?(t.serverPlugins.config=e,t.getPlugins(t.serverPlugins.config.pluginsData).then(function(e){t.serverPlugins.plugins=e,t.mergePlugins()}).catch(function(e){t.serverPlugins.plugins=!1})):t.serverPlugins.plugins=!1})},onAppShowed:function(t){},setApi:function(t){return this.api=t,this.api.asc_registerCallback("asc_onPluginShow",_.bind(this.onPluginShow,this)),this.api.asc_registerCallback("asc_onPluginClose",_.bind(this.onPluginClose,this)),this.api.asc_registerCallback("asc_onPluginResize",_.bind(this.onPluginResize,this)),this.api.asc_registerCallback("asc_onPluginMouseUp",_.bind(this.onPluginMouseUp,this)),this.api.asc_registerCallback("asc_onPluginMouseMove",_.bind(this.onPluginMouseMove,this)),this.api.asc_registerCallback("asc_onPluginsReset",_.bind(this.resetPluginsList,this)),this.api.asc_registerCallback("asc_onPluginsInit",_.bind(this.onPluginsInit,this)),this.loadPlugins(),this},setMode:function(t){return this.appOptions=t,this.customPluginsComplete=!this.appOptions.canBrandingExt,this.appOptions.canBrandingExt&&this.getAppCustomPlugins(this.configPlugins),this},onAfterRender:function(t){t.viewPluginsList.on("item:click",_.bind(this.onSelectPlugin,this)),this.bindViewEvents(this.panelPlugins,this.events);var e=this;Common.NotificationCenter.on({"layout:resizestart":function(t){if(e.panelPlugins.isVisible()){var i=e.panelPlugins.currentPluginFrame.offset();e._moveOffset={x:i.left+parseInt(e.panelPlugins.currentPluginFrame.css("padding-left")),y:i.top+parseInt(e.panelPlugins.currentPluginFrame.css("padding-top"))},e.api.asc_pluginEnableMouseEvents(!0)}},"layout:resizestop":function(t){e.panelPlugins.isVisible()&&e.api.asc_pluginEnableMouseEvents(!1)}})},refreshPluginsList:function(){var t=this.getApplication().getCollection("Common.Collections.Plugins"),e=[];t.each(function(t){var i=new Asc.CPlugin;i.set_Name(t.get("name")),i.set_Guid(t.get("guid")),i.set_BaseUrl(t.get("baseUrl"));var n=t.get("variations"),o=[];n.forEach(function(t){var e=new Asc.CPluginVariation;e.set_Description(t.get("description")),e.set_Url(t.get("url")),e.set_Icons(t.get("icons")),e.set_Visual(t.get("isVisual")),e.set_CustomWindow(t.get("isCustomWindow")),e.set_System(t.get("isSystem")),e.set_Viewer(t.get("isViewer")),e.set_EditorsSupport(t.get("EditorsSupport")),e.set_Modal(t.get("isModal")),e.set_InsideMode(t.get("isInsideMode")),e.set_InitDataType(t.get("initDataType")),e.set_InitData(t.get("initData")),e.set_UpdateOleOnResize(t.get("isUpdateOleOnResize")),e.set_Buttons(t.get("buttons")),e.set_Size(t.get("size")),e.set_InitOnSelectionChanged(t.get("initOnSelectionChanged")),e.set_Events(t.get("events")),o.push(e)}),i.set_Variations(o),t.set("pluginObj",i),e.push(i)}),this.api.asc_pluginsRegister("",e),t.hasVisible()&&Common.NotificationCenter.trigger("tab:visible","plugins",!0)},onAddPlugin:function(t){var e=this;if(e.$toolbarPanelPlugins){var i=e.panelPlugins.createPluginButton(t);if(!i)return;var n=$("> .group",e.$toolbarPanelPlugins),o=$('<span class="slot"></span>').appendTo(n);i.render(o)}},onResetPlugins:function(t){var e=this;if(e.appOptions.canPlugins=!t.isEmpty(),e.$toolbarPanelPlugins){e.$toolbarPanelPlugins.empty();var i=$('<div class="group"></div>'),n=-1,o=0;t.each(function(t){var s=t.get("groupRank");s!==n&&n>-1&&o>0&&(i.appendTo(e.$toolbarPanelPlugins),$('<div class="separator long"></div>').appendTo(e.$toolbarPanelPlugins),i=$('<div class="group"></div>'),o=0);var a=e.panelPlugins.createPluginButton(t);if(a){var l=$('<span class="slot"></span>').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;p<s.items.length;p++)s.removeItem(s.items[p]),p--;s.removeAll();for(var m=i.get("variations"),p=0;p<m.length;p++){var u=m[p],g=new Common.UI.MenuItem({caption:p>0?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=$('<div id="menu-plugin-container" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',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 i<n?0==i?1:-1:i>n?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('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div><% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label><% } %></a>');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('<a id="<%= id %>" tabindex="-1" type="menuitem"><div><%= caption %></div><% if (options.description !== null) { %><label style="display: block;color: #a5a5a5;cursor: pointer;white-space: normal;"><%= options.description %></label><% } %></a>');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('<section id="review-changes-panel" class="panel" data-tab="review"><div class="group no-group-mask"><span id="slot-btn-sharing" class="btn-slot text x-huge"></span><span id="slot-btn-coauthmode" class="btn-slot text x-huge"></span></div><div class="separator long sharing"/><div class="group"><span class="btn-slot text x-huge slot-comment"></span></div><div class="separator long comments"/><div class="group"><span id="btn-review-on" class="btn-slot text x-huge"></span></div><div class="group no-group-mask" style="padding-left: 0;"><span id="btn-review-view" class="btn-slot text x-huge"></span></div><div class="group move-changes" style="padding-left: 0;"><span id="btn-change-prev" class="btn-slot text x-huge"></span><span id="btn-change-next" class="btn-slot text x-huge"></span><span id="btn-change-accept" class="btn-slot text x-huge"></span><span id="btn-change-reject" class="btn-slot text x-huge"></span></div><div class="separator long review"/><div class="group no-group-mask"><span id="slot-btn-chat" class="btn-slot text x-huge"></span></div><div class="separator long chat"/><div class="group no-group-mask"><span id="slot-btn-history" class="btn-slot text x-huge"></span></div></section>')({})),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=['<div class="box">','<div class="input-row">','<div id="id-review-button-prev" style=""></div>','<div id="id-review-button-next" style=""></div>','<div id="id-review-button-accept" style=""></div>','<div id="id-review-button-reject" style="margin-right: 0;"></div>',"</div>","</div>"].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:'<div class="box"><div class="input-row"><label><%= label %></label></div><div class="input-row" id="id-document-language"></div></div><div class="footer right"><button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button><button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button></div>',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(['<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">','<input type="text" class="form-control">','<span class="icon input-icon spellcheck-lang img-toolbarmenu"></span>','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret img-commonctrl"></span></button>','<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',"<% _.each(items, function(item) { %>",'<li id="<%= item.id %>" data-value="<%= item.value %>">','<a tabindex="-1" type="menuitem" style="padding-left: 28px !important;" langval="<%= item.value %>">','<i class="icon <% if (item.spellcheck) { %> img-toolbarmenu spellcheck-lang <% } %>"></i>',"<%= scope.getDisplayValue(item) %>","</a>","</li>","<% }); %>","</ul>","</span>"].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.height<e?this.getPopover().hide():this.popoverChanges.length>0&&(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="<b>"+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+="</b>",n+=o;break;case Asc.c_oAscRevisionsChangeType.ParaPr:if(n="<b>"+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+="</b>",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:"<b>Inserted:</b>",textDeleted:"<b>Deleted:</b>",textParaInserted:"<b>Paragraph Inserted</b> ",textParaDeleted:"<b>Paragraph Deleted</b> ",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:"<b>Table Settings Changed</b>",textTableRowsAdd:"<b>Table Rows Added<b/>",textTableRowsDel:"<b>Table Rows Deleted<b/>",textParaMoveTo:"<b>Moved:</b>",textParaMoveFromUp:"<b>Moved Up:</b>",textParaMoveFromDown:"<b>Moved Down:</b>"},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('<section id="protection-panel" class="panel" data-tab="protect"><div class="group"><span id="slot-btn-add-password" class="btn-slot text x-huge"></span><span id="slot-btn-change-password" class="btn-slot text x-huge"></span><span id="slot-btn-signature" class="btn-slot text x-huge"></span></div></section>')({})),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||['<div class="box" style="height:'+(i.height-85)+'px;">','<div class="input-row" style="margin-bottom: 10px;">',"<label>"+e.txtDescription+"</label>","</div>",'<div class="input-row">',"<label>"+e.txtPassword+"</label>","</div>",'<div id="id-password-txt" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+e.txtRepeat+"</label>","</div>",'<div id="id-repeat-txt" class="input-row"></div>',"</div>",'<div class="separator horizontal"/>','<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">'+e.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+e.cancelButtonText+"</button>","</div>"].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=['<div class="box" style="height: '+("invisible"==this.signType?"132px;":"300px;")+'">','<div id="id-dlg-sign-invisible">','<div class="input-row">',"<label>"+this.textPurpose+"</label>","</div>",'<div id="id-dlg-sign-purpose" class="input-row"></div>',"</div>",'<div id="id-dlg-sign-visible">','<div class="input-row">',"<label>"+this.textInputName+"</label>","</div>",'<div id="id-dlg-sign-name" class="input-row" style="margin-bottom: 5px;"></div>','<div id="id-dlg-sign-fonts" class="input-row" style="display: inline-block;"></div>','<div id="id-dlg-sign-font-size" class="input-row" style="display: inline-block;margin-left: 3px;"></div>','<div id="id-dlg-sign-bold" style="display: inline-block;margin-left: 3px;"></div>','<div id="id-dlg-sign-italic" style="display: inline-block;margin-left: 3px;"></div>','<div style="margin: 10px 0 5px 0;">',"<label>"+this.textUseImage+"</label>","</div>",'<button id="id-dlg-sign-image" class="btn btn-text-default auto">'+this.textSelectImage+"</button>",'<div class="input-row" style="margin-top: 10px;">','<label style="font-weight: bold;">'+this.textSignature+"</label>","</div>",'<div style="border: 1px solid #cbcbcb;"><div id="signature-preview-img" style="width: 100%; height: 50px;position: relative;"></div></div>',"</div>",'<table style="margin-top: 30px;">',"<tr>",'<td><label style="font-weight: bold;margin-bottom: 3px;">'+this.textCertificate+'</label></td><td rowspan="2" style="vertical-align: top; padding-left: 30px;"><button id="id-dlg-sign-change" class="btn btn-text-default" style="">'+this.textSelect+"</button></td>","</tr>",'<tr><td><div id="id-dlg-sign-certificate" class="hidden" style="max-width: 212px;overflow: hidden;"></td></tr>',"</table>","</div>",'<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","</div>"].join(""),this.templateCertificate=_.template(['<label style="display: block;margin-bottom: 3px;"><%= Common.Utils.String.htmlEncode(name) %></label>','<label style="display: block;"><%= Common.Utils.String.htmlEncode(valid) %></label>'].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=['<div class="box" style="height: 260px;">','<div class="input-row">',"<label>"+this.textInfo+"</label>","</div>",'<div class="input-row">',"<label>"+this.textInfoName+"</label>","</div>",'<div id="id-dlg-sign-settings-name" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+this.textInfoTitle+"</label>","</div>",'<div id="id-dlg-sign-settings-title" class="input-row" style="margin-bottom: 5px;"></div>','<div class="input-row">',"<label>"+this.textInfoEmail+"</label>","</div>",'<div id="id-dlg-sign-settings-email" class="input-row" style="margin-bottom: 10px;"></div>','<div class="input-row">',"<label>"+this.textInstructions+"</label>","</div>",'<textarea id="id-dlg-sign-settings-instructions" class="form-control" style="width: 100%;height: 35px;margin-bottom: 10px;resize: none;"></textarea>','<div id="id-dlg-sign-settings-date"></div>',"</div>",'<div class="footer center">','<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">'+this.okButtonText+"</button>",'<% if (type == "edit") { %>','<button class="btn normal dlg-btn" result="cancel">'+this.cancelButtonText+"</button>","<% } %>","</div>"].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