[DE][PE] Refactoring left menu (show/hide)
This commit is contained in:
parent
83fb5c21a3
commit
ad77c48841
|
@ -197,7 +197,6 @@ define([
|
|||
this.supressEvents = true;
|
||||
this.btnAbout.toggle(false);
|
||||
|
||||
if (btn.options.action !== 'search') {
|
||||
if (btn.pressed) {
|
||||
if (!(this.$el.width() > SCALE_MIN)) {
|
||||
this.$el.width(parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART);
|
||||
|
@ -206,12 +205,11 @@ define([
|
|||
Common.localStorage.setItem('de-mainmenu-width',this.$el.width());
|
||||
this.$el.width(SCALE_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
this.supressEvents = false;
|
||||
|
||||
this.onCoauthOptions();
|
||||
(btn.options.action == 'search') && this.fireEvent('search:aftershow', this.leftMenu);
|
||||
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu);
|
||||
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
||||
},
|
||||
|
||||
|
|
|
@ -614,7 +614,6 @@ define([
|
|||
// if (!this.leftMenu.isOpened()) return true;
|
||||
var btnSearch = this.getApplication().getController('Viewport').header.btnSearch;
|
||||
btnSearch.pressed && btnSearch.toggle(false);
|
||||
this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false);
|
||||
|
||||
// TODO:
|
||||
if ( this.leftMenu.menuFile.isVisible() ) {
|
||||
|
@ -724,11 +723,10 @@ define([
|
|||
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
|
||||
this.leftMenu.panelSearch.setSearchMode(mode);
|
||||
}
|
||||
this.leftMenu._state.isSearchOpen = show;
|
||||
},
|
||||
|
||||
isSearchPanelVisible: function () {
|
||||
return this.leftMenu._state.isSearchOpen;
|
||||
return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible();
|
||||
},
|
||||
|
||||
showHistory: function() {
|
||||
|
|
|
@ -67,15 +67,6 @@ define([
|
|||
// Delegated events for creating new items, and clearing completed ones.
|
||||
events: function() {
|
||||
return {
|
||||
/** coauthoring begin **/
|
||||
'click #left-btn-comments': _.bind(this.onCoauthOptions, this),
|
||||
'click #left-btn-chat': _.bind(this.onCoauthOptions, this),
|
||||
'click #left-btn-plugins': _.bind(this.onCoauthOptions, this),
|
||||
/** coauthoring end **/
|
||||
'click #left-btn-searchbar': _.bind(function () {
|
||||
this.onCoauthOptions();
|
||||
this.fireEvent('search:aftershow', this.leftMenu);
|
||||
}, this),
|
||||
'click #left-btn-support': function() {
|
||||
var config = this.mode.customization;
|
||||
config && !!config.feedback && !!config.feedback.url ?
|
||||
|
@ -101,6 +92,7 @@ define([
|
|||
enableToggle: true,
|
||||
toggleGroup: 'leftMenuGroup'
|
||||
});
|
||||
this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this));
|
||||
|
||||
this.btnThumbs = new Common.UI.Button({
|
||||
action: 'thumbs',
|
||||
|
@ -110,6 +102,7 @@ define([
|
|||
disabled: true,
|
||||
toggleGroup: 'leftMenuGroup'
|
||||
});
|
||||
this.btnThumbs.on('click', _.bind(this.onBtnMenuClick, this));
|
||||
|
||||
this.btnAbout = new Common.UI.Button({
|
||||
action: 'about',
|
||||
|
@ -119,6 +112,8 @@ define([
|
|||
disabled: true,
|
||||
toggleGroup: 'leftMenuGroup'
|
||||
});
|
||||
this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this));
|
||||
this.btnAbout.on('click', _.bind(this.onFullMenuClick, this));
|
||||
|
||||
this.btnSupport = new Common.UI.Button({
|
||||
action: 'support',
|
||||
|
@ -135,6 +130,7 @@ define([
|
|||
disabled: true,
|
||||
toggleGroup: 'leftMenuGroup'
|
||||
});
|
||||
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
|
||||
|
||||
this.btnChat = new Common.UI.Button({
|
||||
el: $markup.elementById('#left-btn-chat'),
|
||||
|
@ -143,12 +139,11 @@ define([
|
|||
disabled: true,
|
||||
toggleGroup: 'leftMenuGroup'
|
||||
});
|
||||
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
|
||||
|
||||
this.btnComments.hide();
|
||||
this.btnChat.hide();
|
||||
|
||||
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
|
||||
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
|
||||
/** coauthoring end **/
|
||||
|
||||
this.btnPlugins = new Common.UI.Button({
|
||||
|
@ -160,10 +155,6 @@ define([
|
|||
});
|
||||
this.btnPlugins.hide();
|
||||
this.btnPlugins.on('click', _.bind(this.onBtnMenuClick, this));
|
||||
this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this));
|
||||
this.btnThumbs.on('click', _.bind(this.onBtnMenuClick, this));
|
||||
this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this));
|
||||
this.btnAbout.on('click', _.bind(this.onFullMenuClick, this));
|
||||
|
||||
this.menuFile = new PE.Views.FileMenu({});
|
||||
this.btnAbout.panel = (new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor}));
|
||||
|
@ -185,13 +176,8 @@ define([
|
|||
},
|
||||
|
||||
onBtnMenuClick: function(btn, e) {
|
||||
var full_menu_pressed = this.btnAbout.pressed;
|
||||
if (this.btnAbout.pressed) this.btnAbout.toggle(false);
|
||||
|
||||
if (btn.options.action == 'search') {
|
||||
full_menu_pressed && this.fireEvent('panel:show', [this.btnAbout, 'files', false]);
|
||||
return;
|
||||
} else
|
||||
if (btn.options.action == 'thumbs') {
|
||||
if (!btn.pressed && this._state.pluginIsRunning) {
|
||||
this.$el.width(Common.localStorage.getItem('pe-mainmenu-width') || MENU_SCALE_PART);
|
||||
|
@ -212,9 +198,11 @@ define([
|
|||
Common.localStorage.setItem('pe-mainmenu-width',this.$el.width());
|
||||
this.$el.width(SCALE_MIN);
|
||||
}
|
||||
this.onCoauthOptions();
|
||||
}
|
||||
|
||||
this.fireEvent('panel:show', [this, btn.options.action, btn.pressed]);
|
||||
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu);
|
||||
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
||||
},
|
||||
|
||||
|
@ -348,7 +336,6 @@ define([
|
|||
!this.btnChat.isDisabled() && !this.btnChat.pressed) {
|
||||
this.btnChat.toggle(true);
|
||||
this.onBtnMenuClick(this.btnChat);
|
||||
this.onCoauthOptions();
|
||||
this.panelChat.focus();
|
||||
}
|
||||
} else
|
||||
|
@ -357,14 +344,12 @@ define([
|
|||
!this.btnComments.isDisabled() && !this.btnComments.pressed) {
|
||||
this.btnComments.toggle(true);
|
||||
this.onBtnMenuClick(this.btnComments);
|
||||
this.onCoauthOptions();
|
||||
}
|
||||
} else if (menu == 'advancedsearch') {
|
||||
if (this.btnSearchBar.isVisible() &&
|
||||
!this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) {
|
||||
this.btnSearchBar.toggle(true);
|
||||
this.onBtnMenuClick(this.btnSearchBar);
|
||||
this.onCoauthOptions();
|
||||
!suspendAfter && this.fireEvent('search:aftershow', this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue