2013-05-03 11:57:08 +00:00
|
|
|
/**
|
|
|
|
* @name build.js
|
|
|
|
* @author Philipp Maurer
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2013 by Philipp Maurer, Tobias Reich
|
|
|
|
*
|
|
|
|
* Build Module
|
|
|
|
* This module is used to generate HTML-Code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
build = {
|
|
|
|
|
|
|
|
divider: function(title) {
|
|
|
|
|
|
|
|
return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
album: function(albumJSON) {
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (!albumJSON) return "";
|
|
|
|
|
|
|
|
var album = ""
|
|
|
|
title = albumJSON.title;
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (title.length>18) title = albumJSON.title.substr(0, 18) + "...";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-06-17 18:40:04 +00:00
|
|
|
album += "<div class='album' data-id='" + albumJSON.id + "' data-password='" + albumJSON.password + "'>";
|
2013-09-03 09:59:30 +00:00
|
|
|
album += "<img src='" + albumJSON.thumb2 + "' width='200' height='200' alt='thumb'>";
|
|
|
|
album += "<img src='" + albumJSON.thumb1 + "' width='200' height='200' alt='thumb'>";
|
|
|
|
album += "<img src='" + albumJSON.thumb0 + "' width='200' height='200' alt='thumb'>";
|
2013-05-03 11:57:08 +00:00
|
|
|
album += "<div class='overlay'>";
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (albumJSON.password&&!lychee.publicMode) album += "<h1><span class='icon-lock'></span> " + title + "</h1>";
|
|
|
|
else album += "<h1>" + title + "</h1>";
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
album += "<a>" + albumJSON.sysdate + "</a>";
|
|
|
|
album += "</div>";
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if(!lychee.publicMode&&albumJSON.star==1) album += "<a class='badge red icon-star'></a>";
|
|
|
|
if(!lychee.publicMode&&albumJSON.public==1) album += "<a class='badge red icon-share'></a>";
|
|
|
|
if(!lychee.publicMode&&albumJSON.unsorted==1) album += "<a class='badge red icon-reorder'></a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
album += "</div>";
|
|
|
|
|
|
|
|
return album;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
photo: function(photoJSON) {
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (!photoJSON) return "";
|
|
|
|
|
|
|
|
var photo = "",
|
|
|
|
title = photoJSON.title;
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (title.length>18) title = photoJSON.title.substr(0, 18) + "...";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
photo += "<div class='photo' data-album-id='" + photoJSON.album + "' data-id='" + photoJSON.id + "'>";
|
2013-09-03 09:59:30 +00:00
|
|
|
photo += "<img src='" + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
|
2013-05-03 11:57:08 +00:00
|
|
|
photo += "<div class='overlay'>";
|
2013-09-03 09:59:30 +00:00
|
|
|
photo += "<h1>" + title + "</h1>";
|
2013-05-03 11:57:08 +00:00
|
|
|
photo += "<a>" + photoJSON.sysdate + "</a>";
|
|
|
|
photo += "</div>";
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (photoJSON.star==1) photo += "<a class='badge red icon-star'></a>";
|
|
|
|
if (!lychee.publicMode&&photoJSON.public==1&&album.json.public!=1) photo += "<a class='badge red icon-share'></a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
photo += "</div>";
|
|
|
|
|
|
|
|
return photo;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-06-17 18:40:04 +00:00
|
|
|
no_content: function(typ) {
|
|
|
|
|
|
|
|
var no_content = "";
|
|
|
|
|
|
|
|
no_content += "<div class='no_content fadeIn'>";
|
|
|
|
no_content += "<a class='icon icon-" + typ + "'></a>";
|
|
|
|
|
|
|
|
if (typ=="search") no_content += "<p>No results</p>";
|
|
|
|
else if (typ=="picture") no_content += "<p>No public albums</p>";
|
|
|
|
|
|
|
|
no_content += "</div>";
|
|
|
|
|
|
|
|
return no_content;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
modal: function(title, text, button) {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
var modal = "";
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "<div class='message_overlay fadeIn'>";
|
|
|
|
modal += "<div class='message center'>";
|
|
|
|
modal += "<h1>" + title + "</h1>";
|
|
|
|
modal += "<a class='close icon-remove-sign'></a>";
|
|
|
|
modal += "<p>" + text + "</p>";
|
|
|
|
|
|
|
|
$.each(button, function(index) {
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (this[0]!="") {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (index==0) modal += "<a class='button active'>" + this[0] + "</a>";
|
|
|
|
else modal += "<a class='button'>" + this[0] + "</a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
}
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
modal += "</div>";
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "</div>";
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
addModal: function() {
|
|
|
|
|
|
|
|
var modal = "";
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "<div class='message_overlay fadeIn'>";
|
|
|
|
modal += "<div class='message center add'>";
|
|
|
|
modal += "<h1>Add Album or Photo</h1>";
|
|
|
|
modal += "<a class='close icon-remove-sign'></a>";
|
|
|
|
modal += "<div id='add_album' class='add_album'>";
|
|
|
|
modal += "<div class='icon icon-folder-close'></div>";
|
2013-06-17 18:40:04 +00:00
|
|
|
modal += "<a>New Album</a>";
|
|
|
|
modal += "</div>";
|
|
|
|
modal += "<div id='add_link' class='add_album'>";
|
|
|
|
modal += "<div class='icon icon-link'></div>";
|
|
|
|
modal += "<a>Import Link</a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "</div>";
|
|
|
|
modal += "<div id='add_photo' class='add_album'>";
|
|
|
|
modal += "<div class='icon icon-picture'></div>";
|
2013-06-17 18:40:04 +00:00
|
|
|
modal += "<a>Upload Photo</a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "</div>";
|
|
|
|
modal += "</div>";
|
|
|
|
modal += "</div>";
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
signInModal: function() {
|
|
|
|
|
|
|
|
var modal = "";
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "<div class='message_overlay'>";
|
|
|
|
modal += "<div class='message center'>";
|
2013-06-17 18:40:04 +00:00
|
|
|
modal += "<h1><a class='icon-lock'></a> Sign In</h1>";
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "<div class='sign_in'>";
|
|
|
|
modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
|
|
|
|
modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
|
|
|
|
modal += "</div>";
|
2013-06-17 18:40:04 +00:00
|
|
|
modal += "<div id='version'>Version " + lychee.version + "<span> – <a target='_blank' href='" + lychee.updateURL + "'>Update available!</a><span></div>";
|
|
|
|
modal += "<a onclick='lychee.login()' class='button active'>Sign in</a>";
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "</div>";
|
|
|
|
modal += "</div>";
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
uploadModal: function() {
|
|
|
|
|
|
|
|
var modal = "";
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
modal += "<div class='upload_overlay fadeIn'>";
|
|
|
|
modal += "<div class='upload_message center'>";
|
|
|
|
modal += "<a class='icon-upload'></a>";
|
|
|
|
modal += "<div class='progressbar'><div></div></div>";
|
|
|
|
modal += "</div>";
|
|
|
|
modal += "</div>";
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
contextMenu: function(items) {
|
|
|
|
|
|
|
|
var menu = "";
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
menu += "<div class='contextmenu_bg'></div>";
|
|
|
|
menu += "<div class='contextmenu'>";
|
|
|
|
menu += "<table>";
|
|
|
|
menu += "<tbody>";
|
|
|
|
|
|
|
|
$.each(items, function(index) {
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
if (items[index][0]=="separator"&&items[index][1]==-1) menu += "<tr class='separator'></tr>";
|
|
|
|
else if (items[index][1]==-1) menu += "<tr class='no_hover'><td>" + items[index][0] + "</td></tr>";
|
|
|
|
else if (items[index][2]!=undefined) menu += "<tr><td onclick='" + items[index][2] + "; window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
|
|
|
|
else menu += "<tr><td onclick='window.contextMenu.fns[" + items[index][1] + "](); window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
menu += "</tbody>";
|
|
|
|
menu += "</table>";
|
|
|
|
menu += "</div>";
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
infobox: function(photoJSON, forView) {
|
|
|
|
|
|
|
|
if (!photoJSON) return "";
|
|
|
|
|
|
|
|
var infobox = "",
|
|
|
|
public,
|
|
|
|
editTitleHTML,
|
|
|
|
editDescriptionHTML,
|
|
|
|
infos;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
|
|
|
|
infobox += "<div class='wrapper'>";
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
switch (photoJSON.public) {
|
|
|
|
case "0":
|
|
|
|
public = "Private";
|
|
|
|
break;
|
|
|
|
case "1":
|
|
|
|
public = "Public";
|
|
|
|
break;
|
|
|
|
case "2":
|
|
|
|
public = "Public (Album)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
public = "-";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
editTitleHTML = (forView==true||lychee.publicMode) ? "" : " <div id='edit_title'><a class='icon-pencil'></a></div>";
|
|
|
|
editDescriptionHTML = (forView==true||lychee.publicMode) ? "" : " <div id='edit_description'><a class='icon-pencil'></a></div>";
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
infos = [
|
|
|
|
["", "Basics"],
|
2013-09-03 09:59:30 +00:00
|
|
|
["Name", photoJSON.title + editTitleHTML],
|
|
|
|
["Uploaded", photoJSON.sysdate],
|
|
|
|
["Description", photoJSON.description + editDescriptionHTML],
|
2013-05-03 11:57:08 +00:00
|
|
|
["", "Image"],
|
2013-09-03 09:59:30 +00:00
|
|
|
["Size", photoJSON.size],
|
|
|
|
["Format", photoJSON.type],
|
|
|
|
["Resolution", photoJSON.width + " x " + photoJSON.height],
|
2013-05-03 11:57:08 +00:00
|
|
|
["", "Camera"],
|
2013-09-03 09:59:30 +00:00
|
|
|
["Captured", photoJSON.takedate],
|
|
|
|
["Make", photoJSON.make],
|
|
|
|
["Type/Model", photoJSON.model],
|
|
|
|
["Shutter Speed", photoJSON.shutter],
|
|
|
|
["Aperture", photoJSON.aperture],
|
|
|
|
["Focal Length", photoJSON.focal],
|
|
|
|
["ISO", photoJSON.iso],
|
2013-05-03 11:57:08 +00:00
|
|
|
["", "Share"],
|
2013-09-03 09:59:30 +00:00
|
|
|
["Visibility", public]
|
2013-05-03 11:57:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
$.each(infos, function(index) {
|
|
|
|
|
|
|
|
if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
|
|
|
|
|
|
|
|
if (infos[index][0]=="") {
|
|
|
|
|
|
|
|
infobox += "</table>";
|
|
|
|
infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
|
|
|
|
infobox += "<table id='infos'>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
infobox += "<tr>";
|
|
|
|
infobox += "<td>" + infos[index][0] + "</td>";
|
|
|
|
infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
|
|
|
|
infobox += "</tr>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
infobox += "</table>";
|
|
|
|
infobox += "<div class='bumper'></div>";
|
|
|
|
infobox += "</div>";
|
|
|
|
|
|
|
|
return infobox;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|