1 package SL::Layout::MenuLeft;
4 use parent qw(SL::Layout::Base);
6 use List::MoreUtils qw(apply);
7 use SL::JSON qw(to_json);
10 sub static_stylesheets {
11 qw(icons16.css icons24.css menu.css)
14 sub javascripts_inline {
15 "\$(function(){kivi.LeftMenu.init(@{[ to_json([ section_menu($_[0]->menu) ]) ]})});"
18 sub static_javascripts {
26 "<div id='html-menu'></div>\n";
34 for my $node ($menu->tree_walk) {
35 my $level = $node->{level};
38 push @id_stack, -1 if $level > $#id_stack;
39 pop @id_stack while $level < $#id_stack;
42 my $label = $::locale->text($node->{name});
43 my $href = $menu->href_for_node($node);
45 my @common_args = ($label, "s" . $level, join '_', @id_stack);
47 if (!$node->{parent}) { # toplevel
48 push @items, [ @common_args, "icon24 $node->{icon}", 'm' ];
49 } elsif ($node->{children}) {
50 push @items, [ @common_args, "icon16 submenu", 'sm' ];
52 push @items, [ @common_args, "icon16 $node->{icon}", 'i', $href, $node->{target} ];
60 my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i;
61 my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i;
62 my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i;
64 return $is_mobile_browser && $is_mobile_style ? 130
65 : $is_lynx_browser ? 240
70 # don't show images in links
71 _calc_framesize() != 240;
82 SL::Layout::MenuLeft - ex html meanu, now only left menu
86 Data will be embedded into the page as a json array of entries.
87 Each entry is another array with the following fields:
90 1: indentation classes
97 From each entry the following dom will be generated, with [0] being entry 0 of
100 <div id="mi[2]" class="mi [4] [1]">
102 <span class="mii ms">
103 <div class="[3]"></div>
105 <span class="mic">[0]</span>
109 The classes are minified to keep the json somewhat in check, their meaning is as follows:
113 =item Indentation Classes
116 s1: One level of indentation
117 s2: Two levels of indentation
121 Each icon consists of two classes, one for the icon, and one for the size.
122 The icon classes are taken from the file names, for example C<Master-Data> is
123 the icon for master data, and refers to Master-Icon.png.
131 Role classes may be used to style types of links differently. Currently used:
133 ml: menu link, any <a> tag will have this
134 mi: menu item, the enclosing div for each entry has this
135 mii: menu item icon, the enclosing div for the icons has this
136 ms: menu spacer, the first <span> in the link will have this
137 m: menu, only top level entries have this
138 i: item, only leaf entries have this
139 sm: sub menu, eveything that is not top nor leaf has this
140 mic: menu item content, the span with the human readable description has this
150 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>