From e2b43578a677894d23fa526d9201e5a89b231abc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 15 Jun 2011 19:08:40 -0400 Subject: load attachment javascript into template the clean way --- IkiWiki/Plugin/attachment.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin/attachment.pm') 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" => ''); $form->tmpl_param("field-link" => ''); - # 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.='\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.=''."\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" && -- cgit v1.2.3