diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index f1cb5fe319..5cad4d3e53 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -686,11 +686,7 @@ define([ application.getController('DocumentHolder').getView().focus(); if (this.api && this.appOptions.isEdit && this.api.asc_isDocumentCanSave) { - var cansave = this.api.asc_isDocumentCanSave(), - forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, - isSyncButton = (toolbarView.btnCollabChanges.rendered) ? toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false, - isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - toolbarView.btnSave.setDisabled(isDisabled); + this.disableSaveButton(this.api.asc_isDocumentCanSave()); } if (this.appOptions.isEdit && (toolbarView && toolbarView._isEyedropperStart || rightMenu && rightMenu._isEyedropperStart)) { toolbarView._isEyedropperStart ? toolbarView._isEyedropperStart = false : rightMenu._isEyedropperStart = false; @@ -700,6 +696,16 @@ define([ Common.UI.HintManager.clearHints(true); }, + disableSaveButton: function (isCanSave) { + var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); + if (!toolbarView || !toolbarView.btnSave || !this.api) return; + + var forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, + isSyncButton = (toolbarView.btnCollabChanges && toolbarView.btnCollabChanges.rendered) ? toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false, + isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; + toolbarView.lockToolbar(Common.enumLock.cantSave, isDisabled, {array: [toolbarView.btnSave]}); + }, + onLongActionBegin: function(type, id) { var action = {id: id, type: type}; this.stackLongActions.push(action); @@ -1976,23 +1982,10 @@ define([ } this.updateWindowTitle(); - - var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); - if (toolbarView && toolbarView.btnCollabChanges) { - var isSyncButton = toolbarView.btnCollabChanges.cmpEl.hasClass('notify'), - forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, - isDisabled = !isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - toolbarView.btnSave.setDisabled(isDisabled); - } + this.disableSaveButton(isModified); }, onDocumentCanSaveChanged: function (isCanSave) { - var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); - if ( toolbarView ) { - var isSyncButton = toolbarView.btnCollabChanges.cmpEl.hasClass('notify'), - forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, - isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - toolbarView.btnSave.setDisabled(isDisabled); - } + this.disableSaveButton(isCanSave); }, onContextMenu: function(event){ diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index af8ccbe76e..5aa79f4093 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -1226,7 +1226,7 @@ define([ this.api.asc_Save(); } - toolbar.btnSave.setDisabled(!toolbar.mode.forcesave && !toolbar.mode.canSaveDocumentToBinary); + toolbar.btnSave && toolbar.lockToolbar(Common.enumLock.cantSave, !toolbar.mode.forcesave && !toolbar.mode.canSaveDocumentToBinary, {array: [toolbar.btnSave]}); Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.component.Analytics.trackEvent('Save'); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 882e8b3f08..0b0caa9d98 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -104,7 +104,8 @@ define([ noParagraphObject: 'no-paragraph-obj', inSlideMaster: 'in-slide-master', slideMasterMode: 'slide-master-mode', - cantMergeShape: 'merge-shape-lock' + cantMergeShape: 'merge-shape-lock', + cantSave: 'cant-save' }; for (var key in enumLock) { if (enumLock.hasOwnProperty(key)) { @@ -187,7 +188,7 @@ define([ id: 'id-toolbar-btn-save', cls: 'btn-toolbar', iconCls: 'toolbar__icon no-mask ' + me.btnSaveCls, - lock: [_set.lostConnect], + lock: [_set.cantSave, _set.lostConnect], signals: ['disabled'], dataHint: '1', dataHintDirection: 'top', @@ -2241,8 +2242,7 @@ define([ } else { this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); } - - this.btnSave.setDisabled(false); + this.lockToolbar(Common.enumLock.cantSave, false, {array: [this.btnSave]}); Common.Gateway.collaborativeChanges(); }, @@ -2273,8 +2273,7 @@ define([ if (this.synchTooltip) this.synchTooltip.hide(); this.btnCollabChanges.updateHint(this.btnSaveTip); - this.btnSave.setDisabled(!me.mode.forcesave && !me.mode.canSaveDocumentToBinary); - + this.lockToolbar(Common.enumLock.cantSave, !me.mode.forcesave && !me.mode.canSaveDocumentToBinary, {array: [this.btnSave]}); this._state.hasCollaborativeChanges = false; } } diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 98582b5a14..00a867d196 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2422,22 +2422,20 @@ define([ this._isDocReady && Common.Gateway.setDocumentModified(change); } - if (this.toolbarView && this.toolbarView.btnCollabChanges && this.api) { - var isSyncButton = this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify'), - forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, - cansave = this.api.asc_isDocumentCanSave(), - isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - this.toolbarView.btnSave.setDisabled(isDisabled); - } + this.api && this.disableSaveButton(this.api.asc_isDocumentCanSave()); }, onDocumentCanSaveChanged: function (isCanSave) { - if (this.toolbarView && this.toolbarView.btnCollabChanges) { - var isSyncButton = this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify'), - forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, - isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - this.toolbarView.btnSave.setDisabled(isDisabled); - } + this.disableSaveButton(isCanSave) + }, + + disableSaveButton: function (isCanSave) { + if (!this.toolbarView || !this.toolbarView.btnCollabChanges) return; + + var forcesave = this.appOptions.forcesave || this.appOptions.canSaveDocumentToBinary, + isSyncButton = (this.toolbarView.btnCollabChanges.rendered) ? this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify') : false, + isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; + this.toolbarView.lockToolbar(Common.enumLock.cantSave, isDisabled, {array: [this.toolbarView.btnSave]}); }, onBeforeUnload: function() { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 5c31873ce2..b091c30da6 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -115,7 +115,8 @@ define([ userProtected: 'cell-user-protected', pageBreakLock: 'page-break-lock', fileMenuOpened: 'file-menu-opened', - cantMergeShape: 'merge-shape-lock' + cantMergeShape: 'merge-shape-lock', + cantSave: 'cant-save' }; for (var key in enumLock) { if (enumLock.hasOwnProperty(key)) { @@ -858,7 +859,7 @@ define([ id : 'id-toolbar-btn-save', cls : 'btn-toolbar', iconCls : 'toolbar__icon no-mask ' + me.btnSaveCls, - lock : [_set.lostConnect], + lock : [_set.cantSave, _set.lostConnect], signals : ['disabled'], dataHint : '1', dataHintDirection: 'top', @@ -3287,8 +3288,7 @@ define([ } else { this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); } - - this.btnSave.setDisabled(false); + this.lockToolbar(Common.enumLock.cantSave, false, {array: [this.btnSave]}); Common.Gateway.collaborativeChanges(); }, @@ -3319,8 +3319,7 @@ define([ if (this.synchTooltip) this.synchTooltip.hide(); this.btnCollabChanges.updateHint(this.btnSaveTip); - this.btnSave.setDisabled(!me.mode.forcesave && !me.mode.canSaveDocumentToBinary); - + this.lockToolbar(Common.enumLock.cantSave, !me.mode.forcesave && !me.mode.canSaveDocumentToBinary, {array: [this.btnSave]}); this._state.hasCollaborativeChanges = false; } }