From d59e2485b0e4e6dbf0f464538467354e12861ad1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 11 Jun 2020 11:45:42 +0200 Subject: [PATCH] import custom panik gallery template & script --- panikweb_templates/static/js/combo.gallery.js | 29 +++++++++++++++ .../templates/combo/gallery.html | 36 ++++++++++--------- 2 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 panikweb_templates/static/js/combo.gallery.js diff --git a/panikweb_templates/static/js/combo.gallery.js b/panikweb_templates/static/js/combo.gallery.js new file mode 100644 index 0000000..a91e714 --- /dev/null +++ b/panikweb_templates/static/js/combo.gallery.js @@ -0,0 +1,29 @@ +function gallery(element) { + var element_id = '#' + $(element).attr('id'); + $(element).sortable({ + items: '> li', + containment: 'parent', + placeholder: 'empty-image', + update: function(event, ui) { + var new_order = $(element).find('> li').map(function() { return $(this).data('object-id'); }).get().join(); + $.ajax({ + url: $(element).data('order-url'), + data: {'new-order': new_order}, + success: function(data, status) { + $(element).replaceWith($(data).find(element_id)); + gallery($(element_id)); + } + }); + } + }); + $('.image-delete').on('click', function() { + $.ajax({ + url: $(this).attr('href'), + success: function(data, status) { + $(element).replaceWith($(data).find(element_id)); + gallery($(element_id)); + } + }); + return false; + }); +}; diff --git a/panikweb_templates/templates/combo/gallery.html b/panikweb_templates/templates/combo/gallery.html index 49451a9..6be3c9f 100644 --- a/panikweb_templates/templates/combo/gallery.html +++ b/panikweb_templates/templates/combo/gallery.html @@ -1,28 +1,32 @@ {% load thumbnail %} -{% if cell.title %}

{{ cell.title }}

{% endif %}