IMPR: Offline functionality

This commit is contained in:
Tony Air 2020-04-02 07:54:52 +07:00
parent df000626f8
commit 163461bf3c
7 changed files with 43 additions and 27 deletions

8
dist/css/app.css vendored
View File

@ -15383,6 +15383,14 @@ textarea,
} }
} }
.alert-offline {
display: none;
}
body.is-offline .alert-offline {
display: block;
}
input.date[readonly], input.date[readonly],
input.time[readonly] { input.time[readonly] {
background-color: #fff; background-color: #fff;

File diff suppressed because one or more lines are too long

2
dist/js/app.js vendored

File diff suppressed because one or more lines are too long

2
dist/js/app.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate", "name": "@a2nt/ss-bootstrap-ui-webpack-boilerplate",
"version": "1.8.7", "version": "1.8.9",
"author": "Tony Air <tony@twma.pro>", "author": "Tony Air <tony@twma.pro>",
"license": "MIT", "license": "MIT",
"description": "This UI Kit allows you to build Bootstrap 4 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.", "description": "This UI Kit allows you to build Bootstrap 4 webapp with some extra UI features. It's easy to extend and easy to convert HTML templates to CMS templates.",

View File

@ -4,7 +4,7 @@ import $ from 'jquery';
import Events from './_events'; import Events from './_events';
const LayoutUI = ($ => { const LayoutUI = (($) => {
// Constants // Constants
const W = window; const W = window;
const D = document; const D = document;

View File

@ -49,6 +49,9 @@ const MainUI = (($) => {
// update online/offline state // update online/offline state
const updateOnlineStatus = () => { const updateOnlineStatus = () => {
if (typeof navigator.onLine === 'undefined') {
return;
}
if (!navigator.onLine) { if (!navigator.onLine) {
console.log('Tab: offline'); console.log('Tab: offline');
$Body.addClass('is-offline'); $Body.addClass('is-offline');
@ -60,7 +63,6 @@ const MainUI = (($) => {
} }
}; };
if (typeof navigator.onLine !== 'undefined') {
W.addEventListener( W.addEventListener(
'offline', 'offline',
() => { () => {
@ -80,7 +82,10 @@ const MainUI = (($) => {
W.addEventListener('load', () => { W.addEventListener('load', () => {
updateOnlineStatus(); updateOnlineStatus();
}); });
}
$(W).on(`${Events.AJAX}`, () => {
updateOnlineStatus();
});
// scrollTo // scrollTo
const ScrollTo = (trigger, selector) => { const ScrollTo = (trigger, selector) => {
@ -359,7 +364,10 @@ const MainUI = (($) => {
}); });
} }
if ($AlertNotify.length && typeof $AlertNotify[0].stop !== 'undefined') { if (
$AlertNotify.length &&
typeof $AlertNotify[0].stop !== 'undefined'
) {
$AlertNotify[0].stop(); $AlertNotify[0].stop();
} }