Revision 1490701d
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/Layout/None.pm | ||
---|---|---|
6 | 6 |
use List::MoreUtils qw(apply); |
7 | 7 |
|
8 | 8 |
sub javascripts_inline { |
9 |
_setup_formats(), |
|
10 |
_setup_focus(), |
|
11 |
_setup_ajax_spinner(), |
|
9 |
my ($self) = @_; |
|
10 |
|
|
11 |
my $datefmt = apply { |
|
12 |
s/d+/dd/gi; |
|
13 |
s/m+/mm/gi; |
|
14 |
s/y+/yy/gi; |
|
15 |
} $::myconfig{dateformat}; |
|
16 |
|
|
17 |
return $self->render( |
|
18 |
'layout/javascript_setup', |
|
19 |
{ type => 'js', output => 0, }, |
|
20 |
datefmt => $datefmt, |
|
21 |
focus => $::request->layout->focus, |
|
22 |
ajax_spinner => 1, |
|
23 |
); |
|
12 | 24 |
} |
13 | 25 |
|
14 | 26 |
sub use_javascript { |
... | ... | |
29 | 41 |
$self->SUPER::use_stylesheet(@_); |
30 | 42 |
} |
31 | 43 |
|
32 |
sub _setup_formats { |
|
33 |
my $datefmt = apply { |
|
34 |
s/d+/dd/gi; |
|
35 |
s/m+/mm/gi; |
|
36 |
s/y+/yy/gi; |
|
37 |
} $::myconfig{dateformat}; |
|
38 |
|
|
39 |
$::form->parse_html_template('layout/javascript_setup', { datefmt => $datefmt }); |
|
40 |
} |
|
41 |
|
|
42 |
sub _setup_focus { |
|
43 |
if ($::request->{layout}->focus) { |
|
44 |
return $::form->parse_html_template('layout/focus_setup', { |
|
45 |
focus => $::request->{layout}->focus, |
|
46 |
}) |
|
47 |
} else { |
|
48 |
return (); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
sub _setup_ajax_spinner { |
|
53 |
return SL::Presenter->get->render('layout/ajax_spinner_setup', { type => 'js' }); |
|
54 |
} |
|
55 |
|
|
56 | 44 |
1; |
templates/webpages/layout/ajax_spinner_setup.js | ||
---|---|---|
1 |
$(function() { |
|
2 |
$(document).ajaxSend(function() { |
|
3 |
$('#ajax-spinner').show(); |
|
4 |
}).ajaxStop(function() { |
|
5 |
$('#ajax-spinner').hide(); |
|
6 |
}); |
|
7 |
}); |
templates/webpages/layout/focus_setup.html | ||
---|---|---|
1 |
function fokus(){ [% IF focus %]$('[% focus %]').focus()[% END %] } |
templates/webpages/layout/javascript_setup.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
$(function() { |
|
3 |
setupPoints('[% myconfig.numberformat %]', '[% 'wrongformat' | $T8 %]'); |
|
4 |
setupDateFormat('[% myconfig.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]'); |
|
5 |
|
|
6 |
$.datepicker.setDefaults( |
|
7 |
$.extend({}, $.datepicker.regional["[% myconfig.countrycode %]"], { |
|
8 |
dateFormat: "[% datefmt %]", |
|
9 |
showOn: "button", |
|
10 |
showButtonPanel: true, |
|
11 |
changeMonth: true, |
|
12 |
changeYear: true, |
|
13 |
buttonImage: "image/calendar.png", |
|
14 |
buttonImageOnly: true |
|
15 |
})); |
|
16 |
|
|
17 |
$('.datepicker').each(function() { |
|
18 |
$(this).datepicker(); |
|
19 |
}); |
|
20 |
}) |
templates/webpages/layout/javascript_setup.js | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
$(function() { |
|
3 |
[% IF datefmt %] |
|
4 |
setupPoints('[% MYCONFIG.numberformat %]', '[% 'wrongformat' | $T8 %]'); |
|
5 |
setupDateFormat('[% MYCONFIG.dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]'); |
|
6 |
|
|
7 |
$.datepicker.setDefaults( |
|
8 |
$.extend({}, $.datepicker.regional["[% MYCONFIG.countrycode %]"], { |
|
9 |
dateFormat: "[% datefmt %]", |
|
10 |
showOn: "button", |
|
11 |
showButtonPanel: true, |
|
12 |
changeMonth: true, |
|
13 |
changeYear: true, |
|
14 |
buttonImage: "image/calendar.png", |
|
15 |
buttonImageOnly: true |
|
16 |
})); |
|
17 |
|
|
18 |
$('.datepicker').each(function() { |
|
19 |
$(this).datepicker(); |
|
20 |
}); |
|
21 |
[% END %] |
|
22 |
|
|
23 |
[% IF ajax_spinner %] |
|
24 |
$(document).ajaxSend(function() { |
|
25 |
$('#ajax-spinner').show(); |
|
26 |
}).ajaxStop(function() { |
|
27 |
$('#ajax-spinner').hide(); |
|
28 |
}); |
|
29 |
[% END %] |
|
30 |
}); |
|
31 |
|
|
32 |
function fokus() { |
|
33 |
[%- IF focus -%] |
|
34 |
$('[% focus %]').focus(); |
|
35 |
[%- END -%] |
|
36 |
} |
Auch abrufbar als: Unified diff
"None"-Layout: alle JavaScript-Setup-Funktionen in einer Funktion zusammengefasst