Adjust behavior when dropping left to right or right to left.
This commit is contained in:
parent
272fb0e66e
commit
18cbff6b3d
@ -1511,14 +1511,20 @@
|
||||
};
|
||||
|
||||
_Class.prototype.drop = function() {
|
||||
var el, index, reply;
|
||||
var el, index, newIndex, oldIndex, reply;
|
||||
el = $('.drag', this.parentNode);
|
||||
index = function() {
|
||||
index = function(el) {
|
||||
return Array.prototype.slice.call(el.parentNode.children).indexOf(el);
|
||||
};
|
||||
reply = qr.replies.splice(index(), 1)[0];
|
||||
$.before(this, el);
|
||||
return qr.replies.splice(index(), 0, reply);
|
||||
oldIndex = index(el);
|
||||
newIndex = index(this);
|
||||
if (oldIndex < newIndex) {
|
||||
$.after(this, el);
|
||||
} else {
|
||||
$.before(this, el);
|
||||
}
|
||||
reply = qr.replies.splice(oldIndex, 1)[0];
|
||||
return qr.replies.splice(newIndex, 0, reply);
|
||||
};
|
||||
|
||||
_Class.prototype.dragEnd = function() {
|
||||
|
||||
@ -1132,10 +1132,15 @@ qr =
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
drop: ->
|
||||
el = $ '.drag', @parentNode
|
||||
index = -> Array::slice.call(el.parentNode.children).indexOf el
|
||||
reply = qr.replies.splice(index(), 1)[0]
|
||||
$.before @, el
|
||||
qr.replies.splice index(), 0, reply
|
||||
index = (el) -> Array::slice.call(el.parentNode.children).indexOf el
|
||||
oldIndex = index el
|
||||
newIndex = index @
|
||||
if oldIndex < newIndex
|
||||
$.after @, el
|
||||
else
|
||||
$.before @, el
|
||||
reply = qr.replies.splice(oldIndex, 1)[0]
|
||||
qr.replies.splice newIndex, 0, reply
|
||||
dragEnd: ->
|
||||
$.removeClass @, 'drag'
|
||||
$.removeClass $('.over', @parentNode), 'over'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user