load attachment javascript into template the clean way
authorJoey Hess <joey@kitenet.net>
Wed, 15 Jun 2011 23:08:40 +0000 (19:08 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 15 Jun 2011 23:08:40 +0000 (19:08 -0400)
IkiWiki/Plugin/attachment.pm
doc/style.css
templates/editpage.tmpl
underlays/attachment/ikiwiki/jquery.fileupload-ui.js [moved from underlays/attachments/ikiwiki/jquery.fileupload-ui.js with 100% similarity]
underlays/attachment/ikiwiki/jquery.fileupload.js [moved from underlays/attachments/ikiwiki/jquery.fileupload.js with 100% similarity]
underlays/attachment/ikiwiki/jquery.iframe-transport.js [moved from underlays/attachments/ikiwiki/jquery.iframe-transport.js with 100% similarity]
underlays/attachment/ikiwiki/pbar-ani.gif [moved from underlays/attachments/ikiwiki/pbar-ani.gif with 100% similarity]
underlays/attachments/ikiwiki/jquery.fileupload-ui.css [deleted file]

index fdae8d1e0c4795e93e6340e1405711e33b279d87..be30e97b9e6fb05d21f787ae113fc7634c74542f 100644 (file)
@@ -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" &&
index fcf39be6a74aa6a0569a0d1b66068d4ca5936547..42985c9f44be828aa36e83912ed64dbd5cce123d 100644 (file)
@@ -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);
+}
index b3098a24089f3b9234df710036f425cae85dc7ce..efe077f84ad07dfc3eee8403333a7137e57de1db 100644 (file)
@@ -1,5 +1,3 @@
-<link rel="stylesheet" href="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery-ui.css" id="theme"> 
-<link rel="stylesheet" href="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.fileupload-ui.css"> 
 <TMPL_VAR JAVASCRIPT>
 <TMPL_VAR MESSAGE>
 <br />
 <a class="toggle" href="#attachments">Attachments</a>
 <div class="<TMPL_VAR ATTACHMENTS-CLASS>" id="attachments">
 <div id="fileupload"> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.min.js"></script> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery-ui.min.js"></script> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.tmpl.min.js"></script> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.iframe-transport.js"></script> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.fileupload.js"></script> 
-<script src="http://localhost/~joey/tmp/blueimp-jQuery-File-Upload-7f89121/jquery.fileupload-ui.js"></script> 
 <script>
 $(function () { $('#fileupload').fileupload(); }); // initialize upload widget
 </script>
diff --git a/underlays/attachments/ikiwiki/jquery.fileupload-ui.css b/underlays/attachments/ikiwiki/jquery.fileupload-ui.css
deleted file mode 100644 (file)
index d792724..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.fileupload-content .ui-progressbar {
-  width: 200px;
-  height: 20px;
-}
-
-.fileupload-content .ui-progressbar-value {
-  background: url(pbar-ani.gif);
-}