[Jifty-commit] r1111 - in jifty/trunk: lib/Jifty/Web

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue May 23 17:13:23 EDT 2006


Author: jesse
Date: Tue May 23 17:13:22 2006
New Revision: 1111

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web/Menu.pm

Log:
 r14024 at hualien:  jesse | 2006-05-23 16:40:15 -0400
 * Let the top-level item in a menu be a link


Modified: jifty/trunk/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Menu.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Menu.pm	Tue May 23 17:13:22 2006
@@ -175,7 +175,7 @@
     my @kids = $self->children;
     my $id = Jifty->web->serial;
     Jifty->web->out(
-        qq{<ul class="context_menu">} .qq{<li class="closed toplevel">}.  qq{<span class="title">} . $self->label() . qq{</span>}
+        qq{<ul class="context_menu">} .qq{<li class="closed toplevel">}.  qq{<span class="title">} . $self->as_link() . qq{</span>}
             . (
             @kids
             ? qq{<span class="expand"><a href="#" onClick="Jifty.ContextMenu.hideshow('}.$id.qq{'); return false;">+</a></span>}
@@ -200,11 +200,21 @@
 
 Return this menu item as a C<Jifty::Web::Link>, either the one we were initialized with or a new one made from the C</label> and c</url>
 
+If there's no C</url> and no C</link>, renders just the label.
+
 =cut
 
 sub as_link {
-     my $self = shift;
-     ($self->link ? $self->link : Jifty->web->link(label => _($self->label), url => $self->url)); 
+    my $self = shift;
+    if ( $self->link ) {
+        return $self->link;
+    } elsif ( $self->url ) {
+        return Jifty->web->link( label => _( $self->label ),
+            url => $self->url );
+
+    } else {
+        return _( $self->label );
+    }
 }
 
 1;


More information about the Jifty-commit mailing list