From: Moritz Bunkus Date: Tue, 5 Mar 2013 09:30:37 +0000 (+0100) Subject: "None"-Layout: alle JavaScript-Setup-Funktionen in einer Funktion zusammengefasst X-Git-Tag: release-3.1.0beta1~569^2~1 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1490701d84fadf0349cef487ebb5e830fa7b4bcc;p=kivitendo-erp.git "None"-Layout: alle JavaScript-Setup-Funktionen in einer Funktion zusammengefasst --- diff --git a/SL/Layout/None.pm b/SL/Layout/None.pm index ffd5bb55e..c3708bffc 100644 --- a/SL/Layout/None.pm +++ b/SL/Layout/None.pm @@ -6,9 +6,21 @@ use parent qw(SL::Layout::Base); use List::MoreUtils qw(apply); sub javascripts_inline { - _setup_formats(), - _setup_focus(), - _setup_ajax_spinner(), + my ($self) = @_; + + my $datefmt = apply { + s/d+/dd/gi; + s/m+/mm/gi; + s/y+/yy/gi; + } $::myconfig{dateformat}; + + return $self->render( + 'layout/javascript_setup', + { type => 'js', output => 0, }, + datefmt => $datefmt, + focus => $::request->layout->focus, + ajax_spinner => 1, + ); } sub use_javascript { @@ -29,28 +41,4 @@ sub use_stylesheet { $self->SUPER::use_stylesheet(@_); } -sub _setup_formats { - my $datefmt = apply { - s/d+/dd/gi; - s/m+/mm/gi; - s/y+/yy/gi; - } $::myconfig{dateformat}; - - $::form->parse_html_template('layout/javascript_setup', { datefmt => $datefmt }); -} - -sub _setup_focus { - if ($::request->{layout}->focus) { - return $::form->parse_html_template('layout/focus_setup', { - focus => $::request->{layout}->focus, - }) - } else { - return (); - } -} - -sub _setup_ajax_spinner { - return SL::Presenter->get->render('layout/ajax_spinner_setup', { type => 'js' }); -} - 1; diff --git a/templates/webpages/layout/ajax_spinner_setup.js b/templates/webpages/layout/ajax_spinner_setup.js deleted file mode 100644 index 675c7e6ee..000000000 --- a/templates/webpages/layout/ajax_spinner_setup.js +++ /dev/null @@ -1,7 +0,0 @@ -$(function() { - $(document).ajaxSend(function() { - $('#ajax-spinner').show(); - }).ajaxStop(function() { - $('#ajax-spinner').hide(); - }); -}); diff --git a/templates/webpages/layout/focus_setup.html b/templates/webpages/layout/focus_setup.html deleted file mode 100644 index e97fb69dc..000000000 --- a/templates/webpages/layout/focus_setup.html +++ /dev/null @@ -1 +0,0 @@ -function fokus(){ [% IF focus %]$('[% focus %]').focus()[% END %] } diff --git a/templates/webpages/layout/javascript_setup.html b/templates/webpages/layout/javascript_setup.html deleted file mode 100644 index 3508ef85c..000000000 --- a/templates/webpages/layout/javascript_setup.html +++ /dev/null @@ -1,20 +0,0 @@ -[%- USE T8 %] -$(function() { - setupPoints('[% myconfig.numberformat %]', '[% 'wrongformat' | $T8 %]'); - setupDateFormat('[% myconfig.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]'); - - $.datepicker.setDefaults( - $.extend({}, $.datepicker.regional["[% myconfig.countrycode %]"], { - dateFormat: "[% datefmt %]", - showOn: "button", - showButtonPanel: true, - changeMonth: true, - changeYear: true, - buttonImage: "image/calendar.png", - buttonImageOnly: true - })); - - $('.datepicker').each(function() { - $(this).datepicker(); - }); -}) diff --git a/templates/webpages/layout/javascript_setup.js b/templates/webpages/layout/javascript_setup.js new file mode 100644 index 000000000..dc516348c --- /dev/null +++ b/templates/webpages/layout/javascript_setup.js @@ -0,0 +1,36 @@ +[%- USE T8 %] +$(function() { +[% IF datefmt %] + setupPoints('[% MYCONFIG.numberformat %]', '[% 'wrongformat' | $T8 %]'); + setupDateFormat('[% MYCONFIG.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]'); + + $.datepicker.setDefaults( + $.extend({}, $.datepicker.regional["[% MYCONFIG.countrycode %]"], { + dateFormat: "[% datefmt %]", + showOn: "button", + showButtonPanel: true, + changeMonth: true, + changeYear: true, + buttonImage: "image/calendar.png", + buttonImageOnly: true + })); + + $('.datepicker').each(function() { + $(this).datepicker(); + }); +[% END %] + +[% IF ajax_spinner %] + $(document).ajaxSend(function() { + $('#ajax-spinner').show(); + }).ajaxStop(function() { + $('#ajax-spinner').hide(); + }); +[% END %] +}); + +function fokus() { +[%- IF focus -%] + $('[% focus %]').focus(); +[%- END -%] +}