diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index 8e5ff01a3..62dd31ee7 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -72,10 +72,18 @@ define([ tab.changeState = $.proxy(function (select) { if (select) { tab.toggleClass('selected'); + var selectTab = _.find(this.bar.selectTabs, function (item) {return item.sheetindex === tab.sheetindex;}); + if (selectTab) { + this.bar.selectTabs = _.without(this.bar.selectTabs, selectTab); + } else { + this.bar.selectTabs.push(tab); + } } else { if (!tab.isSelected()) { this.bar.$el.find('ul > li.selected').removeClass('selected'); tab.addClass('selected'); + this.bar.selectTabs.length = 0; + this.bar.selectTabs.push(tab); } this.trigger('tab:change', tab); this.bar.$el.find('ul > li.active').removeClass('active'); @@ -297,9 +305,10 @@ define([ tab.changeState(true); } else if (event.shiftKey) { this.bar.$el.find('ul > li.selected').removeClass('selected'); + this.bar.selectTabs.length = 0; var $active = this.bar.$el.find('ul > li.active'), indexAct = $active.index(), - indexCur = tab.sheetindex; + indexCur = this.bar.tabs.indexOf(tab); var startIndex = (indexCur > indexAct) ? indexAct : indexCur, endIndex = (indexCur > indexAct) ? indexCur : indexAct; for (var i = startIndex; i <= endIndex; i++) { @@ -319,7 +328,11 @@ define([ this.trigger('tab:dblclick', this, this.tabs.indexOf(tab), tab); }, this.bar), contextmenu: $.proxy(function () { - this.trigger('tab:contextmenu', this, this.tabs.indexOf(tab), tab); + if (this.selectTabs.length > 1) { + this.trigger('tab:contextmenu', this, this.tabs.indexOf(tab), tab, this.selectTabs); + } else { + this.trigger('tab:contextmenu', this, this.tabs.indexOf(tab), tab); + } }, this.bar), mousedown: $.proxy(function (e) { if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) { @@ -344,6 +357,7 @@ define([ tabs: [], template: _.template('
'), + selectTabs: [], initialize : function (options) { _.extend(this.config, options); @@ -419,6 +433,10 @@ define([ me.$bar.append(tab.render().$el); me.tabs.push(tab); me.manager.attach(tab); + if (tab.isActive()) { + me.selectTabs.length = 0; + me.selectTabs.push(tab); + } } } else { for (i = tabs.length; i-- > 0 ; ) { @@ -432,6 +450,11 @@ define([ me.tabs.splice(index, 0, tab); } + if (tab.isActive()) { + me.selectTabs.length = 0; + me.selectTabs.push(tab); + } + me.manager.attach(tab); } } diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index b88aee8a8..ca3aeec10 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -247,20 +247,54 @@ define([ onTabMenu: function(obj, item, e) { var me = this; - switch (item.value){ - case 'ins': - setTimeout(function(){ - me.api.asc_insertWorksheet(me.createSheetName()); - }, 1); - break; - case 'del': this.deleteWorksheet(); break; - case 'ren': this.renameWorksheet(); break; - case 'copy': this.moveWorksheet(false); break; - case 'move': this.moveWorksheet(true); break; - case 'hide': - setTimeout(function(){ - me.hideWorksheet(true);}, 1); - break; + var selectTabs = this.statusbar.tabbar.selectTabs; + if (selectTabs.length > 1) { + switch (item.value) { + case 'ins': + setTimeout(function () { + //me.api.asc_insertWorksheets(); + }, 1); + break; + case 'del': + this.deleteWorksheets(); + break; + case 'copy': + this.moveWorksheets(false); + break; + case 'move': + this.moveWorksheets(true); + break; + case 'hide': + setTimeout(function () { + me.hideWorksheets(selectTabs); + }, 1,); + break; + } + } else { + switch (item.value) { + case 'ins': + setTimeout(function () { + me.api.asc_insertWorksheet(me.createSheetName()); + }, 1); + break; + case 'del': + this.deleteWorksheet(); + break; + case 'ren': + this.renameWorksheet(); + break; + case 'copy': + this.moveWorksheet(false); + break; + case 'move': + this.moveWorksheet(true); + break; + case 'hide': + setTimeout(function () { + me.hideWorksheet(true); + }, 1); + break; + } } }, @@ -297,6 +331,10 @@ define([ return name; }, + deleteWorksheets: function() { + + }, + deleteWorksheet: function() { var me = this; @@ -317,6 +355,19 @@ define([ } }, + hideWorksheets: function(selectTabs) { + var me = this; + if (selectTabs) { + if (selectTabs.length === me.statusbar.tabbar.tabs.length) { + Common.UI.warning({msg: me.errorLastSheet}); + } else { + me.statusbar.tabbar.selectTabs.forEach(function (item) { + //me.hideWorksheet(true, item.sheetindex); + }); + } + } + }, + hideWorksheet: function(hide, index) { if ( hide ) { this.statusbar.tabbar.tabs.length == 1 ? @@ -376,6 +427,10 @@ define([ } }, + moveWorksheets: function() { + + }, + moveWorksheet: function(cut, silent, index, destPos) { var me = this; var wc = me.api.asc_getWorksheetsCount(), items = [], i = -1; diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 247da69e5..d4117fb93 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -409,7 +409,7 @@ define([ // Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getActiveWorksheetId()], false); // hide popover }, - onTabMenu: function (o, index, tab) { + onTabMenu: function (o, index, tab, select) { if (this.mode.isEdit && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable) && !this.mode.isDisconnected ) {