fix for bug #386787: Dragging / dropping multiple items causes the order of items to reverse patch=Christine Yen <christineyen+bugs@gmail.com> r=sspitzer

This commit is contained in:
sspitzer@mozilla.org 2007-08-02 22:52:05 -07:00
parent 3bdde5aea4
commit 99413b399d

View File

@ -1470,7 +1470,10 @@ var PlacesControllerDragHelper = {
var xferable = this._initTransferable(session, targetView,
insertionPoint.orientation);
var dropCount = session.numDropItems;
for (var i = dropCount - 1; i >= 0; --i) {
var movedCount = 0;
for (var i = 0; i < dropCount; ++i) {
session.getData(xferable, i);
var data = { }, flavor = { };
@ -1480,9 +1483,20 @@ var PlacesControllerDragHelper = {
// There's only ever one in the D&D case.
var unwrapped = PlacesUtils.unwrapNodes(data.value.data,
flavor.value)[0];
transactions.push(PlacesUtils.makeTransaction(unwrapped,
flavor.value, insertionPoint.itemId,
insertionPoint.index, copy));
var index = insertionPoint.index;
// Adjust insertion index to prevent reversal of dragged items. When you
// drag multiple elts upward: need to increment index or each successive
// elt will be inserted at the same index, each above the previous.
if ((index != -1) && ((index < unwrapped.index) ||
(unwrapped.folder && (index < unwrapped.folder.index)))) {
index = index + movedCount;
movedCount++;
}
transactions.push(PlacesUtils.makeTransaction(unwrapped,
flavor.value, insertionPoint.itemId,
index, copy));
}
var txn = PlacesUtils.ptm.aggregateTransactions("DropItems", transactions);