manage.view 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. @Title{Gallery}@
  2. @CSS{
  3. #main-header .header{
  4. box-shadow:none !important;
  5. }
  6. #tabs{
  7. background:#f44336;
  8. margin:-20px;
  9. margin-bottom:10px;
  10. position:fixed;
  11. width:100%;
  12. box-shadow: 0px 0px 5px 0px rgba(50, 50, 50, 0.8);
  13. overflow-x:auto;
  14. white-space:nowrap;
  15. }
  16. #tabs a{
  17. display:inline-block;
  18. color:#ffcdd2;
  19. padding:15px 30px;
  20. text-decoration:none;
  21. text-transform: uppercase;
  22. }
  23. #tabs a.active{
  24. color:#fff;
  25. border-bottom:3px solid #fff;
  26. }
  27. .image{
  28. width:25%;
  29. display:inline-block;
  30. vertical-align:top;
  31. text-align:center;
  32. }
  33. .image.selected>div{
  34. background:#e57373;
  35. }
  36. .image.selected>div:hover{
  37. background:#ef5350;
  38. }
  39. .image input[type=checkbox]{
  40. display:none;
  41. }
  42. .image>div:hover{
  43. background:#bdbdbd;
  44. }
  45. .image>div{
  46. margin:5px;
  47. padding:5px;
  48. background:#e0e0e0;
  49. }
  50. }@
  51. @CSSMed{
  52. @media(orientation:portrait){
  53. .image{
  54. width:33.3%;
  55. }
  56. }
  57. }@
  58. @CSSSmall{
  59. @media(orientation:portrait){
  60. #albums td:nth-child(3), #albums th:nth-child(3){
  61. display:none;
  62. }
  63. .image{
  64. width:50%;
  65. }
  66. }
  67. @media(orientation:landscape){
  68. .image{
  69. width:33.3%;
  70. }
  71. }
  72. #albums td:first-child, #albums th:first-child{
  73. display:none;
  74. }
  75. table{
  76. width:100%;
  77. }
  78. #albums td:last-child, #albums th:last-child, #albums td:nth-child(3), #albums th:nth-child(3){
  79. width:1px;
  80. }
  81. }@
  82. @ButtonsRight{
  83. <button onclick="Navigate('/gallery/createalbum/')" title="Create Album">
  84. <img src="/images/add_album.svg" alt="Add Album" />
  85. </button>
  86. }@
  87. @JavaScript{
  88. $(function(){
  89. $("#tabs-content").css("margin-top",$("#tabs").height()+"px");
  90. $("#tabs>a").click(function(){
  91. $("#tabs-content>*").hide();
  92. $($(this).attr("href")).show();
  93. $("#tabs>a").removeClass("active");
  94. $(this).addClass("active");
  95. return false;
  96. });
  97. $("#tabs a.active").click();
  98. $(".image input[type=checkbox]").click(function(){
  99. return false;
  100. });
  101. function SetupSelectedImageClass(elem){
  102. var tick=elem.find("input[type=checkbox]");
  103. if (tick.prop("checked"))
  104. elem.addClass("selected");
  105. else
  106. elem.removeClass("selected");
  107. }
  108. function ApplyImageClick(){
  109. $(".image").click(function(){
  110. var tick=$(this).find("input[type=checkbox]");
  111. tick.prop("checked",!tick.prop("checked"));
  112. SetupSelectedImageClass($(this));
  113. });
  114. }
  115. $(".image").each(function(e){ // refresh hack
  116. SetupSelectedImageClass($(this));
  117. });
  118. $("#selectAlbumOld").change(function(){
  119. $.ajax("/gallery/jsonLoadAlbum/"+this.selectedIndex).done(function(data){
  120. var images=JSON.parse(data);
  121. html="";
  122. for (i=0;i<images.length;i++)
  123. html+='<div class="image">'+
  124. '<div>'+
  125. '<img src="/'+images[i].ThumbnailPath+'" alt="'+images[i].ImageTitle+'" />'+
  126. '<span>'+images[i].ImageTitle+'</span>'+
  127. '<input type="checkbox" value="'+images[i].ImageId+'" name="selected[]" />'+
  128. '</div>'+
  129. '</div>';
  130. if (html=="")
  131. html="<p>There are no images in this album</p>";
  132. $("#imageSelector").html(html);
  133. ApplyImageClick();
  134. });
  135. });
  136. ApplyImageClick();
  137. });
  138. }@
  139. @Body{
  140. <div id="tabs">
  141. <a href="#images">Images</a><a href="#albums">Albums</a><a class="active" href="#organise">Organise</a>
  142. </div>
  143. <div id="tabs-content" style="margin-top:55px">
  144. <div id="images">
  145. <h3>New Image</h3>
  146. <form action="/gallery/upload/" method="post" enctype="multipart/form-data">
  147. <table>
  148. <tr>
  149. <td><label for="imageTitle">Image title:</label></td>
  150. <td><input type="text" name="imageTitle" id="imageTitle" value="<?=$image->ImageTitle?>" /></td>
  151. </tr>
  152. <tr>
  153. <td><label for="imageDesc">Image description</label></td>
  154. <td><textarea name="imageDesc" id="imageDesc"><?=$image->ImageDescription?></textarea></td>
  155. </tr>
  156. <tr>
  157. <td><label for="imageFile">Select image:</label></td>
  158. <td><input type="file" name="imageFile" id="imageFile" /></td>
  159. </tr>
  160. <tr>
  161. <td colspan="2" align="right">
  162. <button type="submit" title="Upload" name="imageUpload">
  163. <img src="/images/send.svg" alt="Upload" />
  164. </button>
  165. </td>
  166. </tr>
  167. </table>
  168. </form>
  169. </div>
  170. <div id="albums">
  171. <form action="" method="post" id="manageForm">
  172. <input type="hidden" name="formSubmitted" value="yes" />
  173. <table>
  174. <tr>
  175. <th>ID</th>
  176. <th>Title</th>
  177. <th>Timestamp</th>
  178. <th>Actions</th>
  179. </tr>
  180. <?php foreach ($albums as $album){?>
  181. <tr>
  182. <td><?=$album->AlbumId?></td>
  183. <td><a href="/gallery/view/<?=$album->AlbumUrl?>"><?=$album->AlbumTitle?></a></td>
  184. <td><?=$album->AlbumTimestamp?></td>
  185. <td>
  186. <button value="<?=$album->AlbumId?>" name="delete" title="Delete">
  187. <img src="/images/delete.svg" alt="Delete" />
  188. </button>
  189. <button value="/blog/edit/<?=$album->AlbumId?>" name="edit" title="Edit" class="jsNav">
  190. <img src="/images/edit.svg" alt="Edit" />
  191. </button>
  192. </td>
  193. </tr>
  194. <?php } ?>
  195. </table>
  196. </form>
  197. </div>
  198. <div id="organise">
  199. <form action="/gallery/move" method="post">
  200. <label for="selectAlbumOld">Move from album </label>
  201. <select id="selectAlbumOld" name="selectAlbumOld">
  202. <option value="0">No album</option>
  203. <?php foreach ($albums as $album)
  204. echo '<option value="',$album->AlbumId,'">',$album->AlbumTitle,'</option>';
  205. ?>
  206. </select>
  207. <label for="selectAlbumNew"> to album </label>
  208. <select id="selectAlbumNew" name="selectAlbumNew">
  209. <option value="0">No album</option>
  210. <?php foreach ($albums as $album)
  211. echo '<option value="',$album->AlbumId,'">',$album->AlbumTitle,'</option>';
  212. ?>
  213. </select>
  214. <input type="submit" name="moveImages" value="go" />
  215. <div id="imageSelector">
  216. <?php
  217. foreach ($images as $image)
  218. echo '<div class="image">',
  219. '<div>',
  220. '<img src="/',$image->ThumbnailPath,'" alt="',$image->ImageTitle,'" />',
  221. '<span>',$image->ImageTitle,'</span>',
  222. '<input type="checkbox" value="',$image->ImageId,'" name="selected[]" />',
  223. '</div>',
  224. '</div>';
  225. ?>
  226. </div>
  227. </form>
  228. </div>
  229. </div>
  230. }@