mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-17 02:31:02 +01:00
Implemented logic to detect when offline the internet and suppress Ajax calls
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
$(function(){
|
||||
var root = window || {};
|
||||
var root = window || {},
|
||||
isOnline = typeof navigator.onLine !== 'undefined' && navigator.onLine;
|
||||
|
||||
window.addEventListener('online', function(){
|
||||
isOnline = true;
|
||||
});
|
||||
window.addEventListener('offline', function(){
|
||||
isOnline = false;
|
||||
});
|
||||
|
||||
root.GravAjax = function (url, settings) {
|
||||
if (!isOnline) {
|
||||
toastr.error('You appear to be Offline.');
|
||||
}
|
||||
|
||||
settings = typeof settings === 'undefined' ? typeof url === 'string' ? {} : url : settings;
|
||||
settings.url = typeof settings.url === 'undefined' && typeof url === 'string' ? url : settings.url;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user