From 4061ebb703c95986c6ffaffd688b0db917667117 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 19 Sep 2012 15:52:38 +0200 Subject: [PATCH] =?utf8?q?container=20f=C3=BCr=20focus=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Layout/Base.pm | 1 + SL/Controller/Layout/None.pm | 17 +++++++++++++++++ SL/Form.pm | 1 - templates/webpages/generic/focus_setup.html | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 templates/webpages/generic/focus_setup.html diff --git a/SL/Controller/Layout/Base.pm b/SL/Controller/Layout/Base.pm index dbd5d8835..ed25f1b78 100644 --- a/SL/Controller/Layout/Base.pm +++ b/SL/Controller/Layout/Base.pm @@ -5,6 +5,7 @@ use parent qw(SL::Controller::Base); use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => qw(menu), + 'scalar' => qw(focus), 'array' => [ 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' }, 'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' }, diff --git a/SL/Controller/Layout/None.pm b/SL/Controller/Layout/None.pm index 2d9e2e85e..204b8ee36 100644 --- a/SL/Controller/Layout/None.pm +++ b/SL/Controller/Layout/None.pm @@ -4,7 +4,24 @@ use strict; use parent qw(SL::Controller::Layout::Base); sub javascripts_inline { + _setup_formats(), + _setup_focus(), +} + + +sub _setup_formats { $::form->parse_html_template('generic/javascript_setup') } +sub _setup_focus { + if ($::request->{layout}->focus || $::form->{fokus}) { + return $::form->parse_html_template('generic/focus_setup', { + focus => $::request->{layout}->focus, + fokus => $::form->{fokus}, + }) + } else { + return (); + } +} + 1; diff --git a/SL/Form.pm b/SL/Form.pm index 186e66151..514c282d2 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -488,7 +488,6 @@ sub header { push @header, map { qq|| } $layout->javascripts; push @header, $self->{javascript} if $self->{javascript}; push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; - push @header, "" if $self->{fokus}; my %doctypes = ( strict => qq||, diff --git a/templates/webpages/generic/focus_setup.html b/templates/webpages/generic/focus_setup.html new file mode 100644 index 000000000..22bb2a280 --- /dev/null +++ b/templates/webpages/generic/focus_setup.html @@ -0,0 +1 @@ +function fokus(){ [% IF focus %]$('[% focus %]').focus()[% ELSE %][% fokus %].focus()[% END %] } -- 2.20.1