/**
 * @description	This module takes care of the header.
 * @copyright	2015 by Tobias Reich
 */

header = {

	_dom: $('header')

}

header.dom = function(selector) {

	if (selector===undefined||selector===null||selector==='') return header._dom;
	return header._dom.find(selector);

}

header.show = function() {

	var newMargin = -1*($('#imageview #image').height()/2)+20;

	clearTimeout($(window).data('timeout'));

	lychee.imageview.removeClass('full');
	header.dom().removeClass('hidden');

	// Adjust position or size of photo
	if ($('#imageview #image.small').length>0)	$('#imageview #image').css('margin-top', newMargin);
	else										$('#imageview #image').removeClass('full');

}

header.hide = function(e, delay) {

	var newMargin = -1*($('#imageview #image').height()/2);

	if (delay===undefined) delay = 500;

	if (visible.photo()&&!visible.infobox()&&!visible.contextMenu()&&!visible.message()) {

		clearTimeout($(window).data('timeout'));

		$(window).data('timeout', setTimeout(function() {

			lychee.imageview.addClass('full');
			header.dom().addClass('hidden');

			// Adjust position or size of photo
			if ($('#imageview #image.small').length>0)	$('#imageview #image').css('margin-top', newMargin);
			else										$('#imageview #image').addClass('full');

		}, delay));

	}

}

header.setTitle = function(title) {

	var $title	= header.dom('#title'),
		title	= title || 'Untitled';

	$title.html(title + build.iconic('caret-bottom'));

}

header.setMode = function(mode) {

	var albumID = album.getID();

	switch (mode) {

		case 'albums':

			header.dom().removeClass('view');
			$('#tools_album, #tools_photo').hide();
			$('#tools_albums').show();

			break;

		case 'album':

			header.dom().removeClass('view');
			$('#tools_albums, #tools_photo').hide();
			$('#tools_album').show();

			// Hide download button when album empty
			album.json.content === false ? $('#button_archive').hide() : $('#button_archive').show();

			// Hide download button when not logged in and album not downloadable
			if (lychee.publicMode===true&&album.json.downloadable==='0') $('#button_archive').hide();

			if (albumID==='s'||albumID==='f'||albumID==='r') {
				$('#button_info_album, #button_trash_album, #button_share_album').hide();
			} else if (albumID==='0') {
				$('#button_info_album, #button_share_album').hide();
				$('#button_trash_album').show();
			} else {
				$('#button_info_album, #button_trash_album, #button_share_album').show();
			}

			break;

		case 'photo':

			header.dom().addClass('view');
			$('#tools_albums, #tools_album').hide();
			$('#tools_photo').show();

			break;

	}

}

header.setEditable = function(editable) {

	var $title = header.dom('#title');

	// Hide editable icon when not logged in
	if (lychee.publicMode===true) editable = false;

	if (editable)	$title.addClass('editable');
	else			$title.removeClass('editable');

}
@@ -679,24 +679,39 @@
 s('full');%0A%0A
+%09return true;%0A%0A
 %7D%0A%0Aheader.hi
@@ -730,100 +730,8 @@
 n(e,
- delay) %7B%0A%0A%09var newMargin = -1*($('#imageview #image').height()/2);%0A%0A%09if (delay===undefined)
  del
@@ -738,17 +738,19 @@
 ay = 500
-;
+) %7B
 %0A%0A%09if (v
@@ -778,15 +778,15 @@
 ble.
-infobox
+sidebar
 ()&&
@@ -832,16 +832,75 @@
 e()) %7B%0A%0A
+%09%09var newMargin = -1*($('#imageview #image').height()/2);%0A%0A
 %09%09clearT
@@ -1272,25 +1272,57 @@
  delay));%0A%0A%09
-%7D
+%09return true;%0A%0A%09%7D%0A%0A%09return false;
 %0A%0A%7D%0A%0Aheader.
@@ -1346,16 +1346,29 @@
 on(title
+ = 'Untitled'
 ) %7B%0A%0A%09va
@@ -1402,39 +1402,8 @@
 le')
-,%0A%09%09title%09= title %7C%7C 'Untitled'
 ;%0A%0A%09
@@ -1450,24 +1450,39 @@
 bottom'));%0A%0A
+%09return true;%0A%0A
 %7D%0A%0Aheader.se
@@ -1677,32 +1677,48 @@
 bums').show();%0A%0A
+%09%09%09return true;%0A
 %09%09%09break;%0A%0A%09%09cas
@@ -2498,16 +2498,32 @@
 ;%0A%09%09%09%7D%0A%0A
+%09%09%09return true;%0A
 %09%09%09break
@@ -2657,18 +2657,50 @@
 %0A%09%09%09
-break;%0A%0A%09%7D
+return true;%0A%09%09%09break;%0A%0A%09%7D%0A%0A%09return false;
 %0A%0A%7D%0A
@@ -2953,13 +2953,28 @@
 ditable');%0A%0A
+%09return true;%0A%0A
 %7D

Return true/false in header functions