aboutsummaryrefslogtreecommitdiff
path: root/assets/js/src
diff options
context:
space:
mode:
authorlucascono <[email protected]>2017-10-04 05:33:17 -0300
committerlucascono <[email protected]>2017-10-04 05:33:17 -0300
commit8c04a74c8c7f0174ea08bc02fa3762f49bf615a3 (patch)
treedb9d6923c082243d765c57885992db8dd26a70b5 /assets/js/src
parent9aff890efa3798f831b714c41794c9fee0684bae (diff)
parentb29b1e155880ac953899889c9cbb67f7f7df0529 (diff)
downloadbootstrap-8c04a74c8c7f0174ea08bc02fa3762f49bf615a3.tar.xz
bootstrap-8c04a74c8c7f0174ea08bc02fa3762f49bf615a3.zip
Merge remote-tracking branch 'refs/remotes/twbs/v4-dev' into v4-dev
Diffstat (limited to 'assets/js/src')
-rw-r--r--assets/js/src/application.js15
-rw-r--r--assets/js/src/pwa.js30
2 files changed, 35 insertions, 10 deletions
diff --git a/assets/js/src/application.js b/assets/js/src/application.js
index e1b9721a0..9c236b7c4 100644
--- a/assets/js/src/application.js
+++ b/assets/js/src/application.js
@@ -96,15 +96,10 @@
.tooltip('_fixTitle')
})
+ anchors.options = {
+ icon: '#'
+ }
+ anchors.add('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
+ $('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5').wrapInner('<div></div>')
})
-
}(jQuery))
-
-;(function () {
- 'use strict'
-
- anchors.options = {
- icon: '#'
- }
- anchors.add('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
-}())
diff --git a/assets/js/src/pwa.js b/assets/js/src/pwa.js
new file mode 100644
index 000000000..5e1a43b08
--- /dev/null
+++ b/assets/js/src/pwa.js
@@ -0,0 +1,30 @@
+/* eslint no-console:off */
+
+(function setupSW() {
+ 'use strict'
+
+ if ('serviceWorker' in navigator) {
+ window.addEventListener('load', function () {
+ navigator.serviceWorker.register('/sw.js').then(function (registration) { // eslint-disable-line compat/compat
+ console.log('ServiceWorker registration successful with scope: ', registration.scope)
+ registration.onupdatefound = function () {
+ var installingWorker = registration.installing
+ installingWorker.onstatechange = function () {
+ switch (installingWorker.state) {
+ case 'installed':
+ if (navigator.serviceWorker.controller) { // eslint-disable-line compat/compat
+ console.log('new update available')
+ location.reload(true)
+ }
+ break
+
+ default:
+ }
+ }
+ }
+ }).catch(function (err) {
+ console.log('ServiceWorker registration failed: ', err)
+ })
+ })
+ }
+}())