From 55cd0c22e5ed3e80266f4715e7c9a948cb709a70 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 10 Dec 2021 19:35:03 +0300 Subject: [PATCH] [PE] Add handlers to show toolbar, statusbar buttons in view tab --- .../main/app/controller/Statusbar.js | 23 +++++++++++++------ .../main/app/controller/Toolbar.js | 3 +++ .../main/app/controller/ViewTab.js | 14 ++++++++--- .../main/app/controller/Viewport.js | 11 ++++++--- .../main/app/view/ViewTab.js | 10 ++++++-- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Statusbar.js b/apps/presentationeditor/main/app/controller/Statusbar.js index 592aa85ec..87ef9a162 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -62,13 +62,10 @@ define([ 'langchanged': this.onLangMenu }, 'Common.Views.Header': { - 'statusbar:hide': function (view, status) { - me.statusbar.setVisible(!status); - Common.localStorage.setBool('pe-hidden-status', status); - - Common.NotificationCenter.trigger('layout:changed', 'status'); - Common.NotificationCenter.trigger('edit:complete', this.statusbar); - } + 'statusbar:hide': _.bind(me.onChangeCompactView, me) + }, + 'ViewTab': { + 'statusbar:hide': _.bind(me.onChangeCompactView, me) } }); this._state = { @@ -226,6 +223,18 @@ define([ this.api.put_TextPrLang(langid); }, + onChangeCompactView: function (view, status) { + this.statusbar.setVisible(!status); + Common.localStorage.setBool('pe-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); + }, + zoomText : 'Zoom {0}%' }, PE.Controllers.Statusbar || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index c75035224..b12f0b791 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -177,6 +177,9 @@ define([ 'go:editor': function() { Common.Gateway.requestEditRights(); } + }, + 'ViewTab': { + 'toolbar:setcompact': this.onChangeCompactView.bind(this) } }); diff --git a/apps/presentationeditor/main/app/controller/ViewTab.js b/apps/presentationeditor/main/app/controller/ViewTab.js index 4c99d90fc..99a7a675e 100644 --- a/apps/presentationeditor/main/app/controller/ViewTab.js +++ b/apps/presentationeditor/main/app/controller/ViewTab.js @@ -76,7 +76,8 @@ 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': { @@ -84,9 +85,16 @@ define([ 'zoom:toslide': _.bind(this.onBtnZoomTo, this, 'toslide'), 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth') }, + '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) + }, }); }, diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 895bfb9a1..88026dff1 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -111,6 +111,11 @@ define([ // Events generated by main view 'Viewport': { + }, + 'ViewTab': { + 'statusbar:hide': function (view, state) { + me.header.mnuitemHideStatusBar.setChecked(state, true); + } } }); Common.NotificationCenter.on('preview:start', this.onPreviewStart.bind(this)); @@ -237,7 +242,7 @@ define([ }, this)); } - var mnuitemHideStatusBar = new Common.UI.MenuItem({ + me.header.mnuitemHideStatusBar = new Common.UI.MenuItem({ caption: me.header.textHideStatusBar, checked: Common.localStorage.getBool("pe-hidden-status"), checkable: true, @@ -245,7 +250,7 @@ define([ }); if ( config.canBrandingExt && config.customization && config.customization.statusBar === false ) - mnuitemHideStatusBar.hide(); + me.header.mnuitemHideStatusBar.hide(); var mnuitemHideRulers = new Common.UI.MenuItem({ caption: me.header.textHideLines, @@ -298,7 +303,7 @@ define([ style: 'min-width: 180px;', items: [ me.header.mnuitemCompactToolbar, - mnuitemHideStatusBar, + me.header.mnuitemHideStatusBar, mnuitemHideRulers, me.header.mnuitemHideNotes, {caption:'--'}, diff --git a/apps/presentationeditor/main/app/view/ViewTab.js b/apps/presentationeditor/main/app/view/ViewTab.js index 37aaa690a..f3d5183fe 100644 --- a/apps/presentationeditor/main/app/view/ViewTab.js +++ b/apps/presentationeditor/main/app/view/ViewTab.js @@ -60,6 +60,12 @@ define([ me.btnFitToWidth && me.btnFitToWidth.on('click', function () { me.fireEvent('zoom:towidth', [me.btnFitToWidth]); }); + 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)); }, initialize: function (options) { @@ -138,7 +144,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("pe-hidden-status"), //lock: [_set.lostConnect, _set.coAuth, _set.editCell], dataHint: '1', dataHintDirection: 'left', @@ -149,7 +155,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',