X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Ftemplates%2FimageBrowser.html;h=7b24018f5b1ffd7c61aa063d75f317ad31bc6597;hb=16bebcb43fb56df0ae5d7f206f9fb4032d145fc0;hp=755c43147523e21830d46e875fd7e6c36cf8c9a8;hpb=03a7fb4f25191e6bcb64bc953572aaf7f5958b19;p=Sone.git diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 755c431..7b24018 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -29,7 +29,7 @@ * @param imageId The ID of the image to edit. */ function editImage(imageId) { - if (editingImageId != imageId) { + if (editingImageId !== imageId) { cancelImageEditing(); } else { return; @@ -38,7 +38,7 @@ $(".show-data", getImage(imageId)).hide(); $(".edit-data", getImage(imageId)).show(); $(document).bind("click.sone", function(event) { - if ($(event.target).closest("#image-" + imageId).size() == 0) { + if ($(event.target).closest("#image-" + imageId).size() === 0) { cancelImageEditing(); } }); @@ -80,15 +80,15 @@ sourcePrevSibling = sourceElement.prev(); sourceElement.detach(); destinationElement.before(sourceElement); - if (sourcePrevSibling.get(0) != destinationElement.get(0)) { + 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")) { + 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")) { + 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"); } @@ -105,7 +105,7 @@ 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) { + 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); } @@ -116,13 +116,20 @@ 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").html(data.parsedDescription); - getImage(data.imageId).find(":input[name='title']").attr("defaultValue", title); - getImage(data.imageId).find(":input[name='description']").attr("defaultValue", data.description); + var imageElement = getImage(data.imageId); + var imageTitleInput = imageElement.find(":input[name='title']"); + var imageDescriptionInput = imageElement.find(":input[name='description']"); + if (data && data.success) { + imageElement.find(".image-title").text(data.title); + imageElement.find(".image-description").html(data.parsedDescription); + imageTitleInput.prop("defaultValue", data.title); + imageDescriptionInput.prop("defaultValue", data.description); cancelImageEditing(); - } + } else if (data && !data.success) { + imageTitleInput.prop("value", imageTitleInput.prop("defaultValue")); + imageDescriptionInput.prop("value", imageDescriptionInput.prop("defaultValue")); + cancelImageEditing(); + } }); return false; }); @@ -139,7 +146,7 @@ * @param albumId The ID of the album to edit. */ function editAlbum(albumId) { - if (editingAlbumId != albumId) { + if (editingAlbumId !== albumId) { if (editingAlbumId != null) { cancelAlbumEditing(); } @@ -152,7 +159,7 @@ $(".edit-data", getAlbum(albumId)).show(); console.log(getAlbum(albumId)); $(document).bind("click.sone", function(event) { - if ($(event.target).closest("#album-" + albumId).size() == 0) { + if ($(event.target).closest("#album-" + albumId).size() === 0) { cancelAlbumEditing(); } }); @@ -195,15 +202,15 @@ sourcePrevSibling = sourceElement.prev(); sourceElement.detach(); destinationElement.before(sourceElement); - if (sourcePrevSibling.get(0) != destinationElement.get(0)) { + 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")) { + 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")) { + 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"); } @@ -221,7 +228,7 @@ editAlbum(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) { + 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); } @@ -232,13 +239,20 @@ title = $(":input[name='title']:enabled", this.form).val(); description = $(":input[name='description']:enabled", this.form).val(); ajaxGet("editAlbum.ajax", { "formPassword": getFormPassword(), "album": albumId, "title": title, "description": description }, function(data) { - if (data && data.success) { - getAlbum(data.albumId).find(".album-title").text(data.title); - getAlbum(data.albumId).find(".album-description").text(data.description); - getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title); - getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description); - cancelAlbumEditing(); - } + if (data) { + var albumTitleField = getAlbum(data.albumId).find(".album-title"); + var albumDescriptionField = getAlbum(data.albumId).find(".album-description"); + if (data.success) { + albumTitleField.text(data.title); + albumDescriptionField.text(data.description); + getAlbum(data.albumId).find(":input[name='title']").prop("defaultValue", title); + getAlbum(data.albumId).find(":input[name='description']").prop("defaultValue", description); + } else { + albumTitleField.prop("value", albumTitleField.prop("defaultValue")); + albumDescriptionField.prop("value", albumDescriptionField.prop("defaultValue")); + } + cancelAlbumEditing(); + } }); return false; }); @@ -312,9 +326,11 @@ <%/if> -

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

+

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