mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-17 10:40:55 +01:00
Implemented logic to detect when offline the internet and suppress Ajax calls
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.0.0-rc.6
|
||||
## XX/XX/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Implemented logic to detect when offline and suppress Ajax calls
|
||||
|
||||
# v1.0.0-rc.5
|
||||
## 11/20/2015
|
||||
|
||||
|
||||
@@ -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