Prophet

 view release on metacpan or  search on metacpan

lib/Prophet/Web/Menu.pm  view on Meta::CPAN


__PACKAGE__->meta->make_immutable;
no Any::Moose;

1;

__END__

=pod

=head1 NAME

Prophet::Web::Menu - Handle the API for menu navigation

=head1 VERSION

version 0.751

=head1 ATTRIBUTES

=head2 label [STRING]

Sets or returns the string that the menu item will be displayed as.

=head2 parent [MENU]

Gets or sets the parent L<Prophet::Web::Menu> of this item; this defaults to
null. This ensures that the reference is weakened.

=head2 sort_order [NUMBER]

Gets or sets the sort order of the item, as it will be displayed under the
parent.  This defaults to adding onto the end.

=head2 target [STRING]

Get or set the frame or pseudo-target for this link. something like L<_blank>

=head2 link

Gets or set a Jifty::Web::Link object that represents this menu item. If you're
looking to do complex ajaxy things with menus, this is likely the option you
want.

=head1 METHODS

=head2 new PARAMHASH

Creates a new L<Prophet::Web::Menu> object.  Possible keys in the I<PARAMHASH>
are C<label>, C<parent>, C<sort_order>, C<url>, and C<active>.  See the
subroutines with the respective name below for each option's use.

=head2 url

Gets or sets the URL that the menu's link goes to.  If the link provided is not
absolute (does not start with a "/"), then is is treated as relative to it's
parent's url, and made absolute.

=head2 active [BOOLEAN]

Gets or sets if the menu item is marked as active.  Setting this cascades to
all of the parents of the menu item.

=head2 child KEY [, PARAMHASH]

If only a I<KEY> is provided, returns the child with that I<KEY>.

Otherwise, creates or overwrites the child with that key, passing the
I<PARAMHASH> to L<Jifty::Web::Menu/new>.  Additionally, the paramhash's
C<label> defaults to the I<KEY>, and the C<sort_order> defaults to the
pre-existing child's sort order (if a C<KEY> is being over-written) or the end
of the list, if it is a new C<KEY>.

=head2 active_child

Returns the first active child node, or C<undef> is there is none.

=head2 delete KEY

Removes the child with the provided I<KEY>.

=head2 children

Returns the children of this menu item in sorted order; as an array in array
context, or as an array reference in scalar context.

=head2 render_as_menubar [PARAMHASH]

Render menubar with YUI menu, suitable for an application's menu. It can
support arbitrary levels of submenu.

=head2 as_link

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.

=head2 class [STRING]

Gets or sets the CSS class the link should have in addition to the default
classes.  This is only used if C<link> isn't specified.

=head1 AUTHORS

=over 4

=item *

Jesse Vincent <jesse@bestpractical.com>

=item *

Chia-Liang Kao <clkao@bestpractical.com>

=item *

Christine Spang <christine@spang.cc>

=back



( run in 1.232 second using v1.01-cache-2.11-cpan-df04353d9ac )