use jQuery for the image tool
authorTony Cook <tony@develop-help.com>
Fri, 8 May 2015 08:48:58 +0000 (18:48 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 18 May 2015 09:08:24 +0000 (19:08 +1000)
MANIFEST
site/htdocs/js/admin_jedit.js [new file with mode: 0644]
site/templates/admin/article_img.tmpl

index df275af..faf7de5 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -532,6 +532,7 @@ site/htdocs/js/admin-ui/menu.js
 site/htdocs/js/admin.js
 site/htdocs/js/admin_edit.js
 site/htdocs/js/admin_editprodopt.js
 site/htdocs/js/admin.js
 site/htdocs/js/admin_edit.js
 site/htdocs/js/admin_editprodopt.js
+site/htdocs/js/admin_jedit.js
 site/htdocs/js/admin_messages.js
 site/htdocs/js/admin_prodopts.js
 site/htdocs/js/admin_siteusers.js
 site/htdocs/js/admin_messages.js
 site/htdocs/js/admin_prodopts.js
 site/htdocs/js/admin_siteusers.js
diff --git a/site/htdocs/js/admin_jedit.js b/site/htdocs/js/admin_jedit.js
new file mode 100644 (file)
index 0000000..35842ec
--- /dev/null
@@ -0,0 +1,42 @@
+(function($) {
+    $(function() {
+       $(".tag").each(function() {
+           var closed = this;
+           var input = $("input", this);
+           var del = $("<a/>", { href: "#" });
+           del.text("Delete");
+           del.click(function () {
+               closed.remove();
+               return true;
+           });
+           $(this).append(del);
+       });
+       $(".tags").each(function() {
+           var tags = $(this);
+           var fname = this.dataset["name"];
+           if (!fname)
+               fname = "tag";
+           var add_div = $("<div/>", { "class": "tag_add" });
+           var add_a = $("<a/>", { href: "#" });
+           add_div.append(add_a);
+           add_a.text("Add");
+           add_a.click(function() {
+               var inp = $("<input/>",
+                          { type: "text",
+                            name: fname });
+               var div = $("<div/>", { "class": "tag" });
+               div.append(inp);
+               var del = $("<a/>", { href: "#" });
+               div.append(del);
+               del.text("Delete");
+               del.click(function() {
+                   div.remove();
+                   return true;
+               });
+               add_div.before(div);
+               return true;
+           });
+           tags.append(add_div);
+       });
+    });
+})(jQuery);
\ No newline at end of file
index 2b38bf6..b5e547b 100644 (file)
@@ -18,7 +18,7 @@
 <:.call "make_arrows", down_url:down_url, up_url: up_url -:>
 <:-.end if -:>
 <:.end define:>
 <:.call "make_arrows", down_url:down_url, up_url: up_url -:>
 <:-.end if -:>
 <:.end define:>
-<:.wrap "admin/base.tmpl", title:"Image Wizard", js:"admin_edit.js" :>
+<:.wrap "admin/basej.tmpl", title:"Image Wizard", js:"admin_jedit.js" :>
 <h1><:.if article.id == -1:>Global<:.else:><:= article_type :><:.end if:> Image Wizard</h1>
 
 <:.call "messages":>
 <h1><:.if article.id == -1:>Global<:.else:><:= article_type :><:.end if:> Image Wizard</h1>
 
 <:.call "messages":>
@@ -86,7 +86,7 @@
     <th>Tags</th>
     <td>
       <input type="hidden" name="_save_tags" value="1" />
     <th>Tags</th>
     <td>
       <input type="hidden" name="_save_tags" value="1" />
-      <div id="tags">
+      <div class="tags">
       <:- .set tags = [ cgi.param("tags") ] :>
       <:- .if tags.size == 0 :>
         <:% tags.push("") :>
       <:- .set tags = [ cgi.param("tags") ] :>
       <:- .if tags.size == 0 :>
         <:% tags.push("") :>