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() {
|
_Class.prototype.drop = function() {
|
||||||
var el, index, reply;
|
var el, index, newIndex, oldIndex, reply;
|
||||||
el = $('.drag', this.parentNode);
|
el = $('.drag', this.parentNode);
|
||||||
index = function() {
|
index = function(el) {
|
||||||
return Array.prototype.slice.call(el.parentNode.children).indexOf(el);
|
return Array.prototype.slice.call(el.parentNode.children).indexOf(el);
|
||||||
};
|
};
|
||||||
reply = qr.replies.splice(index(), 1)[0];
|
oldIndex = index(el);
|
||||||
$.before(this, el);
|
newIndex = index(this);
|
||||||
return qr.replies.splice(index(), 0, reply);
|
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() {
|
_Class.prototype.dragEnd = function() {
|
||||||
|
|||||||
@ -1132,10 +1132,15 @@ qr =
|
|||||||
e.dataTransfer.dropEffect = 'move'
|
e.dataTransfer.dropEffect = 'move'
|
||||||
drop: ->
|
drop: ->
|
||||||
el = $ '.drag', @parentNode
|
el = $ '.drag', @parentNode
|
||||||
index = -> Array::slice.call(el.parentNode.children).indexOf el
|
index = (el) -> Array::slice.call(el.parentNode.children).indexOf el
|
||||||
reply = qr.replies.splice(index(), 1)[0]
|
oldIndex = index el
|
||||||
$.before @, el
|
newIndex = index @
|
||||||
qr.replies.splice index(), 0, reply
|
if oldIndex < newIndex
|
||||||
|
$.after @, el
|
||||||
|
else
|
||||||
|
$.before @, el
|
||||||
|
reply = qr.replies.splice(oldIndex, 1)[0]
|
||||||
|
qr.replies.splice newIndex, 0, reply
|
||||||
dragEnd: ->
|
dragEnd: ->
|
||||||
$.removeClass @, 'drag'
|
$.removeClass @, 'drag'
|
||||||
$.removeClass $('.over', @parentNode), 'over'
|
$.removeClass $('.over', @parentNode), 'over'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user