fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-11-04 08:59 am

[dw-free] Revamp /update

[commit: http://hg.dwscoalition.org/dw-free/rev/11a48ac8fe2f]

http://bugs.dwscoalition.org/show_bug.cgi?id=2524

Cancel the second time you use the gear/cog. Should also fix display issues
that happen when the cog was clicked twice before.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/jquery.postform.js
  • htdocs/js/jquery.postoptions.js
--------------------------------------------------------------------------------
diff -r 567f137c3d33 -r 11a48ac8fe2f htdocs/js/jquery.postform.js
--- a/htdocs/js/jquery.postform.js	Fri Nov 04 15:55:23 2011 +0800
+++ b/htdocs/js/jquery.postform.js	Fri Nov 04 17:00:01 2011 +0800
@@ -400,13 +400,18 @@
         $("#post_options").click(function(e){
             e.preventDefault();
 
-            var $img = $(this).find("img");
-            var oldsrc = $img.attr("src");
-            $img.attr("src", $.throbber.src );
-            $("#settings-tools").load(Site.siteroot + "/__rpc_entryoptions", function(html,status,jqxhr) {
-                $img.attr("src", oldsrc);
-                $("#post_entry").trigger("deleted");
-            });
+            var $settings = $("#settings-tools");
+            var $settingsform = $settings.children("form:visible");
+            if ( $settingsform.length > 0 ) {
+                $settingsform.trigger("settings.cancel")
+            } else {
+                var $img = $(this).find("img");
+                var oldsrc = $img.attr("src");
+                $img.attr("src", $.throbber.src );
+                $settings.load(Site.siteroot + "/__rpc_entryoptions", function(html,status,jqxhr) {
+                    $img.attr("src", oldsrc);
+                })
+            }
         });
 
         $.fx.off = formData.minAnimation;
diff -r 567f137c3d33 -r 11a48ac8fe2f htdocs/js/jquery.postoptions.js
--- a/htdocs/js/jquery.postoptions.js	Fri Nov 04 15:55:23 2011 +0800
+++ b/htdocs/js/jquery.postoptions.js	Fri Nov 04 17:00:01 2011 +0800
@@ -10,8 +10,7 @@
 var $inputs = $("#post-options input");
 saveOriginalValues($inputs);
 
-var $cancel_button = $("<input>", { "type": "submit", "value" : "Cancel" }).click(function(e) {
-    e.preventDefault();
+$("#post-options").bind( "settings.cancel", function() {
     stopEditing();
 
     // restore to original
@@ -23,6 +22,12 @@
         var $this = $(this);
         if ($this.data("originalValue") != $this.is(":checked") ) $this.click();
     });
+})
+
+var $cancel_button = $("<input>", { "type": "submit", "value" : "Cancel" }).click(function(e) {
+    e.preventDefault();
+
+    $("#post-options").trigger("settings.cancel");
 
 }).wrap("<fieldset class='destructive submit'></fieldset>").parent();
 
--------------------------------------------------------------------------------