From c708c550566a85055599d5acadb660991201eb0b Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 30 Aug 2019 16:34:11 +0300 Subject: [PATCH 1/9] [SSE] Bug 37388 --- apps/common/main/lib/component/Tab.js | 9 ++++++ apps/common/main/lib/component/TabBar.js | 32 +++++++++++++++---- .../main/resources/less/statusbar.less | 8 +++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/apps/common/main/lib/component/Tab.js b/apps/common/main/lib/component/Tab.js index 29e93b32c..89f6f28e3 100644 --- a/apps/common/main/lib/component/Tab.js +++ b/apps/common/main/lib/component/Tab.js @@ -82,6 +82,10 @@ define([ this.$el.addClass('active'); }, + isSelected: function() { + return this.$el.hasClass('selected'); + }, + deactivate: function(){ this.$el.removeClass('active'); }, @@ -110,6 +114,11 @@ define([ this.$el.removeClass(cls); }, + toggleClass: function(cls) { + if (cls.length) + this.$el.toggleClass(cls); + }, + hasClass: function(cls) { return this.$el.hasClass(cls); }, diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index 0c6868add..b4d3f7803 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -69,12 +69,20 @@ define([ }; StateManager.prototype.attach = function (tab) { - tab.changeState = $.proxy(function () { - this.trigger('tab:change', tab); - this.bar.$el.find('ul > li.active').removeClass('active'); - tab.activate(); + tab.changeState = $.proxy(function (select) { + if (select) { + tab.toggleClass('selected'); + } else { + if (!tab.isSelected()) { + this.bar.$el.find('ul > li.selected').removeClass('selected'); + tab.addClass('selected'); + } + this.trigger('tab:change', tab); + this.bar.$el.find('ul > li.active').removeClass('active'); + tab.activate(); - this.bar.trigger('tab:changed', this.bar, this.bar.tabs.indexOf(tab), tab); + this.bar.trigger('tab:changed', this.bar, this.bar.tabs.indexOf(tab), tab); + } }, this); var dragHelper = new (function() { @@ -283,10 +291,22 @@ define([ }); tab.$el.on({ - click: $.proxy(function () { + click: $.proxy(function (event) { if (!tab.disabled && !tab.$el.hasClass('active')) { if (tab.control == 'manual') { this.bar.trigger('tab:manual', this.bar, this.bar.tabs.indexOf(tab), tab); + } else if (event.ctrlKey || event.metaKey) { + tab.changeState(true); + } else if (event.shiftKey) { + this.bar.$el.find('ul > li.selected').removeClass('selected'); + var $active = this.bar.$el.find('ul > li.active'), + indexAct = $active.index(), + indexCur = tab.sheetindex; + var startIndex = (indexCur > indexAct) ? indexAct : indexCur, + endIndex = (indexCur > indexAct) ? indexCur : indexAct; + for(var i = startIndex; i <= endIndex; i++) { + this.bar.tabs[i].changeState(true); + } } else { tab.changeState(); } diff --git a/apps/spreadsheeteditor/main/resources/less/statusbar.less b/apps/spreadsheeteditor/main/resources/less/statusbar.less index da2c0b79d..58dfef726 100644 --- a/apps/spreadsheeteditor/main/resources/less/statusbar.less +++ b/apps/spreadsheeteditor/main/resources/less/statusbar.less @@ -194,6 +194,14 @@ } } + &.selected { + > a { + border-bottom-color: @body-bg; + background-color: @body-bg; + box-shadow: 0px 2px 0 @gray-deep inset; + } + } + &.coauth-locked { > a { outline: none; From 0cc3ddfca64fa9d9be224b4f1306d2fb57fbb540 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Mon, 2 Sep 2019 13:52:16 +0300 Subject: [PATCH 2/9] [SSE] Bug 37388 --- apps/common/main/lib/component/Tab.js | 2 +- apps/common/main/lib/component/TabBar.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/component/Tab.js b/apps/common/main/lib/component/Tab.js index 89f6f28e3..b3b5644ef 100644 --- a/apps/common/main/lib/component/Tab.js +++ b/apps/common/main/lib/component/Tab.js @@ -51,7 +51,7 @@ define([ this.active = false; this.label = 'Tab'; this.cls = ''; - this.template = _.template(['
  • ', + this.template = _.template(['
  • ', '<%- label %>', '
  • '].join('')); diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index b4d3f7803..8e5ff01a3 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -292,10 +292,8 @@ define([ tab.$el.on({ click: $.proxy(function (event) { - if (!tab.disabled && !tab.$el.hasClass('active')) { - if (tab.control == 'manual') { - this.bar.trigger('tab:manual', this.bar, this.bar.tabs.indexOf(tab), tab); - } else if (event.ctrlKey || event.metaKey) { + if (!tab.disabled) { + if (event.ctrlKey || event.metaKey) { tab.changeState(true); } else if (event.shiftKey) { this.bar.$el.find('ul > li.selected').removeClass('selected'); @@ -304,11 +302,15 @@ define([ indexCur = tab.sheetindex; var startIndex = (indexCur > indexAct) ? indexAct : indexCur, endIndex = (indexCur > indexAct) ? indexCur : indexAct; - for(var i = startIndex; i <= endIndex; i++) { + for (var i = startIndex; i <= endIndex; i++) { this.bar.tabs[i].changeState(true); } - } else { - tab.changeState(); + } else if (!tab.$el.hasClass('active')) { + if (tab.control == 'manual') { + this.bar.trigger('tab:manual', this.bar, this.bar.tabs.indexOf(tab), tab); + } else { + tab.changeState(); + } } } !tab.disabled && Common.NotificationCenter.trigger('edit:complete', this.bar); From db5e747c3671bafbabf7c7d75fc55ca812bbbbe2 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Tue, 3 Sep 2019 14:09:22 +0300 Subject: [PATCH 3/9] [SSE] Bug 37388 --- apps/common/main/lib/component/TabBar.js | 27 +++++- .../main/app/controller/Statusbar.js | 83 +++++++++++++++---- .../main/app/view/Statusbar.js | 2 +- 3 files changed, 95 insertions(+), 17 deletions(-) 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('