[DE] show FileMenu from the toolbar

This commit is contained in:
Maxim Kadushkin 2017-02-20 17:54:12 +03:00
parent 62587692c6
commit b0935bca7a
6 changed files with 65 additions and 56 deletions

View file

@ -82,7 +82,9 @@ define([
'recent:open': _.bind(this.onOpenRecent, this) 'recent:open': _.bind(this.onOpenRecent, this)
}, },
'Toolbar': { 'Toolbar': {
'file:settings': _.bind(this.clickToolbarSettings,this) 'file:settings': _.bind(this.clickToolbarSettings,this),
'file:open': this.clickToolbarTab.bind(this, 'file'),
'file:close': this.clickToolbarTab.bind(this, 'other')
}, },
'SearchDialog': { 'SearchDialog': {
'hide': _.bind(this.onSearchDlgHide, this), 'hide': _.bind(this.onSearchDlgHide, this),
@ -249,7 +251,7 @@ define([
if (close_menu) { if (close_menu) {
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
} }
}, },
@ -265,14 +267,14 @@ define([
if (btn == 'ok') { if (btn == 'ok') {
this.api.asc_DownloadAs(format); this.api.asc_DownloadAs(format);
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
} }
}, this) }, this)
}); });
} else { } else {
this.api.asc_DownloadAs(format); this.api.asc_DownloadAs(format);
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
} }
} else } else
this.api.asc_DownloadOrigin(); this.api.asc_DownloadOrigin();
@ -319,7 +321,7 @@ define([
this.api.put_ShowSnapLines(value===null || parseInt(value) == 1); this.api.put_ShowSnapLines(value===null || parseInt(value) == 1);
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
}, },
onCreateNew: function(menu, type) { onCreateNew: function(menu, type) {
@ -332,14 +334,14 @@ define([
if (menu) { if (menu) {
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
} }
}, },
onOpenRecent: function(menu, url) { onOpenRecent: function(menu, url) {
if (menu) { if (menu) {
menu.hide(); menu.hide();
this.leftMenu.btnFile.toggle(false, true); Common.NotificationCenter.trigger('layout:changed', 'menufile');
} }
var recentDocPage = window.open(url); var recentDocPage = window.open(url);
@ -350,15 +352,18 @@ define([
}, },
clickToolbarSettings: function(obj) { clickToolbarSettings: function(obj) {
if (this.leftMenu.btnFile.pressed && this.leftMenu.btnFile.panel.active == 'opts')
this.leftMenu.close();
else
this.leftMenu.showMenu('file:opts'); this.leftMenu.showMenu('file:opts');
}, },
clickToolbarTab: function (tab, e) {
if (tab == 'file')
this.leftMenu.showMenu('file'); else
this.leftMenu.close();
},
/** coauthoring begin **/ /** coauthoring begin **/
clickStatusbarUsers: function() { clickStatusbarUsers: function() {
this.leftMenu.btnFile.panel.panels['rights'].changeAccessRights(); this.leftMenu.menuFile.panels['rights'].changeAccessRights();
}, },
onHideChat: function() { onHideChat: function() {
@ -514,7 +519,7 @@ define([
}, },
menuFilesHide: function(obj) { menuFilesHide: function(obj) {
$(this.leftMenu.btnFile.el).blur(); // $(this.leftMenu.btnFile.el).blur();
}, },
onMenuChange: function (value) { onMenuChange: function (value) {
@ -536,8 +541,8 @@ define([
Common.UI.Menu.Manager.hideAll(); Common.UI.Menu.Manager.hideAll();
this.showSearchDlg(true,s); this.showSearchDlg(true,s);
this.leftMenu.btnSearch.toggle(true,true); this.leftMenu.btnSearch.toggle(true,true);
this.leftMenu.btnFile.toggle(false);
this.leftMenu.btnAbout.toggle(false); this.leftMenu.btnAbout.toggle(false);
this.leftMenu.menuFile.hide();
return false; return false;
case 'save': case 'save':
if (this.mode.canDownload || this.mode.canDownloadOrigin) { if (this.mode.canDownload || this.mode.canDownloadOrigin) {
@ -574,7 +579,7 @@ define([
return false; return false;
} }
} }
if (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || if (this.leftMenu.menuFile.isVisible() || this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed ||
$(e.target).parents('#left-menu').length ) { $(e.target).parents('#left-menu').length ) {
this.leftMenu.close(); this.leftMenu.close();
Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); Common.NotificationCenter.trigger('layout:changed', 'leftmenu');

View file

@ -1419,6 +1419,7 @@ define([
}, },
onAdvSettingsClick: function(btn, e) { onAdvSettingsClick: function(btn, e) {
this.toolbar.setTab('file');
this.toolbar.fireEvent('file:settings', this); this.toolbar.fireEvent('file:settings', this);
btn.cmpEl.blur(); btn.cmpEl.blur();
}, },

View file

@ -1,6 +1,5 @@
<div id="view-left-menu" class="tool-menu left"> <div id="view-left-menu" class="tool-menu left">
<div class="tool-menu-btns"> <div class="tool-menu-btns">
<button id="left-btn-file" class="btn btn-category" content-target="left-panel-file"><span class="btn-icon img-toolbarmenu btn-menu-file">&nbsp;</span></button>
<button id="left-btn-search" class="btn btn-category" content-target=""><span class="btn-icon img-toolbarmenu btn-menu-search">&nbsp;</span></button> <button id="left-btn-search" class="btn btn-category" content-target=""><span class="btn-icon img-toolbarmenu btn-menu-search">&nbsp;</span></button>
<!-- /** coauthoring begin **/ --> <!-- /** coauthoring begin **/ -->
<button id="left-btn-comments" class="btn btn-category" content-target="left-panel-comments"><span class="btn-icon img-toolbarmenu btn-menu-comments">&nbsp;</span></button> <button id="left-btn-comments" class="btn btn-category" content-target="left-panel-comments"><span class="btn-icon img-toolbarmenu btn-menu-comments">&nbsp;</span></button>

View file

@ -49,6 +49,7 @@ define([
DE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({ DE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({
el: '#file-menu-panel', el: '#file-menu-panel',
options: {alias:'FileMenu'},
template: _.template(tpl), template: _.template(tpl),
@ -198,7 +199,6 @@ define([
panel = this.active || ((this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline)) ? 'saveas' : 'info'); panel = this.active || ((this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline)) ? 'saveas' : 'info');
this.$el.show(); this.$el.show();
this.selectMenu(panel, opts); this.selectMenu(panel, opts);
if (this.mode.isEdit) DE.getController('Toolbar').DisableToolbar(true);
this.api.asc_enableKeyEvents(false); this.api.asc_enableKeyEvents(false);
}, },
@ -313,6 +313,10 @@ define([
this.items[6][(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show'](); this.items[6][(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show']();
}, },
isVisible: function () {
return !this.$el.is(':hidden');
},
btnSaveCaption : 'Save', btnSaveCaption : 'Save',
btnDownloadCaption : 'Download as...', btnDownloadCaption : 'Download as...',
btnInfoCaption : 'Document Info...', btnInfoCaption : 'Document Info...',

View file

@ -91,15 +91,6 @@ define([
el.html(this.template({ el.html(this.template({
})); }));
this.btnFile = new Common.UI.Button({
action: 'file',
el: $('#left-btn-file'),
hint: this.tipFile + Common.Utils.String.platformKey('Alt+F'),
enableToggle: true,
disabled: true,
toggleGroup: 'leftMenuGroup'
});
this.btnSearch = new Common.UI.Button({ this.btnSearch = new Common.UI.Button({
action: 'search', action: 'search',
el: $('#left-btn-search'), el: $('#left-btn-search'),
@ -160,11 +151,9 @@ define([
this.btnSearch.on('click', _.bind(this.onBtnMenuClick, this)); this.btnSearch.on('click', _.bind(this.onBtnMenuClick, this));
this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this));
this.btnFile.on('toggle', _.bind(this.onBtnMenuToggle, this));
var menuFile = new DE.Views.FileMenu({}); this.menuFile = new DE.Views.FileMenu();
menuFile.options = {alias:'FileMenu'}; this.menuFile.render();
this.btnFile.panel = menuFile.render();
this.btnAbout.panel = (new Common.Views.About({el: $('#about-menu-panel'), appName: 'Document Editor'})).render(); this.btnAbout.panel = (new Common.Views.About({el: $('#about-menu-panel'), appName: 'Document Editor'})).render();
return this; return this;
@ -187,9 +176,13 @@ define([
onBtnMenuClick: function(btn, e) { onBtnMenuClick: function(btn, e) {
this.supressEvents = true; this.supressEvents = true;
this.btnFile.toggle(false);
this.btnAbout.toggle(false); this.btnAbout.toggle(false);
if ( this.menuFile.isVisible() ) {
this.menuFile.hide();
Common.NotificationCenter.trigger('layout:changed', 'menufile');
}
if (btn.options.action == 'search') { if (btn.options.action == 'search') {
} else { } else {
if (btn.pressed) { if (btn.pressed) {
@ -264,7 +257,11 @@ define([
/** coauthoring end **/ /** coauthoring end **/
close: function(menu) { close: function(menu) {
this.btnFile.toggle(false); if ( this.menuFile.$el.is(':visible') ) {
this.menuFile.hide();
Common.NotificationCenter.trigger('layout:changed', 'menufile');
} else {
this.btnAbout.toggle(false); this.btnAbout.toggle(false);
this.$el.width(SCALE_MIN); this.$el.width(SCALE_MIN);
/** coauthoring begin **/ /** coauthoring begin **/
@ -285,10 +282,11 @@ define([
this.panelPlugins['hide'](); this.panelPlugins['hide']();
this.btnPlugins.toggle(false, true); this.btnPlugins.toggle(false, true);
} }
}
}, },
isOpened: function() { isOpened: function() {
var isopened = this.btnFile.pressed || this.btnSearch.pressed; var isopened = this.btnSearch.pressed;
/** coauthoring begin **/ /** coauthoring begin **/
!isopened && (isopened = this.btnComments.pressed || this.btnChat.pressed); !isopened && (isopened = this.btnComments.pressed || this.btnChat.pressed);
/** coauthoring end **/ /** coauthoring end **/
@ -296,7 +294,6 @@ define([
}, },
disableMenu: function(menu, disable) { disableMenu: function(menu, disable) {
this.btnFile.setDisabled(false);
this.btnSearch.setDisabled(false); this.btnSearch.setDisabled(false);
this.btnAbout.setDisabled(false); this.btnAbout.setDisabled(false);
this.btnSupport.setDisabled(false); this.btnSupport.setDisabled(false);
@ -309,12 +306,11 @@ define([
showMenu: function(menu, opts) { showMenu: function(menu, opts) {
var re = /^(\w+):?(\w*)$/.exec(menu); var re = /^(\w+):?(\w*)$/.exec(menu);
if (re[1] == 'file' && this.btnFile.isVisible() ) { if ( re[1] == 'file' ) {
if (!this.btnFile.pressed) { if ( !this.menuFile.isVisible() ) {
this.btnFile.toggle(true); // this.btnFile.toggle(true);
// this.onBtnMenuClick(this.btnFile);
} }
this.btnFile.panel.show(re[2].length ? re[2] : undefined, opts); this.menuFile.show(re[2].length ? re[2] : undefined, opts);
} else { } else {
/** coauthoring begin **/ /** coauthoring begin **/
if (menu == 'chat') { if (menu == 'chat') {
@ -341,7 +337,7 @@ define([
getMenu: function(type) { getMenu: function(type) {
switch (type) { switch (type) {
default: return null; default: return null;
case 'file': return this.btnFile.panel; case 'file': return this.menuFile;
case 'about': return this.btnAbout.panel; case 'about': return this.btnAbout.panel;
} }
}, },

View file

@ -64,6 +64,10 @@ button.notify .btn-menu-comments {background-position: -0*@toolbar-icon-size -60
} }
#file-menu-panel { #file-menu-panel {
height: calc(~"100% + @{height-controls}");
top: -@height-controls;
box-shadow: -1px 0 0 0 @gray-dark;
> div { > div {
height: 100%; height: 100%;
} }