Browse Source

Merge pull request #97 from towards-a-new-leftypol/fixes

WIP post ajax behaviour fixes
pull/107/head
towards-a-new-leftypol 3 years ago
committed by GitHub
parent
commit
95ce162d77
  1. 6
      js/ajax.js
  2. 12
      js/auto-reload.js

6
js/ajax.js

@ -79,6 +79,7 @@ $(window).ready(function() {
|| (!settings.get('always_noko_replies', true) && !post_response.noko)) { || (!settings.get('always_noko_replies', true) && !post_response.noko)) {
document.location = post_response.redirect; document.location = post_response.redirect;
} else { } else {
/*
$.ajax({ $.ajax({
url: document.location, url: document.location,
success: function(data) { success: function(data) {
@ -105,9 +106,14 @@ $(window).ready(function() {
contentType: false, contentType: false,
processData: false processData: false
}, 'html'); }, 'html');
*/
} }
$(form).find('input[type="submit"]').val(_('Posted...')); $(form).find('input[type="submit"]').val(_('Posted...'));
$(document).trigger("ajax_after_post", post_response); $(document).trigger("ajax_after_post", post_response);
$(form).find('input[type="submit"]').val(submit_txt);
$(form).find('input[type="submit"]').removeAttr('disabled');
$(form).find('input[name="subject"],input[name="file_url"],\
textarea[name="body"],input[type="file"]').val('').change();
} else { } else {
alert(_('An unknown error occured when posting!')); alert(_('An unknown error occured when posting!'));
$(form).find('input[type="submit"]').val(submit_txt); $(form).find('input[type="submit"]').val(submit_txt);

12
js/auto-reload.js

@ -233,8 +233,11 @@ $(document).ready(function(){
url: document.location, url: document.location,
success: function(data) { success: function(data) {
var loaded_posts = 0; // the number of new posts loaded in this update var loaded_posts = 0; // the number of new posts loaded in this update
$(data).find('div.post.reply').each(function() { $(data).find('div.post.reply').each(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
// check that this post doesn't already exist
if($('#' + id).length == 0) { if($('#' + id).length == 0) {
if (!new_posts) { if (!new_posts) {
first_new_post = this; first_new_post = this;
@ -256,6 +259,7 @@ $(document).ready(function(){
recheck_activated(); recheck_activated();
} }
}); });
time_loaded = Date.now(); // interop with watch.js time_loaded = Date.now(); // interop with watch.js
@ -312,8 +316,12 @@ $(document).ready(function(){
}; };
$(post).on('submit', function(e){ $(post).on('submit', function(e){
poll(manualUpdate = true); setTimeout(
dothis(this); function() {
poll(manualUpdate = true)
},
500
);
}); });
$(window).scrollStopped(function() { $(window).scrollStopped(function() {

Loading…
Cancel
Save