| HTML-Widgets-NavMenu documentation | Contained in the HTML-Widgets-NavMenu distribution. |
HTML::Widgets::NavMenu::Tree::Node - an iterator for HTML.
For internal use only.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Internal use.
Expands the node.
Marks the node as the current node.
Propagate changes.
Adds a new subroutine.
Get the $idx sub.
Customisation to list the regular keys.
Customisation to list the boolean keys.
Set the values from the hash ref.
Tests whether the node is expanded and in a capturing way.
Copyright 2006 Shlomi Fish, all rights reserved.
This program is released under the following license: MIT X11.
| HTML-Widgets-NavMenu documentation | Contained in the HTML-Widgets-NavMenu distribution. |
package HTML::Widgets::NavMenu::Tree::Node; use strict; use warnings; use base 'HTML::Widgets::NavMenu::Object'; __PACKAGE__->mk_acc_ref([ qw( CurrentlyActive expanded hide host role rec_url_type separator show_always skip subs text title url url_is_abs url_type )] ); use HTML::Widgets::NavMenu::ExpandVal;
sub _init { my $self = shift; $self->subs([]); return $self; }
sub expand { my $self = shift; my $v = @_ ? (shift(@_)) : HTML::Widgets::NavMenu::ExpandVal->new({capture => 1}) ; # Don't set it to something if it's already capture_expanded(), # otherwise it can set as a non-capturing expansion. if (! $self->capture_expanded()) { $self->expanded($v); } return 0; }
sub mark_as_current { my $self = shift; $self->expand(); $self->CurrentlyActive(1); return 0; } sub _process_new_sub { my $self = shift; my $sub = shift; $self->update_based_on_sub($sub); }
sub update_based_on_sub { my $self = shift; my $sub = shift; if (my $expand_val = $sub->expanded()) { $self->expand($expand_val); } }
sub add_sub { my $self = shift; my $sub = shift; push (@{$self->subs}, $sub); $self->_process_new_sub($sub); return 0; }
sub get_nth_sub { my $self = shift; my $idx = shift; return $self->subs()->[$idx]; } sub _num_subs { my $self = shift; return scalar(@{$self->subs()}); }
sub list_regular_keys { my $self = shift; return (qw(host rec_url_type role show_always text title url url_type)); }
sub list_boolean_keys { my $self = shift; return (qw(hide separator skip url_is_abs)); }
sub set_values_from_hash_ref { my $self = shift; my $sub_contents = shift; foreach my $key ($self->list_regular_keys()) { if (exists($sub_contents->{$key})) { $self->$key($sub_contents->{$key}); } } foreach my $key ($self->list_boolean_keys()) { if ($sub_contents->{$key}) { $self->$key(1); } } }
sub capture_expanded { my $self = shift; if (my $e = $self->expanded()) { return $e->is_capturing(); } else { return; } }
1;