X-Git-Url: https://git.ozlabs.org/?p=patchwork;a=blobdiff_plain;f=htdocs%2Fjs%2Fbundle.js;fp=htdocs%2Fjs%2Fbundle.js;h=dc4fb9c5958da97b3d1dbfcfba6dee694d624944;hp=0000000000000000000000000000000000000000;hb=c105cb0f107a7459abc8c33988d2da24582a7a5a;hpb=6eb48bb0ca07765185fc21015fe815be18282f07 diff --git a/htdocs/js/bundle.js b/htdocs/js/bundle.js new file mode 100644 index 0000000..dc4fb9c --- /dev/null +++ b/htdocs/js/bundle.js @@ -0,0 +1,41 @@ +function parse_patch_id(id_str) +{ + var i; + + i = id_str.indexOf(':'); + if (i == -1) + return null; + + return id_str.substring(i + 1); +} + +function bundle_handle_drop(table, row) +{ + var relative, relation, current; + var relative_id, current_id; + + current = $(row); + relative = $(current).prev(); + relation = 'after'; + + /* if we have no previous row, position ourselves before the next + * row instead */ + if (!relative.length) { + relative = current.next(); + relation = 'before'; + + if (!relative) + return; + } + + current_id = parse_patch_id(current.attr('id')); + relative_id = parse_patch_id(relative.attr('id')); + + alert("put patch " + current_id + " " + relation + " " + relative_id); +} + +$(document).ready(function() { + $("#patchlist").tableDnD({ + onDrop: bundle_handle_drop + }); +});