Browse Source

Updated loadingBar.js (ES2015)

Tobias Reich 8 years ago
parent
commit
63b2a2412d
4 changed files with 31 additions and 35 deletions
  1. 0 0
      dist/main.js
  2. 2 2
      src/scripts/contextMenu.js
  3. 2 2
      src/scripts/header.js
  4. 27 31
      src/scripts/loadingBar.js

File diff suppressed because it is too large
+ 0 - 0
dist/main.js


+ 2 - 2
src/scripts/contextMenu.js

@@ -1,6 +1,6 @@
 /**
- * @description	This module is used for the context menu.
- * @copyright	2015 by Tobias Reich
+ * @description This module is used for the context menu.
+ * @copyright   2015 by Tobias Reich
  */
 
 contextMenu = {}

+ 2 - 2
src/scripts/header.js

@@ -1,6 +1,6 @@
 /**
- * @description	This module takes care of the header.
- * @copyright	2015 by Tobias Reich
+ * @description This module takes care of the header.
+ * @copyright   2015 by Tobias Reich
  */
 
 header = {

+ 27 - 31
src/scripts/loadingBar.js

@@ -1,19 +1,19 @@
 /**
- * @description	This module is used to show and hide the loading bar.
- * @copyright	2015 by Tobias Reich
+ * @description This module is used to show and hide the loading bar.
+ * @copyright   2015 by Tobias Reich
  */
 
 loadingBar = {
 
-	status:	null,
-	_dom:	$('#loading')
+	status : null,
+	_dom   : $('#loading')
 
 }
 
 loadingBar.dom = function(selector) {
 
-	if (selector===undefined||selector===null||selector==='') return loadingBar._dom;
-	return loadingBar._dom.find(selector);
+	if (selector==null || selector==='') return loadingBar._dom
+	return loadingBar._dom.find(selector)
 
 }
 
@@ -22,56 +22,52 @@ loadingBar.show = function(status, errorText) {
 	if (status==='error') {
 
 		// Set status
-		loadingBar.status = 'error';
+		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!';
+		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');
+		if (visible.header()) header.dom().addClass('error')
 
 		// Modify loading
 		loadingBar.dom()
 			.removeClass('loading uploading error')
-			.html('<h1>Error: <span>' + errorText + '</span></h1>')
+			.html(`<h1>Error: <span>${ errorText }</span></h1>`)
 			.addClass(status)
-			.show();
+			.show()
 
 		// Set timeout
-		clearTimeout(loadingBar._timeout);
-		loadingBar._timeout = setTimeout(function() {
+		clearTimeout(loadingBar._timeout)
+		loadingBar._timeout = setTimeout(() => loadingBar.hide(true), 3000)
 
-			loadingBar.hide(true)
-
-		}, 3000);
-
-		return true;
+		return true
 
 	}
 
 	if (loadingBar.status===null) {
 
 		// Set status
-		loadingBar.status = 'loading';
+		loadingBar.status = 'loading'
 
 		// Set timeout
-		clearTimeout(loadingBar._timeout);
-		loadingBar._timeout = setTimeout(function() {
+		clearTimeout(loadingBar._timeout)
+		loadingBar._timeout = setTimeout(() => {
 
 			// Move header down
-			if (visible.header()) header.dom().addClass('loading');
+			if (visible.header()) header.dom().addClass('loading')
 
 			// Modify loading
 			loadingBar.dom()
 				.removeClass('loading uploading error')
 				.html('')
 				.addClass('loading')
-				.show();
+				.show()
 
-		}, 1000);
+		}, 1000)
 
-		return true;
+		return true
 
 	}
 
@@ -79,17 +75,17 @@ loadingBar.show = function(status, errorText) {
 
 loadingBar.hide = function(force) {
 
-	if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
+	if ((loadingBar.status!=='error' && loadingBar.status!==null) || force) {
 
 		// Remove status
-		loadingBar.status = null;
+		loadingBar.status = null
 
 		// Move header up
-		header.dom().removeClass('error loading');
+		header.dom().removeClass('error loading')
 
 		// Set timeout
-		clearTimeout(loadingBar._timeout);
-		setTimeout(function() { loadingBar.dom().hide() }, 300);
+		clearTimeout(loadingBar._timeout)
+		setTimeout(() => loadingBar.dom().hide(), 300)
 
 	}
 

Some files were not shown because too many files changed in this diff