diff --git a/apps/common/main/lib/component/Mixtbar.js b/apps/common/main/lib/component/Mixtbar.js index 18c878e60..0360db278 100644 --- a/apps/common/main/lib/component/Mixtbar.js +++ b/apps/common/main/lib/component/Mixtbar.js @@ -86,8 +86,23 @@ define([ initialize : function(options) { Common.UI.BaseView.prototype.initialize.call(this, options); + var _template_tabs = + '
' + + '<' + + '' + + '>' + + '
'; + this.$layout = $(options.template({ - tabs: options.tabs + tabsmarkup: _.template(_template_tabs)({items: options.tabs}) })); config.tabs = options.tabs; @@ -120,7 +135,7 @@ define([ return t.length && t.data('tab') == tag; }, - setFolded: function(value, defNum) { + setFolded: function(value, deftab) { this.isFolded = value; var me = this; @@ -178,9 +193,8 @@ define([ if ( active_panel.length ) { var tab = active_panel.data('tab'); me.$tabs.find('> a[data-tab=' + tab + ']').parent().toggleClass('active', true); - } else if (defNum!==undefined && defNum a'); - t.length && me.setTab(t.data('tab')); + } else { + me.setTab(deftab); } } }, @@ -214,28 +228,40 @@ define([ }, onTabClick: function (e) { - var _is_active = $(e.currentTarget).hasClass('active'); - if ( _is_active ) { - if ( this.isFolded ) { - // this.collapse(); + var me = this; + + var $target = $(e.currentTarget); + var tab = $target.find('> a[data-tab]').data('tab'); + var islone = $target.hasClass('x-lone'); + if ( me.isFolded ) { + if ( $target.hasClass('x-lone') ) { + me.collapse(); + // me.fireEvent('') + } else + if ( $target.hasClass('active') ) { + me.collapse(); + } else { + me.setTab(tab); } } else { - var tab = $(e.target).data('tab'); - this.setTab(tab); + if ( !$target.hasClass('active') && !islone ) { + me.setTab(tab); + } } }, setTab: function (tab) { + var me = this; if ( !tab ) { - onShowFullviewPanel.call(this, false); + // onShowFullviewPanel.call(this, false); if ( this.isFolded ) { this.collapse(); } else tab = this.lastPanel; } if ( tab ) { - this.$tabs.removeClass('active'); - this.$panels.removeClass('active'); + me.$tabs.removeClass('active'); + me.$panels.removeClass('active'); var panel = this.$panels.filter('[data-tab=' + tab + ']'); if ( panel.length ) { @@ -244,10 +270,10 @@ define([ } if ( panel.length ) { - if ( this.isFolded ) this.expand(); + if ( me.isFolded ) me.expand(); } else { - onShowFullviewPanel.call(this, true); - if ( this.isFolded ) this.collapse(); + // onShowFullviewPanel.call(this, true); + if ( me.isFolded ) me.collapse(); } var $tp = this.$tabs.find('> a[data-tab=' + tab + ']').parent(); diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 326cf6784..d08a7b27b 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -364,7 +364,7 @@ define([ }, onChangeCompactView: function(view, compact) { - this.toolbar.setFolded(compact, 1); + this.toolbar.setFolded(compact, this.appOptions.isEdit ? 'home' : 'plugins'); this.toolbar.fireEvent('view:compact', [this, compact]); Common.localStorage.setBool('de-compact-toolbar', compact); @@ -2741,6 +2741,7 @@ define([ onAppReady: function (config) { var me = this; + me.appOptions = config; if ( config.canCoAuthoring && config.canComments ) { this.btnsComment = createButtonSet(); @@ -2791,7 +2792,11 @@ define([ }, onFileMenu: function (opts) { - this.toolbar.setTab( opts == 'show' ? 'file' : undefined ); + if ( opts == 'show' ) {} + else { + if ( this.toolbar.isTabActive('file') ) + this.toolbar.setTab(); + } }, textEmptyImgUrl : 'You need to specify image URL.', diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index 7c1ed23c5..3b15aed25 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -1,23 +1,8 @@
-
- - < - - - - > - -
-
-
+ <%= tabsmarkup %> +
diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index cd72246ff..0cbb510a9 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -109,7 +109,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), tabs: [ - {caption: me.textTabFile, action: 'file', extcls: 'canedit'}, + {caption: me.textTabFile, action: 'file', extcls: 'canedit', haspanel:false}, {caption: me.textTabHome, action: 'home', extcls: 'canedit'}, {caption: me.textTabInsert, action: 'ins', extcls: 'canedit'}, {caption: me.textTabLayout, action: 'layout', extcls: 'canedit'}, @@ -1147,7 +1147,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template_view), tabs: [ - {caption: me.textTabFile, action: 'file', extcls: ''} + {caption: me.textTabFile, action: 'file', haspanel: false} ] } ); @@ -1160,7 +1160,7 @@ define([ compactview = true; if (!compactview) { - me.setFolded(false, 1); + me.setFolded(false); me.setTab('plugins'); me.fireEvent('view:compact', [me, compactview]); Common.NotificationCenter.trigger('layout:changed', 'toolbar'); @@ -1226,19 +1226,20 @@ define([ }, onTabClick: function (e) { - var tab = $(e.target).data('tab'), - me = this; - - if ( !me.isTabActive(tab) ) { - if ( tab == 'file' ) { - me.fireEvent('file:open'); - } else - if ( me.isTabActive('file') ) - me.fireEvent('file:close'); - } + var me = this, + tab = $(e.currentTarget).find('> a[data-tab]').data('tab'), + is_file_active = me.isTabActive('file'); Common.UI.Mixtbar.prototype.onTabClick.apply(me, arguments); + if ( is_file_active ) { + me.fireEvent('file:close'); + } else + if ( tab == 'file' ) { + me.fireEvent('file:open'); + me.setTab(tab); + } + if ( me.isTabActive('home')) me.fireEvent('home:open'); }, diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index ec686f8f5..ab226bd8f 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -354,7 +354,7 @@ define([ }, onChangeCompactView: function(view, compact) { - this.toolbar.setFolded(compact, 1); + this.toolbar.setFolded(compact, this.appOptions.isEdit ? 'home' : 'plugins'); this.toolbar.fireEvent('view:compact', [this.toolbar, compact]); Common.localStorage.setBool('pe-compact-toolbar', compact); @@ -2029,6 +2029,7 @@ define([ onAppReady: function (config) { var me = this; + me.appOptions = config; this.btnsComment = []; if ( config.canCoAuthoring && config.canComments ) { @@ -2064,7 +2065,11 @@ define([ }, onFileMenu: function (opts) { - this.toolbar.setTab( opts == 'show' ? 'file' : undefined ); + if ( opts == 'show' ) {} + else { + if ( this.toolbar.isTabActive('file') ) + this.toolbar.setTab(); + } }, textEmptyImgUrl : 'You need to specify image URL.', diff --git a/apps/presentationeditor/main/app/template/Toolbar.template b/apps/presentationeditor/main/app/template/Toolbar.template index 0cb5f81ec..33e675bcd 100644 --- a/apps/presentationeditor/main/app/template/Toolbar.template +++ b/apps/presentationeditor/main/app/template/Toolbar.template @@ -1,21 +1,7 @@
-
- - < - - - - > - -
+ <%= tabsmarkup %>
diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index b95c4a67e..164534a45 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -125,7 +125,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), tabs: [ - {caption: me.textTabFile, action: 'file', extcls: 'canedit'}, + {caption: me.textTabFile, action: 'file', extcls: 'canedit', haspanel:false}, {caption: me.textTabHome, action: 'home', extcls: 'canedit'}, {caption: me.textTabInsert, action: 'ins', extcls: 'canedit'} ] @@ -791,7 +791,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template_view), tabs: [ - {caption: me.textTabFile, action: 'file', extcls: ''} + {caption: me.textTabFile, action: 'file', haspanel:false} ] } ); @@ -804,7 +804,7 @@ define([ compactview = true; if (!compactview) { - me.setFolded(false, 1); + me.setFolded(false); me.setTab('plugins'); me.fireEvent('view:compact', [me, compactview]); Common.NotificationCenter.trigger('layout:changed', 'toolbar'); @@ -894,18 +894,19 @@ define([ }, onTabClick: function (e) { - var tab = $(e.target).data('tab'), - me = this; + var me = this, + tab = $(e.currentTarget).find('> a[data-tab]').data('tab'), + is_file_active = me.isTabActive('file'); - if ( !me.isTabActive(tab) ) { - if ( tab == 'file' ) { - me.fireEvent('file:open'); - } else - if ( me.isTabActive('file') ) - me.fireEvent('file:close'); + Common.UI.Mixtbar.prototype.onTabClick.apply(me, arguments); + + if ( is_file_active ) { + me.fireEvent('file:close'); + } else + if ( tab == 'file' ) { + me.fireEvent('file:open'); + me.setTab(tab); } - - Common.UI.Mixtbar.prototype.onTabClick.apply(this, arguments); }, rendererComponents: function (html) { diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index b4dc39821..defb6014b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1458,7 +1458,7 @@ define([ }, onChangeViewMode: function(item, compact) { - this.toolbar.setFolded(compact, 1); + this.toolbar.setFolded(compact, this.appOptions.isEdit ? 'home' : 'plugins'); this.toolbar.fireEvent('view:compact', [this, compact]); Common.localStorage.setBool('sse-compact-toolbar', compact); @@ -2994,6 +2994,7 @@ define([ onAppReady: function (config) { var me = this; + me.appOptions = config; this.btnsComment = []; if ( config.canCoAuthoring && config.canComments ) { @@ -3034,7 +3035,11 @@ define([ }, onFileMenu: function (opts) { - this.toolbar.setTab( opts == 'show' ? 'file' : undefined ); + if ( opts == 'show' ) {} + else { + if ( this.toolbar.isTabActive('file') ) + this.toolbar.setTab(); + } }, textEmptyImgUrl : 'You need to specify image URL.', diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 5bb2ae135..a7deee373 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -1,23 +1,8 @@
-
- - < - - - - > - -
-
-
+ <%= tabsmarkup %> +
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index b28684839..47b6bcc35 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -336,7 +336,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), tabs: [ - { caption: me.textTabFile, action: 'file', extcls: 'canedit'}, + { caption: me.textTabFile, action: 'file', extcls: 'canedit', haspanel:false}, { caption: me.textTabHome, action: 'home', extcls: 'canedit'}, { caption: me.textTabInsert, action: 'ins', extcls: 'canedit'} ]} @@ -1206,7 +1206,7 @@ define([ Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template_view), tabs: [ - {caption: me.textTabFile, action: 'file', extcls: ''} + {caption: me.textTabFile, action: 'file', haspanel:false} ] } ); @@ -1309,18 +1309,19 @@ define([ }, onTabClick: function (e) { - var tab = $(e.target).data('tab'), - me = this; + var me = this, + tab = $(e.currentTarget).find('> a[data-tab]').data('tab'), + is_file_active = me.isTabActive('file'); - if ( !me.isTabActive(tab) ) { - if ( tab == 'file' ) { - me.fireEvent('file:open'); - } else - if ( me.isTabActive('file') ) - me.fireEvent('file:close'); + Common.UI.Mixtbar.prototype.onTabClick.apply(me, arguments); + + if ( is_file_active ) { + me.fireEvent('file:close'); + } else + if ( tab == 'file' ) { + me.fireEvent('file:open'); + me.setTab(tab); } - - Common.UI.Mixtbar.prototype.onTabClick.apply(this, arguments); }, rendererComponents: function(html) {