Projet

Général

Profil

0001-misc-move-javascript-out-of-logout.html-content-bloc.patch

Benjamin Dauvergne, 04 décembre 2016 22:52

Télécharger (2,75 ko)

Voir les différences:

Subject: [PATCH] misc: move javascript out of logout.html content block (fixes
 #9197)

 src/authentic2/static/authentic2/js/logout.js   | 19 +++++++++++++++++++
 src/authentic2/templates/authentic2/logout.html | 23 ++++++-----------------
 2 files changed, 25 insertions(+), 17 deletions(-)
 create mode 100644 src/authentic2/static/authentic2/js/logout.js
src/authentic2/static/authentic2/js/logout.js
1
window.iframe_count = 1;
2

  
3
$(window).on('load', function () {window.iframe_count -= 1});
4

  
5
$(function() {
6
  var redir_timeout = $('body').data('redir-timeout');
7
  var next_url = $('body').data('next-url');
8

  
9
  window.iframe_count += document.getElementsByTagName("iframe").length;
10
  var refresh_launched = 0;
11
  setInterval(function () {
12
    if (iframe_count == 0) {
13
      if (refresh_launched == 0) {
14
        refresh_launched = 1;
15
        setTimeout(function () { window.location = next_url; }, 300);
16
      }
17
    }
18
  }, redir_timeout);
19
});
src/authentic2/templates/authentic2/logout.html
1 1
{% extends "authentic2/base-page.html" %}
2
{% load i18n gadjo %}
2
{% load i18n gadjo static %}
3 3

  
4 4
{% block page-title %}
5 5
  {{ block.super }} - {% trans "Logout" %}
6 6
{% endblock %}
7 7

  
8
{% block bodyargs %}
9
  data-next-url="{{next_url}}" data-redir-timeout="{{redir_timeout}}"
10
{% endblock %}
11

  
8 12
{% block extrascripts %}
9 13
  {{ block.super }}
10 14
  <script src="{% xstatic 'jquery' 'jquery.min.js' %}"></script>
11
  <script>
12
    window.iframe_count = 1;
13
    $(window).on('load', function () {window.iframe_count -= 1});
14
  </script>
15
  <script type="text/javascript" src="{% static "authentic2/js/logout.js" %}"></script>
15 16
{% endblock %}
16 17

  
17 18
{% block user-links %}
......
24 25
          {{ fragment|safe }}
25 26
      {% endfor %}
26 27
  </ul>
27
  <script>
28
    window.iframe_count += document.getElementsByTagName("iframe").length;
29
    var refresh_launched = 0;
30
    setInterval(function () {
31
      if (iframe_count == 0) {
32
        if (refresh_launched == 0) {
33
          refresh_launched = 1;
34
          setTimeout(function () { window.location = '{{ next_url }}' }, 300);
35
        }
36
      }
37
    }, {{ redir_timeout }})
38
  </script>
39 28

  
40 29
  <div id="continue-link">
41 30
    <a href="{{ next_url }}">{% trans "Continue logout" %}</a>
42
-