[SSE] Fix drag and drop in statusbar for ie11

This commit is contained in:
JuliaSvinareva 2021-04-05 17:58:06 +03:00
parent 192995c854
commit 0a2c03c6b6
2 changed files with 36 additions and 11 deletions

View file

@ -268,9 +268,11 @@ define([
});
tab.$el.children().on(
{dragstart: $.proxy(function (e) {
var event = e.originalEvent,
img = document.createElement('div');
event.dataTransfer.setDragImage(img, 0, 0);
var event = e.originalEvent;
if (!Common.Utils.isIE) {
var 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),
@ -279,8 +281,14 @@ define([
if (!this.bar.isEditFormula) {
this.bar.$el.find('.mousemove').removeClass('mousemove right');
$(e.currentTarget).parent().addClass('mousemove');
var data = event.dataTransfer.getData("onlyoffice");
event.dataTransfer.dropEffect = data ? 'move' : 'none';
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';
}
} else {
event.dataTransfer.dropEffect = 'none';
}
@ -356,8 +364,14 @@ define([
event.dataTransfer.effectAllowed = 'move';
}, this));
addEvent(this.$bar[0], 'dragenter', _.bind(function (event) {
var data = event.dataTransfer.getData("onlyoffice");
event.dataTransfer.dropEffect = (!this.isEditFormula && data) ? 'move' : 'none';
var data;
if (!Common.Utils.isIE) {
data = event.dataTransfer.getData('onlyoffice');
event.dataTransfer.dropEffect = (!this.isEditFormula && data) ? 'move' : 'none';
} else {
data = event.dataTransfer.getData('text');
event.dataTransfer.dropEffect = (data === 'sheet' && !this.isEditFormula) ? 'move' : 'none';
}
}, this));
addEvent(this.$bar[0], 'dragover', _.bind(function (event) {
if (event.preventDefault) {

View file

@ -203,6 +203,7 @@ define([
}, this),
'tab:dragstart': _.bind(function (dataTransfer, selectTabs) {
Common.Utils.isIE && (this.isDrop = false);
Common.UI.Menu.Manager.hideAll();
this.api.asc_closeCellEditor();
var arrTabs = [],
@ -234,12 +235,18 @@ define([
arr.push({type: 'names', value: arrName});
arr.push({type: 'key', value: Common.Utils.InternalSettings.get("sse-doc-info-key")});
var json = JSON.stringify(arr);
dataTransfer.setData("onlyoffice", json);
if (!Common.Utils.isIE) {
dataTransfer.setData('onlyoffice', json);
} else {
dataTransfer.setData('text', 'sheet');
this.dataTransfer = json;
}
this.dropTabs = selectTabs;
}, this),
'tab:drop': _.bind(function (dataTransfer, index) {
if (this.isEditFormula) return;
var data = dataTransfer.getData("onlyoffice");
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;
if (data) {
var arrData = JSON.parse(data);
if (arrData) {
@ -277,7 +284,7 @@ define([
}
}, this),
'tab:dragend': _.bind(function (cut) {
if (cut) {
if (cut && !(Common.Utils.isIE && this.isDrop === false)) {
if (this.dropTabs.length > 0) {
var arr = [];
this.dropTabs.forEach(function (tab) {
@ -287,6 +294,10 @@ define([
}
}
this.dropTabs = undefined;
if (Common.Utils.isIE) {
this.isDrop = undefined;
this.dataTransfer = undefined;
}
Common.NotificationCenter.trigger('tabs:dragend', this);
}, this)
});