* @fixme can't submit file uploads
*
* @param {jQuery} form: jQuery object whose first element is a form
+ * @param function onSuccess: something extra to do on success
*
* @access public
*/
- FormXHR: function(form) {
+ FormXHR: function(form, onSuccess) {
$.ajax({
type: 'POST',
dataType: 'xml',
errorReported = $('#error', xhr.responseXML).text();
}
alert(errorReported || errorThrown || textStatus);
-
+
// Restore the form to original state.
// Hopefully. :D
form
if (typeof($('form', data)[0]) != 'undefined') {
form_new = document._importNode($('form', data)[0], true);
form.replaceWith(form_new);
+ if (onSuccess) {
+ onSuccess();
+ }
}
else if (typeof($('p', data)[0]) != 'undefined') {
form.replaceWith(document._importNode($('p', data)[0], true));
+ if (onSuccess) {
+ onSuccess();
+ }
}
else {
alert('Unknown error.');
results_placeholder.replaceWith(list);
}
else {
- var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
+ var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
results_placeholder.html(_error);
}
form
$('#content .notice_reply').live('click', function(e) {
e.preventDefault();
var notice = $(this).closest('li.notice');
- var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
- SN.U.NoticeInlineReplyTrigger(notice, '@' + nickname.text());
+ SN.U.NoticeInlineReplyTrigger(notice);
return false;
});
},
// and we'll add on the end of it. Will add if needed.
list = $('ul.threaded-replies', notice);
if (list.length == 0) {
- list = $('<ul class="notices threaded-replies xoxo"></ul>');
- notice.append(list);
+ SN.U.NoticeInlineReplyPlaceholder(notice);
+ list = $('ul.threaded-replies', notice);
+ } else {
+ var placeholder = $('li.notice-reply-placeholder', notice);
+ if (placeholder.length == 0) {
+ SN.U.NoticeInlineReplyPlaceholder(notice);
+ }
}
}
var nextStep = function() {
// Override...?
replyForm.find('input[name=inreplyto]').val(id);
+ replyForm.find('#notice_to').attr('disabled', 'disabled').hide();
+ replyForm.find('#notice_private').attr('disabled', 'disabled').hide();
+ replyForm.find('label[for=notice_to]').hide();
+ replyForm.find('label[for=notice_private]').hide();
// Set focus...
var text = replyForm.find('textarea');
NoticeInlineReplyPlaceholder: function(notice) {
var list = notice.find('ul.threaded-replies');
+ if (list.length == 0) {
+ list = $('<ul class="notices threaded-replies xoxo"></ul>');
+ notice.append(list);
+ list = notice.find('ul.threaded-replies');
+ }
var placeholder = $('<li class="notice-reply-placeholder">' +
'<input class="placeholder">' +
'</li>');
* popout before submitting.
*
* Uses 'live' rather than 'bind', so applies to future as well as present items.
+ *
*/
NoticeRepeat: function() {
$('.form_repeat').live('click', function(e) {
$('#input_form_nav_'+tag).addClass('current');
}
+ // Don't remove 'current' if we also have the "nonav" class.
+ // An example would be the message input form. removing
+ // 'current' will cause the form to vanish from the page.
+ var nonav = $('.input_form.current.nonav');
+ if (nonav.length > 0) {
+ return;
+ }
+
$('.input_form.current').removeClass('current');
$('#input_form_'+tag)
.addClass('current')
var form = $(this);
SN.Init.NoticeFormSetup(form);
})
- .find('textarea:first').focus();
+ .find('.notice_data-text').focus();
}
},
});
}
});
+
+ // Infield labels for notice form inputs.
+ $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 });
+
}
},