* @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;
});
},
if (list.length == 0) {
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);
+ }
}
}
list = notice.find('ul.threaded-replies');
}
var placeholder = $('<li class="notice-reply-placeholder">' +
- '<input class="placeholder">' +
+ '<input class="placeholder" />' +
'</li>');
placeholder.find('input')
.val(SN.msg('reply_placeholder'));
* 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) {
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 });
+
}
},