Merge branch 'release/0.9-rc1'
[Sone.git] / src / main / resources / templates / imageBrowser.html
1 <%include include/head.html>
2
3         <div class="page-id hidden">image-browser</div>
4
5         <script language="javascript">
6
7                 /* hide all those forms. */
8                 function hideAndShowBlock(blockElement, clickToShowElement, clickToHideElement) {
9                         $(blockElement).hide();
10                         $(clickToShowElement).removeClass("hidden");
11                         $(clickToShowElement).click(function() {
12                                 $(blockElement).slideDown();
13                                 $(clickToShowElement).addClass("hidden");
14                                 $(clickToHideElement).removeClass("hidden");
15                         });
16                         $(clickToHideElement).click(function() {
17                                 $(blockElement).slideUp();
18                                 $(clickToHideElement).addClass("hidden");
19                                 $(clickToShowElement).removeClass("hidden");
20                         });
21                 }
22
23                 /* ID of the image currently being edited. */
24                 var editingImageId = null;
25
26                 /**
27                  * Shows the form for editing an image.
28                  *
29                  * @param imageId The ID of the image to edit.
30                  */
31                 function editImage(imageId) {
32                         if (editingImageId != imageId) {
33                                 cancelImageEditing();
34                         } else {
35                                 return;
36                         }
37                         editingImageId = imageId;
38                         $(".show-data", getImage(imageId)).hide();
39                         $(".edit-data", getImage(imageId)).show();
40                         $(document).bind("click.sone", function(event) {
41                                 if ($(event.target).closest("#image-" + imageId).size() == 0) {
42                                         cancelImageEditing();
43                                 }
44                         });
45                 }
46
47                 /**
48                  * Cancels all image editing.
49                  */
50                 function cancelImageEditing() {
51                         $(".image .show-data").show();
52                         $(".image .edit-data").hide();
53                         $("form.edit-image").each(function() {
54                                 this.reset();
55                         });
56                         $(document).unbind("click.sone");
57                         editingImageId = null;
58                 }
59
60                 /**
61                  * Returns the image element with the given ID.
62                  *
63                  * @param imageId The ID of the image
64                  * @return The image element
65                  */
66                 function getImage(imageId) {
67                         return $("#sone .image .image-id:contains('" + imageId + "')").closest(".image");
68                 }
69
70                 /**
71                  * Swaps two images.
72                  *
73                  * @param sourceId The ID of the source image
74                  * @param destinationId The ID of the destionation image
75                  */
76                 function swapImage(sourceId, destinationId) {
77                         sourceElement = getImage(sourceId);
78                         destinationElement = getImage(destinationId);
79                         sourceParent = sourceElement.closest(".image-row");
80                         sourcePrevSibling = sourceElement.prev();
81                         sourceElement.detach();
82                         destinationElement.before(sourceElement);
83                         if (sourcePrevSibling.get(0) != destinationElement.get(0)) {
84                                 destinationElement.detach();
85                                 (sourcePrevSibling.size() > 0) ? sourcePrevSibling.after(destinationElement) : sourceParent.prepend(destinationElement);
86                         }
87                         if ($("button[name='moveLeft']", sourceElement).hasClass("hidden") != $("button[name='moveLeft']", destinationElement).hasClass("hidden")) {
88                                 $("button[name='moveLeft']", sourceElement).toggleClass("hidden");
89                                 $("button[name='moveLeft']", destinationElement).toggleClass("hidden");
90                         }
91                         if ($("button[name='moveRight']", sourceElement).hasClass("hidden") != $("button[name='moveRight']", destinationElement).hasClass("hidden")) {
92                                 $("button[name='moveRight']", sourceElement).toggleClass("hidden");
93                                 $("button[name='moveRight']", destinationElement).toggleClass("hidden");
94                         }
95                 }
96
97                 /**
98                  * Prepare all images for inline editing.
99                  */
100                 function prepareImages() {
101                         $(".image").each(function() {
102                                 imageId = $(this).closest(".image").find(".image-id").text();
103                                 (function(element, imageId) {
104                                         $(".show-data", element).click(function() {
105                                                 editImage(imageId);
106                                         });
107                                         $("button[name='moveLeft'], button[name='moveRight']", element).click(function() {
108                                                 ajaxGet("editImage.ajax", { "formPassword": getFormPassword(), "image": imageId, "moveLeft": this.name == "moveLeft", "moveRight": this.name == "moveRight" }, function(data) {
109                                                         if (data && data.success) {
110                                                                 swapImage(data.sourceImageId, data.destinationImageId);
111                                                         }
112                                                 });
113                                                 return false;
114                                         });
115                                         $("button[name='submit']", element).click(function() {
116                                                 title = $(":input[name='title']:enabled", this.form).val();
117                                                 description = $(":input[name='description']:enabled", this.form).val();
118                                                 ajaxGet("editImage.ajax", { "formPassword": getFormPassword(), "image": imageId, "title": title, "description": description }, function(data) {
119                             var imageElement = getImage(data.imageId);
120                             var imageTitleInput = imageElement.find(":input[name='title']");
121                             var imageDescriptionInput = imageElement.find(":input[name='description']");
122                             if (data && data.success) {
123                                                                 imageElement.find(".image-title").text(data.title);
124                                                                 imageElement.find(".image-description").html(data.parsedDescription);
125                                                                 imageTitleInput.attr("defaultValue", data.title);
126                                                                 imageDescriptionInput.attr("defaultValue", data.description);
127                                                                 cancelImageEditing();
128                                                         } else if (data && !data.success) {
129                                                                 imageTitleInput.attr("value", imageTitleInput.attr("defaultValue"));
130                                 imageDescriptionInput.attr("value", imageDescriptionInput.attr("defaultValue"));
131                                 cancelImageEditing();
132                             }
133                                                 });
134                                                 return false;
135                                         });
136                                 })(this, imageId);
137                         });
138                 }
139
140                 /* ID of the album currently being edited. */
141                 var editingAlbumId = null;
142
143                 /**
144                  * Shows the form for editing an album.
145                  *
146                  * @param albumId The ID of the album to edit.
147                  */
148                 function editAlbum(albumId) {
149                         if (editingAlbumId != albumId) {
150                                 if (editingAlbumId != null) {
151                                         cancelAlbumEditing();
152                                 }
153                         } else {
154                                 console.log("already editing " + albumId);
155                                 return;
156                         }
157                         editingAlbumId = albumId;
158                         $(".show-data", getAlbum(albumId)).hide();
159                         $(".edit-data", getAlbum(albumId)).show();
160                         console.log(getAlbum(albumId));
161                         $(document).bind("click.sone", function(event) {
162                                 if ($(event.target).closest("#album-" + albumId).size() == 0) {
163                                         cancelAlbumEditing();
164                                 }
165                         });
166                 }
167
168                 /**
169                  * Cancels all album editing.
170                  */
171                 function cancelAlbumEditing() {
172                         console.log("cancel-album-edit");
173                         $(".album .show-data").show();
174                         $(".album .edit-data").hide();
175                         $("form.edit-album").each(function() {
176                                 this.reset();
177                         });
178                         $(document).unbind("click.sone");
179                         editingAlbumId = null;
180                 }
181
182                 /**
183                  * Returns the album element with the given ID.
184                  *
185                  * @param albumId The ID of the album
186                  * @return The album element
187                  */
188                 function getAlbum(albumId) {
189                         return $("#sone .album .album-id:contains('" + albumId + "')").closest(".album");
190                 }
191
192                 /**
193                  * Swaps two albums.
194                  *
195                  * @param sourceId The ID of the source album
196                  * @param destinationId The ID of the destionation album
197                  */
198                 function swapAlbum(sourceId, destinationId) {
199                         sourceElement = getAlbum(sourceId);
200                         destinationElement = getAlbum(destinationId);
201                         sourceParent = sourceElement.closest(".album-row");
202                         sourcePrevSibling = sourceElement.prev();
203                         sourceElement.detach();
204                         destinationElement.before(sourceElement);
205                         if (sourcePrevSibling.get(0) != destinationElement.get(0)) {
206                                 destinationElement.detach();
207                                 (sourcePrevSibling.size() > 0) ? sourcePrevSibling.after(destinationElement) : sourceParent.prepend(destinationElement);
208                         }
209                         if ($("button[name='moveLeft']", sourceElement).hasClass("hidden") != $("button[name='moveLeft']", destinationElement).hasClass("hidden")) {
210                                 $("button[name='moveLeft']", sourceElement).toggleClass("hidden");
211                                 $("button[name='moveLeft']", destinationElement).toggleClass("hidden");
212                         }
213                         if ($("button[name='moveRight']", sourceElement).hasClass("hidden") != $("button[name='moveRight']", destinationElement).hasClass("hidden")) {
214                                 $("button[name='moveRight']", sourceElement).toggleClass("hidden");
215                                 $("button[name='moveRight']", destinationElement).toggleClass("hidden");
216                         }
217                 }
218
219                 /**
220                  * Prepare all albums for inline editing.
221                  */
222                 function prepareAlbums() {
223                         $(".album").each(function() {
224                                 albumId = $(this).closest(".album").find(".album-id").text();
225                                 (function(element, albumId) {
226                                         $(".show-data", element).click(function() {
227                                                 console.log("show-data");
228                                                 editAlbum(albumId);
229                                         });
230                                         $("button[name='moveLeft'], button[name='moveRight']", element).click(function() {
231                                                 ajaxGet("editAlbum.ajax", { "formPassword": getFormPassword(), "album": albumId, "moveLeft": this.name == "moveLeft", "moveRight": this.name == "moveRight" }, function(data) {
232                                                         if (data && data.success) {
233                                                                 swapAlbum(data.sourceAlbumId, data.destinationAlbumId);
234                                                         }
235                                                 });
236                                                 return false;
237                                         });
238                                         $("button[name='submit']", element).click(function() {
239                                                 title = $(":input[name='title']:enabled", this.form).val();
240                                                 description = $(":input[name='description']:enabled", this.form).val();
241                                                 ajaxGet("editAlbum.ajax", { "formPassword": getFormPassword(), "album": albumId, "title": title, "description": description }, function(data) {
242                                                         if (data) {
243                                 var albumTitleField = getAlbum(data.albumId).find(".album-title");
244                                 var albumDescriptionField = getAlbum(data.albumId).find(".album-description");
245                                 if (data.success) {
246                                     albumTitleField.text(data.title);
247                                     albumDescriptionField.text(data.description);
248                                     getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title);
249                                     getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description);
250                                 } else {
251                                     albumTitleField.attr("value", albumTitleField.attr("defaultValue"));
252                                     albumDescriptionField.attr("value", albumDescriptionField.attr("defaultValue"));
253                                 }
254                                 cancelAlbumEditing();
255                             }
256                                                 });
257                                                 return false;
258                                         });
259                                 })(this, albumId);
260                         });
261                 }
262
263         </script>
264
265         <%if albumRequested>
266
267                 <%ifnull album>
268
269                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
270
271                 <%elseifnull album.title>
272
273                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
274
275                 <%else>
276
277                         <%if album.sone.local>
278                                 <script language="javascript">
279
280                                         $(function() {
281                                                 getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) {
282                                                         $("#upload-image :input[name='title']").each(function() {
283                                                                 registerInputTextareaSwap(this, text, "title", false, true);
284                                                         });
285                                                 });
286                                                 getTranslation("WebInterface.DefaultText.UploadImage.Description", function(text) {
287                                                         $("#upload-image :input[name='description']").each(function() {
288                                                                 registerInputTextareaSwap(this, text, "description", true, false);
289                                                         });
290                                                 });
291                                                 $("#upload-image label").hide();
292                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
293                                                         $("#create-album input[name='name']").each(function() {
294                                                                 registerInputTextareaSwap(this, text, "name", false, true);
295                                                         });
296                                                 });
297                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
298                                                         $("#create-album input[name='description']").each(function() {
299                                                                 registerInputTextareaSwap(this, text, "description", true, true);
300                                                         });
301                                                 });
302                                                 $("#create-album label").hide();
303                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Title", function(text) {
304                                                         $("#edit-album input[name='title']").each(function() {
305                                                                 registerInputTextareaSwap(this, text, "title", false, true);
306                                                         });
307                                                 });
308                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Description", function(text) {
309                                                         $("#edit-album :input[name='description']").each(function() {
310                                                                 registerInputTextareaSwap(this, text, "description", true, false);
311                                                         });
312                                                 });
313                                                 $("#edit-album label").hide();
314
315                                                 /* hide non-js image move buttons. */
316                                                 $(".move-buttons").hide();
317
318                                                 hideAndShowBlock("div.edit-album", ".show-edit-album", ".hide-edit-album");
319                                                 hideAndShowBlock("div.create-album", ".show-create-album", ".hide-create-album");
320                                                 hideAndShowBlock("div.upload-image", ".show-upload-image", ".hide-upload-image");
321                                                 hideAndShowBlock("div.delete-album", ".show-delete-album", ".hide-delete-album");
322
323                                                 prepareAlbums();
324                                                 prepareImages();
325                                         });
326                                 </script>
327                         <%/if>
328
329                         <h1 class="backlink"><%= Page.ImageBrowser.Album.Title|l10n|replace needle=='{album}' replacement=album.title|html></h1>
330
331                         <div class="backlinks">
332                                 <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
333                                 <div class="separator">&gt;</div>
334                                 <%foreach album.backlinks backlink backlinks>
335                                         <div class="backlink">
336                                                 <a href="<% backlink.target|html>"><% backlink.name|html></a>
337                                         </div>
338                                         <%if ! backlinks.last>
339                                                 <div class="separator">&gt;</div>
340                                         <%/if>
341                                 <%/foreach>
342                         </div>
343
344                         <p id="description"><% album.description|parse sone=album.sone></p>
345
346                         <%if album.sone.local>
347                                 <div class="show-edit-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
348                                 <div class="hide-edit-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
349                                 <div class="edit-album">
350                                         <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
351
352                                         <form id="edit-album" action="editAlbum.html" method="post">
353                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
354                                                 <input type="hidden" name="album" value="<%album.id|html>" />
355
356                                                 <%if ! album.images.empty>
357                                                         <div>
358                                                                 <label for="album-image"><%= Page.ImageBrowser.Album.Label.AlbumImage|l10n|html></label>
359                                                                 <select name="album-image">
360                                                                         <option disabled="disabled"><%= Page.ImageBrowser.Album.AlbumImage.Choose|l10n|html></option>
361                                                                         <%foreach album.images image>
362                                                                                 <option value="<% image.id|html>"<%if album.albumImage.id|match value=image.id> selected="selected"<%/if>><% image.title|html></option>
363                                                                         <%/foreach>
364                                                                 </select>
365                                                         </div>
366                                                 <%/if>
367                                                 <div>
368                                                         <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
369                                                         <input type="text" name="title" value="<%album.title|html>" />
370                                                 </div>
371                                                 <div>
372                                                         <label for="description"><%= Page.ImageBrowser.Album.Label.Description|l10n|html></label>
373                                                         <textarea name="description"><%album.description|html></textarea>
374                                                 </div>
375                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Save|l10n|html></button>
376                                         </form>
377                                 </div>
378                         <%/if>
379
380                         <%include include/browseAlbums.html albums=album.albums>
381
382                         <%if album.sone.local>
383                                 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
384                                 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
385                                 <div class="create-album">
386                                         <%include include/createAlbum.html>
387                                 </div>
388                         <%/if>
389
390                         <%foreach album.images image|paginate pageSize=core.preferences.imagesPerPage page=page>
391                                 <%first>
392                                         <h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2>
393                                         <%include include/pagination.html pageParameter=="page">
394                                 <%/first>
395                                 <%if loop.count|mod divisor==3><div class="image-row"><%/if>
396                                 <div id="image-<% image.id|html>" class="image">
397                                         <div class="image-id hidden"><% image.id|html></div>
398                                         <div class="image-container">
399                                                 <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width==250 max-height==250 mode==enlarge title=image.title></a>
400                                         </div>
401                                         <div class="show-data">
402                                                 <div class="image-title"><% image.title|html></div>
403                                                 <div class="image-description"><% image.description|parse sone=image.sone></div>
404                                         </div>
405                                         <%if album.sone.local>
406                                                 <form class="edit-image" action="editImage.html" method="post">
407                                                         <input type="hidden" name="formPassword" value="<%formPassword|html>" />
408                                                         <input type="hidden" name="returnPage" value="<%request.uri|html>" />
409                                                         <input type="hidden" name="image" value="<%image.id|html>" />
410
411                                                         <div class="move-buttons">
412                                                                         <button <%first>class="hidden" <%/first>type="submit" name="moveLeft" value="true"><%= Page.ImageBrowser.Image.Button.MoveLeft|l10n|html></button>
413                                                                         <button <%last>class="hidden" <%/last>type="submit" name="moveRight" value="true"><%= Page.ImageBrowser.Image.Button.MoveRight|l10n|html></button>
414                                                         </div>
415
416                                                         <div class="edit-data hidden">
417                                                                 <div>
418                                                                         <input type="text" name="title" value="<%image.title|html>" />
419                                                                 </div>
420                                                                 <div>
421                                                                         <textarea name="description"><%image.description|html></textarea>
422                                                                 </div>
423                                                                 <div>
424                                                                         <button <%first>class="hidden" <%/first>type="submit" name="moveLeft" value="true"><%= Page.ImageBrowser.Image.Button.MoveLeft|l10n|html></button>
425                                                                         <button type="submit" name="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
426                                                                         <button <%last>class="hidden" <%/last>type="submit" name="moveRight" value="true"><%= Page.ImageBrowser.Image.Button.MoveRight|l10n|html></button>
427                                                                 </div>
428                                                         </div>
429                                                 </form>
430                                         <%/if>
431                                 </div>
432                                 <%= false|store key==endRow>
433                                 <%if loop.count|mod divisor==3 offset==1><%= true|store key==endRow><%/if>
434                                 <%last><%= true|store key==endRow><%/last>
435                                 <%if endRow>
436                                         </div>
437                                 <%/if>
438                 <%last><%include include/pagination.html pageParameter=="page"><%/last>
439                         <%/foreach>
440
441                         <%if album.sone.local>
442                                 <div class="clear show-upload-image hidden toggle-link"><a class="small-link">» <%= View.UploadImage.Title|l10n|html></a></div>
443                                 <div class="clear hide-upload-image hidden toggle-link"><a class="small-link">« <%= View.UploadImage.Title|l10n|html></a></div>
444                                 <div class="upload-image">
445                                         <%include include/uploadImage.html>
446                                 </div>
447
448                                 <%if album.empty>
449                                         <div class="show-delete-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
450                                         <div class="hide-delete-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
451                                         <div class="delete-album">
452                                                 <form id="delete-album" action="deleteAlbum.html" method="get">
453                                                         <input type="hidden" name="album" value="<%album.id|html>" />
454                                                         <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
455                                                 </form>
456                                         </div>
457                                 <%/if>
458
459                         <%/if>
460
461                 <%/if>
462
463         <%elseif imageRequested>
464
465                 <h1 class="backlink"><%image.title|html></h1>
466
467                 <div class="backlinks">
468                         <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
469                         <div class="separator">&gt;</div>
470                         <%foreach image.album.backlinks backlink backlinks>
471                                 <div class="backlink">
472                                         <a href="<% backlink.target|html>"><% backlink.name|html></a>
473                                 </div>
474                                 <%if ! backlinks.last>
475                                         <div class="separator">&gt;</div>
476                                 <%/if>
477                         <%/foreach>
478                         <%ifnull !image.previous><div class="backlink"><a href="imageBrowser.html?image=<%image.previous.id|html>">« <%image.previous.title|html></a></div><%/if>
479                         <%ifnull !image.next><div class="backlink"><a href="imageBrowser.html?image=<%image.next.id|html>">» <%image.next.title|html></a></div><%/if>
480                 </div>
481
482                 <%ifnull image>
483
484                 <%else>
485
486                         <%if image.sone.local>
487                                 <script language="javascript">
488                                         $(function() {
489                                                 getTranslation("WebInterface.DefaultText.EditImage.Title", function(text) {
490                                                         $("#edit-image input[name='title']").each(function() {
491                                                                 registerInputTextareaSwap(this, text, "title", false, true);
492                                                         });
493                                                 });
494                                                 getTranslation("WebInterface.DefaultText.EditImage.Description", function(text) {
495                                                         $("#edit-image :input[name='description']").each(function() {
496                                                                 registerInputTextareaSwap(this, text, "description", true, false);
497                                                         });
498                                                 });
499                                                 $("#edit-image label").hide();
500
501                                                 hideAndShowBlock(".edit-image", ".show-edit-image", ".hide-edit-image");
502                                                 hideAndShowBlock(".delete-image", ".show-delete-image", ".hide-delete-image");
503                                         });
504                                 </script>
505                         <%/if>
506
507                         <div class="single-image">
508                                 <%ifnull !image.key>
509                                         <a href="/<%image.key|html>"><% image|image-link max-width==640 max-height==480></a>
510                                 <%else>
511                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width==640 max-height==480></a>
512                                 <%/if>
513                         </div>
514
515                         <p class="parsed"><%image.description|parse sone=image.sone></p>
516
517                         <%if image.sone.local>
518
519                                 <div class="show-edit-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
520                                 <div class="hide-edit-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
521                                 <div class="edit-image">
522                                         <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
523
524                                         <form id="edit-image" action="editImage.html" method="post">
525                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
526                                                 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
527                                                 <input type="hidden" name="image" value="<%image.id|html>" />
528
529                                                 <div>
530                                                         <label for="title"><%= Page.ImageBrowser.Image.Title.Label|l10n|html></label>
531                                                         <input type="text" name="title" value="<%image.title|html>" />
532                                                 </div>
533                                                 <div>
534                                                         <label for="description"><%= Page.ImageBrowser.Image.Description.Label|l10n|html></label>
535                                                         <textarea name="description"><%image.description|html></textarea>
536                                                 </div>
537                                                 <div>
538                                                         <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
539                                                 </div>
540                                         </form>
541                                 </div>
542
543                                 <div class="show-delete-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
544                                 <div class="hide-delete-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
545                                 <div class="delete-image">
546                                         <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
547
548                                         <form id="delete-image" action="deleteImage.html" method="get">
549                                                 <input type="hidden" name="image" value="<%image.id|html>" />
550                                                 <button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
551                                         </form>
552                                 </div>
553
554                         <%/if>
555
556                 <%/if>
557
558         <%elseif soneRequested>
559
560                 <%if sone.local>
561                         <script language="javascript">
562                                 $(function() {
563                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
564                                                 $("#create-album input[name='name']").each(function() {
565                                                         registerInputTextareaSwap(this, text, "name", false, true);
566                                                 });
567                                         });
568                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
569                                                 $("#create-album input[name='description']").each(function() {
570                                                         registerInputTextareaSwap(this, text, "description", true, true);
571                                                 });
572                                         });
573                                         $("#create-album label").hide();
574
575                                         /* hide non-js move buttons. */
576                                         $(".move-buttons").hide();
577
578                                         hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
579
580                                         prepareAlbums();
581                                 });
582                         </script>
583                 <%/if>
584
585                 <%ifnull sone>
586
587                         <p><%= Page.ImageBrowser.Sone.Error.NotFound.Text|l10n|html></p>
588
589                 <%else>
590
591                         <h1><%= Page.ImageBrowser.Sone.Title|l10n|replace needle=='{sone}' replacement=sone.niceName|html></h1>
592
593                         <div class="backlinks">
594                                 <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
595                                 <div class="separator">&gt;</div>
596                                 <div class="backlink"><a href="imageBrowser.html?sone=<%sone.id|html>"><%sone.niceName|html></a></div>
597                         </div>
598
599                         <%include include/browseAlbums.html albums=sone.rootAlbum.albums>
600
601                         <%if sone.local>
602                                 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
603                                 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
604                                 <div class="create-album">
605                                         <%include include/createAlbum.html>
606                                 </div>
607                         <%/if>
608
609                 <%/if>
610
611         <%elseif galleryRequested>
612
613                 <%foreach albums album|paginate pageSize=core.preferences.imagesPerPage pageParameter=request.page pagination=albumPagination>
614                         <%first>
615                                 <h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2>
616                                 <%include include/pagination.html pagination=albumPagination pageParameter=="page">
617                         <%/first>
618                         <%if loop.count|mod divisor==3><div class="album-row"><%/if>
619                         <div id="album-<% album.id|html>" class="album">
620                                 <div class="album-id hidden"><% album.id|html></div>
621                                 <div class="album-container">
622                                         <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
623                                                 <%ifnull album.albumImage>
624                                                         <img src="images/unknown-image-0.png" width="333" height="250" alt="<% album.title|html> (<%album.sone.niceName|html>)" title="<% album.title|html> (<%album.sone.niceName|html>)" style="position: relative; top: 0px; left: -41px;" />
625                                                 <%else><!-- TODO -->
626                                                         <% album.albumImage|image-link max-width==250 max-height==250 mode==enlarge title=album.title>
627                                                 <%/if>
628                                         </a>
629                                 </div>
630                                 <div class="show-data">
631                                         <div class="album-sone"><a href="imageBrowser.html?sone=<%album.sone.id|html>"><%album.sone.niceName|html></a></div>
632                                         <div class="album-title"><% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)</div>
633                                         <div class="album-description"><% album.description|parse sone=album.sone></div>
634                                 </div>
635                         </div>
636                         <%= false|store key==endRow>
637                         <%if loop.count|mod divisor==3 offset==1><%= true|store key==endRow><%/if>
638                         <%last><%= true|store key==endRow><%/last>
639                         <%if endRow>
640                                 </div>
641                         <%/if>
642                         <%last>
643                                 <%include include/pagination.html pagination=albumPagination pageParameter=="page">
644                         <%/last>
645                 <%/foreach>
646
647         <%/if>
648
649 <%include include/tail.html>