123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- * @description This module is used to show and hide the loading bar.
- * @copyright 2015 by Tobias Reich
- */
- loadingBar = {
- status: null,
- _dom: $('#loading')
- }
- loadingBar.dom = function(selector) {
- if (selector===undefined||selector===null||selector==='') return loadingBar._dom;
- return loadingBar._dom.find(selector);
- }
- loadingBar.show = function(status, errorText) {
- if (status==='error') {
- // Set status
- loadingBar.status = 'error';
- // Parse text
- if (errorText) errorText = errorText.replace('<br>', '');
- if (!errorText) errorText = 'Whoops, it looks like something went wrong. Please reload the site and try again!';
- // Move header down
- if (visible.header()) header.dom().addClass('error');
- // Modify loading
- loadingBar.dom()
- .removeClass('loading uploading error')
- .html('<h1>Error: <span>' + errorText + '</span></h1>')
- .addClass(status)
- .show();
- // Set timeout
- clearTimeout(loadingBar._timeout);
- loadingBar._timeout = setTimeout(function() {
- loadingBar.hide(true)
- }, 3000);
- return true;
- }
- if (loadingBar.status===null) {
- // Set status
- loadingBar.status = 'loading';
- // Set timeout
- clearTimeout(loadingBar._timeout);
- loadingBar._timeout = setTimeout(function() {
- // Move header down
- if (visible.header()) header.dom().addClass('loading');
- // Modify loading
- loadingBar.dom()
- .removeClass('loading uploading error')
- .html('')
- .addClass('loading')
- .show();
- }, 1000);
- return true;
- }
- }
- loadingBar.hide = function(force) {
- if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
- // Remove status
- loadingBar.status = null;
- // Move header up
- header.dom().removeClass('error loading');
- // Set timeout
- clearTimeout(loadingBar._timeout);
- setTimeout(function() { loadingBar.dom().hide() }, 300);
- }
- }
|