From: Joey Hess Date: Wed, 15 Jun 2011 23:08:40 +0000 (-0400) Subject: load attachment javascript into template the clean way X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e2b43578a677894d23fa526d9201e5a89b231abc;p=ikiwiki.git load attachment javascript into template the clean way --- 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" && diff --git a/doc/style.css b/doc/style.css index fcf39be6a..42985c9f4 100644 --- a/doc/style.css +++ b/doc/style.css @@ -493,3 +493,11 @@ a.openid_large_btn:focus { .openid_selected { border: 4px solid #DDD; } + +.fileupload-content .ui-progressbar { + width: 200px; + height: 20px; +} +.fileupload-content .ui-progressbar-value { + background: url(ikiwiki/pbar-ani.gif); +} diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl index b3098a240..efe077f84 100644 --- a/templates/editpage.tmpl +++ b/templates/editpage.tmpl @@ -1,5 +1,3 @@ - -
@@ -29,12 +27,6 @@ Attachments
- - - - - - diff --git a/underlays/attachments/ikiwiki/jquery.fileupload-ui.js b/underlays/attachment/ikiwiki/jquery.fileupload-ui.js similarity index 100% rename from underlays/attachments/ikiwiki/jquery.fileupload-ui.js rename to underlays/attachment/ikiwiki/jquery.fileupload-ui.js diff --git a/underlays/attachments/ikiwiki/jquery.fileupload.js b/underlays/attachment/ikiwiki/jquery.fileupload.js similarity index 100% rename from underlays/attachments/ikiwiki/jquery.fileupload.js rename to underlays/attachment/ikiwiki/jquery.fileupload.js diff --git a/underlays/attachments/ikiwiki/jquery.iframe-transport.js b/underlays/attachment/ikiwiki/jquery.iframe-transport.js similarity index 100% rename from underlays/attachments/ikiwiki/jquery.iframe-transport.js rename to underlays/attachment/ikiwiki/jquery.iframe-transport.js diff --git a/underlays/attachments/ikiwiki/pbar-ani.gif b/underlays/attachment/ikiwiki/pbar-ani.gif similarity index 100% rename from underlays/attachments/ikiwiki/pbar-ani.gif rename to underlays/attachment/ikiwiki/pbar-ani.gif diff --git a/underlays/attachments/ikiwiki/jquery.fileupload-ui.css b/underlays/attachments/ikiwiki/jquery.fileupload-ui.css deleted file mode 100644 index d792724b7..000000000 --- a/underlays/attachments/ikiwiki/jquery.fileupload-ui.css +++ /dev/null @@ -1,8 +0,0 @@ -.fileupload-content .ui-progressbar { - width: 200px; - height: 20px; -} - -.fileupload-content .ui-progressbar-value { - background: url(pbar-ani.gif); -}