It took a *lot* longer than I thought it would (mainly due to my lack of experience merging patches), but I have finally merged and committed most of the Tree control tweaks into the gsoc branch with these changes: http://www.elijahlofgren.com/silverstripe/patches/Merge-Site-Tree-Tweaks-From-Steve-jsparty-gsoc-r37261.patch
> * I made it about 30% faster for expand/collapse (simply by iterating over the LIs instead of over the spans)
I assume that the following change was responsible for that fix (I couldn't find any others that seemed to fit):
@@ -237,10 +268,13 @@
startingPoint = 0;
childUL = null;
for(j=0;j<li.childNodes.length;j++) {
+ // Find last div before first ul (unnecessary in our usage)
+ /*
if(li.childNodes[j].tagName && li.childNodes[j].tagName.toLowerCase() == 'div') {
startingPoint = j + 1;
continue;
}
+ */
if(li.childNodes[j].tagName && li.childNodes[j].tagName.toLowerCase() == 'ul') {
childUL = li.childNodes[j];
> * I added openall and closeall support
This is really nice! We could possible add "Collapse All" and "Expand All" links to show when the "Reorder..." button is clicked:
http://www.elijahlofgren.com/silverstripe/diffs/Add-Site-Tree-Collapse-All-and-Expand-All-links-cms-gsoc-r37191.diff
> * I'm adding support for noticing if a server-side process has already kind put in all the spanA/spanB/spanC structure, and skip initTrees if so.
NOTE: I was unable to merge this in because initTree() no longer exists and I can't find a function that matches it close enough to merge this code.
> I've also fixed what I think of as a bug, namely that when you click on a title, in addition to following the link, it also toggles the expansion there as if you'd clicked on the +/-.
This bug did not seem to exist in the gsoc version of tree.js so I didn't merge in the workaround for it.
> I've also added internal documentation, since it took me a while to figure out some of the details of how it's doing what it does.
Thanks for this Steve!
Note: Many (that is, a lot!) of the changes in the diff I received were simply formatting changes of this nature:
83c145
< if(li) {
---
> if (li) {
129c192
< }
---
> } /* treeToggle */
I did not merge those in for the sake of clarity of changes. ;)
Let me know if there are any more changes I should make regarding this code.
Thanks,
Elijah