From e366e324a709d7bb022e82beb460cc09b2fd89f8 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 10 Feb 2009 22:08:42 -0800 Subject: [PATCH] Note tree link order now updates when notes are themselves reordered. --- static/js/Wiki.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 763aa43..180db1f 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1046,6 +1046,8 @@ Wiki.prototype.editor_focused = function ( editor, synchronous, remove_empty ) { Wiki.prototype.editor_moved = function ( editor, position_after, position_before ) { this.save_editor( editor, false, null, null, null, position_after, position_before ); + if ( this.note_tree ) + this.note_tree.move_link( editor, position_after, position_before ); // reset the revision for each open editor. this is because the server is updating the revisions // on the server while reordering the ntoes. and we don't want to have a stale idea of what the @@ -4649,7 +4651,7 @@ Note_tree.prototype.display_child_links = function ( result, link, children_area if ( expander && link.parentNode.parentNode == expander.parentNode.parentNode ) { swapElementClass( expander, "tree_expander_expanded", "tree_expander_empty" ); disconnectAll( expander ); - return; + return } return; @@ -4664,6 +4666,18 @@ Note_tree.prototype.display_child_links = function ( result, link, children_area connect_expander( expander, note_id ); } +Note_tree.prototype.move_link = function ( editor, position_after, position_before ) { + var item = getElement( "note_tree_item_" + editor.id ); + + if ( position_after ) { + var after_item = getElement( "note_tree_item_" + position_after.id ); + insertSiblingNodesAfter( after_item, item ); + } else if ( position_before ) { + var before_item = getElement( "note_tree_item_" + position_before.id ); + insertSiblingNodesBefore( before_item, item ); + } +} + Note_tree.prototype.start_link_add = function () { // if the add is already in progress, end the add instead of starting one var new_note_tree_link_field = getElement( "new_note_tree_link_field" ); @@ -4786,6 +4800,7 @@ Note_tree.prototype.save_and_display_startup_note = function ( note ) { } ); } + function Recent_notes( wiki, notebook_id, invoker ) { this.wiki = wiki; this.notebook_id = notebook_id;