From 2fd9514a046260b0db928c5b85901d5d872313f9 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 14 Apr 2008 20:14:32 +0000 Subject: [PATCH] When the expander is clicked for a note id that's also a parent/grandparent/etc note, don't expand and just highlight the containing table. --- static/js/Wiki.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/static/js/Wiki.js b/static/js/Wiki.js index fecad37..08cde41 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -2670,6 +2670,23 @@ Note_tree.prototype.expand_link = function ( event, note_id ) { // if it's collapsed, expand it if ( hasElementClass( expander, "tree_expander" ) ) { + // first check if the expander is for a link to a parent/grandparent/etc. if so, just highlight + // the containing table instead of performing an expansion + var parent_node = expander.parentNode; + while ( !hasElementClass( parent_node, "note_tree_root_table" ) ) { + parent_node = parent_node.parentNode; + if ( !parent_node ) break; + var parent_link = parent_node.previousSibling; + + if ( !parent_link || !hasElementClass( parent_link, "note_tree_link" ) ) continue; + var parent_note_id = parse_query( parent_link )[ "note_id" ]; + + if ( note_id == parent_note_id ) { + new Highlight( parent_node.parentNode, { "endcolor": "#fafafa" } ); + return; + } + } + var children_area = createDOM( "div", { "class": "note_tree_children_area" }, createDOM( "span", { "class": "note_tree_loading" }, "loading..." ) );