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