/**
* @name Build Module
* @description This module is used to generate HTML-Code.
* @author Tobias Reich
* @copyright 2014 by Tobias Reich
*/
build = {
divider: function(title) {
return "
" + title + " ";
},
editIcon: function(id) {
return "";
},
multiselect: function(top, left) {
return "
";
},
album: function(albumJSON) {
if (!albumJSON) return "";
var album = "",
longTitle = "",
title = albumJSON.title,
typeThumb = "";
if (title.length>18) {
title = albumJSON.title.substr(0, 18) + "...";
longTitle = albumJSON.title;
}
if (albumJSON.thumb0.split('.').pop()==="svg") typeThumb = "nonretina";
album += "";
album += "
";
album += "
";
album += "
";
album += "
";
if (albumJSON.password&&!lychee.publicMode) album += "
" + title + "";
else album += "
" + title + " ";
album += "
" + albumJSON.sysdate + " ";
album += "
";
if (!lychee.publicMode) {
if(albumJSON.star==1) album += "
";
if(albumJSON.public==1) album += "
";
if(albumJSON.unsorted==1) album += "
";
if(albumJSON.recent==1) album += "
";
}
album += "
";
return album;
},
photo: function(photoJSON) {
if (!photoJSON) return "";
var photo = "",
longTitle = "",
title = photoJSON.title;
if (title.length>18) {
title = photoJSON.title.substr(0, 18) + "...";
longTitle = photoJSON.title;
}
photo += "";
photo += "
";
photo += "
";
if (photoJSON.star==1) photo += "
";
if (!lychee.publicMode&&photoJSON.public==1&&album.json.public!=1) photo += "
";
photo += "
";
return photo;
},
imageview: function(photoJSON, isSmall, visibleControls) {
if (!photoJSON) return "";
var view = "";
view += "";
view += "";
if (isSmall) {
if (visibleControls)
view += "
";
else
view += "
";
} else {
if (visibleControls)
view += "
";
else
view += "
";
}
return view;
},
no_content: function(typ) {
var no_content = "";
no_content += "";
no_content += "
";
if (typ==="search") no_content += "
No results
";
else if (typ==="picture") no_content += "
No public albums
";
else if (typ==="cog") no_content += "
No Configuration!
";
no_content += "
";
return no_content;
},
modal: function(title, text, button, marginTop, closeButton) {
var modal = "",
custom_style = "";
if (marginTop) custom_style = "style='margin-top: " + marginTop + "px;'";
modal += "";
modal += "
";
modal += "
" + title + " ";
if (closeButton!==false) {
modal += "
";
}
modal += "
" + text + "
";
$.each(button, function(index) {
if (this[0]!=="") {
if (index===0) modal += "
" + this[0] + " ";
else modal += "
" + this[0] + " ";
}
});
modal += "
";
modal += "
";
return modal;
},
signInModal: function() {
var modal = "";
modal += "";
modal += "
";
modal += "
Sign In";
modal += "
";
modal += "
";
modal += " ";
modal += " ";
modal += "
";
modal += "
";
modal += "
Sign in ";
modal += "
";
modal += "
";
return modal;
},
uploadModal: function(title, files) {
var modal = "";
modal += "";
modal += "
";
modal += "
" + title + " ";
modal += "
";
modal += "
";
for (var i = 0; i < files.length; i++) {
if (files[i].name.length>40) files[i].name = files[i].name.substr(0, 17) + "..." + files[i].name.substr(files[i].name.length-20, 20);
modal += "
";
}
modal += "
";
modal += "
";
modal += "
";
return modal;
},
contextMenu: function(items) {
var menu = "";
menu += "";
menu += "";
return menu;
},
tags: function(tags, forView) {
var html = "",
editTagsHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_tags");
if (tags!=="") {
tags = tags.split(",");
tags.forEach(function(tag, index, array) {
html += "" + tag + " ";
});
html += editTagsHTML;
} else {
html = "No Tags" + editTagsHTML + "
";
}
return html;
},
infoboxPhoto: function(photoJSON, forView) {
if (!photoJSON) return "";
var infobox = "",
public,
editTitleHTML,
editDescriptionHTML,
infos;
infobox += "";
infobox += "";
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) ? "" : " " + build.editIcon("edit_title");
editDescriptionHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_description");
infos = [
["", "Basics"],
["Title", photoJSON.title + editTitleHTML],
["Uploaded", photoJSON.sysdate],
["Description", photoJSON.description + editDescriptionHTML],
["", "Image"],
["Size", photoJSON.size],
["Format", photoJSON.type],
["Resolution", photoJSON.width + " x " + photoJSON.height],
["Tags", build.tags(photoJSON.tags, forView)]
];
if ((photoJSON.takestamp+photoJSON.make+photoJSON.model+photoJSON.shutter+photoJSON.aperture+photoJSON.focal+photoJSON.iso)!="0") {
infos = infos.concat([
["", "Camera"],
["Captured", photoJSON.takedate],
["Make", photoJSON.make],
["Type/Model", photoJSON.model],
["Shutter Speed", photoJSON.shutter],
["Aperture", photoJSON.aperture],
["Focal Length", photoJSON.focal],
["ISO", photoJSON.iso]
]);
}
infos = infos.concat([
["", "Share"],
["Visibility", public]
]);
$.each(infos, function(index) {
if (infos[index][1]===""||infos[index][1]===undefined||infos[index][1]===null) infos[index][1] = "-";
switch (infos[index][0]) {
case "": // Separator
infobox += "";
infobox += "
" + infos[index][1] + " ";
infobox += "
";
break;
case "Tags": // Tags
if (forView!==true&&!lychee.publicMode) {
infobox += "
";
infobox += "
" + infos[index][0] + " ";
infobox += "
" + infos[index][1] + "
";
}
break;
default: // Item
infobox += "
";
infobox += "" + infos[index][0] + " ";
infobox += "" + infos[index][1] + " ";
infobox += " ";
break;
}
});
infobox += "";
infobox += "
";
infobox += "
";
return infobox;
},
infoboxAlbum: function(albumJSON, forView) {
if (!albumJSON) return "";
var infobox = "",
public,
password,
editTitleHTML,
editDescriptionHTML,
infos;
infobox += "";
infobox += "";
switch (albumJSON.public) {
case "0":
public = "Private";
break;
case "1":
public = "Public";
break;
default:
public = "-";
break;
}
switch (albumJSON.password) {
case false:
password = "No";
break;
case true:
password = "Yes";
break;
default:
password = "-";
break;
}
editTitleHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_title_album");
editDescriptionHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_description_album");
infos = [
["", "Basics"],
["Title", albumJSON.title + editTitleHTML],
["Description", albumJSON.description + editDescriptionHTML],
["", "Album"],
["Created", albumJSON.sysdate],
["Images", albumJSON.num],
["", "Share"],
["Visibility", public],
["Password", password]
];
$.each(infos, function(index) {
if (infos[index][1]===""||infos[index][1]===undefined||infos[index][1]===null) infos[index][1] = "-";
if (infos[index][0]==="") {
infobox += "";
infobox += "
" + infos[index][1] + " ";
infobox += "
";
} else {
infobox += "";
infobox += "" + infos[index][0] + " ";
infobox += "" + infos[index][1] + " ";
infobox += " ";
}
});
infobox += "
";
infobox += "
";
infobox += "
";
return infobox;
}
};