build.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /**
  2. * @name build.js
  3. * @author Philipp Maurer
  4. * @author Tobias Reich
  5. * @copyright 2013 by Philipp Maurer, Tobias Reich
  6. *
  7. * Build Module
  8. * This module is used to generate HTML-Code.
  9. */
  10. build = {
  11. divider: function(title) {
  12. return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
  13. },
  14. album: function(albumJSON) {
  15. if (!albumJSON) return "";
  16. var album = ""
  17. title = albumJSON.title;
  18. if (title.length>18) title = albumJSON.title.substr(0, 18) + "...";
  19. album += "<div class='album' data-id='" + albumJSON.id + "' data-password='" + albumJSON.password + "'>";
  20. album += "<img src='" + albumJSON.thumb2 + "' width='200' height='200' alt='thumb'>";
  21. album += "<img src='" + albumJSON.thumb1 + "' width='200' height='200' alt='thumb'>";
  22. album += "<img src='" + albumJSON.thumb0 + "' width='200' height='200' alt='thumb'>";
  23. album += "<div class='overlay'>";
  24. if (albumJSON.password&&!lychee.publicMode) album += "<h1><span class='icon-lock'></span> " + title + "</h1>";
  25. else album += "<h1>" + title + "</h1>";
  26. album += "<a>" + albumJSON.sysdate + "</a>";
  27. album += "</div>";
  28. if(!lychee.publicMode&&albumJSON.star==1) album += "<a class='badge red icon-star'></a>";
  29. if(!lychee.publicMode&&albumJSON.public==1) album += "<a class='badge red icon-share'></a>";
  30. if(!lychee.publicMode&&albumJSON.unsorted==1) album += "<a class='badge red icon-reorder'></a>";
  31. album += "</div>";
  32. return album;
  33. },
  34. photo: function(photoJSON) {
  35. if (!photoJSON) return "";
  36. var photo = "",
  37. title = photoJSON.title;
  38. if (title.length>18) title = photoJSON.title.substr(0, 18) + "...";
  39. photo += "<div class='photo' data-album-id='" + photoJSON.album + "' data-id='" + photoJSON.id + "'>";
  40. photo += "<img src='" + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
  41. photo += "<div class='overlay'>";
  42. photo += "<h1>" + title + "</h1>";
  43. photo += "<a>" + photoJSON.sysdate + "</a>";
  44. photo += "</div>";
  45. if (photoJSON.star==1) photo += "<a class='badge red icon-star'></a>";
  46. if (!lychee.publicMode&&photoJSON.public==1&&album.json.public!=1) photo += "<a class='badge red icon-share'></a>";
  47. photo += "</div>";
  48. return photo;
  49. },
  50. no_content: function(typ) {
  51. var no_content = "";
  52. no_content += "<div class='no_content fadeIn'>";
  53. no_content += "<a class='icon icon-" + typ + "'></a>";
  54. if (typ=="search") no_content += "<p>No results</p>";
  55. else if (typ=="picture") no_content += "<p>No public albums</p>";
  56. no_content += "</div>";
  57. return no_content;
  58. },
  59. modal: function(title, text, button) {
  60. var modal = "";
  61. modal += "<div class='message_overlay fadeIn'>";
  62. modal += "<div class='message center'>";
  63. modal += "<h1>" + title + "</h1>";
  64. modal += "<a class='close icon-remove-sign'></a>";
  65. modal += "<p>" + text + "</p>";
  66. $.each(button, function(index) {
  67. if (this[0]!="") {
  68. if (index==0) modal += "<a class='button active'>" + this[0] + "</a>";
  69. else modal += "<a class='button'>" + this[0] + "</a>";
  70. }
  71. });
  72. modal += "</div>";
  73. modal += "</div>";
  74. return modal;
  75. },
  76. addModal: function() {
  77. var modal = "";
  78. modal += "<div class='message_overlay fadeIn'>";
  79. modal += "<div class='message center add'>";
  80. modal += "<h1>Add Album or Photo</h1>";
  81. modal += "<a class='close icon-remove-sign'></a>";
  82. modal += "<div id='add_album' class='add_album'>";
  83. modal += "<div class='icon icon-folder-close'></div>";
  84. modal += "<a>New Album</a>";
  85. modal += "</div>";
  86. modal += "<div id='add_link' class='add_album'>";
  87. modal += "<div class='icon icon-link'></div>";
  88. modal += "<a>Import Link</a>";
  89. modal += "</div>";
  90. modal += "<div id='add_photo' class='add_album'>";
  91. modal += "<div class='icon icon-picture'></div>";
  92. modal += "<a>Upload Photo</a>";
  93. modal += "</div>";
  94. modal += "</div>";
  95. modal += "</div>";
  96. return modal;
  97. },
  98. signInModal: function() {
  99. var modal = "";
  100. modal += "<div class='message_overlay'>";
  101. modal += "<div class='message center'>";
  102. modal += "<h1><a class='icon-lock'></a> Sign In</h1>";
  103. modal += "<div class='sign_in'>";
  104. modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
  105. modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
  106. modal += "</div>";
  107. modal += "<div id='version'>Version " + lychee.version + "<span> &#8211; <a target='_blank' href='" + lychee.updateURL + "'>Update available!</a><span></div>";
  108. modal += "<a onclick='lychee.login()' class='button active'>Sign in</a>";
  109. modal += "</div>";
  110. modal += "</div>";
  111. return modal;
  112. },
  113. uploadModal: function() {
  114. var modal = "";
  115. modal += "<div class='upload_overlay fadeIn'>";
  116. modal += "<div class='upload_message center'>";
  117. modal += "<a class='icon-upload'></a>";
  118. modal += "<div class='progressbar'><div></div></div>";
  119. modal += "</div>";
  120. modal += "</div>";
  121. return modal;
  122. },
  123. contextMenu: function(items) {
  124. var menu = "";
  125. menu += "<div class='contextmenu_bg'></div>";
  126. menu += "<div class='contextmenu'>";
  127. menu += "<table>";
  128. menu += "<tbody>";
  129. $.each(items, function(index) {
  130. if (items[index][0]=="separator"&&items[index][1]==-1) menu += "<tr class='separator'></tr>";
  131. else if (items[index][1]==-1) menu += "<tr class='no_hover'><td>" + items[index][0] + "</td></tr>";
  132. else if (items[index][2]!=undefined) menu += "<tr><td onclick='" + items[index][2] + "; window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
  133. else menu += "<tr><td onclick='window.contextMenu.fns[" + items[index][1] + "](); window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
  134. });
  135. menu += "</tbody>";
  136. menu += "</table>";
  137. menu += "</div>";
  138. return menu;
  139. },
  140. infobox: function(photoJSON, forView) {
  141. if (!photoJSON) return "";
  142. var infobox = "",
  143. public,
  144. editTitleHTML,
  145. editDescriptionHTML,
  146. infos;
  147. infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
  148. infobox += "<div class='wrapper'>";
  149. switch (photoJSON.public) {
  150. case "0":
  151. public = "Private";
  152. break;
  153. case "1":
  154. public = "Public";
  155. break;
  156. case "2":
  157. public = "Public (Album)";
  158. break;
  159. default:
  160. public = "-";
  161. break;
  162. }
  163. editTitleHTML = (forView==true||lychee.publicMode) ? "" : " <div id='edit_title'><a class='icon-pencil'></a></div>";
  164. editDescriptionHTML = (forView==true||lychee.publicMode) ? "" : " <div id='edit_description'><a class='icon-pencil'></a></div>";
  165. infos = [
  166. ["", "Basics"],
  167. ["Name", photoJSON.title + editTitleHTML],
  168. ["Uploaded", photoJSON.sysdate],
  169. ["Description", photoJSON.description + editDescriptionHTML],
  170. ["", "Image"],
  171. ["Size", photoJSON.size],
  172. ["Format", photoJSON.type],
  173. ["Resolution", photoJSON.width + " x " + photoJSON.height],
  174. ["", "Camera"],
  175. ["Captured", photoJSON.takedate],
  176. ["Make", photoJSON.make],
  177. ["Type/Model", photoJSON.model],
  178. ["Shutter Speed", photoJSON.shutter],
  179. ["Aperture", photoJSON.aperture],
  180. ["Focal Length", photoJSON.focal],
  181. ["ISO", photoJSON.iso],
  182. ["", "Share"],
  183. ["Visibility", public]
  184. ];
  185. $.each(infos, function(index) {
  186. if (infos[index][1]==""||infos[index][1]==undefined||infos[index][1]==null) infos[index][1] = "-";
  187. if (infos[index][0]=="") {
  188. infobox += "</table>";
  189. infobox += "<div class='separater'><h1>" + infos[index][1] + "</h1></div>";
  190. infobox += "<table id='infos'>";
  191. } else {
  192. infobox += "<tr>";
  193. infobox += "<td>" + infos[index][0] + "</td>";
  194. infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
  195. infobox += "</tr>";
  196. }
  197. });
  198. infobox += "</table>";
  199. infobox += "<div class='bumper'></div>";
  200. infobox += "</div>";
  201. return infobox;
  202. }
  203. }