Browse Source

various improvements

pull/40/head
Michael Foster 11 years ago
parent
commit
31e64f096e
  1. 48
      js/ajax.js

48
js/ajax.js

@ -42,25 +42,31 @@ $(window).ready(function() {
$(form).find('input[type="submit"]').val(submit_txt); $(form).find('input[type="submit"]').val(submit_txt);
$(form).find('input[type="submit"]').removeAttr('disabled'); $(form).find('input[type="submit"]').removeAttr('disabled');
} else if (post_response.redirect && post_response.id) { } else if (post_response.redirect && post_response.id) {
$.ajax({ if ($(form).find('input[name="thread"]')) {
url: post_response.redirect, document.location = post_response.redirect;
success: function(data) { } else {
console.log(data); $.ajax({
$(data).find('div.post.reply').each(function() { url: post_response.redirect,
var id = $(this).attr('id'); success: function(data) {
if($('#' + id).length == 0) { $(data).find('div.post.reply').each(function() {
$(this).insertAfter($('div.post:last').next()).after('<br class="clear">'); var id = $(this).attr('id');
$(document).trigger('new_post', this); if($('#' + id).length == 0) {
} $(this).insertAfter($('div.post:last').next()).after('<br class="clear">');
}); $(document).trigger('new_post', this);
highlightReply(post_response.id); }
document.location = '#' + post_response.id; });
highlightReply(post_response.id);
$(form).find('input[type="submit"]').val(submit_txt); document.location = '#' + post_response.id;
$(form).find('input[type="submit"]').removeAttr('disabled');
} $(form).find('input[type="submit"]').val(submit_txt);
}, 'html'); $(form).find('input[type="submit"]').removeAttr('disabled');
$(form).find('input[name="subject"],textarea[name="body"],input[type="file"]').val('');
},
cache: false,
contentType: false,
processData: false
}, 'html');
}
$(form).find('input[type="submit"]').val('Posted...'); $(form).find('input[type="submit"]').val('Posted...');
} else { } else {
alert(_('An unknown error occured when posting!')); alert(_('An unknown error occured when posting!'));
@ -71,14 +77,14 @@ $(window).ready(function() {
error: function(xhr, status, er) { error: function(xhr, status, er) {
// An error occured // An error occured
// TODO // TODO
console.log('Error'); alert('Something went wrong!');
}, },
// Form data // Form data
data: formData, data: formData,
cache: false, cache: false,
contentType: false, contentType: false,
processData: false processData: false
}, 'html'); }, 'json');
$(form).find('input[type="submit"]').val(_('Posting...')); $(form).find('input[type="submit"]').val(_('Posting...'));
$(form).find('input[type="submit"]').attr('disabled', true); $(form).find('input[type="submit"]').attr('disabled', true);

Loading…
Cancel
Save