From 6d4ed35b3d56d163db25a282a613adadb81b8f64 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 31 Aug 2021 17:03:39 +0300 Subject: [PATCH] [SSE] Fix bug 52232 --- apps/common/main/lib/component/TabBar.js | 99 ++----------------- .../main/app/controller/Statusbar.js | 22 ++--- .../main/app/view/Statusbar.js | 23 +---- 3 files changed, 22 insertions(+), 122 deletions(-) diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index a1ef6a17f..837d59602 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -121,76 +121,6 @@ define([ me.tabBarRight = me.bounds[length - 1].right; me.tabBarRight = Math.min(me.tabBarRight, barBounds.right - 1); } - }, - - setHookTabs: function (e, bar, tabs) { - var me = this; - function dragComplete() { - if (!_.isUndefined(me.drag)) { - bar.dragging = false; - bar.$el.find('li.mousemove').removeClass('mousemove right'); - var arrSelectIndex = []; - tabs.forEach(function (item) { - arrSelectIndex.push(item.sheetindex); - }); - if (!_.isUndefined(me.drag.place)) { - me.bar.trigger('tab:move', arrSelectIndex, me.drag.place); - me.bar.$bar.scrollLeft(me.scrollLeft); - me.bar.scrollX = undefined; - } else { - me.bar.trigger('tab:move', arrSelectIndex); - me.bar.$bar.scrollLeft(me.scrollLeft); - me.bar.scrollX = undefined; - } - me.bar.checkInvisible(); - - me.drag = undefined; - me.bar.trigger('tab:drop', this); - } - } - function dragMove (event) { - if (!_.isUndefined(me.drag)) { - me.drag.moveX = event.clientX*Common.Utils.zoom(); - if (me.drag.moveX < me.leftBorder) { - me.scrollLeft -= 20; - me.bar.$bar.scrollLeft(me.scrollLeft); - me.calculateBounds(); - } else if (me.drag.moveX < me.tabBarRight && me.drag.moveX > me.tabBarLeft) { - var name = $(event.target).parent().data('label'), - currentTab = _.findIndex(bar.tabs, {label: name}); - if (currentTab === -1) { - bar.$el.find('li.mousemove').removeClass('mousemove right'); - me.drag.place = undefined; - } else if (me.bounds[currentTab].left - me.scrollLeft >= me.tabBarLeft) { - me.drag.place = currentTab; - $(event.target).parent().parent().find('li.mousemove').removeClass('mousemove right'); - $(event.target).parent().addClass('mousemove'); - } - } else if (me.drag.moveX > me.lastTabRight && Math.abs(me.tabBarRight - me.bounds[me.bar.tabs.length - 1].right) < 1) { //move to end of list, right border of the right tab is visible - bar.$el.find('li.mousemove').removeClass('mousemove right'); - bar.tabs[bar.tabs.length - 1].$el.addClass('mousemove right'); - me.drag.place = bar.tabs.length; - } else if (me.drag.moveX - me.rightBorder > 3) { - me.scrollLeft += 20; - me.bar.$bar.scrollLeft(me.scrollLeft); - me.calculateBounds(); - } - } - } - if (!_.isUndefined(bar) && !_.isUndefined(tabs) && bar.tabs.length > 1) { - me.bar = bar; - me.drag = {tabs: tabs}; - bar.dragging = true; - this.calculateBounds(); - - $(document).on('mousemove.tabbar', dragMove); - $(document).on('mouseup.tabbar', function (e) { - dragComplete(e); - $(document).off('mouseup.tabbar'); - $(document).off('mousemove.tabbar', dragMove); - }); - this.bar.trigger('tab:drag', this.bar.selectTabs); - } } } }); @@ -277,7 +207,7 @@ define([ tab.$el.find('span').prop('title', ''); }); } - event.dataTransfer.effectAllowed = 'move'; + event.dataTransfer.effectAllowed = 'copyMove'; this.bar.trigger('tab:dragstart', event.dataTransfer, this.bar.selectTabs); }, this), dragenter: $.proxy(function (e) { @@ -285,14 +215,7 @@ define([ if (!this.bar.isEditFormula) { this.bar.$el.find('.mousemove').removeClass('mousemove right'); $(e.currentTarget).parent().addClass('mousemove'); - var data; - if (!Common.Utils.isIE) { - data = event.dataTransfer.getData('onlyoffice'); - event.dataTransfer.dropEffect = data ? 'move' : 'none'; - } else { - data = event.dataTransfer.getData('text'); - event.dataTransfer.dropEffect = data === 'sheet' ? 'move' : 'none'; - } + event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move'; } else { event.dataTransfer.dropEffect = 'none'; } @@ -305,6 +228,7 @@ define([ if (!this.bar.isEditFormula) { this.bar.$el.find('.mousemove').removeClass('mousemove right'); $(e.currentTarget).parent().addClass('mousemove'); + event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move'; } else { event.dataTransfer.dropEffect = 'none'; } @@ -326,7 +250,7 @@ define([ var event = e.originalEvent, index = $(event.currentTarget).data('index'); this.bar.$el.find('.mousemove').removeClass('mousemove right'); - this.bar.trigger('tab:drop', event.dataTransfer, index); + this.bar.trigger('tab:drop', event.dataTransfer, index, event.ctrlKey || event.metaKey); this.bar.isDrop = true; }, this) }); @@ -365,23 +289,20 @@ define([ var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; addEvent(this.$bar[0], eventname, _.bind(this._onMouseWheel,this)); addEvent(this.$bar[0], 'dragstart', _.bind(function (event) { - event.dataTransfer.effectAllowed = 'move'; + event.dataTransfer.effectAllowed = 'copyMove'; }, this)); addEvent(this.$bar[0], 'dragenter', _.bind(function (event) { - var data; - if (!Common.Utils.isIE) { - data = event.dataTransfer.getData('onlyoffice'); - event.dataTransfer.dropEffect = (!this.isEditFormula && data) ? 'move' : 'none'; + if (!this.isEditFormula) { + event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move'; } else { - data = event.dataTransfer.getData('text'); - event.dataTransfer.dropEffect = (data === 'sheet' && !this.isEditFormula) ? 'move' : 'none'; + event.dataTransfer.dropEffect = 'none'; } }, this)); addEvent(this.$bar[0], 'dragover', _.bind(function (event) { if (event.preventDefault) { event.preventDefault(); // Necessary. Allows us to drop. } - event.dataTransfer.dropEffect = !this.isEditFormula ? 'move' : 'none'; + event.dataTransfer.dropEffect = !this.isEditFormula ? (event.metaKey || event.ctrlKey ? 'copy' : 'move') : 'none'; !this.isEditFormula && this.tabs[this.tabs.length - 1].$el.addClass('mousemove right'); return false; }, this)); @@ -392,7 +313,7 @@ define([ addEvent(this.$bar[0], 'drop', _.bind(function (event) { this.$el.find('.mousemove').removeClass('mousemove right'); if (this.isDrop === undefined) { - this.trigger('tab:drop', event.dataTransfer, 'last'); + this.trigger('tab:drop', event.dataTransfer, 'last', event.ctrlKey || event.metaKey); } else { this.isDrop = undefined; } diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 516d7e9fe..47c5c0e53 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -459,7 +459,7 @@ define([ } }, - moveWorksheet: function(selectArr, cut, silent, index, destPos) { + moveWorksheet: function(selectArr, cut, silent, indTo) { var me = this; var wc = me.api.asc_getWorksheetsCount(), items = [], arrIndex = [], i = -1; while (++i < wc) { @@ -477,19 +477,17 @@ define([ } }); } + if (!_.isUndefined(silent)) { - if (_.isUndefined(selectArr)) { - me.api.asc_showWorksheet(items[index].inindex); - - Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getActiveWorksheetId()]); - - if (!_.isUndefined(destPos)) { - me.api.asc_moveWorksheet(items.length === destPos ? wc : items[destPos].inindex); - } + if (cut) { + me.api.asc_moveWorksheet(indTo, arrIndex); + me.api.asc_enableKeyEvents(true); } else { - if (!_.isUndefined(destPos)) { - me.api.asc_moveWorksheet(items.length === destPos ? wc : items[destPos].inindex, arrIndex); - } + var arrNames = []; + arrIndex.forEach(function (item) { + arrNames.push(me.createCopyName(me.api.asc_getWorksheetName(item), arrNames)); + }); + me.api.asc_copyWorksheet(indTo, arrNames, arrIndex); } return; } diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 3d8d73df2..b9038e94a 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -219,24 +219,6 @@ define([ me.fireEvent('sheet:changename'); } }, this), - 'tab:move' : _.bind(function (selectTabs, index) { - me.tabBarScroll = {scrollLeft: me.tabbar.scrollX}; - if (_.isUndefined(selectTabs) || _.isUndefined(index) || (selectTabs && selectTabs.length === 1 && selectTabs[0] === index)) { - return; - } - if (_.isArray(selectTabs)) { - me.fireEvent('sheet:move', [selectTabs, false, true, undefined, index]); - } else { - var tabIndex = selectTabs; - - if (tabIndex < index) { - ++index; - } - - me.fireEvent('sheet:move', [undefined, false, true, tabIndex, index]); - } - - }, this), 'tab:dragstart': _.bind(function (dataTransfer, selectTabs) { Common.Utils.isIE && (this.isDrop = false); Common.UI.Menu.Manager.hideAll(); @@ -278,7 +260,7 @@ define([ } this.dropTabs = selectTabs; }, this), - 'tab:drop': _.bind(function (dataTransfer, index) { + 'tab:drop': _.bind(function (dataTransfer, index, copy) { if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return; Common.Utils.isIE && (this.isDrop = true); var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer; @@ -287,8 +269,7 @@ define([ if (arrData) { var key = _.findWhere(arrData, {type: 'key'}).value; if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) { - this.api.asc_moveWorksheet(_.isNumber(index) ? index : this.api.asc_getWorksheetsCount(), _.findWhere(arrData, {type: 'indexes'}).value); - this.api.asc_enableKeyEvents(true); + this.fireEvent('sheet:move', [_.findWhere(arrData, {type: 'indexes'}).value, !copy, true, _.isNumber(index) ? index : this.api.asc_getWorksheetsCount()]); Common.NotificationCenter.trigger('tabs:dragend', this); } else { var names = [], wc = this.api.asc_getWorksheetsCount();