From 5f1b2918861f7c41641effe390b36f19f3e9233f Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 16 Feb 2018 02:56:17 +0300 Subject: [PATCH] [DE][PE][SSE] synchronize extra buttons state through events --- apps/common/main/lib/component/Button.js | 7 +++++ .../main/app/controller/LeftMenu.js | 7 ++++- .../main/app/controller/Main.js | 21 ++------------ .../main/app/controller/Toolbar.js | 14 ++++++++-- .../main/app/controller/Viewport.js | 12 ++++++++ apps/documenteditor/main/app/view/Toolbar.js | 28 ++++++------------- .../main/app/controller/LeftMenu.js | 8 +++++- .../main/app/controller/Main.js | 21 ++------------ .../main/app/controller/Toolbar.js | 17 +++++++++-- .../main/app/controller/Viewport.js | 13 +++++++++ .../main/app/view/Toolbar.js | 25 ++++++----------- .../main/app/controller/LeftMenu.js | 7 ++++- .../main/app/controller/Main.js | 14 ++-------- .../main/app/controller/Toolbar.js | 13 +++++++++ .../main/app/controller/Viewport.js | 12 ++++++++ .../main/app/view/Toolbar.js | 27 ++++++------------ 16 files changed, 136 insertions(+), 110 deletions(-) diff --git a/apps/common/main/lib/component/Button.js b/apps/common/main/lib/component/Button.js index 013f7f78e..2315c167a 100644 --- a/apps/common/main/lib/component/Button.js +++ b/apps/common/main/lib/component/Button.js @@ -595,6 +595,13 @@ define([ } } } + + if ( !!me.options.signals ) { + var opts = me.options.signals; + if ( !(opts.indexOf('disabled') < 0) ) { + me.trigger('disabled', me, disabled); + } + } } this.disabled = disabled; diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 2180cc6f9..06bf7e080 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -91,7 +91,8 @@ define([ 'Toolbar': { 'file:settings': _.bind(this.clickToolbarSettings,this), 'file:open': this.clickToolbarTab.bind(this, 'file'), - 'file:close': this.clickToolbarTab.bind(this, 'other') + 'file:close': this.clickToolbarTab.bind(this, 'other'), + 'save:disabled': this.changeToolbarSaveState.bind(this) }, 'SearchDialog': { 'hide': _.bind(this.onSearchDlgHide, this), @@ -398,6 +399,10 @@ define([ this.leftMenu.menuFile.hide(); }, + changeToolbarSaveState: function (state) { + this.leftMenu.menuFile.getButton('save').setDisabled(state); + }, + /** coauthoring begin **/ clickStatusbarUsers: function() { this.leftMenu.menuFile.panels['rights'].changeAccessRights(); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 63cd85a79..5e0e20d50 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -622,12 +622,7 @@ define([ forcesave = this.appOptions.forcesave, isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } }, @@ -1528,12 +1523,7 @@ define([ var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave, isDisabled = !isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } /** coauthoring begin **/ @@ -1549,12 +1539,7 @@ define([ var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave, isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 3f82fca07..1611b09fa 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -231,8 +231,11 @@ define([ toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnSave.on('click', _.bind(this.onSave, this)); + toolbar.btnSave.on('disabled', _.bind(this.onBtnChangeState, this, 'save:disabled')); toolbar.btnUndo.on('click', _.bind(this.onUndo, this)); + toolbar.btnUndo.on('disabled', _.bind(this.onBtnChangeState, this, 'undo:disabled')); toolbar.btnRedo.on('click', _.bind(this.onRedo, this)); + toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, true)); toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, false)); toolbar.btnIncFontSize.on('click', _.bind(this.onIncrease, this)); @@ -920,7 +923,7 @@ define([ this.api.asc_Save(); } - toolbar.btnsSave.setDisabled(!toolbar.mode.forcesave); + toolbar.btnSave.setDisabled(!toolbar.mode.forcesave); Common.NotificationCenter.trigger('edit:complete', toolbar); @@ -928,6 +931,13 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Save'); }, + onBtnChangeState: function(prop) { + if ( /\:disabled$/.test(prop) ) { + var _is_disabled = arguments[2]; + this.toolbar.fireEvent(prop, [_is_disabled]); + } + }, + onUndo: function(btn, e) { if (this.api) this.api.Undo(); @@ -2701,7 +2711,7 @@ define([ toolbar._state.previewmode = reviewmode && disable; if (reviewmode) { - toolbar._state.previewmode && toolbar.btnsSave.setDisabled(true); + toolbar._state.previewmode && toolbar.btnSave.setDisabled(true); if (toolbar.needShowSynchTip) { toolbar.needShowSynchTip = false; diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 98281ba0a..83097ded2 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -77,6 +77,18 @@ define([ 'view:compact' : function (toolbar, state) { me.viewport.vlayout.getItem('toolbar').height = state ? Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal'); + }, + 'undo:disabled' : function (state) { + if ( me.header.btnUndo ) + me.header.btnUndo.setDisabled(state); + }, + 'redo:disabled' : function (state) { + if ( me.header.btnRedo ) + me.header.btnRedo.setDisabled(state); + }, + 'save:disabled' : function (state) { + if ( me.header.btnSave ) + me.header.btnSave.setDisabled(state); } } }); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 4fecc3cd1..6125c2e9d 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -120,22 +120,24 @@ define([ this.btnSave = new Common.UI.Button({ id: 'id-toolbar-btn-save', cls: 'btn-toolbar', - iconCls: 'no-mask ' + this.btnSaveCls + iconCls: 'no-mask ' + this.btnSaveCls, + signals: ['disabled'] }); this.toolbarControls.push(this.btnSave); - me.btnsSave = createButtonSet( me.btnSave ); this.btnUndo = new Common.UI.Button({ id: 'id-toolbar-btn-undo', cls: 'btn-toolbar', - iconCls: 'btn-undo' + iconCls: 'btn-undo', + signals: ['disabled'] }); this.toolbarControls.push(this.btnUndo); this.btnRedo = new Common.UI.Button({ id: 'id-toolbar-btn-redo', cls: 'btn-toolbar', - iconCls: 'btn-redo' + iconCls: 'btn-redo', + signals: ['disabled'] }); this.toolbarControls.push(this.btnRedo); @@ -1957,18 +1959,6 @@ define([ maxRows: 8, maxColumns: 10 }); - - var btnsave = DE.getController('LeftMenu').getView('LeftMenu').getMenu('file').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - this.toolbarControls.push(btnsave); - } - - btnsave = DE.getController('Viewport').getView('Common.Views.Header').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - this.toolbarControls.push(btnsave); - } }, onToolbarAfterRender: function(toolbar) { @@ -2052,7 +2042,7 @@ define([ setMode: function (mode) { if (mode.isDisconnected) { - this.btnsSave.setDisabled(true); + this.btnSave.setDisabled(true); if (mode.disableDownload) this.btnPrint.setDisabled(true); } @@ -2143,7 +2133,7 @@ define([ this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); } - this.btnsSave.setDisabled(false); + this.btnSave.setDisabled(false); Common.Gateway.collaborativeChanges(); }, @@ -2174,7 +2164,7 @@ define([ if (this.synchTooltip) this.synchTooltip.hide(); this.btnSave.updateHint(this.btnSaveTip); - this.btnsSave.setDisabled(!me.mode.forcesave); + this.btnSave.setDisabled(!me.mode.forcesave); this._state.hasCollaborativeChanges = false; } } diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 3590306ae..81aa86c15 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -89,7 +89,8 @@ define([ 'Toolbar': { 'file:settings': _.bind(this.clickToolbarSettings,this), 'file:open': this.clickToolbarTab.bind(this, 'file'), - 'file:close': this.clickToolbarTab.bind(this, 'other') + 'file:close': this.clickToolbarTab.bind(this, 'other'), + 'save:disabled' : this.changeToolbarSaveState.bind(this) }, 'SearchDialog': { 'hide': _.bind(this.onSearchDlgHide, this), @@ -311,6 +312,11 @@ define([ this.leftMenu.menuFile.hide(); }, + changeToolbarSaveState: function (state) { + this.leftMenu.menuFile.getButton('save').setDisabled(state); + console.log('save: ' + state); + }, + /** coauthoring begin **/ clickStatusbarUsers: function() { this.leftMenu.menuFile.panels['rights'].changeAccessRights(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index e33d95aa6..150a04afa 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -417,12 +417,7 @@ define([ forcesave = this.appOptions.forcesave, isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } }, @@ -1271,12 +1266,7 @@ define([ var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave, isDisabled = !isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } }, onDocumentCanSaveChanged: function (isCanSave) { @@ -1285,12 +1275,7 @@ define([ var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave, isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (toolbarView.btnSave.isDisabled() !== isDisabled) - toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + toolbarView.btnSave.setDisabled(isDisabled); } }, diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index cdd8f02e6..4099bc566 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -217,10 +217,14 @@ define([ }, onLaunch: function() { - // Create toolbar view - this.toolbar = this.createView('Toolbar'); - var me = this; + + // Create toolbar view + me.toolbar = me.createView('Toolbar'); + me.toolbar.btnSave.on('disabled', _.bind(this.onBtnChangeState, this, 'save:disabled')); + me.toolbar.btnUndo.on('disabled', _.bind(this.onBtnChangeState, this, 'undo:disabled')); + me.toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); + Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me)); Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me)); @@ -922,6 +926,13 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Save'); }, + onBtnChangeState: function(prop) { + if ( /\:disabled$/.test(prop) ) { + var _is_disabled = arguments[2]; + this.toolbar.fireEvent(prop, [_is_disabled]); + } + }, + onUndo: function(btn, e) { if (this.api) { this.api.Undo(); diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 046d7550b..298096677 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -78,6 +78,19 @@ define([ 'view:compact' : function (toolbar, state) { me.viewport.vlayout.getItem('toolbar').height = state ? Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal'); + }, + 'undo:disabled' : function (state) { + if ( me.header.btnUndo ) + me.header.btnUndo.setDisabled(state); + }, + 'redo:disabled' : function (state) { + if ( me.header.btnRedo ) + me.header.btnRedo.setDisabled(state); + }, + 'save:disabled' : function (state) { + if ( me.header.btnSave ) + me.header.btnSave.setDisabled(state); + console.log('header save: ' + state); } }, // Events generated by main view diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 6bb2695e6..fd1afe929 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -170,15 +170,16 @@ define([ id : 'id-toolbar-btn-save', cls : 'btn-toolbar', iconCls : 'no-mask ' + me.btnSaveCls, - lock : [_set.lostConnect] + lock : [_set.lostConnect], + signals : ['disabled'] }); - me.btnsSave = createButtonSet(me.btnSave); me.btnUndo = new Common.UI.Button({ id : 'id-toolbar-btn-undo', cls : 'btn-toolbar', iconCls : 'btn-undo', - lock : [_set.undoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] + lock : [_set.undoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart], + signals : ['disabled'] }); me.slideOnlyControls.push(me.btnUndo); @@ -186,7 +187,8 @@ define([ id : 'id-toolbar-btn-redo', cls : 'btn-toolbar', iconCls : 'btn-redo', - lock : [_set.redoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] + lock : [_set.redoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart], + signals : ['disabled'] }); me.slideOnlyControls.push(me.btnRedo); @@ -1340,17 +1342,6 @@ define([ // // Enable none paragraph components this.lockToolbar(PE.enumLock.disableOnStart, false, {array: this.slideOnlyControls.concat(this.shapeControls)}); - var btnsave = PE.getController('LeftMenu').getView('LeftMenu').getMenu('file').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - this.lockControls.push(btnsave); - } - btnsave = PE.getController('Viewport').getView('Common.Views.Header').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - this.lockControls.push(btnsave); - } - /** coauthoring begin **/ this.showSynchTip = !Common.localStorage.getBool('pe-hide-synch'); this.needShowSynchTip = false; @@ -1499,7 +1490,7 @@ define([ this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); } - this.btnsSave.setDisabled(false); + this.btnSave.setDisabled(false); Common.Gateway.collaborativeChanges(); }, @@ -1530,7 +1521,7 @@ define([ if (this.synchTooltip) this.synchTooltip.hide(); this.btnSave.updateHint(this.btnSaveTip); - this.btnsSave.setDisabled(!me.mode.forcesave); + this.btnSave.setDisabled(!me.mode.forcesave); this._state.hasCollaborativeChanges = false; } diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index d64fe5f54..bb40abea2 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -79,7 +79,8 @@ define([ 'Toolbar': { 'file:settings': _.bind(this.clickToolbarSettings,this), 'file:open': this.clickToolbarTab.bind(this, 'file'), - 'file:close': this.clickToolbarTab.bind(this, 'other') + 'file:close': this.clickToolbarTab.bind(this, 'other'), + 'save:disabled' : this.changeToolbarSaveState.bind(this) }, 'SearchDialog': { 'hide': _.bind(this.onSearchDlgHide, this), @@ -348,6 +349,10 @@ define([ this.leftMenu.menuFile.hide(); }, + changeToolbarSaveState: function (state) { + this.leftMenu.menuFile.getButton('save').setDisabled(state); + }, + /** coauthoring begin **/ clickStatusbarUsers: function() { this.leftMenu.menuFile.panels['rights'].changeAccessRights(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 2d1744f0e..9d5505a6d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1417,12 +1417,7 @@ define([ forcesave = this.appOptions.forcesave, cansave = this.api.asc_isDocumentCanSave(), isDisabled = !cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (this.toolbarView.btnSave.isDisabled() !== isDisabled) - this.toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + this.toolbarView.btnSave.setDisabled(isDisabled); } }, @@ -1431,12 +1426,7 @@ define([ var isSyncButton = $('.icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave, isDisabled = !isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave; - if (this.toolbarView.btnSave.isDisabled() !== isDisabled) - this.toolbarView.btnsSave.forEach(function(button) { - if ( button ) { - button.setDisabled(isDisabled); - } - }); + this.toolbarView.btnSave.setDisabled(isDisabled); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 0f6d1d44a..f1474829c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -247,8 +247,11 @@ define([ } else { toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnSave.on('click', _.bind(this.onSave, this)); + toolbar.btnSave.on('disabled', _.bind(this.onBtnChangeState, this, 'save:disabled')); toolbar.btnUndo.on('click', _.bind(this.onUndo, this)); + toolbar.btnUndo.on('disabled', _.bind(this.onBtnChangeState, this, 'undo:disabled')); toolbar.btnRedo.on('click', _.bind(this.onRedo, this)); + toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled')); toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, true)); toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, false)); toolbar.btnIncFontSize.on('click', _.bind(this.onIncreaseFontSize, this)); @@ -396,6 +399,13 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Save'); }, + onBtnChangeState: function(prop) { + if ( /\:disabled$/.test(prop) ) { + var _is_disabled = arguments[2]; + this.toolbar.fireEvent(prop, [_is_disabled]); + } + }, + onUndo: function(btn, e) { if (this.api) this.api.asc_Undo(); @@ -3039,6 +3049,9 @@ define([ me.toolbar.setMode(config); if ( config.isEdit ) { + me.toolbar.btnSave && me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled')); + me.toolbar.btnUndo && me.toolbar.btnUndo.on('disabled', _.bind(me.onBtnChangeState, me, 'undo:disabled')); + me.toolbar.btnRedo && me.toolbar.btnRedo.on('disabled', _.bind(me.onBtnChangeState, me, 'redo:disabled')); me.toolbar.setApi(me.api); if ( !config.isEditDiagram && !config.isEditMailMerge ) { diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index dd05bf1ed..dadd49ec1 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -76,6 +76,18 @@ define([ 'view:compact' : function (toolbar, state) { me.viewport.vlayout.getItem('toolbar').height = state ? Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal'); + }, + 'undo:disabled' : function (state) { + if ( me.header.btnUndo ) + me.header.btnUndo.setDisabled(state); + }, + 'redo:disabled' : function (state) { + if ( me.header.btnRedo ) + me.header.btnRedo.setDisabled(state); + }, + 'save:disabled' : function (state) { + if ( me.header.btnSave ) + me.header.btnSave.setDisabled(state); } } }); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 24c851321..f627aafb7 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -157,7 +157,8 @@ define([ cls : 'btn-toolbar', iconCls : 'btn-undo', disabled : true, - lock : [_set.lostConnect] + lock : [_set.lostConnect], + signals : ['disabled'] }); me.btnRedo = new Common.UI.Button({ @@ -165,7 +166,8 @@ define([ cls : 'btn-toolbar', iconCls : 'btn-redo', disabled : true, - lock : [_set.lostConnect] + lock : [_set.lostConnect], + signals : ['disabled'] }); return this; @@ -370,9 +372,9 @@ define([ me.btnSave = new Common.UI.Button({ id : 'id-toolbar-btn-save', cls : 'btn-toolbar', - iconCls : 'no-mask ' + me.btnSaveCls + iconCls : 'no-mask ' + me.btnSaveCls, + signals : ['disabled'] }); - me.btnsSave = createButtonSet(me.btnSave); me.btnIncFontSize = new Common.UI.Button({ id : 'id-toolbar-btn-incfont', @@ -1233,7 +1235,7 @@ define([ me.cmbNumberFormat, me.btnBorders, me.btnInsertImage, me.btnInsertHyperlink, me.btnInsertChart, me.btnColorSchemas, me.btnAutofilter, me.btnCopy, me.btnPaste, me.btnSettings, me.listStyles, me.btnPrint, me.btnShowMode, - /*me.btnSave, */me.btnClearStyle, me.btnCopyStyle + me.btnSave, me.btnClearStyle, me.btnCopyStyle ]; var _temp_array = [me.cmbFontName, me.cmbFontSize, me.btnAlignLeft,me.btnAlignCenter,me.btnAlignRight,me.btnAlignJust,me.btnAlignTop, @@ -1706,15 +1708,6 @@ define([ itemTemplate: _.template('
') }); } - - var btnsave = SSE.getController('LeftMenu').getView('LeftMenu').getMenu('file').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - } - btnsave = SSE.getController('Viewport').getView('Common.Views.Header').getButton('save'); - if (btnsave && this.btnsSave) { - this.btnsSave.add(btnsave); - } }, onToolbarAfterRender: function(toolbar) { @@ -1758,8 +1751,6 @@ define([ this.lockToolbar( SSE.enumLock.lostConnect, true ); this.lockToolbar( SSE.enumLock.lostConnect, true, {array:[this.btnEditChart,this.btnUndo,this.btnRedo]} ); - this.lockToolbar( SSE.enumLock.lostConnect, true, - {array:this.btnsSave} ); this.lockToolbar(SSE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]}); } else { this.mode = mode; @@ -1851,7 +1842,7 @@ define([ this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); } - this.btnsSave.setDisabled(false); + this.btnSave.setDisabled(false); Common.Gateway.collaborativeChanges(); }, @@ -1882,7 +1873,7 @@ define([ if (this.synchTooltip) this.synchTooltip.hide(); this.btnSave.updateHint(this.btnSaveTip); - this.btnsSave.setDisabled(!me.mode.forcesave); + this.btnSave.setDisabled(!me.mode.forcesave); this._state.hasCollaborativeChanges = false; }