[PE] Add handlers to show toolbar, statusbar buttons in view tab

This commit is contained in:
JuliaSvinareva 2021-12-10 19:35:03 +03:00
parent d4b08a16ed
commit 55cd0c22e5
5 changed files with 46 additions and 15 deletions

View file

@ -62,13 +62,10 @@ define([
'langchanged': this.onLangMenu 'langchanged': this.onLangMenu
}, },
'Common.Views.Header': { 'Common.Views.Header': {
'statusbar:hide': function (view, status) { 'statusbar:hide': _.bind(me.onChangeCompactView, me)
me.statusbar.setVisible(!status); },
Common.localStorage.setBool('pe-hidden-status', status); 'ViewTab': {
'statusbar:hide': _.bind(me.onChangeCompactView, me)
Common.NotificationCenter.trigger('layout:changed', 'status');
Common.NotificationCenter.trigger('edit:complete', this.statusbar);
}
} }
}); });
this._state = { this._state = {
@ -226,6 +223,18 @@ define([
this.api.put_TextPrLang(langid); 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}%' zoomText : 'Zoom {0}%'
}, PE.Controllers.Statusbar || {})); }, PE.Controllers.Statusbar || {}));
}); });

View file

@ -177,6 +177,9 @@ define([
'go:editor': function() { 'go:editor': function() {
Common.Gateway.requestEditRights(); Common.Gateway.requestEditRights();
} }
},
'ViewTab': {
'toolbar:setcompact': this.onChangeCompactView.bind(this)
} }
}); });

View file

@ -76,7 +76,8 @@ define([
this.toolbar = config.toolbar; this.toolbar = config.toolbar;
this.view = this.createView('ViewTab', { this.view = this.createView('ViewTab', {
toolbar: this.toolbar.toolbar, toolbar: this.toolbar.toolbar,
mode: config.mode mode: config.mode,
compactToolbar: this.toolbar.toolbar.isCompactView
}); });
this.addListeners({ this.addListeners({
'ViewTab': { 'ViewTab': {
@ -84,9 +85,16 @@ define([
'zoom:toslide': _.bind(this.onBtnZoomTo, this, 'toslide'), 'zoom:toslide': _.bind(this.onBtnZoomTo, this, 'toslide'),
'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth') 'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth')
}, },
'Toolbar': {
'view:compact': _.bind(function (toolbar, state) {
this.view.chToolbar.setValue(!state, true);
}, this)
},
'Statusbar': { 'Statusbar': {
'view:hide': _.bind(function (statusbar, state) {
} this.view.chStatusbar.setValue(!state, true);
}, this)
},
}); });
}, },

View file

@ -111,6 +111,11 @@ define([
// Events generated by main view // Events generated by main view
'Viewport': { 'Viewport': {
},
'ViewTab': {
'statusbar:hide': function (view, state) {
me.header.mnuitemHideStatusBar.setChecked(state, true);
}
} }
}); });
Common.NotificationCenter.on('preview:start', this.onPreviewStart.bind(this)); Common.NotificationCenter.on('preview:start', this.onPreviewStart.bind(this));
@ -237,7 +242,7 @@ define([
}, this)); }, this));
} }
var mnuitemHideStatusBar = new Common.UI.MenuItem({ me.header.mnuitemHideStatusBar = new Common.UI.MenuItem({
caption: me.header.textHideStatusBar, caption: me.header.textHideStatusBar,
checked: Common.localStorage.getBool("pe-hidden-status"), checked: Common.localStorage.getBool("pe-hidden-status"),
checkable: true, checkable: true,
@ -245,7 +250,7 @@ define([
}); });
if ( config.canBrandingExt && config.customization && config.customization.statusBar === false ) if ( config.canBrandingExt && config.customization && config.customization.statusBar === false )
mnuitemHideStatusBar.hide(); me.header.mnuitemHideStatusBar.hide();
var mnuitemHideRulers = new Common.UI.MenuItem({ var mnuitemHideRulers = new Common.UI.MenuItem({
caption: me.header.textHideLines, caption: me.header.textHideLines,
@ -298,7 +303,7 @@ define([
style: 'min-width: 180px;', style: 'min-width: 180px;',
items: [ items: [
me.header.mnuitemCompactToolbar, me.header.mnuitemCompactToolbar,
mnuitemHideStatusBar, me.header.mnuitemHideStatusBar,
mnuitemHideRulers, mnuitemHideRulers,
me.header.mnuitemHideNotes, me.header.mnuitemHideNotes,
{caption:'--'}, {caption:'--'},

View file

@ -60,6 +60,12 @@ define([
me.btnFitToWidth && me.btnFitToWidth.on('click', function () { me.btnFitToWidth && me.btnFitToWidth.on('click', function () {
me.fireEvent('zoom:towidth', [me.btnFitToWidth]); 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) { initialize: function (options) {
@ -138,7 +144,7 @@ define([
this.chStatusbar = new Common.UI.CheckBox({ this.chStatusbar = new Common.UI.CheckBox({
el: $host.findById('#slot-chk-statusbar'), el: $host.findById('#slot-chk-statusbar'),
labelText: this.textStatusBar, labelText: this.textStatusBar,
value: true, //!Common.localStorage.getBool(''), value: !Common.localStorage.getBool("pe-hidden-status"),
//lock: [_set.lostConnect, _set.coAuth, _set.editCell], //lock: [_set.lostConnect, _set.coAuth, _set.editCell],
dataHint: '1', dataHint: '1',
dataHintDirection: 'left', dataHintDirection: 'left',
@ -149,7 +155,7 @@ define([
this.chToolbar = new Common.UI.CheckBox({ this.chToolbar = new Common.UI.CheckBox({
el: $host.findById('#slot-chk-toolbar'), el: $host.findById('#slot-chk-toolbar'),
labelText: this.textAlwaysShowToolbar, labelText: this.textAlwaysShowToolbar,
value: true, //!Common.localStorage.getBool(''), value: !options.compactToolbar,
//lock: [_set.lostConnect, _set.coAuth, _set.editCell], //lock: [_set.lostConnect, _set.coAuth, _set.editCell],
dataHint : '1', dataHint : '1',
dataHintDirection: 'left', dataHintDirection: 'left',