Browse Source

Simplified view.photo.photo and only call and save photo.getID() once

Tobias Reich 8 years ago
parent
commit
e6059dbd32
1 changed files with 8 additions and 7 deletions
  1. 8 7
      src/scripts/view.js

+ 8 - 7
src/scripts/view.js

@@ -406,27 +406,28 @@ view.photo = {
 
 	photo: function() {
 
-		lychee.imageview.html(build.imageview(photo.json, photo.getSize(), visible.header()))
+		lychee.imageview.html(build.imageview(photo.json, visible.header()))
 
 		let $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===''
+		    photoID        = photo.getID(),
+		    hasNext        = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].nextPhoto!=='',
+		    hasPrevious    = album.json && album.json.content && album.json.content[photoID] && album.json.content[photoID].previousPhoto!==''
 
-		if (hasNext || lychee.viewMode) { $nextArrow.hide() }
+		if (hasNext===false || lychee.viewMode===true) { $nextArrow.hide() }
 		else {
 
-			let nextPhotoID = album.json.content[photo.getID()].nextPhoto,
+			let nextPhotoID = album.json.content[photoID].nextPhoto,
 			    nextPhoto   = album.json.content[nextPhotoID]
 
 			$nextArrow.css('background-image', lychee.html`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===false || lychee.viewMode===true) { $previousArrow.hide() }
 		else {
 
-			let previousPhotoID = album.json.content[photo.getID()].previousPhoto,
+			let previousPhotoID = album.json.content[photoID].previousPhoto,
 			    previousPhoto   = album.json.content[previousPhotoID]
 
 			$previousArrow.css('background-image', lychee.html`linear-gradient(to bottom, rgba(0, 0, 0, .4), rgba(0, 0, 0, .4)), url("$${ previousPhoto.thumbUrl }")`)