X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLayout%2FJavascript.pm;h=e900012c0bbe5b476004af4d4195c090bfc8f385;hb=7196276bca4a155d1bcc3947859bc7d4ec1edcd6;hp=5ddb4d7fb772835085adade9dd9591a543d5b7b4;hpb=68dbf4a4cb26b9554a23f076438109d7fc2d861c;p=kivitendo-erp.git diff --git a/SL/Layout/Javascript.pm b/SL/Layout/Javascript.pm index 5ddb4d7fb..e900012c0 100644 --- a/SL/Layout/Javascript.pm +++ b/SL/Layout/Javascript.pm @@ -21,9 +21,29 @@ sub use_javascript { $self->SUPER::use_javascript(@_); } +sub javascripts_inline { + $_[0]->SUPER::javascripts_inline, +<<'EOJS' + DHTMLSuite.createStandardObjects(); + DHTMLSuite.configObj.setImagePath('image/dhtmlsuite/'); + var menu_model = new DHTMLSuite.menuModel(); + menu_model.addItemsFromMarkup('main_menu_model'); + menu_model.init(); + var menu_bar = new DHTMLSuite.menuBar(); + menu_bar.addMenuItems(menu_model); + menu_bar.setTarget('main_menu_div'); + menu_bar.init(); +EOJS +} + sub pre_content { $_[0]->SUPER::pre_content . - &display + $_[0]->presenter->render("menu/menunew", + force_ul_width => 1, + menu => $_[0]->menu, + icon_path => sub { my $img = "image/icons/16x16/$_[0].png"; -f $img ? $img : () }, + max_width => sub { 10 * max map { length $::locale->text($_->{name}) } @{ $_[0]{children} || [] } }, + ); } sub start_content { @@ -39,89 +59,9 @@ sub stylesheets { dhtmlsuite/menu-item.css dhtmlsuite/menu-bar.css icons16.css - frame_header/header.css menu.css )); $_[0]->SUPER::stylesheets; } -sub display { - my ($self) = @_; - - $self->presenter->render("menu/menunew", - force_ul_width => 1, - menu_items => $self->acc_menu, - ); -} - -sub acc_menu { - my ($self) = @_; - - my $menu = $self->menu; - - my $all_items = []; - $self->create_menu($menu, $all_items); - - my $item = { 'subitems' => $all_items }; - calculate_width($item); - - return $all_items; -} - -sub calculate_width { - my $item = shift; - - $item->{max_width} = max map { length $_->{title} } @{ $item->{subitems} }; - - foreach my $subitem (@{ $item->{subitems} }) { - calculate_width($subitem) if ($subitem->{subitems}); - } -} - -sub create_menu { - my ($self, $menu, $all_items, $parent, $depth) = @_; - my $html; - - my $form = $main::form; - my %myconfig = %main::myconfig; - - $depth ||= 0; - - die if ($depth * 1 > 5); - - my @menuorder = $menu->access_control(\%myconfig, $parent); - $parent .= "--" if ($parent); - $parent ||= ''; - - foreach my $name (@menuorder) { - substr($name, 0, length($parent), ""); - next if (($name eq "") || ($name =~ /--/)); - - my $menu_item = $menu->{"${parent}${name}"}; - my $item = { 'title' => $::locale->text($name) }; - push @{ $all_items }, $item; - - if ($menu_item->{submenu} || (!defined($menu_item->{module}) && !defined($menu_item->{href}))) { - $item->{subitems} = []; - $item->{image} = _icon_path("$name.png"); - $self->create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1); - - } else { - $item->{image} = _icon_path("${parent}${name}.png"); - $menu->menuitem_new("${parent}${name}", $item); - } - } -} - -sub _icon_path { - my ($label, $size) = @_; - - $size ||= 16; - - my $img = "image/icons/${size}x${size}/$label"; - - return unless -f $img; - return $img; -} - 1;