Remove debug output.
[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                 $(function() {
7
8                         /* hide all those forms. */
9                         hideAndShowBlock = function(blockElement, clickToShowElement, clickToHideElement) {
10                                 $(blockElement).hide();
11                                 $(clickToShowElement).removeClass("hidden");
12                                 $(clickToShowElement).click(function() {
13                                         $(blockElement).slideDown();
14                                         $(clickToShowElement).addClass("hidden");
15                                         $(clickToHideElement).removeClass("hidden");
16                                 });
17                                 $(clickToHideElement).click(function() {
18                                         $(blockElement).slideUp();
19                                         $(clickToHideElement).addClass("hidden");
20                                         $(clickToShowElement).removeClass("hidden");
21                                 });
22                         };
23
24                 });
25         </script>
26
27         <%if albumRequested>
28
29                 <%ifnull album>
30
31                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
32
33                 <%elseifnull album.title>
34
35                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
36
37                 <%else>
38
39                         <%if album.sone.local>
40                                 <script language="javascript">
41
42                                         /* ID of the image currently being edited. */
43                                         var editingImageId = null;
44
45                                         /**
46                                          * Shows the form for editing an image.
47                                          *
48                                          * @param imageId The ID of the image to edit.
49                                          */
50                                         function editImage(imageId) {
51                                                 if (editingImageId != imageId) {
52                                                         cancelEditing();
53                                                 } else {
54                                                         return;
55                                                 }
56                                                 $(".show-data", "#image-" + imageId).hide();
57                                                 $(".edit-data", "#image-" + imageId).show();
58                                                 $(document).bind("click.sone", function(event) {
59                                                         if ($(event.target).closest("#image-" + imageId).size() == 0) {
60                                                                 cancelEditing();
61                                                         }
62                                                 });
63                                         }
64
65                                         /**
66                                          * Cancels all image editing.
67                                          */
68                                         function cancelEditing() {
69                                                 $(".show-data").show();
70                                                 $(".edit-data").hide();
71                                                 $("form.edit-image").each(function() {
72                                                         this.reset();
73                                                 });
74                                                 $(document).unbind("click.sone");
75                                                 editingImageId = null;
76                                         }
77
78                                         $(function() {
79                                                 getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) {
80                                                         $("#upload-image :input[name='title']").each(function() {
81                                                                 registerInputTextareaSwap(this, text, "title", false, true);
82                                                         });
83                                                 });
84                                                 getTranslation("WebInterface.DefaultText.UploadImage.Description", function(text) {
85                                                         $("#upload-image :input[name='description']").each(function() {
86                                                                 registerInputTextareaSwap(this, text, "description", true, false);
87                                                         });
88                                                 });
89                                                 $("#upload-image label").hide();
90                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
91                                                         $("#create-album input[name='name']").each(function() {
92                                                                 registerInputTextareaSwap(this, text, "name", false, true);
93                                                         });
94                                                 });
95                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
96                                                         $("#create-album input[name='description']").each(function() {
97                                                                 registerInputTextareaSwap(this, text, "description", true, true);
98                                                         });
99                                                 });
100                                                 $("#create-album label").hide();
101                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Title", function(text) {
102                                                         $("#edit-album input[name='title']").each(function() {
103                                                                 registerInputTextareaSwap(this, text, "title", false, true);
104                                                         });
105                                                 });
106                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Description", function(text) {
107                                                         $("#edit-album :input[name='description']").each(function() {
108                                                                 registerInputTextareaSwap(this, text, "description", true, false);
109                                                         });
110                                                 });
111                                                 $("#edit-album label").hide();
112
113                                                 hideAndShowBlock(".edit-album", ".show-edit-album", ".hide-edit-album");
114                                                 hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
115                                                 hideAndShowBlock(".upload-image", ".show-upload-image", ".hide-upload-image");
116                                                 hideAndShowBlock(".delete-album", ".show-delete-album", ".hide-delete-album");
117
118                                                 $(".image").each(function() {
119                                                         imageId = $(this).closest(".image").find(".image-id").text();
120                                                         (function(element, imageId) {
121                                                                 $(".show-data", element).click(function() {
122                                                                         editImage(imageId);
123                                                                 });
124                                                         })(this, imageId);
125                                                         });
126                                                 });
127                                         });
128                                 </script>
129                         <%/if>
130
131                         <h1 class="backlink"><%= Page.ImageBrowser.Album.Title|l10n|replace needle='{album}' replacementKey=album.title|html></h1>
132
133                         <div class="backlinks">
134                                 <%foreach album.backlinks backlink backlinks>
135                                         <div class="backlink">
136                                                 <a href="<% backlink.target|html>"><% backlink.name|html></a>
137                                         </div>
138                                         <%if ! backlinks.last>
139                                                 <div class="separator">&gt;</div>
140                                         <%/if>
141                                 <%/foreach>
142                         </div>
143
144                         <p id="description"><% album.description|html></p>
145
146                         <%if album.sone.local>
147                                 <div class="show-edit-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
148                                 <div class="hide-edit-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
149                                 <div class="edit-album">
150                                         <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
151
152                                         <form id="edit-album" action="editAlbum.html" method="post">
153                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
154                                                 <input type="hidden" name="album" value="<%album.id|html>" />
155
156                                                 <%if ! album.images.empty>
157                                                         <div>
158                                                                 <label for="album-image"><%= Page.ImageBrowser.Album.Label.AlbumImage|l10n|html></label>
159                                                                 <select name="album-image">
160                                                                         <option disabled="disabled"><%= Page.ImageBrowser.Album.AlbumImage.Choose|l10n|html></option>
161                                                                         <%foreach album.images image>
162                                                                                 <option value="<% image.id|html>"<%if album.albumImage.id|match key=image.id> selected="selected"<%/if>><% image.title|html></option>
163                                                                         <%/foreach>
164                                                                 </select>
165                                                         </div>
166                                                 <%/if>
167                                                 <div>
168                                                         <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
169                                                         <input type="text" name="title" value="<%album.title|html>" />
170                                                 </div>
171                                                 <div>
172                                                         <label for="description"><%= Page.ImageBrowser.Album.Label.Description|l10n|html></label>
173                                                         <textarea name="description"><%album.description|html></textarea>
174                                                 </div>
175                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Save|l10n|html></button>
176                                         </form>
177                                 </div>
178                         <%/if>
179
180                         <%foreach album.albums album>
181                                 <%first><h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2><%/first>
182                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
183                                 <div class="album image">
184                                         <div class="image-container">
185                                                 <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
186                                                         <%ifnull album.albumImage>
187                                                                 <img src="images/unknown-image-0.png" width="266" height="200" alt="<% album.title|html>" title="<% album.title|html>" style="position: relative; top: 0px; left: -33px;" />
188                                                         <%else><!-- TODO -->
189                                                                 <% album.albumImage|image-link max-width=200 max-height=200 mode=enlarge title==album.title>
190                                                         <%/if>
191                                                 </a>
192                                         </div>
193                                         <div class="show-data">
194                                                 <div class="album-title"><% album.title|html></div>
195                                                 <div class="album-description"><% album.description|html></div>
196                                         </div>
197                                 </div>
198                                 <%= false|store key=endRow>
199                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
200                                 <%last><%= true|store key=endRow><%/last>
201                                 <%if endRow></div><%/if>
202                         <%/foreach>
203
204                         <%if album.sone.local>
205                                 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
206                                 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
207                                 <div class="create-album">
208                                         <%include include/createAlbum.html>
209                                 </div>
210                         <%/if>
211
212                         <%foreach album.images image>
213                                 <%first><h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2><%/first>
214                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
215                                 <div id="image-<% image.id|html>" class="image">
216                                         <div class="image-id hidden"><% image.id|html></div>
217                                         <div class="image-container">
218                                                 <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=200 max-height=200 mode=enlarge title==image.title></a>
219                                         </div>
220                                         <div class="show-data">
221                                                 <div class="image-title"><% image.title|html></div>
222                                                 <div class="image-description"><% image.description|html></div>
223                                         </div>
224                                         <%if album.sone.local>
225                                                 <form class="edit-image" action="editImage.html" method="post">
226                                                         <input type="hidden" name="formPassword" value="<%formPassword|html>" />
227                                                         <input type="hidden" name="returnPage" value="<%request.uri|html>" />
228                                                         <input type="hidden" name="image" value="<%image.id|html>" />
229
230                                                         <div class="edit-data hidden">
231                                                                 <div>
232                                                                         <input type="text" name="title" value="<%image.title|html>" />
233                                                                 </div>
234                                                                 <div>
235                                                                         <textarea name="description"><%image.description|html></textarea>
236                                                                 </div>
237                                                                 <div>
238                                                                         <%notfirst><button type="submit" name="moveLeft" value="true"><%= Page.ImageBrowser.Image.Button.MoveLeft|l10n|html></button><%/notfirst>
239                                                                         <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
240                                                                         <%notlast><button type="submit" name="moveRight" value="true"><%= Page.ImageBrowser.Image.Button.MoveRight|l10n|html></button><%/notlast>
241                                                                 </div>
242                                                         </div>
243                                                 </form>
244                                         <%/if>
245                                 </div>
246                                 <%= false|store key=endRow>
247                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
248                                 <%last><%= true|store key=endRow><%/last>
249                                 <%if endRow></div><%/if>
250                         <%/foreach>
251
252                         <%if album.sone.local>
253                                 <div class="show-upload-image hidden toggle-link"><a class="small-link">» <%= View.UploadImage.Title|l10n|html></a></div>
254                                 <div class="hide-upload-image hidden toggle-link"><a class="small-link">« <%= View.UploadImage.Title|l10n|html></a></div>
255                                 <div class="upload-image">
256                                         <%include include/uploadImage.html>
257                                 </div>
258
259                                 <%if album.empty>
260                                         <div class="show-delete-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
261                                         <div class="hide-delete-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
262                                         <div class="delete-album">
263                                                 <form id="delete-album" action="deleteAlbum.html" method="get">
264                                                         <input type="hidden" name="album" value="<%album.id|html>" />
265                                                         <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
266                                                 </form>
267                                         </div>
268                                 <%/if>
269
270                         <%/if>
271
272                 <%/if>
273
274         <%elseif imageRequested>
275
276                 <h1 class="backlink"><%image.title|html></h1>
277
278                 <div class="backlinks">
279                         <%foreach image.album.backlinks backlink backlinks>
280                                 <div class="backlink">
281                                         <a href="<% backlink.target|html>"><% backlink.name|html></a>
282                                 </div>
283                                 <%if ! backlinks.last>
284                                         <div class="separator">&gt;</div>
285                                 <%/if>
286                         <%/foreach>
287                 </div>
288
289                 <%ifnull image>
290
291                 <%else>
292
293                         <%if image.sone.local>
294                                 <script language="javascript">
295                                         $(function() {
296                                                 getTranslation("WebInterface.DefaultText.EditImage.Title", function(text) {
297                                                         $("#edit-image input[name='title']").each(function() {
298                                                                 registerInputTextareaSwap(this, text, "title", false, true);
299                                                         });
300                                                 });
301                                                 getTranslation("WebInterface.DefaultText.EditImage.Description", function(text) {
302                                                         $("#edit-image :input[name='description']").each(function() {
303                                                                 registerInputTextareaSwap(this, text, "description", true, false);
304                                                         });
305                                                 });
306                                                 $("#edit-image label").hide();
307
308                                                 hideAndShowBlock(".edit-image", ".show-edit-image", ".hide-edit-image");
309                                                 hideAndShowBlock(".delete-image", ".show-delete-image", ".hide-delete-image");
310                                         });
311                                 </script>
312                         <%/if>
313
314                         <div class="single-image">
315                                 <%ifnull !image.key>
316                                         <a href="/<%image.key|html>"><% image|image-link max-width=640 max-height=480></a>
317                                 <%else>
318                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=640 max-height=480></a>
319                                 <%/if>
320                         </div>
321
322                         <p class="parsed"><%image.description|parse sone=image.sone></p>
323
324                         <%if image.sone.local>
325
326                                 <div class="show-edit-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
327                                 <div class="hide-edit-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
328                                 <div class="edit-image">
329                                         <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
330
331                                         <form id="edit-image" action="editImage.html" method="post">
332                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
333                                                 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
334                                                 <input type="hidden" name="image" value="<%image.id|html>" />
335
336                                                 <div>
337                                                         <label for="title"><%= Page.ImageBrowser.Image.Title.Label|l10n|html></label>
338                                                         <input type="text" name="title" value="<%image.title|html>" />
339                                                 </div>
340                                                 <div>
341                                                         <label for="description"><%= Page.ImageBrowser.Image.Description.Label|l10n|html></label>
342                                                         <textarea name="description"><%image.description|html></textarea>
343                                                 </div>
344                                                 <div>
345                                                         <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
346                                                 </div>
347                                         </form>
348                                 </div>
349
350                                 <div class="show-delete-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
351                                 <div class="hide-delete-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
352                                 <div class="delete-image">
353                                         <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
354
355                                         <form id="delete-image" action="deleteImage.html" method="get">
356                                                 <input type="hidden" name="image" value="<%image.id|html>" />
357                                                 <button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
358                                         </form>
359                                 </div>
360
361                         <%/if>
362
363                 <%/if>
364
365         <%elseif soneRequested>
366
367                 <%if sone.local>
368                         <script language="javascript">
369                                 $(function() {
370                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
371                                                 $("#create-album input[name='name']").each(function() {
372                                                         registerInputTextareaSwap(this, text, "name", false, true);
373                                                 });
374                                         });
375                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
376                                                 $("#create-album input[name='description']").each(function() {
377                                                         registerInputTextareaSwap(this, text, "description", true, true);
378                                                 });
379                                         });
380                                         $("#create-album label").hide();
381
382                                         hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
383                                 });
384                         </script>
385                 <%/if>
386
387                 <%ifnull sone>
388
389                         <p><%= Page.ImageBrowser.Sone.Error.NotFound.Text|l10n|html></p>
390
391                 <%else>
392
393                         <h1><%= Page.ImageBrowser.Sone.Title|l10n|replace needle='{sone}' replacementKey=sone.niceName|html></h1>
394
395                         <%foreach sone.albums album>
396                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
397                                 <div class="album image">
398                                         <div class="image-container">
399                                                 <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
400                                                         <%ifnull album.albumImage>
401                                                                 <img src="images/unknown-image-0.png" width="266" height="200" alt="<% album.title|html>" title="<% album.title|html>" style="position: relative; top: 0px; left: -33px;"/>
402                                                         <%else><!-- TODO -->
403                                                                 <% album.albumImage|image-link max-width=200 max-height=200 mode=enlarge title==album.title>
404                                                         <%/if>
405                                                 </a>
406                                         </div>
407                                         <div class="show-data">
408                                                 <div class="album-title"><% album.title|html></div>
409                                                 <div class="album-description"><% album.description|html></div>
410                                         </div>
411                                 </div>
412                                 <%= false|store key=endRow>
413                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
414                                 <%last><%= true|store key=endRow><%/last>
415                                 <%if endRow></div><%/if>
416                         <%/foreach>
417
418                         <%if sone.local>
419                                 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
420                                 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
421                                 <div class="create-album">
422                                         <%include include/createAlbum.html>
423                                 </div>
424                         <%/if>
425
426                 <%/if>
427
428         <%/if>
429
430 <%include include/tail.html>