From e4792c42b4180d3779bf7d75c7e5ee6f41001d85 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 13 Mar 2012 23:40:16 +0100 Subject: Make playlist sortable. --- static/init.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'static') diff --git a/static/init.js b/static/init.js index 6102e29..6a37be5 100644 --- a/static/init.js +++ b/static/init.js @@ -90,4 +90,17 @@ $(document).ready(function() { preload_images(); load_directory(0); $('#progress').slider(); + $('#playlist tbody').sortable({ + items: 'tr:not(.playing)', + cancel: '.playing', + update: function() { + $('#playlist tbody tr').each(function(i, tr) { + var cid = $(tr).attr('id').match(/^cid-(c\d+)$/)[1]; + var model = items.getByCid(cid); + model.attributes.order_id = i+1; + model.save(); + }); + items.sort({silent: true}); + } + }); }); -- cgit v1.2.3