X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Ftemplates%2FimageBrowser.html;h=a4fef7988bb8a86327b0e4abb4eea31f587ce886;hb=eaee6b8f5e18c32388abd6aa33f1d940dc36471f;hp=74dac806886cc49cffbbc9b086fa39da13388c16;hpb=768bbb738423c13854a195dc8dafe64bf4eeba6c;p=Sone.git diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 74dac80..a4fef79 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -75,6 +75,43 @@ editingImageId = null; } + /** + * Returns the image element with the given ID. + * + * @param imageId The ID of the image + * @return The image element + */ + function getImage(imageId) { + return $("#sone .image .image-id:contains('" + imageId + "')").closest(".image"); + } + + /** + * Swaps two images. + * + * @param sourceId The ID of the source image + * @param destinationId The ID of the destionation image + */ + function swapImage(sourceId, destinationId) { + sourceElement = getImage(sourceId); + destinationElement = getImage(destinationId); + sourceParent = sourceElement.closest(".image-row"); + sourcePrevSibling = sourceElement.prev(); + sourceElement.detach(); + destinationElement.before(sourceElement); + if (sourcePrevSibling.get(0) != destinationElement.get(0)) { + destinationElement.detach(); + (sourcePrevSibling.size() > 0) ? sourcePrevSibling.after(destinationElement) : sourceParent.prepend(destinationElement); + } + if ($("button[name='moveLeft']", sourceElement).hasClass("hidden") != $("button[name='moveLeft']", destinationElement).hasClass("hidden")) { + $("button[name='moveLeft']", sourceElement).toggleClass("hidden"); + $("button[name='moveLeft']", destinationElement).toggleClass("hidden"); + } + if ($("button[name='moveRight']", sourceElement).hasClass("hidden") != $("button[name='moveRight']", destinationElement).hasClass("hidden")) { + $("button[name='moveRight']", sourceElement).toggleClass("hidden"); + $("button[name='moveRight']", destinationElement).toggleClass("hidden"); + } + } + $(function() { getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) { $("#upload-image :input[name='title']").each(function() { @@ -121,8 +158,29 @@ $(".show-data", element).click(function() { editImage(imageId); }); + $("button[name='moveLeft'], button[name='moveRight']", element).click(function() { + ajaxGet("editImage.ajax", { "formPassword": getFormPassword(), "image": imageId, "moveLeft": this.name == "moveLeft", "moveRight": this.name == "moveRight" }, function(data) { + if (data && data.success) { + swapImage(data.sourceImageId, data.destinationImageId); + } + }); + return false; + }); + $("button[name='submit']", element).click(function() { + title = $(":input[name='title']:enabled", this.form).val(); + description = $(":input[name='description']:enabled", this.form).val(); + ajaxGet("editImage.ajax", { "formPassword": getFormPassword(), "image": imageId, "title": title, "description": description }, function(data) { + if (data && data.success) { + getImage(data.imageId).find(".image-title").text(data.title); + getImage(data.imageId).find(".image-description").text(data.description); + getImage(data.imageId).find(":input[name='title']").attr("defaultValue", title); + getImage(data.imageId).find(":input[name='description']").attr("defaultValue", description); + cancelEditing(); + } + }); + return false; + }); })(this, imageId); - }); }); }); @@ -184,9 +242,9 @@
<%ifnull album.albumImage> - <% album.title|html> + <% album.title|html> <%else> - <% album.albumImage|image-link max-width=200 max-height=200 mode=enlarge title==album.title> + <% album.albumImage|image-link max-width=250 max-height=250 mode=enlarge title==album.title> <%/if>
@@ -215,7 +273,7 @@
- <% image|image-link max-width=200 max-height=200 mode=enlarge title==image.title> + <% image|image-link max-width=250 max-height=250 mode=enlarge title==image.title>
<% image.title|html>
@@ -235,9 +293,9 @@
- <%notfirst><%/notfirst> - - <%notlast><%/notlast> + + +
@@ -398,9 +456,9 @@
<%ifnull album.albumImage> - <% album.title|html> + <% album.title|html> <%else> - <% album.albumImage|image-link max-width=200 max-height=200 mode=enlarge title==album.title> + <% album.albumImage|image-link max-width=250 max-height=250 mode=enlarge title==album.title> <%/if>