Version push and cleanup of loadingBar.js

This commit is contained in:
Tobias Reich 2014-03-30 17:43:49 +02:00
parent 5cce602a05
commit f6177e9d3e
5 changed files with 55 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,7 @@
/* Content ------------------------------------------------*/ /* Content ------------------------------------------------*/
#loading h1 { #loading h1 {
margin: 13px; margin: 13px 13px 0px 13px;
color: #ddd; color: #ddd;
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;

View File

@ -11,48 +11,77 @@ loadingBar = {
show: function(status, errorText) { show: function(status, errorText) {
if (status==="error") { if (status==='error') {
loadingBar.status = "error"; // Set status
loadingBar.status = 'error';
if (!errorText) errorText = "Whoops, it looks like something went wrong. Please reload the site and try again!"; // 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.controls()) lychee.header.addClass('error');
// Modify loading
lychee.loadingBar lychee.loadingBar
.removeClass("loading uploading error") .removeClass('loading uploading error')
.addClass(status) .addClass(status)
.html("<h1>Error: <span>" + errorText + "</span></h1>") .html('<h1>Error: <span>' + errorText + '</span></h1>')
.show() .show()
.css("height", "40px"); .css('height', '40px');
if (visible.controls()) lychee.header.addClass("error");
clearTimeout(lychee.loadingBar.data("timeout")); // Set timeout
lychee.loadingBar.data("timeout", setTimeout(function() { loadingBar.hide(true) }, 3000)); clearTimeout(lychee.loadingBar.data('timeout'));
lychee.loadingBar.data('timeout', setTimeout(function() { loadingBar.hide(true) }, 3000));
} else if (loadingBar.status===null) { return true;
loadingBar.status = "loading"; }
clearTimeout(lychee.loadingBar.data("timeout")); if (loadingBar.status===null) {
lychee.loadingBar.data("timeout", setTimeout(function() {
// Set status
loadingBar.status = 'loading';
// Set timeout
clearTimeout(lychee.loadingBar.data('timeout'));
lychee.loadingBar.data('timeout', setTimeout(function() {
// Move header down
if (visible.controls()) lychee.header.addClass('loading');
// Modify loading
lychee.loadingBar lychee.loadingBar
.show() .removeClass('loading uploading error')
.removeClass("loading uploading error") .addClass('loading')
.addClass("loading"); .show();
if (visible.controls()) lychee.header.addClass("loading");
}, 1000)); }, 1000));
return true;
} }
}, },
hide: function(force_hide) { hide: function(force) {
if ((loadingBar.status!=="error"&&loadingBar.status!==null)||force_hide) { if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
// Remove status
loadingBar.status = null; loadingBar.status = null;
clearTimeout(lychee.loadingBar.data("timeout"));
lychee.loadingBar.html("").css("height", "3px"); // Move header up
if (visible.controls()) lychee.header.removeClass("error loading"); if (visible.controls()) lychee.header.removeClass('error loading');
// Modify loading
lychee.loadingBar
.html('')
.css('height', '3px');
// Set timeout
clearTimeout(lychee.loadingBar.data('timeout'));
setTimeout(function() { lychee.loadingBar.hide() }, 300); setTimeout(function() { lychee.loadingBar.hide() }, 300);
} }

View File

@ -8,7 +8,7 @@
var lychee = { var lychee = {
title: "", title: "",
version: "2.1.1", version: "2.2",
api_path: "php/api.php", api_path: "php/api.php",
update_path: "http://lychee.electerious.com/version/index.php", update_path: "http://lychee.electerious.com/version/index.php",