[SSE] Move sheet: drag and drop
This commit is contained in:
parent
5e47e79659
commit
45b7b71a0a
|
@ -52,7 +52,7 @@ define([
|
||||||
this.label = 'Tab';
|
this.label = 'Tab';
|
||||||
this.cls = '';
|
this.cls = '';
|
||||||
this.template = _.template(['<li class="<% if(active){ %>active selected<% } %> <% if(cls.length){%><%= cls %><%}%>" data-label="<%= label %>">',
|
this.template = _.template(['<li class="<% if(active){ %>active selected<% } %> <% if(cls.length){%><%= cls %><%}%>" data-label="<%= label %>">',
|
||||||
'<a title="<%= label %>"><%- label %></a>',
|
'<a title="<%= label %>" draggable="true" oo_editor_input="true" tabindex="-1"><%- label %></a>',
|
||||||
'</li>'].join(''));
|
'</li>'].join(''));
|
||||||
|
|
||||||
this.initialize.call(this, opts);
|
this.initialize.call(this, opts);
|
||||||
|
|
|
@ -233,15 +233,32 @@ 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 (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)
|
||||||
tab.changeState();
|
tab.changeState();
|
||||||
dragHelper.setHookTabs(e, this.bar, this.bar.selectTabs);
|
dragHelper.setHookTabs(e, this.bar, this.bar.selectTabs);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
this.bar.trigger('tab:drag', this.bar.selectTabs);
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
tab.$el.children().on(
|
||||||
|
{dragstart: $.proxy(function (e) {
|
||||||
|
var event = e.originalEvent,
|
||||||
|
img = document.createElement('div');
|
||||||
|
event.dataTransfer.setDragImage(img, 0, 0);
|
||||||
|
event.dataTransfer.effectAllowed = 'move';
|
||||||
|
}, this),
|
||||||
|
dragover: $.proxy(function (e) {
|
||||||
|
var event = e.originalEvent;
|
||||||
|
if (event.preventDefault) {
|
||||||
|
event.preventDefault(); // Necessary. Allows us to drop.
|
||||||
|
}
|
||||||
|
event.dataTransfer.dropEffect = 'move';
|
||||||
|
return false;
|
||||||
|
}, this),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
StateManager.prototype.detach = function (tab) {
|
StateManager.prototype.detach = function (tab) {
|
||||||
|
@ -276,6 +293,16 @@ 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) {
|
||||||
|
event.dataTransfer.effectAllowed = 'move';
|
||||||
|
}, this));
|
||||||
|
addEvent(this.$bar[0], 'dragover', _.bind(function (event) {
|
||||||
|
if (event.preventDefault) {
|
||||||
|
event.preventDefault(); // Necessary. Allows us to drop.
|
||||||
|
}
|
||||||
|
event.dataTransfer.dropEffect = 'move';
|
||||||
|
return false;
|
||||||
|
}, this));
|
||||||
|
|
||||||
this.manager = new StateManager({bar: this});
|
this.manager = new StateManager({bar: this});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue