From: David ‘Bombe’ Roden Date: Fri, 31 Jul 2015 17:14:25 +0000 (+0200) Subject: Remove currently unused javascript X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=23f50fca8e95f5ea7b82aaf114b9c4ad3dcb83da;p=Sone.git Remove currently unused javascript --- diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 3a720b6..c49cead 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -20,43 +20,6 @@ }); } - /* ID of the image currently being edited. */ - var editingImageId = null; - - /** - * Shows the form for editing an image. - * - * @param imageId The ID of the image to edit. - */ - function editImage(imageId) { - if (editingImageId != imageId) { - cancelImageEditing(); - } else { - return; - } - editingImageId = imageId; - $(".show-data", getImage(imageId)).hide(); - $(".edit-data", getImage(imageId)).show(); - $(document).bind("click.sone", function(event) { - if ($(event.target).closest("#image-" + imageId).size() == 0) { - cancelImageEditing(); - } - }); - } - - /** - * Cancels all image editing. - */ - function cancelImageEditing() { - $(".image .show-data").show(); - $(".image .edit-data").hide(); - $("form.edit-image").each(function() { - this.reset(); - }); - $(document).unbind("click.sone"); - editingImageId = null; - } - /** * Returns the image element with the given ID. * @@ -64,7 +27,7 @@ * @return The image element */ function getImage(imageId) { - return $("#sone .image .image-id:contains('" + imageId + "')").closest(".image"); + return $("#sone .image-in-album .image-id:contains('" + imageId + "')").closest(".image-in-album"); } /** @@ -99,11 +62,8 @@ */ function prepareImages() { $(".image").each(function() { - imageId = $(this).closest(".image").find(".image-id").text(); + imageId = $(this).closest(".image-in-album").find(".image-id").text(); (function(element, imageId) { - $(".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) { @@ -112,73 +72,10 @@ }); 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) { - 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.attr("defaultValue", data.title); - imageDescriptionInput.attr("defaultValue", data.description); - cancelImageEditing(); - } else if (data && !data.success) { - imageTitleInput.attr("value", imageTitleInput.attr("defaultValue")); - imageDescriptionInput.attr("value", imageDescriptionInput.attr("defaultValue")); - cancelImageEditing(); - } - }); - return false; - }); })(this, imageId); }); } - /* ID of the album currently being edited. */ - var editingAlbumId = null; - - /** - * Shows the form for editing an album. - * - * @param albumId The ID of the album to edit. - */ - function editAlbum(albumId) { - if (editingAlbumId != albumId) { - if (editingAlbumId != null) { - cancelAlbumEditing(); - } - } else { - console.log("already editing " + albumId); - return; - } - editingAlbumId = albumId; - $(".show-data", getAlbum(albumId)).hide(); - $(".edit-data", getAlbum(albumId)).show(); - console.log(getAlbum(albumId)); - $(document).bind("click.sone", function(event) { - if ($(event.target).closest("#album-" + albumId).size() == 0) { - cancelAlbumEditing(); - } - }); - } - - /** - * Cancels all album editing. - */ - function cancelAlbumEditing() { - console.log("cancel-album-edit"); - $(".album .show-data").show(); - $(".album .edit-data").hide(); - $("form.edit-album").each(function() { - this.reset(); - }); - $(document).unbind("click.sone"); - editingAlbumId = null; - } - /** * Returns the album element with the given ID. * @@ -223,10 +120,6 @@ $(".album").each(function() { albumId = $(this).closest(".album").find(".album-id").text(); (function(element, albumId) { - $(".show-data", element).click(function() { - console.log("show-data"); - 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) { if (data && data.success) { @@ -235,27 +128,6 @@ }); 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("editAlbum.ajax", { "formPassword": getFormPassword(), "album": albumId, "title": title, "description": description }, function(data) { - 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.html(data.description); - getAlbum(data.albumId).find(":input[name='title']").attr("defaultValue", title); - getAlbum(data.albumId).find(":input[name='description']").attr("defaultValue", description); - } else { - albumTitleField.attr("value", albumTitleField.attr("defaultValue")); - albumDescriptionField.attr("value", albumDescriptionField.attr("defaultValue")); - } - cancelAlbumEditing(); - } - }); - return false; - }); })(this, albumId); }); } @@ -567,9 +439,6 @@ }); $("#create-album label").hide(); - /* hide non-js move buttons. */ - $(".move-buttons").hide(); - hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album"); prepareAlbums();