X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Ftemplates%2FimageBrowser.html;h=c705a2ceac437a3927c54b458b1391992f6b11f2;hb=e5e67f4536966700d9a5e3120ca70fd3d4a4867d;hp=72fd3406a9d7aa1f84687c921cbf7b271bfa45f3;hpb=4345bd3c2e5997193d4df442db464b8775d8de66;p=Sone.git diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 72fd340..c705a2c 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -1,25 +1,138 @@ <%include include/head.html> + + + /** + * 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-in-album .image-id:contains('" + imageId + "')").closest(".image-in-album"); + } - + /** + * 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"); + } + } + + /** + * Prepare all images for inline editing. + */ + function prepareImages() { + $(".image-in-album").each(function() { + imageId = $(this).closest(".image-in-album").find(".image-id").text(); + (function(element, 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; + }); + })(this, imageId); + }); + } + + /** + * Returns the album element with the given ID. + * + * @param albumId The ID of the album + * @return The album element + */ + function getAlbum(albumId) { + return $("#sone .album .album-id:contains('" + albumId + "')").closest(".album"); + } + + /** + * Swaps two albums. + * + * @param sourceId The ID of the source album + * @param destinationId The ID of the destionation album + */ + function swapAlbum(sourceId, destinationId) { + sourceElement = getAlbum(sourceId); + destinationElement = getAlbum(destinationId); + sourceParent = sourceElement.closest(".album-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"); + } + } + + /** + * Prepare all albums for inline editing. + */ + function prepareAlbums() { + $(".album").each(function() { + albumId = $(this).closest(".album").find(".album-id").text(); + (function(element, albumId) { + $("button[name='moveLeft'], button[name='moveRight']", element).click(function() { + ajaxGet("editAlbum.ajax", { "formPassword": getFormPassword(), "album": albumId, "moveLeft": this.name == "moveLeft", "moveRight": this.name == "moveRight" }, function(data) { + if (data && data.success) { + swapAlbum(data.sourceAlbumId, data.destinationAlbumId); + } + }); + return false; + }); + })(this, albumId); + }); + } + + <%if albumRequested> @@ -33,9 +146,60 @@ <%else> -

<%= Page.ImageBrowser.Album.Title|l10n|replace needle='{album}' replacementKey=album.title|html>

+ <%if album.sone.local> + + <%/if> + +

<%= Page.ImageBrowser.Album.Title|l10n|replace needle=='{album}' replacement=album.title|html>