SN.U.Counter(form);
- NDT = form.find('[name=status_textarea]');
+ NDT = form.find('.notice_data-text:first');
NDT.bind('keyup', function(e) {
SN.U.Counter(form);
* @return number of chars
*/
CharacterCount: function(form) {
- return form.find('[name=status_textarea]').val().length;
+ return form.find('.notice_data-text:first').val().length;
},
/**
dataType: 'xml',
timeout: '60000',
beforeSend: function(formData) {
- if (form.find('[name=status_textarea]').val() == '') {
+ if (form.find('.notice_data-text:first').val() == '') {
form.addClass(SN.C.S.Warning);
return false;
}
list.append(replyItem);
var form = replyForm = $(formEl);
- SN.U.NoticeLocationAttach(form);
- SN.U.FormNoticeXHR(form);
- SN.U.FormNoticeEnhancements(form);
- SN.U.NoticeDataAttach(form);
+ SN.Init.NoticeFormSetup(form);
nextStep();
};
'</li>');
placeholder.click(function() {
SN.U.NoticeInlineReplyTrigger(notice);
+ return false;
});
placeholder.find('input').val(SN.msg('reply_placeholder'));
list.append(placeholder);
return false;
},
+ /**
+ * Switch to another active input sub-form.
+ * This will hide the current form (if any), show the new one, and
+ * update the input type tab selection state.
+ *
+ * @param {String} tag
+ */
switchInputFormTab: function(tag) {
// The one that's current isn't current anymore
$('.input_form_nav_tab.current').removeClass('current');
if ($('body.user_in').length > 0) {
$('.ajax-notice').each(function() {
var form = $(this);
- SN.U.NoticeLocationAttach(form);
- SN.U.FormNoticeXHR(form);
- SN.U.FormNoticeEnhancements(form);
- SN.U.NoticeDataAttach(form);
+ SN.Init.NoticeFormSetup(form);
+ });
+
+ // Make inline reply forms self-close when clicking out.
+ $('body').bind('click', function(e) {
+ var openReplies = $('li.notice-reply');
+ if (openReplies.length > 0) {
+ var target = $(e.target).closest('li.notice-reply');
+ if (target.length == 0) {
+ // There are inline replies open, and we
+ // clicked outside of one...
+ openReplies.each(function() {
+ var replyItem = $(this);
+ // Only close if there's been no edit.
+ if (replyItem.find('.notice_data-text:first').val() == '') {
+ var parentNotice = replyItem.closest('li.notice');
+ replyItem.remove();
+ SN.U.NoticeInlineReplyPlaceholder(parentNotice);
+ }
+ });
+ }
+ }
});
}
},
+ /**
+ * Encapsulate notice form setup for a single form.
+ * Plugins can add extra setup by monkeypatching this
+ * function.
+ *
+ * @param {jQuery} form
+ */
+ NoticeFormSetup: function(form) {
+ SN.U.NoticeLocationAttach(form);
+ SN.U.FormNoticeXHR(form);
+ SN.U.FormNoticeEnhancements(form);
+ SN.U.NoticeDataAttach(form);
+ },
+
/**
* Run setup code for notice timeline views items:
*