offline.js 469 B

123456789101112131415161718192021
  1. import $ from 'jquery';
  2. import isOnline from '../utils/offline';
  3. const offlineElement = $('#offline-status');
  4. $(window).on('offline', () => {
  5. offlineElement.slideDown();
  6. });
  7. $(window).on('online', () => {
  8. offlineElement.slideUp();
  9. });
  10. $(document).ready(() => {
  11. if (!isOnline) {
  12. offlineElement.slideDown();
  13. }
  14. });
  15. // assume online if can't check
  16. export default typeof global.navigator.onLine !== 'undefined' ? global.navigator.onLine : true;