aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-15 19:08:40 -0400
committerJoey Hess <joey@kitenet.net>2011-06-15 19:08:40 -0400
commite2b43578a677894d23fa526d9201e5a89b231abc (patch)
treecd59dc2071520757b616d038e8c27ac6a0195bc4 /IkiWiki
parent3a939f05c509ef57740d6524c785667e36ccff24 (diff)
downloadikiwiki-e2b43578a677894d23fa526d9201e5a89b231abc.tar
ikiwiki-e2b43578a677894d23fa526d9201e5a89b231abc.tar.gz
load attachment javascript into template the clean way
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/attachment.pm17
1 files changed, 14 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index fdae8d1e0..be30e97b9 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -7,6 +7,7 @@ use IkiWiki 3.00;
sub import {
add_underlay("javascript");
+ add_underlay("attachment");
hook(type => "getsetup", id => "attachment", call => \&getsetup);
hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
@@ -89,10 +90,20 @@ sub formbuilder_setup (@) {
$form->tmpl_param("field-upload" => '<input name="_submit" type="submit" value="Upload Attachment" />');
$form->tmpl_param("field-link" => '<input name="_submit" type="submit" value="Insert Links" />');
- # Add the toggle javascript; the attachments interface uses
- # it to toggle visibility.
+ # Add all the javascript used by the attachments interface.
require IkiWiki::Plugin::toggle;
- $form->tmpl_param("javascript" => IkiWiki::Plugin::toggle::include_javascript($params{page}));
+ my $js=IkiWiki::Plugin::toggle::include_javascript($params{page});
+ $js.='<link rel="stylesheet" href="'.urlto("ikiwiki/jquery-ui.css", $params{page}).' id="theme">\n';
+ my @jsfiles=qw{jquery.min jquery-ui.min
+ jquery.tmpl.min jquery.iframe-transport
+ jquery.fileupload jquery.fileupload-ui
+ };
+ foreach my $file (@jsfiles) {
+ $js.='<script src="'.urlto("ikiwiki/$file.js", $params{page}).
+ '" type="text/javascript" charset="utf-8"></script>'."\n";
+ }
+ $form->tmpl_param("javascript" => $js);
+
# Start with the attachments interface toggled invisible,
# but if it was used, keep it open.
if ($form->submitted ne "Upload Attachment" &&