From 6066bce02c87e1b543d1d9b5b1501342fcaba61b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 10 Mar 2011 17:52:03 -0800 Subject: [PATCH] Clicking outside the active top posting form now returns to the placeholder if all textarea/input fields are empty --- js/util.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/util.js b/js/util.js index 4ff2b661fe..c4bcf81b88 100644 --- a/js/util.js +++ b/js/util.js @@ -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); -- 2.39.5