From e11301512d37d53cecc845fa9359be7ad2c84d51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 27 Oct 2016 16:27:15 +0200 Subject: [PATCH] Javascript Layout: ActionBar --- SL/Layout/Javascript.pm | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/SL/Layout/Javascript.pm b/SL/Layout/Javascript.pm index 76728ef91..3b170a46f 100644 --- a/SL/Layout/Javascript.pm +++ b/SL/Layout/Javascript.pm @@ -5,12 +5,15 @@ 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 { + $_[0]->sub_layouts_by_name->{actionbar} = SL::Layout::ActionBar->new; [ SL::Layout::None->new, SL::Layout::Top->new, @@ -18,17 +21,19 @@ sub init_sub_layouts { ] } -sub use_javascript { - my $self = shift; - qw( - js/dhtmlsuite/menu-for-applications.js - ), - $self->SUPER::use_javascript(@_); +sub javascripts { + my ($self) = @_; + + 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 javascripts_inline { $_[0]->SUPER::javascripts_inline, -<<'EOJS' +<<'EOJS', DHTMLSuite.createStandardObjects(); DHTMLSuite.configObj.setImagePath('image/dhtmlsuite/'); var menu_model = new DHTMLSuite.menuModel(); @@ -39,6 +44,7 @@ sub javascripts_inline { menu_bar.setTarget('main_menu_div'); menu_bar.init(); EOJS + $_[0]->sub_layouts_by_name->{actionbar}->javascripts_inline, } sub pre_content { @@ -48,17 +54,27 @@ sub pre_content { 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 - icons16.css - menu.css - )); - $_[0]->SUPER::stylesheets; + my ($self) = @_; + my $css_path = $self->get_stylesheet_for_user; + + return + 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; -- 2.20.1