[SSE] Fix bug 52232
This commit is contained in:
parent
ca4bd0e915
commit
6d4ed35b3d
|
@ -121,76 +121,6 @@ define([
|
||||||
me.tabBarRight = me.bounds[length - 1].right;
|
me.tabBarRight = me.bounds[length - 1].right;
|
||||||
me.tabBarRight = Math.min(me.tabBarRight, barBounds.right - 1);
|
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', '');
|
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.bar.trigger('tab:dragstart', event.dataTransfer, this.bar.selectTabs);
|
||||||
}, this),
|
}, this),
|
||||||
dragenter: $.proxy(function (e) {
|
dragenter: $.proxy(function (e) {
|
||||||
|
@ -285,14 +215,7 @@ define([
|
||||||
if (!this.bar.isEditFormula) {
|
if (!this.bar.isEditFormula) {
|
||||||
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
||||||
$(e.currentTarget).parent().addClass('mousemove');
|
$(e.currentTarget).parent().addClass('mousemove');
|
||||||
var data;
|
event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move';
|
||||||
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 {
|
} else {
|
||||||
event.dataTransfer.dropEffect = 'none';
|
event.dataTransfer.dropEffect = 'none';
|
||||||
}
|
}
|
||||||
|
@ -305,6 +228,7 @@ define([
|
||||||
if (!this.bar.isEditFormula) {
|
if (!this.bar.isEditFormula) {
|
||||||
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
||||||
$(e.currentTarget).parent().addClass('mousemove');
|
$(e.currentTarget).parent().addClass('mousemove');
|
||||||
|
event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move';
|
||||||
} else {
|
} else {
|
||||||
event.dataTransfer.dropEffect = 'none';
|
event.dataTransfer.dropEffect = 'none';
|
||||||
}
|
}
|
||||||
|
@ -326,7 +250,7 @@ define([
|
||||||
var event = e.originalEvent,
|
var event = e.originalEvent,
|
||||||
index = $(event.currentTarget).data('index');
|
index = $(event.currentTarget).data('index');
|
||||||
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
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.bar.isDrop = true;
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
@ -365,23 +289,20 @@ define([
|
||||||
var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
|
var eventname=(/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
|
||||||
addEvent(this.$bar[0], eventname, _.bind(this._onMouseWheel,this));
|
addEvent(this.$bar[0], eventname, _.bind(this._onMouseWheel,this));
|
||||||
addEvent(this.$bar[0], 'dragstart', _.bind(function (event) {
|
addEvent(this.$bar[0], 'dragstart', _.bind(function (event) {
|
||||||
event.dataTransfer.effectAllowed = 'move';
|
event.dataTransfer.effectAllowed = 'copyMove';
|
||||||
}, this));
|
}, this));
|
||||||
addEvent(this.$bar[0], 'dragenter', _.bind(function (event) {
|
addEvent(this.$bar[0], 'dragenter', _.bind(function (event) {
|
||||||
var data;
|
if (!this.isEditFormula) {
|
||||||
if (!Common.Utils.isIE) {
|
event.dataTransfer.dropEffect = event.metaKey || event.ctrlKey ? 'copy' : 'move';
|
||||||
data = event.dataTransfer.getData('onlyoffice');
|
|
||||||
event.dataTransfer.dropEffect = (!this.isEditFormula && data) ? 'move' : 'none';
|
|
||||||
} else {
|
} else {
|
||||||
data = event.dataTransfer.getData('text');
|
event.dataTransfer.dropEffect = 'none';
|
||||||
event.dataTransfer.dropEffect = (data === 'sheet' && !this.isEditFormula) ? 'move' : 'none';
|
|
||||||
}
|
}
|
||||||
}, this));
|
}, this));
|
||||||
addEvent(this.$bar[0], 'dragover', _.bind(function (event) {
|
addEvent(this.$bar[0], 'dragover', _.bind(function (event) {
|
||||||
if (event.preventDefault) {
|
if (event.preventDefault) {
|
||||||
event.preventDefault(); // Necessary. Allows us to drop.
|
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');
|
!this.isEditFormula && this.tabs[this.tabs.length - 1].$el.addClass('mousemove right');
|
||||||
return false;
|
return false;
|
||||||
}, this));
|
}, this));
|
||||||
|
@ -392,7 +313,7 @@ define([
|
||||||
addEvent(this.$bar[0], 'drop', _.bind(function (event) {
|
addEvent(this.$bar[0], 'drop', _.bind(function (event) {
|
||||||
this.$el.find('.mousemove').removeClass('mousemove right');
|
this.$el.find('.mousemove').removeClass('mousemove right');
|
||||||
if (this.isDrop === undefined) {
|
if (this.isDrop === undefined) {
|
||||||
this.trigger('tab:drop', event.dataTransfer, 'last');
|
this.trigger('tab:drop', event.dataTransfer, 'last', event.ctrlKey || event.metaKey);
|
||||||
} else {
|
} else {
|
||||||
this.isDrop = undefined;
|
this.isDrop = undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,7 +459,7 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
moveWorksheet: function(selectArr, cut, silent, index, destPos) {
|
moveWorksheet: function(selectArr, cut, silent, indTo) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var wc = me.api.asc_getWorksheetsCount(), items = [], arrIndex = [], i = -1;
|
var wc = me.api.asc_getWorksheetsCount(), items = [], arrIndex = [], i = -1;
|
||||||
while (++i < wc) {
|
while (++i < wc) {
|
||||||
|
@ -477,19 +477,17 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_.isUndefined(silent)) {
|
if (!_.isUndefined(silent)) {
|
||||||
if (_.isUndefined(selectArr)) {
|
if (cut) {
|
||||||
me.api.asc_showWorksheet(items[index].inindex);
|
me.api.asc_moveWorksheet(indTo, arrIndex);
|
||||||
|
me.api.asc_enableKeyEvents(true);
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!_.isUndefined(destPos)) {
|
var arrNames = [];
|
||||||
me.api.asc_moveWorksheet(items.length === destPos ? wc : items[destPos].inindex, arrIndex);
|
arrIndex.forEach(function (item) {
|
||||||
}
|
arrNames.push(me.createCopyName(me.api.asc_getWorksheetName(item), arrNames));
|
||||||
|
});
|
||||||
|
me.api.asc_copyWorksheet(indTo, arrNames, arrIndex);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,24 +219,6 @@ define([
|
||||||
me.fireEvent('sheet:changename');
|
me.fireEvent('sheet:changename');
|
||||||
}
|
}
|
||||||
}, this),
|
}, 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) {
|
'tab:dragstart': _.bind(function (dataTransfer, selectTabs) {
|
||||||
Common.Utils.isIE && (this.isDrop = false);
|
Common.Utils.isIE && (this.isDrop = false);
|
||||||
Common.UI.Menu.Manager.hideAll();
|
Common.UI.Menu.Manager.hideAll();
|
||||||
|
@ -278,7 +260,7 @@ define([
|
||||||
}
|
}
|
||||||
this.dropTabs = selectTabs;
|
this.dropTabs = selectTabs;
|
||||||
}, this),
|
}, this),
|
||||||
'tab:drop': _.bind(function (dataTransfer, index) {
|
'tab:drop': _.bind(function (dataTransfer, index, copy) {
|
||||||
if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return;
|
if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return;
|
||||||
Common.Utils.isIE && (this.isDrop = true);
|
Common.Utils.isIE && (this.isDrop = true);
|
||||||
var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer;
|
var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer;
|
||||||
|
@ -287,8 +269,7 @@ define([
|
||||||
if (arrData) {
|
if (arrData) {
|
||||||
var key = _.findWhere(arrData, {type: 'key'}).value;
|
var key = _.findWhere(arrData, {type: 'key'}).value;
|
||||||
if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) {
|
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.fireEvent('sheet:move', [_.findWhere(arrData, {type: 'indexes'}).value, !copy, true, _.isNumber(index) ? index : this.api.asc_getWorksheetsCount()]);
|
||||||
this.api.asc_enableKeyEvents(true);
|
|
||||||
Common.NotificationCenter.trigger('tabs:dragend', this);
|
Common.NotificationCenter.trigger('tabs:dragend', this);
|
||||||
} else {
|
} else {
|
||||||
var names = [], wc = this.api.asc_getWorksheetsCount();
|
var names = [], wc = this.api.asc_getWorksheetsCount();
|
||||||
|
|
Loading…
Reference in a new issue