2013-09-03 09:59:30 +00:00
|
|
|
/**
|
2014-01-22 10:12:51 +00:00
|
|
|
* @name UI View
|
|
|
|
* @description Responsible to reflect data changes to the UI.
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2014 by Tobias Reich
|
2013-09-03 09:59:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
view = {
|
|
|
|
|
|
|
|
header: {
|
|
|
|
|
|
|
|
show: function() {
|
|
|
|
|
|
|
|
clearTimeout($(window).data("timeout"));
|
|
|
|
|
|
|
|
if (visible.photo()) {
|
|
|
|
lychee.imageview.removeClass("full");
|
|
|
|
lychee.loadingBar.css("opacity", 1);
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.header.removeClass("hidden");
|
2013-09-03 09:59:30 +00:00
|
|
|
if ($("#imageview #image.small").length>0) {
|
|
|
|
$("#imageview #image").css({
|
|
|
|
marginTop: -1*($("#imageview #image").height()/2)+20
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$("#imageview #image").css({
|
2014-01-22 10:12:51 +00:00
|
|
|
top: 60,
|
2013-09-03 09:59:30 +00:00
|
|
|
right: 30,
|
|
|
|
bottom: 30,
|
|
|
|
left: 30
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
|
2014-01-24 12:49:01 +00:00
|
|
|
if (visible.photo()&&!visible.infobox()&&!visible.contextMenu()&&!visible.message()) {
|
2013-09-03 09:59:30 +00:00
|
|
|
clearTimeout($(window).data("timeout"));
|
|
|
|
$(window).data("timeout", setTimeout(function() {
|
|
|
|
lychee.imageview.addClass("full");
|
|
|
|
lychee.loadingBar.css("opacity", 0);
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.header.addClass("hidden");
|
2013-09-03 09:59:30 +00:00
|
|
|
if ($("#imageview #image.small").length>0) {
|
|
|
|
$("#imageview #image").css({
|
|
|
|
marginTop: -1*($("#imageview #image").height()/2)
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$("#imageview #image").css({
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
left: 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 500));
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
mode: function(mode) {
|
2014-01-26 13:42:45 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
var albumID = album.getID();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case "albums":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.header.removeClass("view");
|
2013-09-03 09:59:30 +00:00
|
|
|
$("#tools_album, #tools_photo").hide();
|
|
|
|
$("#tools_albums").show();
|
|
|
|
break;
|
|
|
|
case "album":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.header.removeClass("view");
|
2013-09-03 09:59:30 +00:00
|
|
|
$("#tools_albums, #tools_photo").hide();
|
|
|
|
$("#tools_album").show();
|
2014-01-26 13:42:45 +00:00
|
|
|
album.json.content === false ? $("#button_archive").hide() : $("#button_archive").show();
|
2014-01-22 10:12:51 +00:00
|
|
|
if (albumID==="s"||albumID==="f") {
|
|
|
|
$("#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();
|
|
|
|
}
|
2013-09-03 09:59:30 +00:00
|
|
|
break;
|
|
|
|
case "photo":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.header.addClass("view");
|
2013-09-03 09:59:30 +00:00
|
|
|
$("#tools_albums, #tools_album").hide();
|
|
|
|
$("#tools_photo").show();
|
|
|
|
break;
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
infobox: {
|
|
|
|
|
|
|
|
show: function() {
|
|
|
|
|
|
|
|
if (!visible.infobox()) $("body").append("<div id='infobox_overlay' class='fadeIn'></div>");
|
|
|
|
lychee.infobox.addClass("active");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
|
|
|
|
lychee.animate("#infobox_overlay", "fadeOut");
|
|
|
|
setTimeout(function() { $("#infobox_overlay").remove() }, 300);
|
|
|
|
lychee.infobox.removeClass("active");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
albums: {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
view.albums.title();
|
|
|
|
view.albums.content.init();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: function() {
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.setTitle("Albums", false);
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
content: {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
var smartData = "",
|
|
|
|
albumsData = "";
|
|
|
|
|
|
|
|
/* Smart Albums */
|
|
|
|
albums.parse(albums.json.unsortedAlbum);
|
|
|
|
albums.parse(albums.json.publicAlbum);
|
|
|
|
albums.parse(albums.json.starredAlbum);
|
|
|
|
if (!lychee.publicMode) smartData = build.divider("Smart Albums") + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum);
|
|
|
|
|
|
|
|
/* Albums */
|
|
|
|
if (albums.json.content) {
|
|
|
|
|
|
|
|
if (!lychee.publicMode) albumsData = build.divider("Albums");
|
|
|
|
$.each(albums.json.content, function() {
|
|
|
|
albums.parse(this);
|
|
|
|
albumsData += build.album(this);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (smartData===""&&albumsData==="") $("body").append(build.no_content("picture"));
|
2013-09-03 09:59:30 +00:00
|
|
|
else lychee.content.html(smartData + albumsData);
|
|
|
|
|
2014-01-25 15:57:15 +00:00
|
|
|
$("img[data-type!='svg']").retina();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: function(albumID) {
|
|
|
|
|
|
|
|
var prefix = "",
|
2014-01-28 21:22:05 +00:00
|
|
|
longTitle = "",
|
2013-09-03 09:59:30 +00:00
|
|
|
title = albums.json.content[albumID].title;
|
|
|
|
|
|
|
|
if (albums.json.content[albumID].password) prefix = "<span class='icon-lock'></span> ";
|
2014-01-28 21:22:05 +00:00
|
|
|
if (title.length>18) {
|
2014-01-28 21:56:03 +00:00
|
|
|
longTitle = title;
|
2014-01-28 21:22:05 +00:00
|
|
|
title = title.substr(0, 18) + "...";
|
|
|
|
}
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-28 21:22:05 +00:00
|
|
|
$(".album[data-id='" + albumID + "'] .overlay h1")
|
|
|
|
.html(prefix + title)
|
|
|
|
.attr("title", longTitle);
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
delete: function(albumID) {
|
|
|
|
|
|
|
|
$(".album[data-id='" + albumID + "']").css("opacity", 0).animate({
|
|
|
|
width: 0,
|
|
|
|
marginLeft: 0
|
|
|
|
}, 300, function() {
|
|
|
|
$(this).remove();
|
2014-01-22 10:12:51 +00:00
|
|
|
if (albums.json.num<=0) lychee.animate(".divider:last-of-type", "fadeOut");
|
2013-09-03 09:59:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
album: {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
album.parse();
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
view.album.infobox();
|
2013-09-03 09:59:30 +00:00
|
|
|
view.album.title();
|
|
|
|
view.album.public();
|
|
|
|
view.album.content.init();
|
|
|
|
|
|
|
|
album.json.init = 1;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
hide: function() {
|
|
|
|
|
|
|
|
view.infobox.hide();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-31 20:22:25 +00:00
|
|
|
title: function() {
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
if ((visible.album()||!album.json.init)&&!visible.photo()) {
|
|
|
|
|
|
|
|
switch (album.getID()) {
|
|
|
|
case "f":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.setTitle("Starred", false);
|
2013-09-03 09:59:30 +00:00
|
|
|
break;
|
|
|
|
case "s":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.setTitle("Public", false);
|
2013-09-03 09:59:30 +00:00
|
|
|
break;
|
|
|
|
case "0":
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.setTitle("Unsorted", false);
|
2013-09-03 09:59:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-01-22 10:12:51 +00:00
|
|
|
if (album.json.init) $("#infobox .attr_name").html(album.json.title + " " + build.editIcon("edit_title_album"));
|
|
|
|
lychee.setTitle(album.json.title, true);
|
2013-09-03 09:59:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
description: function() {
|
|
|
|
|
|
|
|
$("#infobox .attr_description").html(album.json.description + " " + build.editIcon("edit_description_album"));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
content: {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
var photosData = "";
|
|
|
|
|
|
|
|
$.each(album.json.content, function() {
|
|
|
|
album.parse(this);
|
|
|
|
photosData += build.photo(this);
|
|
|
|
});
|
|
|
|
lychee.content.html(photosData);
|
|
|
|
|
2014-01-25 15:57:15 +00:00
|
|
|
$("img[data-type!='svg']").retina();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: function(photoID) {
|
|
|
|
|
2014-01-28 21:56:03 +00:00
|
|
|
var longTitle = "",
|
|
|
|
title = album.json.content[photoID].title;
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-28 21:56:03 +00:00
|
|
|
if (title.length>18) {
|
|
|
|
longTitle = title;
|
|
|
|
title = title.substr(0, 18) + "...";
|
|
|
|
}
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-28 21:56:03 +00:00
|
|
|
$(".photo[data-id='" + photoID + "'] .overlay h1")
|
|
|
|
.html(title)
|
|
|
|
.attr("title", longTitle);
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
star: function(photoID) {
|
|
|
|
|
|
|
|
$(".photo[data-id='" + photoID + "'] .icon-star").remove();
|
|
|
|
if (album.json.content[photoID].star==1) $(".photo[data-id='" + photoID + "']").append("<a class='badge red icon-star'></a>");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
public: function(photoID) {
|
|
|
|
|
|
|
|
$(".photo[data-id='" + photoID + "'] .icon-share").remove();
|
|
|
|
if (album.json.content[photoID].public==1) $(".photo[data-id='" + photoID + "']").append("<a class='badge red icon-share'></a>");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
delete: function(photoID) {
|
|
|
|
|
|
|
|
$(".photo[data-id='" + photoID + "']").css("opacity", 0).animate({
|
|
|
|
width: 0,
|
|
|
|
marginLeft: 0
|
|
|
|
}, 300, function() {
|
|
|
|
$(this).remove();
|
|
|
|
// Only when search is not active
|
|
|
|
if (!visible.albums()) {
|
|
|
|
album.json.num--;
|
2014-01-22 10:12:51 +00:00
|
|
|
view.album.num();
|
2013-09-03 09:59:30 +00:00
|
|
|
view.album.title();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
num: function() {
|
|
|
|
|
|
|
|
$("#infobox .attr_images").html(album.json.num);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
public: function() {
|
|
|
|
|
|
|
|
if (album.json.public==1) {
|
|
|
|
$("#button_share_album a").addClass("active");
|
|
|
|
$("#button_share_album").attr("title", "Share Album");
|
|
|
|
$(".photo .icon-share").remove();
|
2014-01-22 10:12:51 +00:00
|
|
|
if (album.json.init) $("#infobox .attr_visibility").html("Public");
|
2013-09-03 09:59:30 +00:00
|
|
|
} else {
|
|
|
|
$("#button_share_album a").removeClass("active");
|
|
|
|
$("#button_share_album").attr("title", "Make Public");
|
2014-01-22 10:12:51 +00:00
|
|
|
if (album.json.init) $("#infobox .attr_visibility").html("Private");
|
2013-09-03 09:59:30 +00:00
|
|
|
}
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
password: function() {
|
|
|
|
|
|
|
|
if (album.json.password==1) $("#infobox .attr_password").html("Yes");
|
|
|
|
else $("#infobox .attr_password").html("No");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
infobox: function() {
|
|
|
|
|
|
|
|
if ((visible.album()||!album.json.init)&&!visible.photo()) lychee.infobox.html(build.infoboxAlbum(album.json)).show();
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
photo: {
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
photo.parse();
|
|
|
|
|
|
|
|
view.photo.infobox();
|
|
|
|
view.photo.title();
|
|
|
|
view.photo.star();
|
|
|
|
view.photo.public();
|
|
|
|
view.photo.photo();
|
|
|
|
|
|
|
|
photo.json.init = 1;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function() {
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
// Change header
|
|
|
|
lychee.content.addClass("view");
|
2013-09-03 09:59:30 +00:00
|
|
|
view.header.mode("photo");
|
|
|
|
|
|
|
|
// Make body not scrollable
|
|
|
|
$("body").css("overflow", "hidden");
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
// Fullscreen
|
|
|
|
$(document)
|
|
|
|
.bind("mouseenter", view.header.show)
|
|
|
|
.bind("mouseleave", view.header.hide);
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
lychee.animate(lychee.imageview, "fadeIn");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
|
|
|
|
if (!visible.controls()) view.header.show();
|
2014-01-22 10:12:51 +00:00
|
|
|
if (visible.infobox) view.infobox.hide();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.content.removeClass("view");
|
2013-09-03 09:59:30 +00:00
|
|
|
view.header.mode("album");
|
|
|
|
|
|
|
|
// Make body scrollable
|
2014-01-27 19:47:40 +00:00
|
|
|
$("body").css("overflow", "auto");
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
// Disable Fullscreen
|
|
|
|
$(document)
|
|
|
|
.unbind("mouseenter")
|
|
|
|
.unbind("mouseleave");
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
// Hide Photo
|
|
|
|
lychee.animate(lychee.imageview, "fadeOut");
|
2014-01-22 10:12:51 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
lychee.imageview.hide();
|
|
|
|
view.album.infobox();
|
|
|
|
}, 300);
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-31 20:22:25 +00:00
|
|
|
title: function() {
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (photo.json.init) $("#infobox .attr_name").html(photo.json.title + " " + build.editIcon("edit_title"));
|
|
|
|
lychee.setTitle(photo.json.title, true);
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
description: function() {
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (photo.json.init) $("#infobox .attr_description").html(photo.json.description + " " + build.editIcon("edit_description"));
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
star: function() {
|
|
|
|
|
|
|
|
$("#button_star a").removeClass("icon-star-empty icon-star");
|
|
|
|
if (photo.json.star==1) {
|
|
|
|
// Starred
|
|
|
|
$("#button_star a").addClass("icon-star");
|
|
|
|
$("#button_star").attr("title", "Unstar Photo");
|
|
|
|
} else {
|
|
|
|
// Unstarred
|
|
|
|
$("#button_star a").addClass("icon-star-empty");
|
|
|
|
$("#button_star").attr("title", "Star Photo");
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
public: function() {
|
|
|
|
|
|
|
|
if (photo.json.public==1||photo.json.public==2) {
|
|
|
|
// Photo public
|
|
|
|
$("#button_share a").addClass("active");
|
|
|
|
$("#button_share").attr("title", "Share Photo");
|
|
|
|
if (photo.json.init) $("#infobox .attr_visibility").html("Public");
|
|
|
|
} else {
|
|
|
|
// Photo private
|
|
|
|
$("#button_share a").removeClass("active");
|
|
|
|
$("#button_share").attr("title", "Make Public");
|
|
|
|
if (photo.json.init) $("#infobox .attr_visibility").html("Private");
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2014-02-02 14:11:46 +00:00
|
|
|
|
|
|
|
tags: function() {
|
|
|
|
|
|
|
|
$("#infobox #tags").html(build.tags(photo.json.tags));
|
|
|
|
|
|
|
|
},
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
photo: function() {
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.imageview.html(build.imageview(photo.json, photo.isSmall(), visible.controls()));
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-02-14 18:03:26 +00:00
|
|
|
if ((album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].nextPhoto==="")||lychee.viewMode) $("a#next").hide();
|
|
|
|
if ((album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].previousPhoto==="")||lychee.viewMode) $("a#previous").hide();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
infobox: function() {
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.infobox.html(build.infoboxPhoto(photo.json)).show();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|