From d8e1f30847398cdd78f9aee33a88e602dbfc1166 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Mon, 13 Jan 2020 11:36:22 +0300 Subject: [PATCH] [SSE] Move sheet: drag and drop --- apps/common/main/lib/component/Tab.js | 3 ++- apps/common/main/lib/component/TabBar.js | 17 ++++++++++++++++- .../main/app/controller/Main.js | 2 +- .../main/app/view/Statusbar.js | 17 +++++++++++++---- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/Tab.js b/apps/common/main/lib/component/Tab.js index be04ba493..199911557 100644 --- a/apps/common/main/lib/component/Tab.js +++ b/apps/common/main/lib/component/Tab.js @@ -51,8 +51,9 @@ define([ this.active = false; this.label = 'Tab'; this.cls = ''; + this.index = -1; this.template = _.template(['
  • ', - '<%- label %>', + '<%- label %>', '
  • '].join('')); this.initialize.call(this, opts); diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index d0d82bd6a..a7a93d000 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -249,6 +249,11 @@ define([ img = document.createElement('div'); event.dataTransfer.setDragImage(img, 0, 0); event.dataTransfer.effectAllowed = 'move'; + this.bar.trigger('tab:dragstart', event.dataTransfer, this.bar.selectTabs); + }, this), + dragenter: $.proxy(function (e) { + this.bar.$el.find('.mousemove').removeClass('mousemove right'); + $(e.currentTarget).parent().addClass('mousemove'); }, this), dragover: $.proxy(function (e) { var event = e.originalEvent; @@ -258,6 +263,15 @@ define([ event.dataTransfer.dropEffect = 'move'; return false; }, this), + dragend: $.proxy(function (e) { + this.bar.$el.find('.mousemove').removeClass('mousemove right'); + }, this), + drop: $.proxy(function (e) { + 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) }); }; @@ -273,7 +287,7 @@ define([ }, tabs: [], - template: _.template('