container für focus handling
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 19 Sep 2012 13:52:38 +0000 (15:52 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 17 Oct 2012 14:00:46 +0000 (16:00 +0200)
SL/Controller/Layout/Base.pm
SL/Controller/Layout/None.pm
SL/Form.pm
templates/webpages/generic/focus_setup.html [new file with mode: 0644]

index dbd5d88..ed25f1b 100644 (file)
@@ -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' },
index 2d9e2e8..204b8ee 100644 (file)
@@ -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;
index 186e661..514c282 100644 (file)
@@ -488,7 +488,6 @@ sub header {
   push @header, map { qq|<script type="text/javascript" src="$_"></script>| }                    $layout->javascripts;
   push @header, $self->{javascript} if $self->{javascript};
   push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] };
-  push @header, "<script type='text/javascript'>function fokus(){ document.$self->{fokus}.focus(); }</script>" if $self->{fokus};
 
   my  %doctypes = (
     strict       => qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">|,
diff --git a/templates/webpages/generic/focus_setup.html b/templates/webpages/generic/focus_setup.html
new file mode 100644 (file)
index 0000000..22bb2a2
--- /dev/null
@@ -0,0 +1 @@
+function fokus(){ [% IF focus %]$('[% focus %]').focus()[% ELSE %][% fokus %].focus()[% END %] }