MediaWiki:Mobile.js: Unterschied zwischen den Versionen
Aus FürthWiki
(register serviceworker) Markierungen: Mobile Bearbeitung Mobile Web-Bearbeitung |
(fix #36) |
||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
if ('serviceWorker' in navigator) { | if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', function() { | window.addEventListener('load', function() { | ||
navigator.serviceWorker.register(' | navigator.serviceWorker.register('/wiki/serviceworker.js').then(function(registration) { | ||
// Registration was successful | // Registration was successful | ||
console.log('ServiceWorker registration successful with scope: ', registration.scope); | console.log('ServiceWorker registration successful with scope: ', registration.scope); | ||
Zeile 10: | Zeile 10: | ||
}); | }); | ||
} | } | ||
/* ************************************************* | |||
* Reinitialize leaflet after each tab change. | |||
* fixes #36 | |||
*/ | |||
$(document).ready(function() { | |||
$('.tabs-label').click(function(e) { | |||
var mapExists = setInterval(function() { | |||
var counter = 0; | |||
var mapsLeafletList = window.mapsLeafletList; | |||
if (mapsLeafletList && mapsLeafletList.length) { | |||
mapsLeafletList.forEach(function(l) { | |||
if (l.map) { | |||
l.map.invalidateSize(false); | |||
clearInterval(mapExists); | |||
} | |||
}); | |||
} | |||
if (counter++ > 10) clearInterval(mapExists); | |||
}, 100); | |||
}); | |||
}); |
Aktuelle Version vom 5. Mai 2021, 19:08 Uhr
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/wiki/serviceworker.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
/* *************************************************
* Reinitialize leaflet after each tab change.
* fixes #36
*/
$(document).ready(function() {
$('.tabs-label').click(function(e) {
var mapExists = setInterval(function() {
var counter = 0;
var mapsLeafletList = window.mapsLeafletList;
if (mapsLeafletList && mapsLeafletList.length) {
mapsLeafletList.forEach(function(l) {
if (l.map) {
l.map.invalidateSize(false);
clearInterval(mapExists);
}
});
}
if (counter++ > 10) clearInterval(mapExists);
}, 100);
});
});