Projet

Général

Profil

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

Frédéric Péters, 03 décembre 2015 20:50

Télécharger (2,55 ko)

Voir les différences:

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

 src/authentic2/static/authentic2/js/logout.js   | 15 +++++++++++++++
 src/authentic2/templates/authentic2/logout.html | 16 +++-------------
 2 files changed, 18 insertions(+), 13 deletions(-)
 create mode 100644 src/authentic2/static/authentic2/js/logout.js
src/authentic2/static/authentic2/js/logout.js
1
$(function() {
2
  var redir_timeout = $('body').data('redir-timeout');
3
  var next_url = $('body').data('next-url');
4

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

  
4 4
{% block title %}
5 5
  {% trans "Logout" %}
......
9 9
{% endblock %}
10 10

  
11 11
{% block bodyargs %}
12
  data-next-url="{{next_url}}" data-redir-timeout="{{redir_timeout}}"
12 13
  onload="window.iframe_count -= 1"
13 14
{% endblock %}
14 15

  
15 16
{% comment %}Initialize iframe countdown {% endcomment %}
16 17
{% block extra_scripts %}
18
  <script type="text/javascript" src="{% static "authentic2/js/logout.js" %}"></script>
17 19
  <script>
18 20
    window.iframe_count = 1;
19 21
  </script>
......
26 28
          {{ fragment|safe }}
27 29
      {% endfor %}
28 30
  </ul>
29
  <script>
30
    window.iframe_count += document.getElementsByTagName("iframe").length;
31
    var refresh_launched = 0;
32
    setInterval(function () {
33
      if (iframe_count == 0) {
34
        if (refresh_launched == 0) {
35
          refresh_launched = 1;
36
          setTimeout(function () { window.location = '{{ next_url }}' }, 300);
37
        }
38
      }
39
    }, {{ redir_timeout }})
40
  </script>
41 31

  
42 32
  <div id="continue-link">
43 33
    <a href="{{ next_url }}">{% trans "Continue logout" %}</a>
44
-