nextStep();
} else {
// Remove placeholder if any
- $('li.notice-reply-placeholder').remove();
+ list.find('li.notice-reply-placeholder').remove();
// Create the reply form entry at the end
var replyItem = $('li.notice-reply', list);
var placeholder = $('<li class="notice-reply-placeholder">' +
'<input class="placeholder">' +
'</li>');
- placeholder.click(function() {
- SN.U.NoticeInlineReplyTrigger(notice);
- return false;
- });
- placeholder.find('input').val(SN.msg('reply_placeholder'));
+ placeholder.find('input')
+ .val(SN.msg('reply_placeholder'))
+ .focus(function() {
+ SN.U.NoticeInlineReplyTrigger(notice);
+ return false;
+ });
list.append(placeholder);
},
}
var NGW = form.find('.notice_data-geo_wrap');
- var geocodeURL = NGW.attr('title');
- NGW.removeAttr('title');
+ var geocodeURL = NGW.attr('data-api');
label
.attr('title', label.text());
wrapper = $('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">×</button><div class="geo_status"></div></div>');
wrapper.find('button.close').click(function() {
form.find('[name=notice_data-geo]').removeAttr('checked').change();
+ return false;
});
form.append(wrapper);
}
$('#input_form_nav_'+tag).addClass('current');
$('.input_form.current').removeClass('current');
- $('#input_form_'+tag).addClass('current');
+ $('#input_form_'+tag)
+ .addClass('current')
+ .find('.ajax-notice').each(function() {
+ var form = $(this);
+ SN.Init.NoticeFormSetup(form);
+ })
+ .find('textarea:first').focus();
}
},
*/
NoticeForm: function() {
if ($('body.user_in').length > 0) {
- $('.ajax-notice').each(function() {
- var form = $(this);
- SN.Init.NoticeFormSetup(form);
+ // SN.Init.NoticeFormSetup() will get run
+ // when forms get displayed for the first time...
+
+ // Hack to initialize the placeholder at top
+ $('#input_form_placeholder input.placeholder').focus(function() {
+ SN.U.switchInputFormTab("status");
});
// 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);
+ var target = $(e.target);
+ openReplies.each(function() {
+ // Did we click outside this one?
+ var replyItem = $(this);
+ if (replyItem.has(e.target).length == 0) {
+ var textarea = replyItem.find('.notice_data-text:first');
+ var cur = $.trim(textarea.val());
// Only close if there's been no edit.
- if (replyItem.find('.notice_data-text:first').val() == '') {
+ if (cur == '' || cur == textarea.data('initialText')) {
var parentNotice = replyItem.closest('li.notice');
replyItem.remove();
SN.U.NoticeInlineReplyPlaceholder(parentNotice);
}
- });
- }
+ }
+ });
}
});
}
* @param {jQuery} form
*/
NoticeFormSetup: function(form) {
- SN.U.NoticeLocationAttach(form);
- SN.U.FormNoticeXHR(form);
- SN.U.FormNoticeEnhancements(form);
- SN.U.NoticeDataAttach(form);
+ if (!form.data('NoticeFormSetup')) {
+ SN.U.NoticeLocationAttach(form);
+ SN.U.FormNoticeXHR(form);
+ SN.U.FormNoticeEnhancements(form);
+ SN.U.NoticeDataAttach(form);
+ form.data('NoticeFormSetup', true);
+ }
},
/**