From ae56066281c8d980615aa7525c468c27dc112a4f Mon Sep 17 00:00:00 2001 From: junior Date: Tue, 15 Feb 2022 21:31:03 +0000 Subject: [PATCH] Allow editing of current album metadata when viewing images in album --- js/scalemodels.js | 18 +++++++++++------- scalemodels.php | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/js/scalemodels.js b/js/scalemodels.js index bbe3a6a..cf87958 100644 --- a/js/scalemodels.js +++ b/js/scalemodels.js @@ -1,6 +1,7 @@ var lightboxImages = []; var editAlbumID = 0; var editImageID = 0; +var currentAlbum = 0; $(document).ready(function() { $("#edit_album").dialog({ @@ -49,6 +50,7 @@ $(document).ready(function() { }); $("#btn_refresh").click(function() { refreshAlbums() }); $("#btn_album_0").click(function() { showAlbum($(this)) }); + $(".albuminfo_label").click(function() { editAlbum(currentAlbum); }); getAlbumInfo(); }); @@ -105,14 +107,14 @@ function getAlbumInfo() { showImage($(this)); } }); + currentAlbum = data.currentalbum; $(".griditem_title").click(function() { if ( data.currentalbum == 0 ) { - editAlbum($(this)); + editAlbum($(this).attr("id").substring($(this).attr("id").lastIndexOf("_") + 1)); } else { - editImage($(this)); + editImage($(this).attr("id").substring($(this).attr("id").lastIndexOf("_") + 1)); } }); - console.log(lightboxImages); }, error: function(jqp, status, error) { toastr.error("Error retrieving album info!\n" + error, "Server Error"); @@ -205,6 +207,10 @@ function saveAlbumInfo() { if ( data.success ) { $("#edit_album").dialog("close"); $("#title_"+data.album.id).text(data.album.title); + if ( currentAlbum != 0 ) { + $("#albumtitle").text(data.album.title); + $("#albumdescription").text(data.album.description); + } } else { toastr.error("Could not get album information!", "Album Data Error"); } @@ -215,8 +221,7 @@ function saveAlbumInfo() { }); } -function editAlbum(clickedElement) { - var albumid = clickedElement.attr("id").substring(clickedElement.attr("id").lastIndexOf("_") + 1); +function editAlbum(albumid) { $.ajax({ type: 'GET', url: 'ajax/getalbum.php', @@ -240,8 +245,7 @@ function editAlbum(clickedElement) { }); } -function editImage(clickedElement) { - var imageid = clickedElement.attr("id").substring(clickedElement.attr("id").lastIndexOf("_") + 1); +function editImage(imageid) { $.ajax({ type: 'GET', url: 'ajax/getimage.php', diff --git a/scalemodels.php b/scalemodels.php index 61ca1d8..9a1f383 100755 --- a/scalemodels.php +++ b/scalemodels.php @@ -14,8 +14,8 @@ if ( $currentuser->isLoggedIn() ) { } ?>