witten
/
luminotes
Archived
1
0
Fork 0

Clicking an external link or a file link in the note tree now opens with target=_new.

This commit is contained in:
Dan Helfman 2008-04-12 02:32:11 +00:00
parent 3499aa3624
commit 0d4bb81943
3 changed files with 10 additions and 7 deletions

View File

@ -489,12 +489,12 @@ class Notebooks( object ):
# if it has a link target, it's a link to an external web site
if target:
items.append( Note_tree_area.make_item( title, attributes, "note_tree_external_link" ) )
items.append( Note_tree_area.make_item( title, attributes, u"note_tree_external_link", target = u"_new" ) )
continue
# if it has '/files/' in its path, it's an uploaded file link
if self.FILE_PATTERN.search( href ):
items.append( Note_tree_area.make_item( title, attributes, "note_tree_file_link" ) )
items.append( Note_tree_area.make_item( title, attributes, u"note_tree_file_link", target = u"_new" ) )
continue
# if it has a note_id, load that child note and see whether it has any children of its own
@ -504,11 +504,11 @@ class Notebooks( object ):
child_note_id = child_note_ids[ 0 ]
child_note = self.__database.load( Note, child_note_id )
if child_note and self.LINK_PATTERN.search( child_note.contents ):
items.append( Note_tree_area.make_item( title, attributes, "note_tree_link", has_children = True ) )
items.append( Note_tree_area.make_item( title, attributes, u"note_tree_link", has_children = True ) )
continue
# otherwise, it's childless
items.append( Note_tree_area.make_item( title, attributes, "note_tree_link", has_children = False ) )
items.append( Note_tree_area.make_item( title, attributes, u"note_tree_link", has_children = False ) )
return dict(
tree_html = unicode( Note_tree_area.make_tree( items ) ),

View File

@ -2690,6 +2690,8 @@ Note_tree.prototype.expand_link = function ( event, note_id ) {
}
);
// TODO: add onclick handler for each link that's to a note
return;
}

View File

@ -35,15 +35,16 @@ class Note_tree_area( Div ):
)
@staticmethod
def make_item( title, link_attributes, link_class, has_children = False, root_note_id = None ):
def make_item( title, link_attributes, link_class, has_children = False, root_note_id = None, target = None ):
return Tr(
has_children and \
Td( id = root_note_id and u"note_tree_expander_" + root_note_id or None, class_ = u"tree_expander" ) or
Td( id = root_note_id and u"note_tree_expander_" + root_note_id or None, class_ = u"tree_expander_empty" ),
Td(
u"<a %s%s class=%s>%s</a>" % (
u"<a %s%s%s class=%s>%s</a>" % (
link_attributes,
root_note_id and u" id=note_tree_link_" + root_note_id or None,
root_note_id and u' id="note_tree_link_%s"' % root_note_id or "",
target and u' target="%s"' % target or "",
link_class,
title or u"untitled note",
),