From d4b08a16ed1bf7ea40ef54925eb7cea654394938 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 10 Dec 2021 15:24:58 +0300 Subject: [PATCH] [DE] Add handlers to show toolbar, statusbar, rulers buttons in view tab --- .../main/app/controller/Statusbar.js | 23 ++++++++++----- .../main/app/controller/Toolbar.js | 3 ++ .../main/app/controller/ViewTab.js | 29 +++++++++++++++++-- .../main/app/controller/Viewport.js | 21 ++++++++++---- apps/documenteditor/main/app/view/ViewTab.js | 15 ++++++++-- 5 files changed, 72 insertions(+), 19 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index d46eaefee..e09d34c1a 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -65,13 +65,10 @@ define([ }.bind(this) }, 'Common.Views.Header': { - 'statusbar:hide': function (view, status) { - me.statusbar.setVisible(!status); - Common.localStorage.setBool('de-hidden-status', status); - - Common.NotificationCenter.trigger('layout:changed', 'status'); - Common.NotificationCenter.trigger('edit:complete', me.statusbar); - } + 'statusbar:hide': _.bind(me.onChangeCompactView, me) + }, + 'ViewTab': { + 'statusbar:hide': _.bind(me.onChangeCompactView, me) } }); }, @@ -174,6 +171,18 @@ define([ }); }, + onChangeCompactView: function (view, status) { + this.statusbar.setVisible(!status); + Common.localStorage.setBool('de-hidden-status', status); + + if ($(view).parent().prop('id') !== 'slot-btn-options') { + this.statusbar.fireEvent('view:hide', [this, status]); + } + + Common.NotificationCenter.trigger('layout:changed', 'status'); + Common.NotificationCenter.trigger('edit:complete', this.statusbar); + }, + onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) { var global = (localFlag===null), state = global ? globalFlag : localFlag; diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 0b8c6dfec..786848685 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -172,6 +172,9 @@ define([ 'go:editor': function() { Common.Gateway.requestEditRights(); } + }, + 'ViewTab': { + 'toolbar:setcompact': this.onChangeCompactView.bind(this) } }); diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index d447d7456..22cc61454 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -73,16 +73,30 @@ define([ this.toolbar = config.toolbar; this.view = this.createView('ViewTab', { toolbar: this.toolbar.toolbar, - mode: config.mode + mode: config.mode, + compactToolbar: this.toolbar.toolbar.isCompactView }); this.addListeners({ 'ViewTab': { 'zoom:value': _.bind(this.onChangeZoomValue, this), 'zoom:topage': _.bind(this.onBtnZoomTo, this, 'topage'), - 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth') + 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth'), + 'rulers:change': _.bind(this.onChangeRulers, this) + }, + 'Toolbar': { + 'view:compact': _.bind(function (toolbar, state) { + this.view.chToolbar.setValue(!state, true); + }, this) }, 'Statusbar': { - + 'view:hide': _.bind(function (statusbar, state) { + this.view.chStatusbar.setValue(!state, true); + }, this) + }, + 'Common.Views.Header': { + 'toolbar:hiderulers': _.bind(function (isChecked) { + this.view.chRulers.setValue(!isChecked, true); + }, this) } }); }, @@ -164,5 +178,14 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, + onChangeRulers: function (btn, checked) { + this.api.asc_SetViewRulers(checked); + Common.localStorage.setBool('de-hidden-rulers', !checked); + Common.Utils.InternalSettings.set("de-hidden-rulers", !checked); + this.view.fireEvent('rulers:hide', [!checked]); + Common.NotificationCenter.trigger('layout:changed', 'rulers'); + Common.NotificationCenter.trigger('edit:complete', this.view); + }, + }, DE.Controllers.ViewTab || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 8a229dc0b..f6061b469 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -105,6 +105,14 @@ define([ if ( me.header.btnSave ) me.header.btnSave.setDisabled(state); } + }, + 'ViewTab': { + 'rulers:hide': function (state) { + me.header.mnuitemHideRulers.setChecked(state, true); + }, + 'statusbar:hide': function (view, state) { + me.header.mnuitemHideStatusBar.setChecked(state, true); + } } }); }, @@ -231,7 +239,7 @@ define([ }, this)); } - var mnuitemHideStatusBar = new Common.UI.MenuItem({ + me.header.mnuitemHideStatusBar = new Common.UI.MenuItem({ caption: me.header.textHideStatusBar, checked: Common.localStorage.getBool("de-hidden-status"), checkable: true, @@ -239,16 +247,16 @@ define([ }); if ( config.canBrandingExt && config.customization && config.customization.statusBar === false ) - mnuitemHideStatusBar.hide(); + me.header.mnuitemHideStatusBar.hide(); - var mnuitemHideRulers = new Common.UI.MenuItem({ + me.header.mnuitemHideRulers = new Common.UI.MenuItem({ caption: me.header.textHideLines, checked: Common.Utils.InternalSettings.get("de-hidden-rulers"), checkable: true, value: 'rulers' }); if (!config.isEdit) - mnuitemHideRulers.hide(); + me.header.mnuitemHideRulers.hide(); me.header.menuItemsDarkMode = new Common.UI.MenuItem({ caption: me.txtDarkMode, @@ -292,8 +300,8 @@ define([ style: 'min-width: 180px;', items: [ me.header.mnuitemCompactToolbar, - mnuitemHideStatusBar, - mnuitemHideRulers, + me.header.mnuitemHideStatusBar, + me.header.mnuitemHideRulers, {caption:'--'}, me.header.menuItemsDarkMode, {caption:'--'}, @@ -422,6 +430,7 @@ define([ Common.Utils.InternalSettings.set("de-hidden-rulers", item.isChecked()); Common.NotificationCenter.trigger('layout:changed', 'rulers'); Common.NotificationCenter.trigger('edit:complete', me.header); + me.header.fireEvent('toolbar:hiderulers', [item.isChecked()]); break; case 'zoom:page': item.isChecked() ? me.api.zoomFitToPage() : me.api.zoomCustomMode(); diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 1e558f107..082188553 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -63,6 +63,15 @@ define([ me.btnFitToWidth && me.btnFitToWidth.on('click', function () { me.fireEvent('zoom:towidth'); }); + me.chToolbar && me.chToolbar.on('change', _.bind(function(checkbox, state) { + me.fireEvent('toolbar:setcompact', [me.chToolbar, state !== 'checked']); + }, me)); + me.chStatusbar && me.chStatusbar.on('change', _.bind(function (checkbox, state) { + me.fireEvent('statusbar:hide', [me.chStatusbar, state !== 'checked']); + }, me)); + me.chRulers && me.chRulers.on('change', _.bind(function (checkbox, state) { + me.fireEvent('rulers:change', [me.chRulers, state === 'checked']); + }, me)); }, initialize: function (options) { @@ -164,7 +173,7 @@ define([ this.chStatusbar = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-statusbar'), labelText: this.textStatusBar, - value: true, //!Common.localStorage.getBool(''), + value: !Common.localStorage.getBool("de-hidden-status"), //lock: [_set.lostConnect, _set.coAuth, _set.editCell], dataHint: '1', dataHintDirection: 'left', @@ -175,7 +184,7 @@ define([ this.chToolbar = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-toolbar'), labelText: this.textAlwaysShowToolbar, - value: true, //!Common.localStorage.getBool(''), + value: !options.compactToolbar, //lock: [_set.lostConnect, _set.coAuth, _set.editCell], dataHint : '1', dataHintDirection: 'left', @@ -186,7 +195,7 @@ define([ this.chRulers = new Common.UI.CheckBox({ el: $host.findById('#slot-chk-rulers'), labelText: this.textRulers, - value: true, //!Common.localStorage.getBool(''), + value: !Common.Utils.InternalSettings.get("de-hidden-rulers"), //lock: [_set.lostConnect, _set.coAuth, _set.editCell], dataHint: '1', dataHintDirection: 'left',