Browse Source

Several changes

- New classes for previous and forward photo
- Improved setTitle
- Use document.title for lychee.title as default
- Updated jQuery and other deps
Tobias Reich 9 years ago
parent
commit
3465c96180

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


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


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


+ 1 - 1
src/bower.json

@@ -2,7 +2,7 @@
   "name": "Lychee",
   "private": true,
   "dependencies": {
-    "jQuery": "~2.1.1",
+    "jQuery": "~2.1.3",
     "js-md5": "~1.1.0",
     "mousetrap": "~1.4.6",
     "basicContext": "~2.0.2"

+ 1 - 1
src/package.json

@@ -13,7 +13,7 @@
     "gulp": "^3.8.10",
     "gulp-autoprefixer": "2.0.0",
     "gulp-coffee": "^2.2.0",
-    "gulp-concat": "^2.4.2",
+    "gulp-concat": "^2.4.3",
     "gulp-load-plugins": "^0.8.0",
     "gulp-minify-css": "^0.3.11",
     "gulp-rimraf": "^0.1.1",

+ 2 - 2
src/scripts/build.coffee

@@ -106,8 +106,8 @@ build.imageview = (data, size, visibleControls) ->
 	return '' if not data?
 
 	html =	"""
-			<div class='arrow_wrapper previous'><a id='previous'>#{ build.iconic('caret-left') }</a></div>
-			<div class='arrow_wrapper next'><a id='next'>#{ build.iconic('caret-right') }</a></div>
+			<div class='arrow_wrapper arrow_wrapper--previous'><a id='previous'>#{ build.iconic('caret-left') }</a></div>
+			<div class='arrow_wrapper arrow_wrapper--next'><a id='next'>#{ build.iconic('caret-right') }</a></div>
 			"""
 
 	if size is 'big'

+ 32 - 0
src/scripts/contextMenu.js

@@ -69,6 +69,38 @@ contextMenu.albumMulti = function(albumIDs, e) {
 
 }
 
+contextMenu.albumTitle = function(albumID, e) {
+
+	var items = [
+		{ type: 'item', title: 'Rename', icon: 'icon-edit', fn: function() { album.setTitle([albumID]) } }
+	];
+
+	lychee.api('getAlbums', function(data) {
+
+		if (data.num!==0) {
+
+			items.push({ type: 'separator' });
+
+			// Generate list of albums
+			$.each(data.content, function(index) {
+
+				var that = this;
+
+				if (!that.thumb0) that.thumb0 = 'src/images/no_cover.svg';
+				that.title = "<img class='albumCover' width='16' height='16' src='" + that.thumb0 + "'><div class='albumTitle'>" + that.title + "</div>";
+
+				if (that.id!=album.getID()) items.push({ type: 'item', title: that.title, fn: function() { lychee.goto(that.id) } });
+
+			});
+
+		}
+
+		basicContext.show(items, e, contextMenu.close);
+
+	});
+
+}
+
 contextMenu.photo = function(photoID, e) {
 
 	// Notice for 'Move':

+ 32 - 33
src/scripts/init.js

@@ -16,48 +16,53 @@ $(document).ready(function() {
 	$(document)		.on('mouseup',		multiselect.getSelection);
 
 	/* Header */
-	$('#button_share').on(event_name, function(e) {
+	lychee.header.find('#title').on(event_name, function(e) {
+		if (!$(this).hasClass('editable'))	return false;
+		if (visible.photo())				photo.setTitle([photo.getID()]);
+		else								contextMenu.albumTitle([album.getID()], e);
+	});
+	lychee.header.find('#button_share').on(event_name, function(e) {
 		if (photo.json.public==1||photo.json.public==2)	contextMenu.sharePhoto(photo.getID(), e);
 		else											photo.setPublic(photo.getID(), e);
 	});
-	$('#button_share_album').on(event_name, function(e) {
+	lychee.header.find('#button_share_album').on(event_name, function(e) {
 		if (album.json.public==1)	contextMenu.shareAlbum(album.getID(), e);
 		else						album.setPublic(album.getID(), e);
 	});
-	$('#button_signin')			.on(event_name, lychee.loginDialog);
-	$('#button_settings')		.on(event_name, contextMenu.settings);
-	$('#button_info_album')		.on(event_name, view.infobox.show);
-	$('#button_info')			.on(event_name, view.infobox.show);
-	$('.button_add')			.on(event_name, contextMenu.add);
-	$('#button_more')			.on(event_name, function(e) { contextMenu.photoMore(photo.getID(), e) });
-	$('#button_move')			.on(event_name, function(e) { contextMenu.move([photo.getID()], e) });
-	$('#hostedwith')			.on(event_name, function() { window.open(lychee.website) });
-	$('#button_trash_album')	.on(event_name, function() { album.delete([album.getID()]) });
-	$('#button_trash')			.on(event_name, function() { photo.delete([photo.getID()]) });
-	$('#button_archive')		.on(event_name, function() { album.getArchive(album.getID()) });
-	$('#button_star')			.on(event_name, function() { photo.setStar([photo.getID()]) });
-	$('#button_back_home')		.on(event_name, function() { lychee.goto('') });
-	$('#button_back')			.on(event_name, function() { lychee.goto(album.getID()) });
+	lychee.header.find('#button_signin')		.on(event_name, lychee.loginDialog);
+	lychee.header.find('#button_settings')		.on(event_name, contextMenu.settings);
+	lychee.header.find('#button_info_album')	.on(event_name, view.infobox.show);
+	lychee.header.find('#button_info')			.on(event_name, view.infobox.show);
+	lychee.header.find('.button_add')			.on(event_name, contextMenu.add);
+	lychee.header.find('#button_more')			.on(event_name, function(e) { contextMenu.photoMore(photo.getID(), e) });
+	lychee.header.find('#button_move')			.on(event_name, function(e) { contextMenu.move([photo.getID()], e) });
+	lychee.header.find('#hostedwith')			.on(event_name, function() { window.open(lychee.website) });
+	lychee.header.find('#button_trash_album')	.on(event_name, function() { album.delete([album.getID()]) });
+	lychee.header.find('#button_trash')			.on(event_name, function() { photo.delete([photo.getID()]) });
+	lychee.header.find('#button_archive')		.on(event_name, function() { album.getArchive(album.getID()) });
+	lychee.header.find('#button_star')			.on(event_name, function() { photo.setStar([photo.getID()]) });
+	lychee.header.find('#button_back_home')		.on(event_name, function() { lychee.goto('') });
+	lychee.header.find('#button_back')			.on(event_name, function() { lychee.goto(album.getID()) });
 
 	/* Search */
-	$('#search').on('keyup click', function() { search.find($(this).val()) });
-
-	/* Infobox */
-	$('#infobox .header .close').on(event_name, view.infobox.hide);
+	lychee.header.find('#search').on('keyup click', function() { search.find($(this).val()) });
 
 	/* Clear Search */
-	$('#clearSearch').on(event_name, function () {
-		$('#search').focus();
+	lychee.header.find('#clearSearch').on(event_name, function () {
+		lychee.header.find('#search').focus();
 		search.reset();
 	});
 
+	/* Infobox */
+	lychee.infobox.find('.header .close').on(event_name, view.infobox.hide);
+
 	/* Image View */
 	lychee.imageview
-		.on(event_name, '.arrow_wrapper.previous',	photo.previous)
-		.on(event_name, '.arrow_wrapper.next',		photo.next);
+		.on(event_name, '.arrow_wrapper--previous',	photo.previous)
+		.on(event_name, '.arrow_wrapper--next',		photo.next);
 
 	/* Infobox */
-	$('#infobox')
+	lychee.infobox
 		.on(event_name, '#edit_title_album',		function() { album.setTitle([album.getID()]) })
 		.on(event_name, '#edit_description_album',	function() { album.setDescription(album.getID()) })
 		.on(event_name, '#edit_title',				function() { photo.setTitle([photo.getID()]) })
@@ -72,10 +77,10 @@ $(document).ready(function() {
 		.bind(['u', 'ctrl+u'],	function() { $('#upload_files').click() })
 		.bind(['s', 'ctrl+s', 'f', 'ctrl+f'], function(e) {
 			if (visible.photo()) {
-				$('#button_star').click();
+				lychee.header.find('#button_star').click();
 			} else if (visible.albums()) {
 				e.preventDefault();
-				$('#search').focus();
+				lychee.header.find('#search').focus();
 			}
 		})
 		.bind(['r', 'ctrl+r'], function(e) {
@@ -148,12 +153,6 @@ $(document).ready(function() {
 		/* Login */
 		.on('keyup', '#password', function() { if ($(this).val().length>0) $(this).removeClass('error') })
 
-		/* Header */
-		.on(event_name, '#title.editable', function() {
-			if (visible.photo())	photo.setTitle([photo.getID()]);
-			else					album.setTitle([album.getID()]);
-		})
-
 		/* Navigation */
 		.on('click', '.album', function() { lychee.goto($(this).attr('data-id')) })
 		.on('click', '.photo', function() { lychee.goto(album.getID() + '/' + $(this).attr('data-id')) })

+ 11 - 14
src/scripts/lychee.js

@@ -5,7 +5,7 @@
 
 lychee = {
 
-	title:			'',
+	title:			document.title,
 	version:		'2.7.0',
 	version_code:	'020700',
 
@@ -77,10 +77,10 @@ lychee.api = function(params, callback) {
 	loadingBar.show();
 
 	$.ajax({
-		type:		'POST',
-		url:		lychee.api_path,
-		data:		'function=' + params,
-		dataType:	'text',
+		type: 'POST',
+		url: lychee.api_path,
+		data: 'function=' + params,
+		dataType: 'text',
 		success: function(data) {
 
 			setTimeout(function() { loadingBar.hide() }, 100);
@@ -168,9 +168,7 @@ lychee.loginDialog = function() {
 
 lychee.logout = function() {
 
-	lychee.api('logout', function() {
-		window.location.reload();
-	});
+	lychee.api('logout', window.location.reload);
 
 }
 
@@ -252,15 +250,14 @@ lychee.getUpdate = function() {
 
 lychee.setTitle = function(title, editable) {
 
-	if (lychee.title==='')	lychee.title = document.title;
+	var $title = lychee.header.find('#title');
 
-	if (title==='Albums')	document.title = lychee.title;
-	else					document.title = lychee.title + ' - ' + title;
+	document.title = lychee.title + ' - ' + title;
 
-	if (editable)	$('#title').addClass('editable');
-	else			$('#title').removeClass('editable');
+	if (editable)	$title.addClass('editable');
+	else			$title.removeClass('editable');
 
-	$('#title').html(title);
+	$title.html(title + build.iconic('caret-bottom'));
 
 }
 

+ 6 - 6
src/scripts/view.js

@@ -488,28 +488,28 @@ view.photo = {
 
 		lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.controls()));
 
-		var nextArrow		= lychee.imageview.find('a#next'),
-			previousArrow	= lychee.imageview.find('a#previous'),
+		var $nextArrow		= lychee.imageview.find('a#next'),
+			$previousArrow	= lychee.imageview.find('a#previous'),
 			hasNext			= album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].nextPhoto==='',
 			hasPrevious		= album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].previousPhoto==='';
 
-		if (hasNext||lychee.viewMode) { nextArrow.hide(); }
+		if (hasNext||lychee.viewMode) { $nextArrow.hide(); }
 		else {
 
 			var nextPhotoID	= album.json.content[photo.getID()].nextPhoto,
 				nextPhoto	= album.json.content[nextPhotoID];
 
-			nextArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + nextPhoto.thumbUrl + '")');
+			$nextArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + nextPhoto.thumbUrl + '")');
 
 		}
 
-		if (hasPrevious||lychee.viewMode) { previousArrow.hide(); }
+		if (hasPrevious||lychee.viewMode) { $previousArrow.hide(); }
 		else {
 
 			var previousPhotoID	= album.json.content[photo.getID()].previousPhoto,
 				previousPhoto	= album.json.content[previousPhotoID];
 
-			previousArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + previousPhoto.thumbUrl + '")');
+			$previousArrow.css('background-image', 'linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("' + previousPhoto.thumbUrl + '")');
 
 		};
 

+ 2 - 2
src/styles/_imageview.scss

@@ -54,9 +54,9 @@
 		top: 60px;
 		z-index: 1;
 
-		&.previous { left: 0; }
+		&--previous { left: 0; }
 
-		&.next { right: 0; }
+		&--next { right: 0; }
 
 		a {
 			position: fixed;

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