Projet

Général

Profil

0004-forms-let-autosave-call-finish-before-starting-a-new.patch

Frédéric Péters, 20 janvier 2016 15:08

Télécharger (1,59 ko)

Voir les différences:

Subject: [PATCH 4/4] forms: let autosave() call finish before starting a new
 one

 wcs/qommon/static/js/qommon.forms.js | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
wcs/qommon/static/js/qommon.forms.js
5 5
  });
6 6
  if ($('form[data-has-draft]').length == 1) {
7 7
    var last_auto_save = $('form[data-has-draft]').serialize();
8
    var timeout_id = window.setInterval(function() {
8
    var timeout_id = null;
9
    function autosave() {
9 10
      var new_auto_save = $('form[data-has-draft]').serialize();
10
      if (last_auto_save == new_auto_save) return;
11
      if (last_auto_save == new_auto_save) {
12
        timeout_id = window.setTimeout(autosave, 5000);
13
        return;
14
      }
11 15
      $.ajax({
12 16
        type: 'POST',
13 17
        url: window.location.pathname + 'autosave',
......
16 20
          if (json.result == 'success') {
17 21
            last_auto_save = new_auto_save;
18 22
          }
23
        },
24
        complete: function() {
25
          timeout_id = window.setTimeout(autosave, 5000);
19 26
        }
20 27
      });
21
    }, 5000);
28
    }
29
    timeout_id = window.setTimeout(autosave, 5000);
22 30
  }
23 31
  $('#tracking-code button').click(function() {
24 32
    $('input[name=savedraft]').click();
25
-