/* * ul2finder * written by Christian Heilmann (http://icant.co.uk) * support for closing the finder items added by Silvio (s1lv10 at uol.com.br) * turns the nested list with the ID "finder" into a dynamic list * uses the CSS classes defined in the variables */ function ul2finder() { // Define variables used and classes to be applied/removed var i,uls,als,finder; var parentClass='parent'; var showClass='shown'; var hideClass='hidden'; var openClass='open'; window.finderOpened = new Object(); window.finderHook = new Object(); // check if our finder list exists, if not, stop all activities finder=document.getElementById('finder'); if(!finder){return;} // add the class domenabled to the body cssjs('add',document.body,'domenabled'); // loop through all lists inside finder, position and hide them // by applying the class hidden uls=finder.getElementsByTagName('ul'); for(i=0;i= 0) { return true; } return false; } /* * connected * written by Silvio (s1lv10 at uol.com.br) * checks if two elements are connect via DOM, either by one being * child of parent of the another. */ function connected(a,b) { if (a == b) { return true; } else if (isparent(a,b) || isparent(b,a)) { return true; } return false; } /* * cssjs * written by Christian Heilmann (http://icant.co.uk) * eases the dynamic application of CSS classes via DOM * parameters: action a, object o and class names c1 and c2 (c2 optional) * actions: swap exchanges c1 and c2 in object o * add adds class c1 to object o * remove removes class c1 from object o * check tests if class c1 is applied to object o * example: cssjs('swap',document.getElementById('foo'),'bar','baz'); */ function cssjs(a,o,c1,c2) { switch (a){ case 'swap': o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2); break; case 'add': if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;} break; case 'remove': var rep=o.className.match(' '+c1)?' '+c1:c1; o.className=o.className.replace(rep,''); break; case 'check': return new RegExp('\\b'+c1+'\\b').test(o.className) break; } } } Drupal.behaviors.finderMenu = function() { $('#finder:not(.finder-menu-processed)').addClass('finder-menu-processed').each(function() { ul2finder(); // Remove hidden class, used to hide finder if no js is available. $('#finder').removeClass('finder-degraded'); }); };