From be6afad731b965a75d9fe0b254ea72858a4deec4 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 1 Dec 2015 12:08:10 +0100 Subject: fixes #377 use Ajax calls to refresh/delete album thumbnail --- admin/themes/default/template/cat_modify.tpl | 78 +++++++++++++++++++++++++--- admin/themes/default/theme.css | 7 ++- 2 files changed, 76 insertions(+), 9 deletions(-) (limited to 'admin/themes') diff --git a/admin/themes/default/template/cat_modify.tpl b/admin/themes/default/template/cat_modify.tpl index d71ad0528..af1fb5792 100644 --- a/admin/themes/default/template/cat_modify.tpl +++ b/admin/themes/default/template/cat_modify.tpl @@ -28,6 +28,67 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), { return filtered; } }); + +jQuery(document).ready(function() { + jQuery(document).on('click', '.refreshRepresentative', function(e) { + var $this = jQuery(this); + var method = 'pwg.categories.refreshRepresentative'; + + jQuery.ajax({ + url: "ws.php?format=json&method="+method, + type:"POST", + data: { + category_id: $this.data("category_id") + }, + success:function(data) { + var data = jQuery.parseJSON(data); + if (data.stat == 'ok') { + jQuery(".albumThumbnailImage").attr('href', data.result.url); + jQuery(".albumThumbnailImage img").attr('src', data.result.src); + jQuery(".albumThumbnailImage").show(); + jQuery(".albumThumbnailRandom").hide(); + } + else { + alert("error on "+method); + } + }, + error:function(XMLHttpRequest, textStatus, errorThrows) { + alert("serious error on "+method); + } + }); + + e.preventDefault(); + }); + + jQuery(document).on('click', '.deleteRepresentative', function(e) { + var $this = jQuery(this); + var method = 'pwg.categories.deleteRepresentative'; + + jQuery.ajax({ + url: "ws.php?format=json&method="+method, + type:"POST", + data: { + category_id: $this.data("category_id") + }, + success:function(data) { + var data = jQuery.parseJSON(data); + if (data.stat == 'ok') { + jQuery(".albumThumbnailImage").hide(); + jQuery(".albumThumbnailRandom").show(); + } + else { + alert("error on "+method); + } + }, + error:function(XMLHttpRequest, textStatus, errorThrows) { + alert("serious error on "+method); + } + }); + + e.preventDefault(); + }); +}); + {/footer_script} @@ -35,7 +96,7 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), {

{$CATEGORIES_NAV} › {'Edit album'|@translate} {$TABSHEET_TITLE}

-
+
{'Informations'|@translate} @@ -44,19 +105,18 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), { {if isset($representant) } - {if isset($representant.picture) } - - {else} - {'Random photo'|@translate} - {/if} + + {'Random photo'|@translate} +

{if $representant.ALLOW_SET_RANDOM } -

+ {'Refresh'|@translate} {/if} {if isset($representant.ALLOW_DELETE) } -

+ | {'Delete'|translate} {/if} +

{/if} @@ -90,6 +150,7 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
+
{'Properties'|@translate}

@@ -137,3 +198,4 @@ categoriesCache.selectize(jQuery('[data-selectize=categories]'), {

+
{* #catModify *} \ No newline at end of file diff --git a/admin/themes/default/theme.css b/admin/themes/default/theme.css index 4a151b9a4..509aff377 100644 --- a/admin/themes/default/theme.css +++ b/admin/themes/default/theme.css @@ -213,7 +213,7 @@ LI.menuLi { } /* */ -FORM#catModify TABLE { width: auto; } +#catModify TABLE { width: auto; } #catModify p { line-height: 20px; @@ -221,6 +221,11 @@ FORM#catModify TABLE { width: auto; } text-align: left; } +#catModify p.albumThumbnailActions { + text-align:center; + white-space:nowrap; +} + FIELDSET.elementEdit .thumb { display: block; float: right; -- cgit v1.2.3