]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Clicking outside the active top posting form now returns to the placeholder if all...
authorBrion Vibber <brion@pobox.com>
Fri, 11 Mar 2011 01:52:03 +0000 (17:52 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 11 Mar 2011 01:52:03 +0000 (17:52 -0800)
js/util.js

index 4ff2b661feb684e1b3516080a4fa36bb631927a6..c4bcf81b88ec013c15df8b4eeac1c9e8f7b051ea 100644 (file)
@@ -1323,6 +1323,21 @@ var SN = { // StatusNet
 
                 // Make inline reply forms self-close when clicking out.
                 $('body').bind('click', function(e) {
+                    var currentForm = $('#content .input_forms div.current');
+                    if (currentForm.length > 0) {
+                        if ($('#content .input_forms').has(e.target).length == 0) {
+                            // If all fields are empty, switch back to the placeholder.
+                            var fields = currentForm.find('textarea, input[type=text], input[type=""]');
+                            var anything = false;
+                            fields.each(function() {
+                                anything = anything || $(this).val();
+                            });
+                            if (!anything) {
+                                SN.U.switchInputFormTab("placeholder");
+                            }
+                        }
+                    }
+
                     var openReplies = $('li.notice-reply');
                     if (openReplies.length > 0) {
                         var target = $(e.target);