Browse Source

Added loadingBar.dom, changed visible.header

Tobias Reich 9 years ago
parent
commit
61cf46be1f
7 changed files with 30 additions and 21 deletions
  1. 0 0
      dist/main.js
  2. 0 2
      src/scripts/header.js
  3. 1 1
      src/scripts/init.js
  4. 26 14
      src/scripts/loadingBar.js
  5. 0 1
      src/scripts/lychee.js
  6. 1 1
      src/scripts/view.js
  7. 2 2
      src/scripts/visible.js

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


+ 0 - 2
src/scripts/header.js

@@ -24,7 +24,6 @@ header.show = function() {
 
 	lychee.imageview.removeClass('full');
 	header.dom().removeClass('hidden');
-	lychee.loadingBar.css('opacity', 1);
 
 	// Adjust position or size of photo
 	if ($('#imageview #image.small').length>0)	$('#imageview #image').css('margin-top', newMargin);
@@ -46,7 +45,6 @@ header.hide = function(e, delay) {
 
 			lychee.imageview.addClass('full');
 			header.dom().addClass('hidden');
-			lychee.loadingBar.css('opacity', 0);
 
 			// Adjust position or size of photo
 			if ($('#imageview #image.small').length>0)	$('#imageview #image').css('margin-top', newMargin);

+ 1 - 1
src/scripts/init.js

@@ -132,7 +132,7 @@ $(document).ready(function() {
 			/* Fullscreen on mobile */
 			.on('touchend', '#image', function(e) {
 				if (swipe.obj===null||(swipe.offset>=-5&&swipe.offset<=5)) {
-					if (visible.controls())	header.hide(e, 0);
+					if (visible.header())	header.hide(e, 0);
 					else					header.show();
 				}
 			})

+ 26 - 14
src/scripts/loadingBar.js

@@ -5,7 +5,15 @@
 
 loadingBar = {
 
-	status: null
+	status:	null,
+	_dom:	$('#loading')
+
+}
+
+loadingBar.dom = function(selector) {
+
+	if (selector===undefined||selector===null||selector==='') return loadingBar._dom;
+	return loadingBar._dom.find(selector);
 
 }
 
@@ -21,10 +29,10 @@ loadingBar.show = function(status, errorText) {
 		if (!errorText)	errorText = 'Whoops, it looks like something went wrong. Please reload the site and try again!';
 
 		// Move header down
-		if (visible.controls()) header.dom().addClass('error');
+		if (visible.header()) header.dom().addClass('error');
 
 		// Modify loading
-		lychee.loadingBar
+		loadingBar.dom()
 			.removeClass('loading uploading error')
 			.addClass(status)
 			.html('<h1>Error: <span>' + errorText + '</span></h1>')
@@ -32,8 +40,12 @@ loadingBar.show = function(status, errorText) {
 			.css('height', '40px');
 
 		// Set timeout
-		clearTimeout(lychee.loadingBar.data('timeout'));
-		lychee.loadingBar.data('timeout', setTimeout(function() { loadingBar.hide(true) }, 3000));
+		clearTimeout(loadingBar._timeout);
+		loadingBar._timeout = setTimeout(function() {
+
+			loadingBar.hide(true)
+
+		}, 3000);
 
 		return true;
 
@@ -45,19 +57,19 @@ loadingBar.show = function(status, errorText) {
 		loadingBar.status = 'loading';
 
 		// Set timeout
-		clearTimeout(lychee.loadingBar.data('timeout'));
-		lychee.loadingBar.data('timeout', setTimeout(function() {
+		clearTimeout(loadingBar._timeout);
+		loadingBar._timeout = setTimeout(function() {
 
 			// Move header down
-			if (visible.controls()) header.dom().addClass('loading');
+			if (visible.header()) header.dom().addClass('loading');
 
 			// Modify loading
-			lychee.loadingBar
+			loadingBar.dom()
 				.removeClass('loading uploading error')
 				.addClass('loading')
 				.show();
 
-		}, 1000));
+		}, 1000);
 
 		return true;
 
@@ -73,16 +85,16 @@ loadingBar.hide = function(force) {
 		loadingBar.status = null;
 
 		// Move header up
-		if (visible.controls()) header.dom().removeClass('error loading');
+		if (visible.header()) header.dom().removeClass('error loading');
 
 		// Modify loading
-		lychee.loadingBar
+		loadingBar.dom()
 			.html('')
 			.css('height', '3px');
 
 		// Set timeout
-		clearTimeout(lychee.loadingBar.data('timeout'));
-		setTimeout(function() { lychee.loadingBar.hide() }, 300);
+		clearTimeout(loadingBar._timeout);
+		setTimeout(function() { loadingBar.dom().hide() }, 300);
 
 	}
 

+ 0 - 1
src/scripts/lychee.js

@@ -25,7 +25,6 @@ lychee = {
 	dropbox:		false,
 	dropboxKey:		'',
 
-	loadingBar:		$('#loading'),
 	content:		$('#content'),
 	imageview:		$('#imageview'),
 	infobox:		$('#infobox')

+ 1 - 1
src/scripts/view.js

@@ -409,7 +409,7 @@ view.photo = {
 
 	photo: function() {
 
-		lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.controls()));
+		lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.header()));
 
 		var $nextArrow		= lychee.imageview.find('a#next'),
 			$previousArrow	= lychee.imageview.find('a#previous'),

+ 2 - 2
src/scripts/visible.js

@@ -37,8 +37,8 @@ visible.infoboxbutton = function() {
 	return false;
 }
 
-visible.controls = function() {
-	if (lychee.loadingBar.css('opacity')<1) return false;
+visible.header = function() {
+	if (header.dom().hasClass('hidden')===true) return false;
 	return true;
 }
 

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