Projet

Général

Profil

0002-templates-declare-service-worker-when-a-pwa-display-.patch

Frédéric Péters, 12 août 2018 16:22

Télécharger (5,5 ko)

Voir les différences:

Subject: [PATCH 2/2] templates: declare service worker when a pwa display mode
 is requested (#25343)

 static/grandlyon-gnm/extra.js               | 11 -----------
 static/toodego/extra.js                     | 13 -------------
 templates/combo/page_template.html          | 20 ++++++++++++++++++++
 templates/theme.html                        |  5 +++++
 templates/variants/grandlyon-gnm/theme.html |  1 -
 templates/variants/toodego/theme.html       |  1 -
 6 files changed, 25 insertions(+), 26 deletions(-)
static/grandlyon-gnm/extra.js
565 565
  $('input, select, textarea').on('change', function() {
566 566
    $(this).parents('.widget-with-error').removeClass('widget-with-error');
567 567
  });
568

  
569
  /* service worker */
570
  if ('serviceWorker' in navigator) {
571
    navigator.serviceWorker.register('/service-worker.js', {scope: '/'}).then(function(registration) {
572
      // Registration was successful
573
      console.log('ServiceWorker registration successful with scope: ', registration.scope);
574
    }).catch(function(err) {
575
      // registration failed :(
576
      console.log('ServiceWorker registration failed: ', err);
577
    });
578
  }
579 568
});
static/toodego/extra.js
347 347
      $('#forms-count').next().text('demandes');
348 348
    }
349 349
  });
350

  
351

  
352

  
353
  /* service worker */
354
  if ('serviceWorker' in navigator) {
355
    navigator.serviceWorker.register('/service-worker.js', {scope: '/'}).then(function(registration) {
356
      // Registration was successful
357
      console.log('ServiceWorker registration successful with scope: ', registration.scope);
358
    }).catch(function(err) {
359
      // registration failed :(
360
      console.log('ServiceWorker registration failed: ', err);
361
    });
362
  }
363 350
});
templates/combo/page_template.html
88 88
          {% endif %}
89 89
{% end_skeleton_extra_placeholder %}
90 90
{% endblock %}
91

  
92
{% block body-bottom %}
93
{% skeleton_extra_placeholder service-worker %}
94
{% if page %}  {# limit this to combo itself #}
95
  {% if pwa_display == "standalone" or pwa_display == "fullscreen" %}
96
    <script>
97
    if ('serviceWorker' in navigator) {
98
      navigator.serviceWorker.register('/service-worker.js', {scope: '/'}).then(function(registration) {
99
        // Registration was successful
100
        console.log('ServiceWorker registration successful with scope: ', registration.scope);
101
      }).catch(function(err) {
102
        // registration failed :(
103
        console.log('ServiceWorker registration failed: ', err);
104
      });
105
    }
106
    </script>
107
  {% endif %}
108
{% endif %}
109
{% end_skeleton_extra_placeholder %}
110
{% endblock %}
templates/theme.html
21 21
    <meta name="theme-color" content="{{theme_color}}">
22 22
    <meta name="msapplication-navbutton-color" content="{{theme_color}}">
23 23
    {% endif %}
24
    {% if pwa_display == "standalone" or pwa_display == "fullscreen" %}
25
    <link rel="manifest" href="{{site_base}}/manifest.json">
26
    {% endif %}
24 27
    {% block extra_top_head %}
25 28
    {% endblock %}
26 29
    {{ media }}
......
139 142
   {% if environment_label %}<span id="environment-label">{{ environment_label }}</span>{% endif %}
140 143
   <a style="display: none" href="#" accesskey="t">Retour en haut de page</a>
141 144
   {% include "includes/tracking.html" %}
145
   {% block body-bottom %}
146
   {% endblock %}
142 147
  </body>
143 148
</html>
templates/variants/grandlyon-gnm/theme.html
2 2
{% load static gnm %}
3 3

  
4 4
{% block extra_top_head %}
5
<link rel="manifest" href="{{site_base}}/manifest.json">
6 5
<link rel="preload" href="{{site_base}}/static/xstatic/fonts/Roboto-Regular.woff2" as="font" type="font/woff2" crossorigin>
7 6
<link rel="preload" href="{{site_base}}/static/xstatic/fonts/Roboto-Bold.woff2" as="font" type="font/woff2" crossorigin>
8 7
<link rel="icon" type="image/png" href="{{site_base}}{% static "" %}{{css_variant}}/img/favicon-16.png" sizes="16x16">
templates/variants/toodego/theme.html
2 2
{% load static gnm assets %}
3 3

  
4 4
{% block extra_top_head %}
5
<link rel="manifest" href="{{site_base}}/manifest.json">
6 5
<link rel="preload" href="{{site_base}}/static/fonts/Oswald/oswald-regular-webfont.woff2" as="font" type="font/woff2" crossorigin>
7 6
<link rel="preload" href="{{site_base}}/static/fonts/Oswald/oswald-bold-webfont.woff2" as="font" type="font/woff2" crossorigin>
8 7
<link rel="preload" href="{{site_base}}/static/fonts/Raleway/raleway-regular-webfont.woff2" as="font" type="font/woff2" crossorigin>
9
-