X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Ftemplates%2FimageBrowser.html;h=c705a2ceac437a3927c54b458b1391992f6b11f2;hb=e5e67f4536966700d9a5e3120ca70fd3d4a4867d;hp=58ed8ab8c037f708bc20816565b7622a10e9796f;hpb=7d5aff5d52afa5d9725ce252c846b1aca6f1a761;p=Sone.git diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 58ed8ab..c705a2c 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"); } /** @@ -98,12 +61,9 @@ * Prepare all images for inline editing. */ function prepareImages() { - $(".image").each(function() { - imageId = $(this).closest(".image").find(".image-id").text(); + $(".image-in-album").each(function() { + 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,66 +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) { - 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); - 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. * @@ -216,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) { @@ -228,20 +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 && 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(); - } - }); - return false; - }); })(this, albumId); }); } @@ -298,9 +184,6 @@ }); $("#edit-album label").hide(); - /* hide non-js image move buttons. */ - $(".move-buttons").hide(); - hideAndShowBlock("div.edit-album", ".show-edit-album", ".hide-edit-album"); hideAndShowBlock("div.create-album", ".show-create-album", ".hide-create-album"); hideAndShowBlock("div.upload-image", ".show-upload-image", ".hide-upload-image"); @@ -312,7 +195,7 @@ <%/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>

-

<% album.description|parse sone=album.sone>

+

<% album.description|parse sone=album.sone|render>

<%if album.sone.local> @@ -345,7 +228,7 @@ @@ -373,54 +256,29 @@ <%/if> - <%foreach album.images image> - <%first>

<%= Page.ImageBrowser.Header.Images|l10n|html>

<%/first> - <%if loop.count|mod divisor=3>
<%/if> -
- - -
-
<% image.title|html>
-
<% image.description|parse sone=image.sone>
+ <%foreach album.images image|paginate pageSize=core.preferences.imagesPerPage page=page> + <%first> +

<%= Page.ImageBrowser.Header.Images|l10n|html>

+ <%include include/pagination.html pageParameter=="page"> +
+ <%/first> + <%if loop.even>
<%/if> +
+ + <%include include/viewImage.html> +
+ <%= false|store key==endRow> + <%if loop.odd><%= true|store key==endRow><%/if> + <%last><%= true|store key==endRow><%/last> + <%if endRow>
- <%if album.sone.local> -
- - - - -
- - -
- - -
- <%/if> -
- <%= false|store key=endRow> - <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if> - <%last><%= true|store key=endRow><%/last> - <%if endRow>
<%/if> + <%/if> + <%last>
<%include include/pagination.html pageParameter=="page"><%/last> <%/foreach> <%if album.sone.local> - - + +
<%include include/uploadImage.html>
@@ -486,13 +344,13 @@
<%ifnull !image.key> - <% image|image-link max-width=640 max-height=480> + <% image|image-link max-width==640 max-height==480> <%else> - <% image|image-link max-width=640 max-height=480> + <% image|image-link max-width==640 max-height==480> <%/if>
-

<%image.description|parse sone=image.sone>

+

<%image.description|parse sone=image.sone|render>

<%if image.sone.local> @@ -552,9 +410,6 @@ }); $("#create-album label").hide(); - /* hide non-js move buttons. */ - $(".move-buttons").hide(); - hideAndShowBlock(".create-album", ".show-create-album", ".hide-create-album"); prepareAlbums(); @@ -568,15 +423,15 @@ <%else> -

<%= Page.ImageBrowser.Sone.Title|l10n|replace needle='{sone}' replacementKey=sone.niceName|html>

+

<%= Page.ImageBrowser.Sone.Title|l10n|replace needle=='{sone}' replacement=sone.niceName|html>

- <%include include/browseAlbums.html albums=sone.albums> + <%include include/browseAlbums.html albums=sone.rootAlbum.albums> <%if sone.local> @@ -590,30 +445,25 @@ <%elseif galleryRequested> - <%foreach albums album> - <%first>

<%= Page.ImageBrowser.Header.Albums|l10n|html>

<%/first> - <%if loop.count|mod divisor=3>
<%/if> + <%foreach albums album|paginate pageSize=core.preferences.imagesPerPage pageParameter=request.page pagination=albumPagination> + <%first> +

<%= Page.ImageBrowser.Header.Albums|l10n|html>

+ <%include include/pagination.html pagination=albumPagination pageParameter=="page"> +
+ <%/first> + <%if loop.even>
<%/if>
- -
- -
<% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)
-
<% album.description|parse sone=album.sone>
-
+ <%include include/viewAlbum.html>
- <%= false|store key=endRow> - <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if> - <%last><%= true|store key=endRow><%/last> + <%= false|store key==endRow> + <%if loop.odd><%= true|store key==endRow><%/if> + <%last><%= true|store key==endRow><%/last> <%if endRow>
<%/if> + <%last> +
+ <%include include/pagination.html pagination=albumPagination pageParameter=="page"> + <%/last> <%/foreach> <%/if>