[SSE] Refactoring left menu (show/hide)
This commit is contained in:
parent
ad77c48841
commit
ee6448c8c5
|
@ -209,7 +209,7 @@ define([
|
||||||
this.supressEvents = false;
|
this.supressEvents = false;
|
||||||
|
|
||||||
this.onCoauthOptions();
|
this.onCoauthOptions();
|
||||||
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu);
|
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this);
|
||||||
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fireEvent('panel:show', [this, btn.options.action, btn.pressed]);
|
this.fireEvent('panel:show', [this, btn.options.action, btn.pressed]);
|
||||||
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this.leftMenu);
|
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this);
|
||||||
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -740,7 +740,6 @@ define([
|
||||||
case 'escape':
|
case 'escape':
|
||||||
var btnSearch = this.getApplication().getController('Viewport').header.btnSearch;
|
var btnSearch = this.getApplication().getController('Viewport').header.btnSearch;
|
||||||
btnSearch.pressed && btnSearch.toggle(false);
|
btnSearch.pressed && btnSearch.toggle(false);
|
||||||
this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false);
|
|
||||||
|
|
||||||
if ( this.leftMenu.menuFile.isVisible() ) {
|
if ( this.leftMenu.menuFile.isVisible() ) {
|
||||||
if (Common.UI.HintManager.needCloseFileMenu())
|
if (Common.UI.HintManager.needCloseFileMenu())
|
||||||
|
@ -865,11 +864,10 @@ define([
|
||||||
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
|
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
|
||||||
this.leftMenu.panelSearch.setSearchMode(mode);
|
this.leftMenu.panelSearch.setSearchMode(mode);
|
||||||
}
|
}
|
||||||
this.leftMenu._state.isSearchOpen = show;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isSearchPanelVisible: function () {
|
isSearchPanelVisible: function () {
|
||||||
return this.leftMenu._state.isSearchOpen;
|
return this.leftMenu && this.leftMenu.panelSearch && this.leftMenu.panelSearch.isVisible();
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuChange: function (value) {
|
onMenuChange: function (value) {
|
||||||
|
|
|
@ -59,13 +59,6 @@ define([
|
||||||
// Delegated events for creating new items, and clearing completed ones.
|
// Delegated events for creating new items, and clearing completed ones.
|
||||||
events: function() {
|
events: function() {
|
||||||
return {
|
return {
|
||||||
/** coauthoring begin **/
|
|
||||||
'click #left-btn-comments': _.bind(this.onCoauthOptions, this),
|
|
||||||
'click #left-btn-chat': _.bind(this.onCoauthOptions, this),
|
|
||||||
/** coauthoring end **/
|
|
||||||
'click #left-btn-plugins': _.bind(this.onCoauthOptions, this),
|
|
||||||
'click #left-btn-spellcheck': _.bind(this.onCoauthOptions, this),
|
|
||||||
'click #left-btn-searchbar': _.bind(this.onCoauthOptions, this),
|
|
||||||
'click #left-btn-support': function() {
|
'click #left-btn-support': function() {
|
||||||
var config = this.mode.customization;
|
var config = this.mode.customization;
|
||||||
config && !!config.feedback && !!config.feedback.url ?
|
config && !!config.feedback && !!config.feedback.url ?
|
||||||
|
@ -91,6 +84,7 @@ define([
|
||||||
enableToggle: true,
|
enableToggle: true,
|
||||||
toggleGroup: 'leftMenuGroup'
|
toggleGroup: 'leftMenuGroup'
|
||||||
});
|
});
|
||||||
|
this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this));
|
||||||
|
|
||||||
this.btnAbout = new Common.UI.Button({
|
this.btnAbout = new Common.UI.Button({
|
||||||
action: 'about',
|
action: 'about',
|
||||||
|
@ -100,6 +94,7 @@ define([
|
||||||
disabled: true,
|
disabled: true,
|
||||||
toggleGroup: 'leftMenuGroup'
|
toggleGroup: 'leftMenuGroup'
|
||||||
});
|
});
|
||||||
|
this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this));
|
||||||
|
|
||||||
this.btnSupport = new Common.UI.Button({
|
this.btnSupport = new Common.UI.Button({
|
||||||
action: 'support',
|
action: 'support',
|
||||||
|
@ -116,6 +111,8 @@ define([
|
||||||
disabled: true,
|
disabled: true,
|
||||||
toggleGroup: 'leftMenuGroup'
|
toggleGroup: 'leftMenuGroup'
|
||||||
});
|
});
|
||||||
|
this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this));
|
||||||
|
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
|
||||||
|
|
||||||
this.btnChat = new Common.UI.Button({
|
this.btnChat = new Common.UI.Button({
|
||||||
el: $markup.elementById('#left-btn-chat'),
|
el: $markup.elementById('#left-btn-chat'),
|
||||||
|
@ -124,13 +121,10 @@ define([
|
||||||
disabled: true,
|
disabled: true,
|
||||||
toggleGroup: 'leftMenuGroup'
|
toggleGroup: 'leftMenuGroup'
|
||||||
});
|
});
|
||||||
|
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
|
||||||
|
|
||||||
this.btnComments.hide();
|
this.btnComments.hide();
|
||||||
this.btnChat.hide();
|
this.btnChat.hide();
|
||||||
|
|
||||||
this.btnComments.on('toggle', this.onBtnCommentsToggle.bind(this));
|
|
||||||
this.btnComments.on('click', this.onBtnMenuClick.bind(this));
|
|
||||||
this.btnChat.on('click', this.onBtnMenuClick.bind(this));
|
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
|
|
||||||
this.btnPlugins = new Common.UI.Button({
|
this.btnPlugins = new Common.UI.Button({
|
||||||
|
@ -153,9 +147,6 @@ define([
|
||||||
this.btnSpellcheck.hide();
|
this.btnSpellcheck.hide();
|
||||||
this.btnSpellcheck.on('click', _.bind(this.onBtnMenuClick, this));
|
this.btnSpellcheck.on('click', _.bind(this.onBtnMenuClick, this));
|
||||||
|
|
||||||
this.btnSearchBar.on('click', _.bind(this.onBtnMenuClick, this));
|
|
||||||
this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this));
|
|
||||||
|
|
||||||
this.menuFile = new SSE.Views.FileMenu({});
|
this.menuFile = new SSE.Views.FileMenu({});
|
||||||
this.btnAbout.panel = (new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor}));
|
this.btnAbout.panel = (new Common.Views.About({el: '#about-menu-panel', appName: this.txtEditor}));
|
||||||
this.$el.html($markup);
|
this.$el.html($markup);
|
||||||
|
@ -183,19 +174,16 @@ define([
|
||||||
onBtnMenuClick: function(btn, e) {
|
onBtnMenuClick: function(btn, e) {
|
||||||
this.btnAbout.toggle(false);
|
this.btnAbout.toggle(false);
|
||||||
|
|
||||||
if (btn.options.action == 'search') {
|
if (btn.pressed) {
|
||||||
} else {
|
if (!(this.$el.width() > SCALE_MIN)) {
|
||||||
if (btn.pressed) {
|
this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART);
|
||||||
if (!(this.$el.width() > SCALE_MIN)) {
|
|
||||||
this.$el.width(Common.localStorage.getItem('sse-mainmenu-width') || MENU_SCALE_PART);
|
|
||||||
}
|
|
||||||
} else if (!this._state.pluginIsRunning){
|
|
||||||
Common.localStorage.setItem('sse-mainmenu-width',this.$el.width());
|
|
||||||
this.$el.width(SCALE_MIN);
|
|
||||||
}
|
}
|
||||||
|
} else if (!this._state.pluginIsRunning){
|
||||||
|
Common.localStorage.setItem('sse-mainmenu-width',this.$el.width());
|
||||||
|
this.$el.width(SCALE_MIN);
|
||||||
}
|
}
|
||||||
|
this.onCoauthOptions();
|
||||||
// this.btnChat.id == btn.id && !this.btnChat.pressed && this.fireEvent('chat:hide', this);
|
(btn.options.action == 'advancedsearch') && this.fireEvent('search:aftershow', this);
|
||||||
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -228,7 +216,6 @@ define([
|
||||||
if (this.panelSearch) {
|
if (this.panelSearch) {
|
||||||
if (this.btnSearchBar.pressed) {
|
if (this.btnSearchBar.pressed) {
|
||||||
this.panelSearch.show();
|
this.panelSearch.show();
|
||||||
this.fireEvent('search:aftershow', this);
|
|
||||||
} else {
|
} else {
|
||||||
this.panelSearch.hide();
|
this.panelSearch.hide();
|
||||||
}
|
}
|
||||||
|
@ -335,7 +322,6 @@ define([
|
||||||
!this.btnChat.isDisabled() && !this.btnChat.pressed) {
|
!this.btnChat.isDisabled() && !this.btnChat.pressed) {
|
||||||
this.btnChat.toggle(true);
|
this.btnChat.toggle(true);
|
||||||
this.onBtnMenuClick(this.btnChat);
|
this.onBtnMenuClick(this.btnChat);
|
||||||
this.onCoauthOptions();
|
|
||||||
this.panelChat.focus();
|
this.panelChat.focus();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -344,7 +330,6 @@ define([
|
||||||
!this.btnComments.isDisabled() && !this.btnComments.pressed) {
|
!this.btnComments.isDisabled() && !this.btnComments.pressed) {
|
||||||
this.btnComments.toggle(true);
|
this.btnComments.toggle(true);
|
||||||
this.onBtnMenuClick(this.btnComments);
|
this.onBtnMenuClick(this.btnComments);
|
||||||
this.onCoauthOptions();
|
|
||||||
this.btnComments.$el.focus();
|
this.btnComments.$el.focus();
|
||||||
}
|
}
|
||||||
} else if (menu == 'advancedsearch') {
|
} else if (menu == 'advancedsearch') {
|
||||||
|
@ -352,7 +337,6 @@ define([
|
||||||
!this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) {
|
!this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) {
|
||||||
this.btnSearchBar.toggle(true);
|
this.btnSearchBar.toggle(true);
|
||||||
this.onBtnMenuClick(this.btnSearchBar);
|
this.onBtnMenuClick(this.btnSearchBar);
|
||||||
this.onCoauthOptions();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
|
|
Loading…
Reference in a new issue