X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FLayout%2FJavascript.pm;h=85454c4ee658869f19ef7fdcfbf980e316ef045e;hb=211f4e60ebc94a7fd73564ca750f7f52f416773f;hp=b08cf6dccbb715796d12162ad291058db77d57b1;hpb=cd73950c9f7616255cf917e36a6e1a03627f860d;p=kivitendo-erp.git
diff --git a/SL/Layout/Javascript.pm b/SL/Layout/Javascript.pm
index b08cf6dcc..85454c4ee 100644
--- a/SL/Layout/Javascript.pm
+++ b/SL/Layout/Javascript.pm
@@ -3,150 +3,78 @@ package SL::Layout::Javascript;
use strict;
use parent qw(SL::Layout::Base);
+use SL::Layout::None;
+use SL::Layout::Top;
+use SL::Layout::ActionBar;
+use SL::Layout::Content;
+
use List::Util qw(max);
+use List::MoreUtils qw(uniq);
use URI;
sub init_sub_layouts {
- [ SL::Layout::None->new ]
+ $_[0]->sub_layouts_by_name->{actionbar} = SL::Layout::ActionBar->new;
+ [
+ SL::Layout::None->new,
+ SL::Layout::Top->new,
+ SL::Layout::Content->new,
+ ]
}
-sub use_javascript {
- my $self = shift;
- qw(
- js/quicksearch_input.js
- ),
- $self->SUPER::use_javascript(@_);
-}
+sub javascripts {
+ my ($self) = @_;
-sub pre_content {
- &display
+ return uniq grep { $_ } map { $self->_find_javascript($_) }
+ map({ $_->javascripts } $self->sub_layouts),
+ qw(dhtmlsuite/menu-for-applications.js),
+ $_[0]->sub_layouts_by_name->{actionbar}->javascripts,
+ $self->use_javascript;
}
-sub start_content {
- "
\n";
+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
+ $_[0]->sub_layouts_by_name->{actionbar}->javascripts_inline,
}
-sub end_content {
- "
\n";
+sub pre_content {
+ $_[0]->SUPER::pre_content .
+ $_[0]->presenter->render("menu/menunew",
+ force_ul_width => 1,
+ menu => $_[0]->menu,
+ icon_path => sub { my $simg = "image/icons/svg/$_[0].svg"; my $pimg="image/icons/16x16/$_[0].png"; -f $simg ? $simg : ( -f $pimg ? $pimg : ()) },
+ max_width => sub { 10 * max map { length $::locale->text($_->{name}) } @{ $_[0]{children} || [] } },
+ ) .
+ ($_[0]->sub_layouts_by_name->{actionbar}->pre_content // '');
}
sub stylesheets {
- $_[0]->add_stylesheets(qw(
- dhtmlsuite/menu-item.css
- dhtmlsuite/menu-bar.css
- menu.css
- ));
- $_[0]->SUPER::stylesheets;
-}
-
-sub display {
my ($self) = @_;
- my $form = $main::form;
-
- my $callback = $form->unescape($form->{callback});
- $callback = URI->new($callback)->rel($callback) if $callback;
- $callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
-
- $self->presenter->render("menu/menunew",
- force_ul_width => 1,
- date => $self->clock_line,
- menu_items => $self->acc_menu,
- callback => $callback,
- );
-}
-
-sub clock_line {
- my $form = $main::form;
+ my $css_path = $self->get_stylesheet_for_user;
- my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat,
- $Jahr, $Wochentag, $Jahrestag, $Sommerzeit)
- = localtime(time);
- $Monat += 1;
- $Jahrestag += 1;
- $Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat;
- $Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag;
- $Jahr += 1900;
- my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch",
- "Donnerstag", "Freitag", "Samstag");
- my @Monatsnamen = ("", "Januar", "Februar", "März",
- "April", "Mai", "Juni", "Juli",
- "August", "September", "Oktober", "November",
- "Dezember");
return
- $Wochentage[$Wochentag] . ", der "
- . $Monatstag . "."
- . $Monat . "."
- . $Jahr . " - ";
-}
-
-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;
+ uniq
+ grep { $_ }
+ map { $self->_find_stylesheet($_, $css_path) }
+ qw(
+ dhtmlsuite/menu-item.css
+ dhtmlsuite/menu-bar.css
+ icons16.css
+ menu.css
+ ),
+ ( map { $_->stylesheets } $_[0]->sub_layouts ),
+ $_[0]->sub_layouts_by_name->{actionbar}->stylesheets,
+ $_[0]->use_stylesheet;
}
1;