Revision a8814e0e
Von Sven Schöling vor etwa 12 Jahren hinzugefügt
SL/Controller/Layout/Base.pm | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use Rose::Object::MakeMethods::Generic ( |
7 | 7 |
'scalar --get_set_init' => qw(menu), |
8 |
'array' => [ |
|
9 |
'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' }, |
|
10 |
'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' }, |
|
11 |
'sub_layouts', |
|
12 |
'add_sub_layouts' => { interface => 'add', hash_key => 'sub_layouts' }, |
|
13 |
], |
|
8 | 14 |
); |
9 | 15 |
|
10 | 16 |
use SL::Menu; |
... | ... | |
26 | 32 |
########################################## |
27 | 33 |
|
28 | 34 |
sub pre_content { |
35 |
join '', map { $_->pre_content } $_[0]->sub_layouts; |
|
29 | 36 |
} |
30 | 37 |
|
31 | 38 |
sub start_content { |
39 |
join '', map { $_->start_content } $_[0]->sub_layouts; |
|
32 | 40 |
} |
33 | 41 |
|
34 | 42 |
sub end_content { |
43 |
join '', map { $_->end_content } $_[0]->sub_layouts; |
|
35 | 44 |
} |
36 | 45 |
|
37 | 46 |
sub post_content { |
47 |
join '', map { $_->post_content } $_[0]->sub_layouts; |
|
38 | 48 |
} |
39 | 49 |
|
40 | 50 |
sub stylesheets_inline { |
51 |
( map { $_->stylesheets_inline } $_[0]->sub_layouts ), |
|
52 |
@{ $_[0]->{stylesheets_inline} || [] }; |
|
41 | 53 |
} |
42 | 54 |
|
43 |
sub javascript_inline { |
|
55 |
sub javascripts_inline { |
|
56 |
( map { $_->javascripts_inline } $_[0]->sub_layouts ), |
|
57 |
@{ $_[0]->{javascripts_inline} || [] }; |
|
44 | 58 |
} |
45 | 59 |
|
60 |
|
|
46 | 61 |
######################################### |
47 | 62 |
# Interface |
48 | 63 |
######################################## |
... | ... | |
57 | 72 |
my ($self) = @_; |
58 | 73 |
my $css_path = $self->get_stylesheet_for_user; |
59 | 74 |
|
60 |
return grep { $_ } map { $self->_find_stylesheet($_, $css_path) } $self->use_stylesheet; |
|
75 |
return grep { $_ } map { $self->_find_stylesheet($_, $css_path) } |
|
76 |
$self->use_stylesheet, map { $_->stylesheets } $self->sub_layouts; |
|
61 | 77 |
} |
62 | 78 |
|
63 | 79 |
sub _find_stylesheet { |
... | ... | |
89 | 105 |
|
90 | 106 |
sub use_javascript { |
91 | 107 |
my $self = shift; |
92 |
$::lxdebug->dump(0, "class", \@_); |
|
93 | 108 |
push @{ $self->{javascripts} ||= [] }, @_ if @_; |
94 | 109 |
@{ $self->{javascripts} ||= [] }; |
95 | 110 |
} |
... | ... | |
97 | 112 |
sub javascripts { |
98 | 113 |
my ($self) = @_; |
99 | 114 |
|
100 |
return map { $self->_find_javascript($_) } $self->use_javascript; |
|
115 |
return map { $self->_find_javascript($_) } |
|
116 |
$self->use_javascript, map { $_->javascripts } $self->sub_layouts; |
|
101 | 117 |
} |
102 | 118 |
|
103 | 119 |
sub _find_javascript { |
SL/Controller/Layout/Classic.pm | ||
---|---|---|
11 | 11 |
|
12 | 12 |
my $self = $class->SUPER::new(@slurp); |
13 | 13 |
|
14 |
$self->{top} = SL::Controller::Layout::Top->new; |
|
15 |
$self->{left} = SL::Controller::Layout::MenuLeft->new; |
|
16 |
|
|
17 |
$self->use_stylesheet( |
|
18 |
$self->{top}->stylesheets, |
|
19 |
$self->{left}->stylesheets, |
|
20 |
); |
|
21 |
|
|
22 |
$self->use_javascript( |
|
23 |
$self->{top}->javascripts, |
|
24 |
$self->{left}->javascripts, |
|
25 |
); |
|
14 |
$self->add_sub_layouts([ |
|
15 |
SL::Controller::Layout::Top->new, |
|
16 |
SL::Controller::Layout::MenuLeft->new, |
|
17 |
]); |
|
26 | 18 |
|
27 | 19 |
$self; |
28 | 20 |
} |
29 | 21 |
|
30 |
sub pre_content { |
|
31 |
$_[0]{top}->render . |
|
32 |
$_[0]{left}->render; |
|
33 |
} |
|
34 |
|
|
35 |
sub start_content { |
|
36 |
"<div id='content' class='html-menu'>\n"; |
|
37 |
} |
|
38 |
|
|
39 |
sub end_content { |
|
40 |
"</div>\n"; |
|
41 |
} |
|
42 |
|
|
43 | 22 |
1; |
SL/Controller/Layout/MenuLeft.pm | ||
---|---|---|
12 | 12 |
|
13 | 13 |
my $self = $class->SUPER::new(@slurp); |
14 | 14 |
|
15 |
$self->use_stylesheet(qw(css/icons16.css css/icons24.css)); |
|
16 |
|
|
17 | 15 |
$self; |
18 | 16 |
} |
19 | 17 |
|
20 |
sub render {
|
|
21 |
my ($self) = @_;
|
|
22 |
my $sections = [ section_menu($self->menu) ];
|
|
18 |
sub stylesheets {
|
|
19 |
qw(css/icons16.css css/icons24.css)
|
|
20 |
}
|
|
23 | 21 |
|
24 |
$self->SUPER::render('menu/menu', { no_menu => 1, no_output => 1 }, |
|
22 |
sub javascripts_inline { |
|
23 |
my $self = shift; |
|
24 |
my $sections = [ section_menu($self->menu) ]; |
|
25 |
$self->render('menu/menu', { no_menu => 1, no_output => 1 }, |
|
25 | 26 |
sections => $sections, |
26 |
); |
|
27 |
) |
|
28 |
} |
|
29 |
|
|
30 |
sub pre_content { |
|
31 |
"<div id='html-menu'></div>\n"; |
|
32 |
} |
|
33 |
|
|
34 |
sub start_content { |
|
35 |
"<div id='content' class='html-menu'>\n"; |
|
36 |
} |
|
37 |
|
|
38 |
sub end_content { |
|
39 |
"</div>\n"; |
|
27 | 40 |
} |
28 | 41 |
|
29 | 42 |
sub section_menu { |
SL/Controller/Layout/Top.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
use parent qw(SL::Controller::Layout::Base); |
5 | 5 |
|
6 |
sub render {
|
|
6 |
sub pre_content {
|
|
7 | 7 |
my ($self) = @_; |
8 | 8 |
|
9 | 9 |
$self->SUPER::render('menu/header', { partial => 1, no_output => 1 }, |
SL/Controller/Layout/V4.pm | ||
---|---|---|
11 | 11 |
my ($class, @slurp) = @_; |
12 | 12 |
|
13 | 13 |
my $self = $class->SUPER::new(@slurp); |
14 |
$self->{top} = SL::Controller::Layout::Top->new;
|
|
14 |
$self->add_sub_layouts(SL::Controller::Layout::Top->new);
|
|
15 | 15 |
$self; |
16 | 16 |
} |
17 | 17 |
|
18 |
sub pre_content { |
|
19 |
$_[0]{top}->render . |
|
20 |
&render; |
|
21 |
} |
|
22 |
|
|
23 |
sub stylesheets { |
|
24 |
$_[0]{top}->stylesheets |
|
25 |
} |
|
26 |
|
|
27 | 18 |
sub start_content { |
28 | 19 |
"<div id='content'>\n"; |
29 | 20 |
} |
... | ... | |
32 | 23 |
"</div>\n"; |
33 | 24 |
} |
34 | 25 |
|
35 |
sub render {
|
|
26 |
sub pre_content {
|
|
36 | 27 |
my ($self) = @_; |
37 | 28 |
|
38 | 29 |
$self->{sub_class} = 1; |
... | ... | |
41 | 32 |
$callback = URI->new($callback)->rel($callback) if $callback; |
42 | 33 |
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; |
43 | 34 |
|
35 |
$self->SUPER::pre_content . |
|
36 |
|
|
44 | 37 |
$self->SUPER::render('menu/menuv4', { no_menu => 1, no_output => 1 }, |
45 | 38 |
force_ul_width => 1, |
46 | 39 |
date => $self->clock_line, |
SL/Form.pm | ||
---|---|---|
537 | 537 |
|
538 | 538 |
print $::request->{layout}->end_content; |
539 | 539 |
print $::request->{layout}->post_content; |
540 |
# print "<script type='text/javascript' src='$_'></script>\n" for $::request->{layout}->javascripts; |
|
541 |
# if (my @inline_scripts = $::request->{layout}->javascript_inline) {
|
|
542 |
# print "<script type='text/javascript'>$_</script>\n" for @inline_scripts;
|
|
543 |
# }
|
|
540 |
|
|
541 |
if (my @inline_scripts = $::request->{layout}->javascripts_inline) {
|
|
542 |
print "<script type='text/javascript'>$_</script>\n" for @inline_scripts; |
|
543 |
} |
|
544 | 544 |
|
545 | 545 |
print <<EOL |
546 | 546 |
</body> |
templates/webpages/menu/menu.html | ||
---|---|---|
1 | 1 |
[%- USE JSON %] |
2 |
<div id='html-menu'></div> |
|
3 |
<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> |
|
2 |
$(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()})})}) |
Auch abrufbar als: Unified diff
besseres interface und delegating für layouts, inline accessoren
html menü in footer verschoben