[DE] Add handler for navigation button in view tab

This commit is contained in:
JuliaSvinareva 2021-12-08 18:01:00 +03:00
parent 63e8983359
commit 4583e2014c
4 changed files with 52 additions and 6 deletions

View file

@ -45,14 +45,16 @@ define([
'common/main/lib/util/Shortcuts',
'common/main/lib/view/SaveAsDlg',
'documenteditor/main/app/view/LeftMenu',
'documenteditor/main/app/view/FileMenu'
'documenteditor/main/app/view/FileMenu',
'documenteditor/main/app/view/ViewTab',
], function () {
'use strict';
DE.Controllers.LeftMenu = Backbone.Controller.extend(_.extend({
views: [
'LeftMenu',
'FileMenu'
'FileMenu',
'ViewTab'
],
initialize: function() {
@ -106,6 +108,9 @@ define([
},
'Common.Views.ReviewChanges': {
'collaboration:chat': _.bind(this.onShowHideChat, this)
},
'ViewTab': {
'viewtab:navigation': _.bind(this.onShowHideNavigation, this)
}
});
@ -914,6 +919,16 @@ define([
}
},
onShowHideNavigation: function(state) {
if (state) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu('navigation');
} else {
this.leftMenu.btnNavigation.toggle(false, true);
this.leftMenu.onBtnMenuClick(this.leftMenu.btnNavigation);
}
},
isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},

View file

@ -58,6 +58,7 @@ define([
},
onLaunch: function () {
this._state = {};
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
setApi: function (api) {
@ -97,5 +98,20 @@ define([
this.SetDisabled(true);
},
onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
accept();
})).then(function(){
me.view.setEvents();
});
if (me.view.btnNavigation) {
me.getApplication().getController('LeftMenu').leftMenu.btnNavigation.on('toggle', function(btn, state){
if (state !== me.view.btnNavigation.pressed)
me.view.turnNavigation(state);
});
}
},
}, DE.Controllers.ViewTab || {}));
});

View file

@ -378,6 +378,13 @@ define([
this.onBtnMenuClick(this.btnComments);
this.onCoauthOptions();
}
} else if (menu == 'navigation') {
if (this.btnNavigation.isVisible() &&
!this.btnNavigation.isDisabled() && !this.btnNavigation.pressed) {
this.btnNavigation.toggle(true);
this.onBtnMenuClick(this.btnNavigation);
this.onCoauthOptions();
}
}
/** coauthoring end **/
}

View file

@ -46,13 +46,16 @@ define([
'use strict';
DE.Views.ViewTab = Common.UI.BaseView.extend(_.extend((function(){
function setEvents() {
var me = this;
}
return {
options: {},
setEvents() {
var me = this;
me.btnNavigation && me.btnNavigation.on('click', function (btn, e) {
me.fireEvent('viewtab:navigation', [btn.pressed]);
});
},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this);
this.toolbar = options.toolbar;
@ -68,6 +71,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-navigation',
caption: this.textNavigation,
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
@ -190,6 +194,10 @@ define([
}, this);
},
turnNavigation: function (state) {
this.btnNavigation && this.btnNavigation.toggle(state, true);
},
textNavigation: 'Navigation',
textZoom: 'Zoom',
textFitToPage: 'Fit To Page',