]> git.0d.be Git - panikweb.git/blob - panikweb_templates/static/js/combo.gallery.js
import custom panik gallery template & script
[panikweb.git] / panikweb_templates / static / js / combo.gallery.js
1 function gallery(element) {
2   var element_id = '#' + $(element).attr('id');
3   $(element).sortable({
4     items: '> li',
5     containment: 'parent',
6     placeholder: 'empty-image',
7     update: function(event, ui) {
8       var new_order = $(element).find('> li').map(function() { return $(this).data('object-id'); }).get().join();
9       $.ajax({
10         url: $(element).data('order-url'),
11         data: {'new-order': new_order},
12         success: function(data, status) {
13           $(element).replaceWith($(data).find(element_id));
14           gallery($(element_id));
15         }
16       });
17     }
18   });
19   $('.image-delete').on('click', function() {
20     $.ajax({
21       url: $(this).attr('href'),
22       success: function(data, status) {
23         $(element).replaceWith($(data).find(element_id));
24         gallery($(element_id));
25       }
26     });
27     return false;
28   });
29 };