]> git.ozlabs.org Git - patchwork/blob - htdocs/js/bundle.js
Initial bundle reordering support
[patchwork] / htdocs / js / bundle.js
1 function parse_patch_id(id_str)
2 {
3     var i;
4
5     i = id_str.indexOf(':');
6     if (i == -1)
7         return null;
8
9     return id_str.substring(i + 1);
10 }
11
12 function bundle_handle_drop(table, row)
13 {
14     var relative, relation, current;
15     var relative_id, current_id;
16
17     current = $(row);
18     relative = $(current).prev();
19     relation = 'after';
20
21     /* if we have no previous row, position ourselves before the next
22      * row instead */
23     if (!relative.length) {
24         relative = current.next();
25         relation = 'before';
26
27         if (!relative)
28             return;
29     }
30
31     current_id = parse_patch_id(current.attr('id'));
32     relative_id = parse_patch_id(relative.attr('id'));
33
34     alert("put patch " + current_id + " " + relation + " " + relative_id);
35 }
36
37 $(document).ready(function() {
38     $("#patchlist").tableDnD({
39         onDrop: bundle_handle_drop
40     });
41 });