Add inline image editing.
[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         <%if albumRequested>
6
7                 <%ifnull album>
8
9                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
10
11                 <%elseifnull album.title>
12
13                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
14
15                 <%else>
16
17                         <%if album.sone.local>
18                                 <script language="javascript">
19                                         $(function() {
20                                                 getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) {
21                                                         $("#upload-image :input[name='title']").each(function() {
22                                                                 registerInputTextareaSwap(this, text, "title", false, true);
23                                                         });
24                                                 });
25                                                 getTranslation("WebInterface.DefaultText.UploadImage.Description", function(text) {
26                                                         $("#upload-image :input[name='description']").each(function() {
27                                                                 registerInputTextareaSwap(this, text, "description", true, false);
28                                                         });
29                                                 });
30                                                 $("#upload-image label").hide();
31                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
32                                                         $("#create-album input[name='name']").each(function() {
33                                                                 registerInputTextareaSwap(this, text, "name", false, true);
34                                                         });
35                                                 });
36                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
37                                                         $("#create-album input[name='description']").each(function() {
38                                                                 registerInputTextareaSwap(this, text, "description", true, true);
39                                                         });
40                                                 });
41                                                 $("#create-album label").hide();
42                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Title", function(text) {
43                                                         $("#edit-album input[name='title']").each(function() {
44                                                                 registerInputTextareaSwap(this, text, "title", false, true);
45                                                         });
46                                                 });
47                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Description", function(text) {
48                                                         $("#edit-album :input[name='description']").each(function() {
49                                                                 registerInputTextareaSwap(this, text, "description", true, false);
50                                                         });
51                                                 });
52                                                 $("#edit-album label").hide();
53
54                                                 /* hide all those forms. */
55                                                 hideBlock = function(blockElement, clickElement) {
56                                                         $(blockElement).hide();
57                                                         $(clickElement).removeClass("hidden").click(function() {
58                                                                 $(blockElement).slideDown();
59                                                                 $(this).slideUp();
60                                                                 return false;
61                                                         });
62                                                 };
63
64                                                 hideBlock(".edit-album", ".show-edit-album");
65                                                 hideBlock(".create-album", ".show-create-album");
66                                                 hideBlock(".upload-image", ".show-upload-image");
67                                         });
68                                 </script>
69                         <%/if>
70
71                         <h1 class="backlink"><%= Page.ImageBrowser.Album.Title|l10n|replace needle='{album}' replacementKey=album.title|html></h1>
72
73                         <div class="backlinks">
74                                 <%foreach album.backlinks backlink backlinks>
75                                         <div class="backlink">
76                                                 <a href="<% backlink.target|html>"><% backlink.name|html></a>
77                                         </div>
78                                         <%if ! backlinks.last>
79                                                 <div class="separator">&gt;</div>
80                                         <%/if>
81                                 <%/foreach>
82                         </div>
83
84                         <p id="description"><% album.description|html></p>
85
86                         <%if album.sone.local>
87                                 <p><a class="show-edit-album hidden small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></p>
88                                 <div class="edit-album">
89                                         <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
90
91                                         <form id="edit-album" action="editAlbum.html" method="post">
92                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
93                                                 <input type="hidden" name="album" value="<%album.id|html>" />
94
95                                                 <div>
96                                                         <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
97                                                         <input type="text" name="title" value="<%album.title|html>" />
98                                                 </div>
99                                                 <div>
100                                                         <label for="description"><%= Page.ImageBrowser.Album.Label.Description|l10n|html></label>
101                                                         <textarea name="description"><%album.description|html></textarea>
102                                                 </div>
103                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Save|l10n|html></button>
104                                         </form>
105                                 </div>
106                         <%/if>
107
108                         <%foreach album.albums album>
109                                 <%first><h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2><%/first>
110                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
111                                 <div class="album image">
112                                         <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
113                                                 <%ifnull album.albumImage>
114                                                         <img src="images/unknown-image-0.png" width="200" height="150" alt="<% album.title|html>" title="<% album.title|html>" />
115                                                 <%else><!-- TODO -->
116                                                         <% album.albumImage|image-link max-width=200 max-height=150 title==album.title>
117                                                 <%/if>
118                                                 <br/>
119                                                 <% album.title|html>
120                                         </a>
121                                 </div>
122                                 <%= false|store key=endRow>
123                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
124                                 <%last><%= true|store key=endRow><%/last>
125                                 <%if endRow></div><%/if>
126                         <%/foreach>
127
128                         <%if album.sone.local>
129                                 <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
130                                 <div class="create-album">
131                                         <%include include/createAlbum.html>
132                                 </div>
133                         <%/if>
134
135                         <%foreach album.images image>
136                                 <%first><h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2><%/first>
137                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
138                                 <div class="image">
139                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=200 max-height=150></a>
140                                         <%if album.sone.local>
141                                                 <br/>
142                                                 <form class="edit-image" action="editImage.html" method="post">
143                                                         <input type="hidden" name="formPassword" value="<%formPassword|html>" />
144                                                         <input type="hidden" name="returnPage" value="<%request.uri|html>" />
145                                                         <input type="hidden" name="image" value="<%image.id|html>" />
146
147                                                         <div>
148                                                                 <input type="text" name="title" value="<%image.title|html>" />
149                                                         </div>
150                                                         <div>
151                                                                 <textarea name="description"><%image.description|html></textarea>
152                                                         </div>
153                                                         <div>
154                                                                 <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
155                                                         </div>
156                                                 </form>
157                                         <%/if>
158                                 </div>
159                                 <%= false|store key=endRow>
160                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
161                                 <%last><%= true|store key=endRow><%/last>
162                                 <%if endRow></div><%/if>
163                         <%/foreach>
164
165                         <%if album.sone.local>
166                                 <p><a class="show-upload-image hidden small-link">» <%= View.UploadImage.Title|l10n|html></a></p>
167                                 <div class="upload-image">
168                                         <%include include/uploadImage.html>
169                                 </div>
170
171                                 <%if album.empty>
172                                         <form id="delete-album" action="deleteAlbum.html" method="get">
173                                                 <input type="hidden" name="album" value="<%album.id|html>" />
174                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
175                                         </form>
176                                 <%/if>
177
178                         <%/if>
179
180                 <%/if>
181
182         <%elseif imageRequested>
183
184                 <h1 class="backlink"><%image.title|html></h1>
185
186                 <div class="backlinks">
187                         <%foreach image.album.backlinks backlink backlinks>
188                                 <div class="backlink">
189                                         <a href="<% backlink.target|html>"><% backlink.name|html></a>
190                                 </div>
191                                 <%if ! backlinks.last>
192                                         <div class="separator">&gt;</div>
193                                 <%/if>
194                         <%/foreach>
195                 </div>
196
197                 <%ifnull image>
198
199                 <%else>
200
201                         <%if image.sone.local>
202                                 <script language="javascript">
203                                         $(function() {
204                                                 getTranslation("WebInterface.DefaultText.EditImage.Title", function(text) {
205                                                         $("#edit-image input[name='title']").each(function() {
206                                                                 registerInputTextareaSwap(this, text, "title", false, true);
207                                                         });
208                                                 });
209                                                 getTranslation("WebInterface.DefaultText.EditImage.Description", function(text) {
210                                                         $("#edit-image :input[name='description']").each(function() {
211                                                                 registerInputTextareaSwap(this, text, "description", true, false);
212                                                         });
213                                                 });
214                                                 $("#edit-image label").hide();
215
216                                                 /* hide all those forms. */
217                                                 hideBlock = function(blockElement, clickElement) {
218                                                         $(blockElement).hide();
219                                                         $(clickElement).removeClass("hidden").click(function() {
220                                                                 $(blockElement).slideDown();
221                                                                 $(this).slideUp();
222                                                                 return false;
223                                                         });
224                                                 };
225
226                                                 hideBlock(".edit-image", ".show-edit-image");
227                                                 hideBlock(".delete-image", ".show-delete-image");
228                                         });
229                                 </script>
230                         <%/if>
231
232                         <div class="single-image">
233                                 <%ifnull !image.key>
234                                         <a href="/<%image.key|html>"><% image|image-link max-width=640 max-height=480></a>
235                                 <%else>
236                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=640 max-height=480></a>
237                                 <%/if>
238                         </div>
239
240                         <p class="parsed"><%image.description|parse sone=image.sone></p>
241
242                         <%if image.sone.local>
243
244                                 <p><a class="show-edit-image hidden small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></p>
245                                 <div class="edit-image">
246                                         <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
247
248                                         <form id="edit-image" action="editImage.html" method="post">
249                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
250                                                 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
251                                                 <input type="hidden" name="image" value="<%image.id|html>" />
252
253                                                 <div>
254                                                         <label for="title"><%= Page.ImageBrowser.Image.Title.Label|l10n|html></label>
255                                                         <input type="text" name="title" value="<%image.title|html>" />
256                                                 </div>
257                                                 <div>
258                                                         <label for="description"><%= Page.ImageBrowser.Image.Description.Label|l10n|html></label>
259                                                         <textarea name="description"><%image.description|html></textarea>
260                                                 </div>
261                                                 <div>
262                                                         <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
263                                                 </div>
264                                         </form>
265                                 </div>
266
267                                 <p><a class="show-delete-image hidden small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></p>
268                                 <div class="delete-image">
269                                         <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
270
271                                         <form id="delete-image" action="deleteImage.html" method="get">
272                                                 <input type="hidden" name="image" value="<%image.id|html>" />
273                                                 <button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
274                                         </form>
275                                 </div>
276
277                         <%/if>
278
279                 <%/if>
280
281         <%elseif soneRequested>
282
283                 <%if sone.local>
284                         <script language="javascript">
285                                 $(function() {
286                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
287                                                 $("#create-album input[name='name']").each(function() {
288                                                         registerInputTextareaSwap(this, text, "name", false, true);
289                                                 });
290                                         });
291                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
292                                                 $("#create-album input[name='description']").each(function() {
293                                                         registerInputTextareaSwap(this, text, "description", true, true);
294                                                 });
295                                         });
296                                         $("#create-album label").hide();
297
298                                         /* hide all those forms. */
299                                         hideBlock = function(blockElement, clickElement) {
300                                                 $(blockElement).hide();
301                                                 $(clickElement).removeClass("hidden").click(function() {
302                                                         $(blockElement).slideDown();
303                                                         $(this).slideUp();
304                                                         return false;
305                                                 });
306                                         };
307
308                                         hideBlock(".create-album", ".show-create-album");
309                                 });
310                         </script>
311                 <%/if>
312
313                 <%ifnull sone>
314
315                         <p><%= Page.ImageBrowser.Sone.Error.NotFound.Text|l10n|html></p>
316
317                 <%else>
318
319                         <h1><%= Page.ImageBrowser.Sone.Title|l10n|replace needle='{sone}' replacementKey=sone.niceName|html></h1>
320
321                         <%foreach sone.albums album>
322                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
323                                 <div class="album image">
324                                         <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
325                                                 <%ifnull album.albumImage>
326                                                         <img src="images/unknown-image-0.png" width="200" height="150" alt="<% album.title|html>" title="<% album.title|html>" />
327                                                 <%else><!-- TODO -->
328                                                         <% album.albumImage|image-link max-width=200 max-height=150 title==album.title>
329                                                 <%/if>
330                                                 <br/>
331                                                 <% album.title|html>
332                                         </a>
333                                 </div>
334                                 <%= false|store key=endRow>
335                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
336                                 <%last><%= true|store key=endRow><%/last>
337                                 <%if endRow></div><%/if>
338                         <%/foreach>
339
340                         <%if sone.local>
341                                 <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
342                                 <div class="create-album">
343                                         <%include include/createAlbum.html>
344                                 </div>
345                         <%/if>
346
347                 <%/if>
348
349         <%/if>
350
351 <%include include/tail.html>