From cd98b7c9e66678b3f5fb501518757c86b6db1625 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 10 Apr 2008 19:40:17 +0000 Subject: [PATCH] Now the tree expander arrow only displays if there are actually any links within the note. --- static/css/style.css | 8 ++++++++ static/js/Wiki.js | 9 ++++++++- view/Note_tree_area.py | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/static/css/style.css b/static/css/style.css index fd69348..c48109c 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -525,10 +525,12 @@ img { .link_area_item { padding: 0.2em 0.25em 0.2em 0.5em; + font-size: 90%; } .note_tree_item { padding: 0.2em 0.25em 0.2em 0; + font-size: 90%; } .tree_expander { @@ -543,6 +545,12 @@ img { cursor: pointer; } +.tree_expander_empty { + float: left; + width: 20px; + height: 1.5em; +} + #storage_usage_area { padding-top: 0.1em; } diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 3714e1c..e2faf18 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -2588,12 +2588,19 @@ Note_tree.prototype.link_clicked = function ( event ) { event.stop(); } +LINK_PATTERN = /]+\s)?href="[^"]+"[^>]*>/; + Note_tree.prototype.add_link = function ( editor ) { // for now, only add startup notes to the note tree if ( !editor.startup ) return; - var expander = createDOM( "div", { "class": "tree_expander" } ); + // display the tree expander arrow if the given note's editor contains any outgoing links + if ( LINK_PATTERN.exec( editor.contents() ) ) + var expander = createDOM( "div", { "class": "tree_expander" } ); + else + var expander = createDOM( "div", { "class": "tree_expander_empty" } ); + var link = createDOM( "a", { "href": "/notebooks/" + this.notebook_id + "?note_id=" + editor.id, "id": "note_tree_link_" + editor.id, diff --git a/view/Note_tree_area.py b/view/Note_tree_area.py index bf86955..edeaae6 100644 --- a/view/Note_tree_area.py +++ b/view/Note_tree_area.py @@ -1,7 +1,10 @@ +import re from Tags import Div, Span, H4, A class Note_tree_area( Div ): + LINK_PATTERN = re.compile( u']+\s)?href="[^"]+"[^>]*>', re.IGNORECASE ) + def __init__( self, toolbar, notebook, root_notes, total_notes_count ): Div.__init__( self, @@ -15,7 +18,9 @@ class Note_tree_area( Div ): id = u"note_tree_area_title", ), [ Div( - Div( class_ = u"tree_expander" ), + self.LINK_PATTERN.search( note.contents ) and \ + Div( id = u"note_tree_expander_" + note.object_id, class_ = u"tree_expander" ) or + Div( id = u"note_tree_expander_" + note.object_id, class_ = u"tree_expander_empty" ), A( note.title or u"untitled note", href = u"/notebooks/%s?note_id=%s" % ( notebook.object_id, note.object_id ),