[Rt-commit] rt branch, 4.2/arbitrary-menu-attributes, created. rt-4.1.17-175-ga1f55bf
Thomas Sibley
trs at bestpractical.com
Wed Jul 31 17:56:16 EDT 2013
The branch, 4.2/arbitrary-menu-attributes has been created
at a1f55bfb2bb760b454f6d30ff7acbf66efd57657 (commit)
- Log -----------------------------------------------------------------
commit a1f55bfb2bb760b454f6d30ff7acbf66efd57657
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Jul 31 14:55:12 2013 -0700
Support arbitrary HTML attributes on menu items
This lets extensions add whatever hooks they need to enhance menu items.
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c7af47c..78b928a 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1760,6 +1760,14 @@ sub RenderMenu {
if ( $tmp = $child->target ) {
$res .= ' target="'. $interp->apply_escapes($tmp, 'h') .'"'
}
+
+ if ($child->attributes) {
+ for my $key (keys %{$child->attributes}) {
+ my ($name, $value) = map { $interp->apply_escapes($_, 'h') }
+ $key, $child->attributes->{$key};
+ $res .= " $name=\"$value\"";
+ }
+ }
$res .= '>';
if ( $child->escape_title ) {
diff --git a/lib/RT/Interface/Web/Menu.pm b/lib/RT/Interface/Web/Menu.pm
index e4e08d6..3343b9b 100644
--- a/lib/RT/Interface/Web/Menu.pm
+++ b/lib/RT/Interface/Web/Menu.pm
@@ -57,7 +57,7 @@ use URI;
use Scalar::Util qw(weaken);
__PACKAGE__->mk_accessors(qw(
- key title description raw_html escape_title sort_order target class
+ key title description raw_html escape_title sort_order target class attributes
));
=head1 NAME
@@ -70,9 +70,9 @@ RT::Interface::Web::Menu - Handle the API for menu navigation
Creates a new L<RT::Interface::Web::Menu> object. Possible keys in the
I<PARAMHASH> are L</parent>, L</title>, L</description>, L</path>,
-L</raw_html>, L<escape_title>, L</sort_order>, L</class>, L</target> and
-L</active>. See the subroutines with the respective name below for
-each option's use.
+L</raw_html>, L<escape_title>, L</sort_order>, L</class>, L</target>,
+L<attributes>, and L</active>. See the subroutines with the respective name
+below for each option's use.
=cut
@@ -139,6 +139,12 @@ Get or set the frame or pseudo-target for this link. something like L<_blank>
Gets or sets the CSS class the menu item should have in addition to the default
classes. This is only used if L</raw_html> isn't specified.
+=head2 attributes [HASHREF]
+
+Gets or sets a hashref of HTML attribute name-value pairs that the menu item
+should have in addition to the attributes which have their own accessor, like
+L</class> and L</target>. This is only used if L</raw_html> isn't specified.
+
=head2 path
Gets or sets the URL that the menu's link goes to. If the link
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list