[SSE] Move sheet: drag and drop
This commit is contained in:
parent
200dacc33a
commit
8cefc20a94
|
@ -233,6 +233,8 @@ define([
|
|||
this.trigger('tab:contextmenu', this, this.tabs.indexOf(tab), tab, this.selectTabs);
|
||||
}, this.bar),
|
||||
mousedown: $.proxy(function (e) {
|
||||
if ((3 !== e.which) && !e.ctrlKey && !e.metaKey && !e.shiftKey)
|
||||
tab.changeState();
|
||||
/*if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) {
|
||||
if (!tab.isLockTheDrag) {
|
||||
if (!e.ctrlKey && !e.metaKey && !e.shiftKey)
|
||||
|
@ -261,8 +263,12 @@ define([
|
|||
event.preventDefault(); // Necessary. Allows us to drop.
|
||||
}
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
$(e.currentTarget).parent().addClass('mousemove');
|
||||
return false;
|
||||
}, this),
|
||||
dragleave: $.proxy(function (e) {
|
||||
$(e.currentTarget).parent().removeClass('mousemove right');
|
||||
}, this),
|
||||
dragend: $.proxy(function (e) {
|
||||
this.bar.$el.find('.mousemove').removeClass('mousemove right');
|
||||
}, this),
|
||||
|
@ -318,6 +324,14 @@ define([
|
|||
this.tabs[this.tabs.length - 1].$el.addClass('mousemove right');
|
||||
return false;
|
||||
}, this));
|
||||
addEvent(this.$bar[0], 'dragleave', _.bind(function (event) {
|
||||
this.tabs[this.tabs.length - 1].$el.removeClass('mousemove right');
|
||||
}, this));
|
||||
addEvent(this.$bar[0], 'drop', _.bind(function (event) {
|
||||
var index = this.tabs.length;
|
||||
this.$el.find('.mousemove').removeClass('mousemove right');
|
||||
this.trigger('tab:drop', event.dataTransfer, index);
|
||||
}, this));
|
||||
|
||||
this.manager = new StateManager({bar: this});
|
||||
|
||||
|
|
|
@ -410,6 +410,8 @@ define([
|
|||
docInfo.put_Permissions(_permissions);
|
||||
|
||||
this.headerView && this.headerView.setDocumentCaption(data.doc.title);
|
||||
|
||||
Common.Utils.InternalSettings.set("sse-doc-info-key", data.doc.key);
|
||||
}
|
||||
|
||||
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
|
||||
|
|
|
@ -210,18 +210,29 @@ define([
|
|||
arrTabs.push(item.sheetindex);
|
||||
arrName.push(me.api.asc_getWorksheetName(item.sheetindex));
|
||||
});
|
||||
var stringSheet = this.api.asc_StartMoveSheet(arrTabs),
|
||||
var stringSheet,
|
||||
stringSheetJson,
|
||||
stringNameJson;
|
||||
stringNameJson,
|
||||
stringIndexJson;
|
||||
stringIndexJson = JSON.stringify(arrTabs);
|
||||
stringSheet = this.api.asc_StartMoveSheet(arrTabs);
|
||||
stringSheetJson = JSON.stringify(stringSheet);
|
||||
stringNameJson = JSON.stringify(arrName);
|
||||
dataTransfer.setData("onlyoffice", stringSheetJson);
|
||||
dataTransfer.setData("name", stringNameJson);
|
||||
dataTransfer.setData("arrindex", stringIndexJson);
|
||||
dataTransfer.setData("key", Common.Utils.InternalSettings.get("sse-doc-info-key"));
|
||||
}, this),
|
||||
'tab:drop' : _.bind(function (dataTransfer, index) {
|
||||
var arrSheets = dataTransfer.getData("onlyoffice"),
|
||||
arrNames = dataTransfer.getData("name");
|
||||
this.api.asc_EndMoveSheet(index, JSON.parse(arrNames), JSON.parse(arrSheets));
|
||||
var arrSheets = JSON.parse(dataTransfer.getData("onlyoffice")),
|
||||
arrNames = JSON.parse(dataTransfer.getData("name")),
|
||||
arrIndex = JSON.parse(dataTransfer.getData("arrindex")),
|
||||
key = dataTransfer.getData("key");
|
||||
if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) {
|
||||
this.api.asc_moveWorksheet(index, arrIndex);
|
||||
} else {
|
||||
this.api.asc_EndMoveSheet(index, arrNames, arrSheets);
|
||||
}
|
||||
}, this)
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue