[SSE] Bug 37388 (move worksheet)
This commit is contained in:
parent
8f4537a22a
commit
9df4e5f763
|
@ -294,6 +294,61 @@ define([
|
||||||
document.removeEventListener('dragstart',dragDropText);
|
document.removeEventListener('dragstart',dragDropText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
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.drag = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function dragMove (event) {
|
||||||
|
if (!_.isUndefined(me.drag)) {
|
||||||
|
me.drag.moveX = event.clientX*Common.Utils.zoom();
|
||||||
|
if (me.drag.moveX > me.tabBarRight) {
|
||||||
|
bar.tabs[bar.tabs.length - 1].$el.addClass('mousemove right');
|
||||||
|
me.drag.place = bar.tabs.length;
|
||||||
|
} else {
|
||||||
|
$(event.target).parent().parent().find('li.mousemove').removeClass('mousemove right');
|
||||||
|
$(event.target).parent().addClass('mousemove');
|
||||||
|
var name = event.target.parentElement.dataset.label,
|
||||||
|
currentTab = _.findWhere(bar.tabs, {label: name});
|
||||||
|
if (!_.isUndefined(currentTab)) {
|
||||||
|
me.drag.place = currentTab.sheetindex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -337,9 +392,13 @@ define([
|
||||||
mousedown: $.proxy(function (e) {
|
mousedown: $.proxy(function (e) {
|
||||||
if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) {
|
if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) {
|
||||||
if (!tab.isLockTheDrag) {
|
if (!tab.isLockTheDrag) {
|
||||||
|
if (this.bar.selectTabs.length > 1) {
|
||||||
|
dragHelper.setHookTabs(e, this.bar, this.bar.selectTabs);
|
||||||
|
} else {
|
||||||
dragHelper.setHook(e, this.bar, tab);
|
dragHelper.setHook(e, this.bar, tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -265,10 +265,10 @@ define([
|
||||||
this.renameWorksheet();
|
this.renameWorksheet();
|
||||||
break;
|
break;
|
||||||
case 'copy':
|
case 'copy':
|
||||||
this.moveWorksheet(false);
|
this.moveWorksheet(arrIndex, false);
|
||||||
break;
|
break;
|
||||||
case 'move':
|
case 'move':
|
||||||
this.moveWorksheet(true);
|
this.moveWorksheet(arrIndex, true);
|
||||||
break;
|
break;
|
||||||
case 'hide':
|
case 'hide':
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
@ -390,18 +390,26 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
moveWorksheet: function(cut, silent, index, destPos) {
|
moveWorksheet: function(selectArr, cut, silent, index, destPos) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var wc = me.api.asc_getWorksheetsCount(), items = [], i = -1;
|
var wc = me.api.asc_getWorksheetsCount(), items = [], arrIndex = [], i = -1;
|
||||||
while (++i < wc) {
|
while (++i < wc) {
|
||||||
if (!this.api.asc_isWorksheetHidden(i)) {
|
if (!this.api.asc_isWorksheetHidden(i)) {
|
||||||
items.push({
|
items.push({
|
||||||
value : me.api.asc_getWorksheetName(i),
|
value: me.api.asc_getWorksheetName(i),
|
||||||
inindex : i
|
inindex: i
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!_.isUndefined(selectArr)) {
|
||||||
|
items.forEach(function (item) {
|
||||||
|
if (selectArr.indexOf(item.inindex) !== -1) {
|
||||||
|
arrIndex.push(item.inindex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!_.isUndefined(silent)) {
|
if (!_.isUndefined(silent)) {
|
||||||
|
if (_.isUndefined(selectArr)) {
|
||||||
me.api.asc_showWorksheet(items[index].inindex);
|
me.api.asc_showWorksheet(items[index].inindex);
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getActiveWorksheetId()]);
|
Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getActiveWorksheetId()]);
|
||||||
|
@ -409,7 +417,11 @@ define([
|
||||||
if (!_.isUndefined(destPos)) {
|
if (!_.isUndefined(destPos)) {
|
||||||
me.api.asc_moveWorksheet(items.length === destPos ? wc : items[destPos].inindex);
|
me.api.asc_moveWorksheet(items.length === destPos ? wc : items[destPos].inindex);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!_.isUndefined(destPos)) {
|
||||||
|
me.api.asc_moveWorksheet(destPos, arrIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +432,7 @@ define([
|
||||||
handler : function(btn, i) {
|
handler : function(btn, i) {
|
||||||
if (btn == 'ok') {
|
if (btn == 'ok') {
|
||||||
if (cut) {
|
if (cut) {
|
||||||
me.api.asc_moveWorksheet(i == -255 ? wc : i);
|
me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex);
|
||||||
} else {
|
} else {
|
||||||
var new_text = me.createCopyName(me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()));
|
var new_text = me.createCopyName(me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()));
|
||||||
me.api.asc_copyWorksheet(i == -255 ? wc : i, new_text);
|
me.api.asc_copyWorksheet(i == -255 ? wc : i, new_text);
|
||||||
|
|
|
@ -182,18 +182,22 @@ define([
|
||||||
me.fireEvent('sheet:changename');
|
me.fireEvent('sheet:changename');
|
||||||
}
|
}
|
||||||
}, this),
|
}, this),
|
||||||
'tab:move' : _.bind(function (tabIndex, index) {
|
'tab:move' : _.bind(function (selectTabs, index) {
|
||||||
me.tabBarScroll = {scrollLeft: me.tabbar.scrollX};
|
me.tabBarScroll = {scrollLeft: me.tabbar.scrollX};
|
||||||
|
if (_.isUndefined(selectTabs) || _.isUndefined(index) || selectTabs === index) {
|
||||||
if (_.isUndefined(index) || tabIndex === index) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_.isArray(selectTabs)) {
|
||||||
|
me.fireEvent('sheet:move', [selectTabs, false, true, undefined, index]);
|
||||||
|
} else {
|
||||||
|
var tabIndex = selectTabs;
|
||||||
|
|
||||||
if (tabIndex < index) {
|
if (tabIndex < index) {
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.fireEvent('sheet:move', [false, true, tabIndex, index]);
|
me.fireEvent('sheet:move', [undefined, false, true, tabIndex, index]);
|
||||||
|
}
|
||||||
|
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
|
|
@ -232,6 +232,17 @@
|
||||||
color: @gray-darker;
|
color: @gray-darker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.mousemove {
|
||||||
|
> a {
|
||||||
|
background: linear-gradient(to right, @black, @gray-light 1px);
|
||||||
|
}
|
||||||
|
&.right {
|
||||||
|
> a {
|
||||||
|
background: linear-gradient(to left, @black, @gray-light 1px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue