/** * @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 != null && title.length>18) { title = albumJSON.title.substr(0, 18) + "..."; longTitle = albumJSON.title; } if (albumJSON.thumb0.split('.').pop()==="svg") typeThumb = "nonretina"; album += "
"; album += "thumb"; album += "thumb"; album += "thumb"; 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 != null && title.length>18) { title = photoJSON.title.substr(0, 18) + "..."; longTitle = photoJSON.title; } photo += "
"; photo += "thumb"; photo += "
"; photo += "

" + title + "

"; if (photoJSON.cameraDate==1) { photo += "" + photoJSON.sysdate + ""; } else { photo += "" + photoJSON.sysdate + ""; } 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==="share") 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 += "
Version " + lychee.version + "Update available!
"; 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 += "" + lychee.escapeHTML(files[i].name) + ""; if (files[i].supported===true) modal += ""; else modal += "Not supported"; modal += "

"; modal += "
"; } modal += "
"; modal += "
"; modal += "
"; return modal; }, contextMenu: function(items) { var menu = ""; menu += "
"; menu += "
"; menu += ""; menu += ""; $.each(items, function(index) { if (items[index][0]==="separator"&&items[index][1]===-1) menu += ""; else if (items[index][1]===-1) menu += ""; else if (items[index][2]!=undefined) menu += ""; else menu += ""; }); menu += ""; menu += "
" + items[index][0] + "
" + items[index][0] + "
" + items[index][0] + "
"; 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 += "

About

"; infobox += "
"; switch (photoJSON.public) { case "0": public = "No"; break; case "1": public = "Yes"; break; case "2": public = "Yes (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"], ["Public", 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 = "-", downloadable = "-", editTitleHTML, editDescriptionHTML, infos; infobox += "

About

"; infobox += "
"; switch (albumJSON.public) { case "0": public = "No"; break; case "1": public = "Yes"; break; } switch (albumJSON.password) { case false: password = "No"; break; case true: password = "Yes"; break; } switch (albumJSON.downloadable) { case "0": downloadable = "No"; break; case "1": downloadable = "Yes"; 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"], ["Public", public], ["Downloadable", downloadable], ["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 += ""; infobox += ""; infobox += ""; } }); infobox += "
" + infos[index][0] + "" + infos[index][1] + "
"; infobox += "
"; infobox += "
"; return infobox; } };