use Rose::Object::MakeMethods::Generic (
'scalar --get_set_init' => qw(menu),
+ 'array' => [
+ 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' },
+ 'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' },
+ 'sub_layouts',
+ 'add_sub_layouts' => { interface => 'add', hash_key => 'sub_layouts' },
+ ],
);
use SL::Menu;
##########################################
sub pre_content {
+ join '', map { $_->pre_content } $_[0]->sub_layouts;
}
sub start_content {
+ join '', map { $_->start_content } $_[0]->sub_layouts;
}
sub end_content {
+ join '', map { $_->end_content } $_[0]->sub_layouts;
}
sub post_content {
+ join '', map { $_->post_content } $_[0]->sub_layouts;
}
sub stylesheets_inline {
+ ( map { $_->stylesheets_inline } $_[0]->sub_layouts ),
+ @{ $_[0]->{stylesheets_inline} || [] };
}
-sub javascript_inline {
+sub javascripts_inline {
+ ( map { $_->javascripts_inline } $_[0]->sub_layouts ),
+ @{ $_[0]->{javascripts_inline} || [] };
}
+
#########################################
# Interface
########################################
my ($self) = @_;
my $css_path = $self->get_stylesheet_for_user;
- return grep { $_ } map { $self->_find_stylesheet($_, $css_path) } $self->use_stylesheet;
+ return grep { $_ } map { $self->_find_stylesheet($_, $css_path) }
+ $self->use_stylesheet, map { $_->stylesheets } $self->sub_layouts;
}
sub _find_stylesheet {
sub use_javascript {
my $self = shift;
- $::lxdebug->dump(0, "class", \@_);
push @{ $self->{javascripts} ||= [] }, @_ if @_;
@{ $self->{javascripts} ||= [] };
}
sub javascripts {
my ($self) = @_;
- return map { $self->_find_javascript($_) } $self->use_javascript;
+ return map { $self->_find_javascript($_) }
+ $self->use_javascript, map { $_->javascripts } $self->sub_layouts;
}
sub _find_javascript {
my $self = $class->SUPER::new(@slurp);
- $self->{top} = SL::Controller::Layout::Top->new;
- $self->{left} = SL::Controller::Layout::MenuLeft->new;
-
- $self->use_stylesheet(
- $self->{top}->stylesheets,
- $self->{left}->stylesheets,
- );
-
- $self->use_javascript(
- $self->{top}->javascripts,
- $self->{left}->javascripts,
- );
+ $self->add_sub_layouts([
+ SL::Controller::Layout::Top->new,
+ SL::Controller::Layout::MenuLeft->new,
+ ]);
$self;
}
-sub pre_content {
- $_[0]{top}->render .
- $_[0]{left}->render;
-}
-
-sub start_content {
- "<div id='content' class='html-menu'>\n";
-}
-
-sub end_content {
- "</div>\n";
-}
-
1;
my $self = $class->SUPER::new(@slurp);
- $self->use_stylesheet(qw(css/icons16.css css/icons24.css));
-
$self;
}
-sub render {
- my ($self) = @_;
- my $sections = [ section_menu($self->menu) ];
+sub stylesheets {
+ qw(css/icons16.css css/icons24.css)
+}
- $self->SUPER::render('menu/menu', { no_menu => 1, no_output => 1 },
+sub javascripts_inline {
+ my $self = shift;
+ my $sections = [ section_menu($self->menu) ];
+ $self->render('menu/menu', { no_menu => 1, no_output => 1 },
sections => $sections,
- );
+ )
+}
+
+sub pre_content {
+ "<div id='html-menu'></div>\n";
+}
+
+sub start_content {
+ "<div id='content' class='html-menu'>\n";
+}
+
+sub end_content {
+ "</div>\n";
}
sub section_menu {
use strict;
use parent qw(SL::Controller::Layout::Base);
-sub render {
+sub pre_content {
my ($self) = @_;
$self->SUPER::render('menu/header', { partial => 1, no_output => 1 },
my ($class, @slurp) = @_;
my $self = $class->SUPER::new(@slurp);
- $self->{top} = SL::Controller::Layout::Top->new;
+ $self->add_sub_layouts(SL::Controller::Layout::Top->new);
$self;
}
-sub pre_content {
- $_[0]{top}->render .
- &render;
-}
-
-sub stylesheets {
- $_[0]{top}->stylesheets
-}
-
sub start_content {
"<div id='content'>\n";
}
"</div>\n";
}
-sub render {
+sub pre_content {
my ($self) = @_;
$self->{sub_class} = 1;
$callback = URI->new($callback)->rel($callback) if $callback;
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/;
+ $self->SUPER::pre_content .
+
$self->SUPER::render('menu/menuv4', { no_menu => 1, no_output => 1 },
force_ul_width => 1,
date => $self->clock_line,
print $::request->{layout}->end_content;
print $::request->{layout}->post_content;
-# print "<script type='text/javascript' src='$_'></script>\n" for $::request->{layout}->javascripts;
-# if (my @inline_scripts = $::request->{layout}->javascript_inline) {
-# print "<script type='text/javascript'>$_</script>\n" for @inline_scripts;
-# }
+
+ if (my @inline_scripts = $::request->{layout}->javascripts_inline) {
+ print "<script type='text/javascript'>$_</script>\n" for @inline_scripts;
+ }
print <<EOL
</body>
[%- USE JSON %]
-<div id='html-menu'></div>
-<script type='text/javascript'>$(function(){$([% JSON.json(sections) %]).each(function(i,b){var a=$('<a class="ml">').append($('<span class="mii ms">').append($('<div>').addClass(b.i)),$('<span class="mic">').append(b.l));if(b.h)a.attr('href', b.h);if(b.t)a.attr('target', b.t);$('#html-menu').append($('<div class="mi">').addClass(b.c).addClass(b.s).attr('id','mi'+b.id).append(a))});$('#html-menu div.i, #html-menu div.sm').not('[id^='+$.cookie('html-menu-selection')+'_]').hide();$('#html-menu div.m').each(function(){$(this).click(function(){$.cookie('html-menu-selection',$(this).attr('id'));$('#html-menu div.mi').not('div.m').not('[id^='+$(this).attr('id')+'_]').hide();$('#html-menu div.mi[id^='+$(this).attr('id')+'_]').toggle()})})})</script>
+$(function(){$([% JSON.json(sections) %]).each(function(i,b){var a=$('<a class="ml">').append($('<span class="mii ms">').append($('<div>').addClass(b.i)),$('<span class="mic">').append(b.l));if(b.h)a.attr('href', b.h);if(b.t)a.attr('target', b.t);$('#html-menu').append($('<div class="mi">').addClass(b.c).addClass(b.s).attr('id','mi'+b.id).append(a))});$('#html-menu div.i, #html-menu div.sm').not('[id^='+$.cookie('html-menu-selection')+'_]').hide();$('#html-menu div.m').each(function(){$(this).click(function(){$.cookie('html-menu-selection',$(this).attr('id'));$('#html-menu div.mi').not('div.m').not('[id^='+$(this).attr('id')+'_]').hide();$('#html-menu div.mi[id^='+$(this).attr('id')+'_]').toggle()})})})