Scrolling, load order.
This commit is contained in:
		@ -52,10 +52,10 @@ $(document).ready(function() {
 | 
				
			|||||||
		$("#loading").hide();
 | 
							$("#loading").hide();
 | 
				
			||||||
		album_cache[cachePath(album.path)] = album;
 | 
							album_cache[cachePath(album.path)] = album;
 | 
				
			||||||
		current_album = album;
 | 
							current_album = album;
 | 
				
			||||||
		if (cachePath(album.path) == current_album_cache)
 | 
					 | 
				
			||||||
			showAlbum();
 | 
					 | 
				
			||||||
		if (current_photo_cache != null)
 | 
							if (current_photo_cache != null)
 | 
				
			||||||
			showPhoto();
 | 
								showPhoto();
 | 
				
			||||||
 | 
							if (cachePath(album.path) == current_album_cache)
 | 
				
			||||||
 | 
								showAlbum(true);
 | 
				
			||||||
		setTitle();
 | 
							setTitle();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	function trimExtension(title) {
 | 
						function trimExtension(title) {
 | 
				
			||||||
@ -89,16 +89,16 @@ $(document).ready(function() {
 | 
				
			|||||||
			title += trimExtension(current_photo.name);
 | 
								title += trimExtension(current_photo.name);
 | 
				
			||||||
		$("#title").html(title);
 | 
							$("#title").html(title);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	function showAlbum() {
 | 
						function showAlbum(populate) {
 | 
				
			||||||
		$("html, body").animate({ scrollTop: 0 }, "slow");
 | 
							if (current_photo_cache == null && previous_photo_cache == null)
 | 
				
			||||||
 | 
								$("html, body").stop().animate({ scrollTop: 0 }, "slow");
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (populate) {
 | 
				
			||||||
			var photos = "";
 | 
								var photos = "";
 | 
				
			||||||
			for (var i = 0; i < current_album.photos.length; ++i)
 | 
								for (var i = 0; i < current_album.photos.length; ++i)
 | 
				
			||||||
				photos += "<a href=\"#" + current_album_cache + "/" + cachePath(current_album.photos[i].name) + "\"><img title=\"" + trimExtension(current_album.photos[i].name) + "\" alt=\"" + trimExtension(current_album.photos[i].name) + "\" id=\"thumb-" + cachePath(current_album.photos[i].name) + "\" src=\"" + imagePath(current_album.photos[i].name, current_album.path, 150, true) + "\" height=\"150\" width=\"150\"></a>";
 | 
									photos += "<a href=\"#" + current_album_cache + "/" + cachePath(current_album.photos[i].name) + "\"><img title=\"" + trimExtension(current_album.photos[i].name) + "\" alt=\"" + trimExtension(current_album.photos[i].name) + "\" id=\"thumb-" + cachePath(current_album.photos[i].name) + "\" src=\"" + imagePath(current_album.photos[i].name, current_album.path, 150, true) + "\" height=\"150\" width=\"150\"></a>";
 | 
				
			||||||
			$("#thumbs").html(photos);
 | 
								$("#thumbs").html(photos);
 | 
				
			||||||
		if (current_album.albums.length)
 | 
								
 | 
				
			||||||
			$("#subalbums-title").show();
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			$("#subalbums-title").hide();
 | 
					 | 
				
			||||||
			var subalbums = "";
 | 
								var subalbums = "";
 | 
				
			||||||
			var thumbFinderList = new Array();
 | 
								var thumbFinderList = new Array();
 | 
				
			||||||
			for (var i = current_album.albums.length - 1; i >= 0; --i) {
 | 
								for (var i = current_album.albums.length - 1; i >= 0; --i) {
 | 
				
			||||||
@ -114,11 +114,15 @@ $(document).ready(function() {
 | 
				
			|||||||
						$("#" + thumb.id).css("background-image", "url(" + imagePath(photo.name, album.path, 150, true) + ")");
 | 
											$("#" + thumb.id).css("background-image", "url(" + imagePath(photo.name, album.path, 150, true) + ")");
 | 
				
			||||||
					});
 | 
										});
 | 
				
			||||||
				})(thumbFinderList[i]);
 | 
									})(thumbFinderList[i]);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
							if (current_photo_cache == null) {
 | 
				
			||||||
			$("#album-view").removeClass("photo-view-container");
 | 
								$("#album-view").removeClass("photo-view-container");
 | 
				
			||||||
			$("#subalbums").show();
 | 
								$("#subalbums").show();
 | 
				
			||||||
			$("#photo-view").hide();
 | 
								$("#photo-view").hide();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							scrollToThumb();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	function getDecimal(fraction) {
 | 
						function getDecimal(fraction) {
 | 
				
			||||||
		if (fraction[0] < fraction[1])
 | 
							if (fraction[0] < fraction[1])
 | 
				
			||||||
			return fraction[0] + "/" + fraction[1];
 | 
								return fraction[0] + "/" + fraction[1];
 | 
				
			||||||
@ -176,10 +180,22 @@ $(document).ready(function() {
 | 
				
			|||||||
		$("#album-view").addClass("photo-view-container");
 | 
							$("#album-view").addClass("photo-view-container");
 | 
				
			||||||
		$("#subalbums").hide();
 | 
							$("#subalbums").hide();
 | 
				
			||||||
		$("#photo-view").show();
 | 
							$("#photo-view").show();
 | 
				
			||||||
		var thumb = $("#thumb-" + escapeId(current_photo_cache));
 | 
						}
 | 
				
			||||||
 | 
						function scrollToThumb() {
 | 
				
			||||||
 | 
							var photo = current_photo_cache
 | 
				
			||||||
 | 
							if (photo == null) {
 | 
				
			||||||
 | 
								photo = previous_photo_cache;
 | 
				
			||||||
 | 
								if (photo == null)
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							var thumb = $("#thumb-" + escapeId(photo));
 | 
				
			||||||
 | 
							if (!thumb.length)
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							if (current_photo_cache != null) {
 | 
				
			||||||
			var scroller = $("#album-view");
 | 
								var scroller = $("#album-view");
 | 
				
			||||||
		scroller.stop();
 | 
								scroller.stop().animate({ scrollLeft: thumb.position().left + scroller.scrollLeft() - scroller.width() / 2 + thumb.width() / 2 }, "slow");
 | 
				
			||||||
		scroller.animate({ scrollLeft: thumb.position().left + scroller.scrollLeft() - scroller.width() / 2 + thumb.width() / 2 }, "slow");
 | 
							} else
 | 
				
			||||||
 | 
								$("html, body").stop().animate({ scrollTop: thumb.offset().top - $(window).height() / 2 + thumb.height() }, "slow");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	function currentPhoto() {
 | 
						function currentPhoto() {
 | 
				
			||||||
		for (current_photo_index = 0; current_photo_index < current_album.photos.length; ++current_photo_index) {
 | 
							for (current_photo_index = 0; current_photo_index < current_album.photos.length; ++current_photo_index) {
 | 
				
			||||||
@ -229,6 +245,7 @@ $(document).ready(function() {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	var current_album_cache = null;
 | 
						var current_album_cache = null;
 | 
				
			||||||
	var current_photo_cache = null;
 | 
						var current_photo_cache = null;
 | 
				
			||||||
 | 
						var previous_photo_cache = null;
 | 
				
			||||||
	var current_album = null;
 | 
						var current_album = null;
 | 
				
			||||||
	var current_photo = null;
 | 
						var current_photo = null;
 | 
				
			||||||
	var current_photo_index = -1;
 | 
						var current_photo_index = -1;
 | 
				
			||||||
@ -237,21 +254,25 @@ $(document).ready(function() {
 | 
				
			|||||||
		var new_album_cache = location.hash.substring(1);
 | 
							var new_album_cache = location.hash.substring(1);
 | 
				
			||||||
		var index = new_album_cache.lastIndexOf("/");
 | 
							var index = new_album_cache.lastIndexOf("/");
 | 
				
			||||||
		if (index != -1 && index != new_album_cache.length - 1) {
 | 
							if (index != -1 && index != new_album_cache.length - 1) {
 | 
				
			||||||
 | 
								previous_photo_cache = current_photo_cache;
 | 
				
			||||||
			current_photo_cache = new_album_cache.substring(index + 1);
 | 
								current_photo_cache = new_album_cache.substring(index + 1);
 | 
				
			||||||
			new_album_cache = new_album_cache.substring(0, index);
 | 
								new_album_cache = new_album_cache.substring(0, index);
 | 
				
			||||||
		} else
 | 
							} else {
 | 
				
			||||||
 | 
								previous_photo_cache = current_photo_cache;
 | 
				
			||||||
			current_photo_cache = null;
 | 
								current_photo_cache = null;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (!new_album_cache.length)
 | 
							if (!new_album_cache.length)
 | 
				
			||||||
			new_album_cache = cachePath("root");
 | 
								new_album_cache = cachePath("root");
 | 
				
			||||||
		if (new_album_cache != current_album_cache) {
 | 
							if (new_album_cache != current_album_cache) {
 | 
				
			||||||
			current_album_cache = new_album_cache;
 | 
								current_album_cache = new_album_cache;
 | 
				
			||||||
 | 
								previous_photo_cache = null;
 | 
				
			||||||
			loadAlbum();
 | 
								loadAlbum();
 | 
				
			||||||
		} else if (current_photo_cache != null) {
 | 
							} else if (current_photo_cache != null) {
 | 
				
			||||||
			showAlbum();
 | 
					 | 
				
			||||||
			showPhoto();
 | 
								showPhoto();
 | 
				
			||||||
 | 
								showAlbum(false);
 | 
				
			||||||
			setTitle();
 | 
								setTitle();
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			showAlbum();
 | 
								showAlbum(false);
 | 
				
			||||||
			setTitle();
 | 
								setTitle();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user