Browse Source

Code adjustments

Tobias Reich 9 years ago
parent
commit
f882bac6f2
4 changed files with 163 additions and 165 deletions
  1. 0 0
      dist/main.js
  2. 13 13
      src/scripts/build.js
  3. 140 142
      src/scripts/multiselect.js
  4. 10 10
      src/scripts/visible.js

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


+ 13 - 13
src/scripts/build.js

@@ -11,19 +11,19 @@ build.divider = function(title) {
 
 	return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
 
-},
+}
 
 build.editIcon = function(id) {
 
 	return "<div id='" + id + "' class='edit'><a class='icon-pencil'></a></div>";
 
-},
+}
 
 build.multiselect = function(top, left) {
 
 	return "<div id='multiselect' style='top: " + top + "px; left: " + left + "px;'></div>";
 
-},
+}
 
 build.album = function(albumJSON) {
 
@@ -66,7 +66,7 @@ build.album = function(albumJSON) {
 
 	return album;
 
-},
+}
 
 build.photo = function(photoJSON) {
 
@@ -101,7 +101,7 @@ build.photo = function(photoJSON) {
 
 	return photo;
 
-},
+}
 
 build.imageview = function(photoJSON, size, visibleControls) {
 
@@ -138,7 +138,7 @@ build.imageview = function(photoJSON, size, visibleControls) {
 
 	return view;
 
-},
+}
 
 build.no_content = function(typ) {
 
@@ -155,7 +155,7 @@ build.no_content = function(typ) {
 
 	return no_content;
 
-},
+}
 
 build.modal = function(title, text, button, marginTop, closeButton) {
 
@@ -192,7 +192,7 @@ build.modal = function(title, text, button, marginTop, closeButton) {
 
 	return modal;
 
-},
+}
 
 build.signInModal = function() {
 
@@ -213,7 +213,7 @@ build.signInModal = function() {
 
 	return modal;
 
-},
+}
 
 build.uploadModal = function(title, files) {
 
@@ -246,7 +246,7 @@ build.uploadModal = function(title, files) {
 
 	return modal;
 
-},
+}
 
 build.contextMenu = function(items) {
 
@@ -272,7 +272,7 @@ build.contextMenu = function(items) {
 
 	return menu;
 
-},
+}
 
 build.tags = function(tags, forView) {
 
@@ -300,7 +300,7 @@ build.tags = function(tags, forView) {
 
 	return html;
 
-},
+}
 
 build.infoboxPhoto = function(photoJSON, forView) {
 
@@ -405,7 +405,7 @@ build.infoboxPhoto = function(photoJSON, forView) {
 
 	return infobox;
 
-},
+}
 
 build.infoboxAlbum = function(albumJSON, forView) {
 

+ 140 - 142
src/scripts/multiselect.js

@@ -5,206 +5,204 @@
  * @copyright	2014 by Tobias Reich
  */
 
-multiselect = {
+multiselect = {};
 
-	position: {
+multiselect.position = {
 
-		top:	null,
-		right:	null,
-		bottom:	null,
-		left:	null
+	top:	null,
+	right:	null,
+	bottom:	null,
+	left:	null
 
-	},
+}
 
-	show: function(e) {
+multiselect.show = function(e) {
 
-		if (mobileBrowser())	return false;
-		if (lychee.publicMode)	return false;
-		if (visible.search())	return false;
-		if (visible.infobox())	return false;
-		if (!visible.albums()&&!visible.album)			return false;
-		if ($('.album:hover, .photo:hover').length!==0)	return false;
-		if (visible.multiselect())						$('#multiselect').remove();
+	if (mobileBrowser())	return false;
+	if (lychee.publicMode)	return false;
+	if (visible.search())	return false;
+	if (visible.infobox())	return false;
+	if (!visible.albums()&&!visible.album)			return false;
+	if ($('.album:hover, .photo:hover').length!==0)	return false;
+	if (visible.multiselect())						$('#multiselect').remove();
 
-		multiselect.position.top	= e.pageY;
-		multiselect.position.right	= -1 * (e.pageX - $(document).width());
-		multiselect.position.bottom	= -1 * (multiselect.position.top - $(window).height());
-		multiselect.position.left	= e.pageX;
+	multiselect.position.top	= e.pageY;
+	multiselect.position.right	= -1 * (e.pageX - $(document).width());
+	multiselect.position.bottom	= -1 * (multiselect.position.top - $(window).height());
+	multiselect.position.left	= e.pageX;
 
-		$('body').append(build.multiselect(multiselect.position.top, multiselect.position.left));
-		$(document).on('mousemove', multiselect.resize);
+	$('body').append(build.multiselect(multiselect.position.top, multiselect.position.left));
+	$(document).on('mousemove', multiselect.resize);
 
-	},
+}
 
-	selectAll: function() {
+multiselect.selectAll = function() {
 
-		var e,
-			newWidth,
-			newHeight;
+	var e,
+		newWidth,
+		newHeight;
 
-		if (mobileBrowser())		return false;
-		if (lychee.publicMode)		return false;
-		if (visible.search())		return false;
-		if (visible.infobox())		return false;
-		if (!visible.albums()&&!visible.album)	return false;
-		if (visible.multiselect())	$('#multiselect').remove();
+	if (mobileBrowser())		return false;
+	if (lychee.publicMode)		return false;
+	if (visible.search())		return false;
+	if (visible.infobox())		return false;
+	if (!visible.albums()&&!visible.album)	return false;
+	if (visible.multiselect())	$('#multiselect').remove();
 
-		multiselect.position.top	= 70;
-		multiselect.position.right	= 40;
-		multiselect.position.bottom	= 90;
-		multiselect.position.left	= 20;
+	multiselect.position.top	= 70;
+	multiselect.position.right	= 40;
+	multiselect.position.bottom	= 90;
+	multiselect.position.left	= 20;
 
-		$('body').append(build.multiselect(multiselect.position.top, multiselect.position.left));
+	$('body').append(build.multiselect(multiselect.position.top, multiselect.position.left));
 
-		newWidth	= $(document).width() - multiselect.position.right + 2;
-		newHeight	= $(document).height() - multiselect.position.bottom;
+	newWidth	= $(document).width() - multiselect.position.right + 2;
+	newHeight	= $(document).height() - multiselect.position.bottom;
 
-		$('#multiselect').css({
-			width: newWidth,
-			height: newHeight
-		});
+	$('#multiselect').css({
+		width: newWidth,
+		height: newHeight
+	});
 
-		e = {
-			pageX: $(document).width() - (multiselect.position.right / 2),
-			pageY: $(document).height() - multiselect.position.bottom
-		};
+	e = {
+		pageX: $(document).width() - (multiselect.position.right / 2),
+		pageY: $(document).height() - multiselect.position.bottom
+	};
 
-		multiselect.getSelection(e);
+	multiselect.getSelection(e);
 
-	},
+}
 
-	resize: function(e) {
+multiselect.resize = function(e) {
 
-		var mouse_x = e.pageX,
-			mouse_y = e.pageY,
-			newHeight,
-			newWidth;
+	var mouse_x = e.pageX,
+		mouse_y = e.pageY,
+		newHeight,
+		newWidth;
 
-		if (multiselect.position.top===null||
-			multiselect.position.right===null||
-			multiselect.position.bottom===null||
-			multiselect.position.left===null) return false;
+	if (multiselect.position.top===null||
+		multiselect.position.right===null||
+		multiselect.position.bottom===null||
+		multiselect.position.left===null) return false;
 
-		if (mouse_y>=multiselect.position.top) {
+	if (mouse_y>=multiselect.position.top) {
 
-			// Do not leave the screen
-			newHeight = mouse_y - multiselect.position.top;
-			if ((multiselect.position.top+newHeight)>=$(document).height())
-				newHeight -= (multiselect.position.top + newHeight) - $(document).height() + 2;
+		// Do not leave the screen
+		newHeight = mouse_y - multiselect.position.top;
+		if ((multiselect.position.top+newHeight)>=$(document).height())
+			newHeight -= (multiselect.position.top + newHeight) - $(document).height() + 2;
 
-			$('#multiselect').css({
-				top: multiselect.position.top,
-				bottom: 'inherit',
-				height: newHeight
-			});
-
-		} else {
+		$('#multiselect').css({
+			top: multiselect.position.top,
+			bottom: 'inherit',
+			height: newHeight
+		});
 
-			$('#multiselect').css({
-				top: 'inherit',
-				bottom: multiselect.position.bottom,
-				height: multiselect.position.top - e.pageY
-			});
+	} else {
 
-		}
+		$('#multiselect').css({
+			top: 'inherit',
+			bottom: multiselect.position.bottom,
+			height: multiselect.position.top - e.pageY
+		});
 
-		if (mouse_x>=multiselect.position.left) {
+	}
 
-			// Do not leave the screen
-			newWidth = mouse_x - multiselect.position.left;
-			if ((multiselect.position.left+newWidth)>=$(document).width())
-				newWidth -= (multiselect.position.left + newWidth) - $(document).width() + 2;
+	if (mouse_x>=multiselect.position.left) {
 
-			$('#multiselect').css({
-				right: 'inherit',
-				left: multiselect.position.left,
-				width: newWidth
-			});
+		// Do not leave the screen
+		newWidth = mouse_x - multiselect.position.left;
+		if ((multiselect.position.left+newWidth)>=$(document).width())
+			newWidth -= (multiselect.position.left + newWidth) - $(document).width() + 2;
 
-		} else {
+		$('#multiselect').css({
+			right: 'inherit',
+			left: multiselect.position.left,
+			width: newWidth
+		});
 
-			$('#multiselect').css({
-				right: multiselect.position.right,
-				left: 'inherit',
-				width: multiselect.position.left - e.pageX
-			});
+	} else {
 
-		}
+		$('#multiselect').css({
+			right: multiselect.position.right,
+			left: 'inherit',
+			width: multiselect.position.left - e.pageX
+		});
 
-	},
+	}
 
-	stopResize: function() {
+}
 
-		$(document).off('mousemove');
+multiselect.stopResize = function() {
 
-	},
+	$(document).off('mousemove');
 
-	getSize: function() {
+}
 
-		if (!visible.multiselect()) return false;
+multiselect.getSize = function() {
 
-		return {
-			top:	$('#multiselect').offset().top,
-			left:	$('#multiselect').offset().left,
-			width:	parseInt($('#multiselect').css('width').replace('px', '')),
-			height:	parseInt($('#multiselect').css('height').replace('px', ''))
-		};
+	if (!visible.multiselect()) return false;
 
-	},
+	return {
+		top:	$('#multiselect').offset().top,
+		left:	$('#multiselect').offset().left,
+		width:	parseInt($('#multiselect').css('width').replace('px', '')),
+		height:	parseInt($('#multiselect').css('height').replace('px', ''))
+	};
 
-	getSelection: function(e) {
+}
 
-		var tolerance = 150,
-			id,
-			ids = [],
-			offset,
-			size = multiselect.getSize();
+multiselect.getSelection = function(e) {
 
-		if (visible.contextMenu()) return false;
-		if (!visible.multiselect()) return false;
+	var tolerance = 150,
+		id,
+		ids = [],
+		offset,
+		size = multiselect.getSize();
 
-		$('.photo, .album').each(function() {
+	if (visible.contextMenu()) return false;
+	if (!visible.multiselect()) return false;
 
-			offset = $(this).offset();
+	$('.photo, .album').each(function() {
 
-			if (offset.top>=(size.top-tolerance)&&
-				offset.left>=(size.left-tolerance)&&
-				(offset.top+206)<=(size.top+size.height+tolerance)&&
-				(offset.left+206)<=(size.left+size.width+tolerance)) {
+		offset = $(this).offset();
 
-					id = $(this).data('id');
+		if (offset.top>=(size.top-tolerance)&&
+			offset.left>=(size.left-tolerance)&&
+			(offset.top+206)<=(size.top+size.height+tolerance)&&
+			(offset.left+206)<=(size.left+size.width+tolerance)) {
 
-					if (id!=='0'&&id!==0&&id!=='f'&&id!=='s'&&id!=='r'&&id!==null&&id!==undefined) {
+				id = $(this).data('id');
 
-						ids.push(id);
-						$(this).addClass('active');
+				if (id!=='0'&&id!==0&&id!=='f'&&id!=='s'&&id!=='r'&&id!==null&&id!==undefined) {
 
-					}
+					ids.push(id);
+					$(this).addClass('active');
 
 				}
 
-		});
+			}
 
-		if (ids.length!==0&&visible.album()) contextMenu.photoMulti(ids, e);
-		else if (ids.length!==0&&visible.albums()) contextMenu.albumMulti(ids, e);
-		else multiselect.close();
+	});
 
-	},
+	if (ids.length!==0&&visible.album()) contextMenu.photoMulti(ids, e);
+	else if (ids.length!==0&&visible.albums()) contextMenu.albumMulti(ids, e);
+	else multiselect.close();
 
-	close: function() {
+}
 
-		multiselect.stopResize();
+multiselect.close = function() {
 
-		multiselect.position.top	= null;
-		multiselect.position.right	= null;
-		multiselect.position.bottom	= null;
-		multiselect.position.left	= null;
+	multiselect.stopResize();
 
-		lychee.animate('#multiselect', 'fadeOut');
-		setTimeout(function() {
-			$('#multiselect').remove();
-		}, 300);
+	multiselect.position.top	= null;
+	multiselect.position.right	= null;
+	multiselect.position.bottom	= null;
+	multiselect.position.left	= null;
 
-	}
+	lychee.animate('#multiselect', 'fadeOut');
+	setTimeout(function() {
+		$('#multiselect').remove();
+	}, 300);
 
-};
+}

+ 10 - 10
src/scripts/visible.js

@@ -10,54 +10,54 @@ visible = {};
 visible.albums = function() {
 	if ($('#tools_albums').css('display')==='block') return true;
 	else return false;
-},
+}
 
 visible.album = function() {
 	if ($('#tools_album').css('display')==='block') return true;
 	else return false;
-},
+}
 
 visible.photo = function() {
 	if ($('#imageview.fadeIn').length>0) return true;
 	else return false;
-},
+}
 
 visible.search = function() {
 	if (search.code!==null&&search.code!=='') return true;
 	else return false;
-},
+}
 
 visible.infobox = function() {
 	if ($('#infobox.active').length>0) return true;
 	else return false;
-},
+}
 
 visible.infoboxbutton = function() {
 	if (visible.albums()) return false;
 	if (visible.photo()) return true;
 	if (visible.album()&&$('#button_info_album:visible').length>0) return true;
 	else return false;
-},
+}
 
 visible.controls = function() {
 	if (lychee.loadingBar.css('opacity')<1) return false;
 	else return true;
-},
+}
 
 visible.message = function() {
 	if ($('.message').length>0) return true;
 	else return false;
-},
+}
 
 visible.signin = function() {
 	if ($('.message .sign_in').length>0) return true;
 	else return false;
-},
+}
 
 visible.contextMenu = function() {
 	if ($('.contextmenu').length>0) return true;
 	else return false;
-},
+}
 
 visible.multiselect = function() {
 	if ($('#multiselect').length>0) return true;

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