Author: reebalazs
Date: Thu May 24 23:52:26 2007
New Revision: 43610
Modified:
kukit/azax/branch/1.1-ree-plugin-dad/plugins/draganddrop/browser/kss_dragdrop.js
Log:
Fix the drop method emulation in sortables
we need to also change the order of elements programmatically
which messes up the internal state
so, we have a sortreset event that must be called up in this case
to recover state.
To get rid of this workaround, we'd need extensive customization
of prototype, and only possible with dupplicating code at the
moment.
Modified:
kukit/azax/branch/1.1-ree-plugin-dad/plugins/draganddrop/browser/kss_dragdrop.js
==============================================================================
---
kukit/azax/branch/1.1-ree-plugin-dad/plugins/draganddrop/browser/kss_dragdrop.js
(original)
+++
kukit/azax/branch/1.1-ree-plugin-dad/plugins/draganddrop/browser/kss_dragdrop.js
Thu May 24 23:52:26 2007
@@ -208,6 +208,9 @@
* ids as an attribute. Since we rather want a "drop" event, this gets
implemented but
* again, since we cannot access the original drag and drop events from
here, we make
* this emulated that requires a painful processing of the entire list.
+ * (Remark: in addition if other then the sortables rearrange the elements
within
+ * the container, also needs to call sortrefresh as a continuation event
because of
+ * this, this will refresh the "state" of the containers.)
*
* 3. The Sortables object is a singleton. This is a problem because all
sortable container
* will act as one common pool. This is a problem because this way we
cannot have more
@@ -312,9 +315,10 @@
var options = Sortable.options(element);
var originalIds = options.originalIds;
// update the list in the options
- options.originalIds = newIds;
if (originalIds.length > newIds.length) {
// we did not drop an element here.
+ // set the new order now, that we are ok
+ options.originalIds = newIds;
return parms;
}
// find the first place where they differ
@@ -348,6 +352,8 @@
// supply the rest of the parameters
parms.drag = document.getElementById(parms.dragid);
parms.drop = document.getElementById(parms.dropid);
+ // set the new order now, that we are ok
+ options.originalIds = newIds;
return parms;
};
@@ -362,7 +368,18 @@
}
};
+// This is a programmatical (continuiation) event that refreshes the state of
the sortable,
+// it is needed because collectDefaultParms compares the state with the
previous
+// one, so this needs to be called if someone else changed the sortable.
+kukit.draganddrop.SortableEvent.prototype.__default_refresh__ = function(name,
oper) {
+ oper.completeParms([], {}, 'dad-sortrefresh event default action');
+ // store original order on options
+ var realoptions = Sortable.options(oper.node);
+ realoptions.originalIds = this.getOrderedIds(oper.node);
+};
+
if (kukit.draganddrop.base_library_present) {
kukit.eventsGlobalRegistry.registerForAllEvents('dad', ['sortupdate',
'sortchange', 'sortdrop'], kukit.draganddrop.SortableEvent, '__bind__', null,
'allnodes');
+ kukit.eventsGlobalRegistry.register('dad', 'sortrefresh',
kukit.draganddrop.SortableEvent, null, '__default_refresh__');
}
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins