1 <%include include/head.html>
3 <div class="page-id hidden">image-browser</div>
5 <script language="javascript">
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");
16 $(clickToHideElement).click(function() {
17 $(blockElement).slideUp();
18 $(clickToHideElement).addClass("hidden");
19 $(clickToShowElement).removeClass("hidden");
23 /* ID of the image currently being edited. */
24 var editingImageId = null;
27 * Shows the form for editing an image.
29 * @param imageId The ID of the image to edit.
31 function editImage(imageId) {
32 if (editingImageId != imageId) {
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) {
48 * Cancels all image editing.
50 function cancelImageEditing() {
51 $(".image .show-data").show();
52 $(".image .edit-data").hide();
53 $("form.edit-image").each(function() {
56 $(document).unbind("click.sone");
57 editingImageId = null;
61 * Returns the image element with the given ID.
63 * @param imageId The ID of the image
64 * @return The image element
66 function getImage(imageId) {
67 return $("#sone .image .image-id:contains('" + imageId + "')").closest(".image");
73 * @param sourceId The ID of the source image
74 * @param destinationId The ID of the destionation image
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);
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");
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");
98 * Prepare all images for inline editing.
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() {
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);
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();
140 /* ID of the album currently being edited. */
141 var editingAlbumId = null;
144 * Shows the form for editing an album.
146 * @param albumId The ID of the album to edit.
148 function editAlbum(albumId) {
149 if (editingAlbumId != albumId) {
150 if (editingAlbumId != null) {
151 cancelAlbumEditing();
154 console.log("already editing " + albumId);
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();
169 * Cancels all album editing.
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() {
178 $(document).unbind("click.sone");
179 editingAlbumId = null;
183 * Returns the album element with the given ID.
185 * @param albumId The ID of the album
186 * @return The album element
188 function getAlbum(albumId) {
189 return $("#sone .album .album-id:contains('" + albumId + "')").closest(".album");
195 * @param sourceId The ID of the source album
196 * @param destinationId The ID of the destionation album
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);
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");
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");
220 * Prepare all albums for inline editing.
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");
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);
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 && data.success) {
243 getAlbum(data.albumId).find(".album-title").text(data.title);
244 getAlbum(data.albumId).find(".album-description").text(data.description);
245 getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title);
246 getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description);
247 cancelAlbumEditing();
262 <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
264 <%elseifnull album.title>
266 <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
270 <%if album.sone.local>
271 <script language="javascript">
274 getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) {
275 $("#upload-image :input[name='title']").each(function() {
276 registerInputTextareaSwap(this, text, "title", false, true);
279 getTranslation("WebInterface.DefaultText.UploadImage.Description", function(text) {
280 $("#upload-image :input[name='description']").each(function() {
281 registerInputTextareaSwap(this, text, "description", true, false);
284 $("#upload-image label").hide();
285 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
286 $("#create-album input[name='name']").each(function() {
287 registerInputTextareaSwap(this, text, "name", false, true);
290 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
291 $("#create-album input[name='description']").each(function() {
292 registerInputTextareaSwap(this, text, "description", true, true);
295 $("#create-album label").hide();
296 getTranslation("WebInterface.DefaultText.EditAlbum.Title", function(text) {
297 $("#edit-album input[name='title']").each(function() {
298 registerInputTextareaSwap(this, text, "title", false, true);
301 getTranslation("WebInterface.DefaultText.EditAlbum.Description", function(text) {
302 $("#edit-album :input[name='description']").each(function() {
303 registerInputTextareaSwap(this, text, "description", true, false);
306 $("#edit-album label").hide();
308 /* hide non-js image move buttons. */
309 $(".move-buttons").hide();
311 hideAndShowBlock("div.edit-album", ".show-edit-album", ".hide-edit-album");
312 hideAndShowBlock("div.create-album", ".show-create-album", ".hide-create-album");
313 hideAndShowBlock("div.upload-image", ".show-upload-image", ".hide-upload-image");
314 hideAndShowBlock("div.delete-album", ".show-delete-album", ".hide-delete-album");
322 <h1 class="backlink"><%= Page.ImageBrowser.Album.Title|l10n|replace needle=='{album}' replacement=album.title|html></h1>
324 <div class="backlinks">
325 <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
326 <div class="separator">></div>
327 <%foreach album.backlinks backlink backlinks>
328 <div class="backlink">
329 <a href="<% backlink.target|html>"><% backlink.name|html></a>
331 <%if ! backlinks.last>
332 <div class="separator">></div>
337 <p id="description"><% album.description|parse sone=album.sone></p>
339 <%if album.sone.local>
340 <div class="show-edit-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
341 <div class="hide-edit-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></div>
342 <div class="edit-album">
343 <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
345 <form id="edit-album" action="editAlbum.html" method="post">
346 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
347 <input type="hidden" name="album" value="<%album.id|html>" />
349 <%if ! album.images.empty>
351 <label for="album-image"><%= Page.ImageBrowser.Album.Label.AlbumImage|l10n|html></label>
352 <select name="album-image">
353 <option disabled="disabled"><%= Page.ImageBrowser.Album.AlbumImage.Choose|l10n|html></option>
354 <%foreach album.images image>
355 <option value="<% image.id|html>"<%if album.albumImage.id|match value=image.id> selected="selected"<%/if>><% image.title|html></option>
361 <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
362 <input type="text" name="title" value="<%album.title|html>" />
365 <label for="description"><%= Page.ImageBrowser.Album.Label.Description|l10n|html></label>
366 <textarea name="description"><%album.description|html></textarea>
368 <button type="submit"><%= Page.ImageBrowser.Album.Button.Save|l10n|html></button>
373 <%include include/browseAlbums.html albums=album.albums>
375 <%if album.sone.local>
376 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
377 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
378 <div class="create-album">
379 <%include include/createAlbum.html>
383 <%foreach album.images image|paginate pageSize=core.preferences.imagesPerPage page=page>
385 <h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2>
386 <%include include/pagination.html pageParameter=="page">
388 <%if loop.count|mod divisor==3><div class="image-row"><%/if>
389 <div id="image-<% image.id|html>" class="image">
390 <div class="image-id hidden"><% image.id|html></div>
391 <div class="image-container">
392 <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width==250 max-height==250 mode==enlarge title=image.title></a>
394 <div class="show-data">
395 <div class="image-title"><% image.title|html></div>
396 <div class="image-description"><% image.description|parse sone=image.sone></div>
398 <%if album.sone.local>
399 <form class="edit-image" action="editImage.html" method="post">
400 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
401 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
402 <input type="hidden" name="image" value="<%image.id|html>" />
404 <div class="move-buttons">
405 <button <%first>class="hidden" <%/first>type="submit" name="moveLeft" value="true"><%= Page.ImageBrowser.Image.Button.MoveLeft|l10n|html></button>
406 <button <%last>class="hidden" <%/last>type="submit" name="moveRight" value="true"><%= Page.ImageBrowser.Image.Button.MoveRight|l10n|html></button>
409 <div class="edit-data hidden">
411 <input type="text" name="title" value="<%image.title|html>" />
414 <textarea name="description"><%image.description|html></textarea>
417 <button <%first>class="hidden" <%/first>type="submit" name="moveLeft" value="true"><%= Page.ImageBrowser.Image.Button.MoveLeft|l10n|html></button>
418 <button type="submit" name="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
419 <button <%last>class="hidden" <%/last>type="submit" name="moveRight" value="true"><%= Page.ImageBrowser.Image.Button.MoveRight|l10n|html></button>
425 <%= false|store key==endRow>
426 <%if loop.count|mod divisor==3 offset==1><%= true|store key==endRow><%/if>
427 <%last><%= true|store key==endRow><%/last>
431 <%last><%include include/pagination.html pageParameter=="page"><%/last>
434 <%if album.sone.local>
435 <div class="clear show-upload-image hidden toggle-link"><a class="small-link">» <%= View.UploadImage.Title|l10n|html></a></div>
436 <div class="clear hide-upload-image hidden toggle-link"><a class="small-link">« <%= View.UploadImage.Title|l10n|html></a></div>
437 <div class="upload-image">
438 <%include include/uploadImage.html>
442 <div class="show-delete-album hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
443 <div class="hide-delete-album hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Album.Delete.Title|l10n|html></a></div>
444 <div class="delete-album">
445 <form id="delete-album" action="deleteAlbum.html" method="get">
446 <input type="hidden" name="album" value="<%album.id|html>" />
447 <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
456 <%elseif imageRequested>
458 <h1 class="backlink"><%image.title|html></h1>
460 <div class="backlinks">
461 <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
462 <div class="separator">></div>
463 <%foreach image.album.backlinks backlink backlinks>
464 <div class="backlink">
465 <a href="<% backlink.target|html>"><% backlink.name|html></a>
467 <%if ! backlinks.last>
468 <div class="separator">></div>
471 <%ifnull !image.previous><div class="backlink"><a href="imageBrowser.html?image=<%image.previous.id|html>">« <%image.previous.title|html></a></div><%/if>
472 <%ifnull !image.next><div class="backlink"><a href="imageBrowser.html?image=<%image.next.id|html>">» <%image.next.title|html></a></div><%/if>
479 <%if image.sone.local>
480 <script language="javascript">
482 getTranslation("WebInterface.DefaultText.EditImage.Title", function(text) {
483 $("#edit-image input[name='title']").each(function() {
484 registerInputTextareaSwap(this, text, "title", false, true);
487 getTranslation("WebInterface.DefaultText.EditImage.Description", function(text) {
488 $("#edit-image :input[name='description']").each(function() {
489 registerInputTextareaSwap(this, text, "description", true, false);
492 $("#edit-image label").hide();
494 hideAndShowBlock(".edit-image", ".show-edit-image", ".hide-edit-image");
495 hideAndShowBlock(".delete-image", ".show-delete-image", ".hide-delete-image");
500 <div class="single-image">
502 <a href="/<%image.key|html>"><% image|image-link max-width==640 max-height==480></a>
504 <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width==640 max-height==480></a>
508 <p class="parsed"><%image.description|parse sone=image.sone></p>
510 <%if image.sone.local>
512 <div class="show-edit-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
513 <div class="hide-edit-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></div>
514 <div class="edit-image">
515 <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
517 <form id="edit-image" action="editImage.html" method="post">
518 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
519 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
520 <input type="hidden" name="image" value="<%image.id|html>" />
523 <label for="title"><%= Page.ImageBrowser.Image.Title.Label|l10n|html></label>
524 <input type="text" name="title" value="<%image.title|html>" />
527 <label for="description"><%= Page.ImageBrowser.Image.Description.Label|l10n|html></label>
528 <textarea name="description"><%image.description|html></textarea>
531 <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
536 <div class="show-delete-image hidden toggle-link"><a class="small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
537 <div class="hide-delete-image hidden toggle-link"><a class="small-link">« <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></div>
538 <div class="delete-image">
539 <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
541 <form id="delete-image" action="deleteImage.html" method="get">
542 <input type="hidden" name="image" value="<%image.id|html>" />
543 <button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
551 <%elseif soneRequested>
554 <script language="javascript">
556 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
557 $("#create-album input[name='name']").each(function() {
558 registerInputTextareaSwap(this, text, "name", false, true);
561 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
562 $("#create-album input[name='description']").each(function() {
563 registerInputTextareaSwap(this, text, "description", true, true);
566 $("#create-album label").hide();
568 /* hide non-js move buttons. */
569 $(".move-buttons").hide();
571 hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album");
580 <p><%= Page.ImageBrowser.Sone.Error.NotFound.Text|l10n|html></p>
584 <h1><%= Page.ImageBrowser.Sone.Title|l10n|replace needle=='{sone}' replacement=sone.niceName|html></h1>
586 <div class="backlinks">
587 <div class="backlink"><a href="imageBrowser.html?mode=gallery"><%= Page.ImageBrowser.Link.All|l10n|html></a></div>
588 <div class="separator">></div>
589 <div class="backlink"><a href="imageBrowser.html?sone=<%sone.id|html>"><%sone.niceName|html></a></div>
592 <%include include/browseAlbums.html albums=sone.rootAlbum.albums>
595 <div class="show-create-album hidden toggle-link"><a class="small-link">» <%= View.CreateAlbum.Title|l10n|html></a></div>
596 <div class="hide-create-album hidden toggle-link"><a class="small-link">« <%= View.CreateAlbum.Title|l10n|html></a></div>
597 <div class="create-album">
598 <%include include/createAlbum.html>
604 <%elseif galleryRequested>
606 <%foreach albums album|paginate pageSize=core.preferences.imagesPerPage pageParameter=request.page pagination=albumPagination>
608 <h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2>
609 <%include include/pagination.html pagination=albumPagination pageParameter=="page">
611 <%if loop.count|mod divisor==3><div class="album-row"><%/if>
612 <div id="album-<% album.id|html>" class="album">
613 <div class="album-id hidden"><% album.id|html></div>
614 <div class="album-container">
615 <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
616 <%ifnull album.albumImage>
617 <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;" />
619 <% album.albumImage|image-link max-width==250 max-height==250 mode==enlarge title=album.title>
623 <div class="show-data">
624 <div class="album-sone"><a href="imageBrowser.html?sone=<%album.sone.id|html>"><%album.sone.niceName|html></a></div>
625 <div class="album-title"><% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)</div>
626 <div class="album-description"><% album.description|parse sone=album.sone></div>
629 <%= false|store key==endRow>
630 <%if loop.count|mod divisor==3 offset==1><%= true|store key==endRow><%/if>
631 <%last><%= true|store key==endRow><%/last>
636 <%include include/pagination.html pagination=albumPagination pageParameter=="page">
642 <%include include/tail.html>