summaryrefslogtreecommitdiffstats
path: root/htdocs/js
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2009-02-08 21:40:17 +1100
committerJeremy Kerr <jk@ozlabs.org>2009-02-08 21:44:25 +1100
commit6ce62d26739ebf0dd81ecff5284adf3fbe2aed23 (patch)
tree1bd8034844b48ef8c91f232de7000ff12450a06d /htdocs/js
parent6cf8d6e128b9117f10431eb9b534e9c8b1024cdf (diff)
downloadpatchwork-6ce62d26739ebf0dd81ecff5284adf3fbe2aed23.tar.bz2
patchwork-6ce62d26739ebf0dd81ecff5284adf3fbe2aed23.tar.xz
Bundle reordering support
Bundles can now be reordered and saved. Add dependency on jquery in INSTALL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'htdocs/js')
-rw-r--r--htdocs/js/bundle.js99
l---------htdocs/js/jquery-1.2.6.js1
2 files changed, 70 insertions, 30 deletions
diff --git a/htdocs/js/bundle.js b/htdocs/js/bundle.js
index dc4fb9c..0bdf41a 100644
--- a/htdocs/js/bundle.js
+++ b/htdocs/js/bundle.js
@@ -1,41 +1,82 @@
-function parse_patch_id(id_str)
+
+var editing_order = false;
+var dragging = false;
+
+function order_button_click(node)
{
- var i;
+ var rows, form;
- i = id_str.indexOf(':');
- if (i == -1)
- return null;
+ form = $("#reorderform");
+ rows = $("#patchlist").get(0).tBodies[0].rows;
- return id_str.substring(i + 1);
-}
+ if (rows.length < 1)
+ return;
-function bundle_handle_drop(table, row)
-{
- var relative, relation, current;
- var relative_id, current_id;
+ if (editing_order) {
- current = $(row);
- relative = $(current).prev();
- relation = 'after';
+ /* disable the save button */
+ node.disabled = true;
- /* if we have no previous row, position ourselves before the next
- * row instead */
- if (!relative.length) {
- relative = current.next();
- relation = 'before';
+ /* add input elements as the sequence of patches */
+ for (var i = 0; i < rows.length; i++) {
+ form.append('<input type="hidden" name="neworder" value="' +
+ row_to_patch_id(rows[i]) + '"/>');
+ }
- if (!relative)
- return;
+ form.get(0).submit();
+ } else {
+
+ /* store the first order value */
+ start_order = row_to_patch_id(rows[0]);
+ $("input[name='order_start']").attr("value", start_order);
+
+ /* update buttons */
+ node.setAttribute("value", "Save order");
+ $("#reorder\\-cancel").css("display", "inline");
+
+ /* show help text */
+ $("#reorderhelp").text('Drag & drop rows to reorder');
+
+ /* enable drag & drop on the patches list */
+ $("#patchlist").tableDnD({
+ onDragClass: 'dragging',
+ onDragStart: function() { dragging = true; },
+ onDrop: function() { dragging = false; }
+ });
+
+ /* replace zebra striping with hover */
+ $("#patchlist tbody tr").css("background", "inherit");
+ $("#patchlist tbody tr").hover(drag_hover_in, drag_hover_out);
}
- current_id = parse_patch_id(current.attr('id'));
- relative_id = parse_patch_id(relative.attr('id'));
+ editing_order = !editing_order;
+}
- alert("put patch " + current_id + " " + relation + " " + relative_id);
+function order_cancel_click(node)
+{
+ node.form.submit();
}
-$(document).ready(function() {
- $("#patchlist").tableDnD({
- onDrop: bundle_handle_drop
- });
-});
+/* dragging helper functions */
+function drag_hover_in()
+{
+ if (!dragging)
+ $(this).addClass("draghover");
+}
+function drag_hover_out()
+{
+ $(this).removeClass("draghover");
+}
+
+function row_to_patch_id(node)
+{
+ var id_str, i;
+
+ id_str = node.getAttribute("id");
+
+ i = id_str.indexOf(':');
+ if (i == -1)
+ return null;
+
+ return id_str.substring(i + 1);
+}
diff --git a/htdocs/js/jquery-1.2.6.js b/htdocs/js/jquery-1.2.6.js
deleted file mode 120000
index cb24de6..0000000
--- a/htdocs/js/jquery-1.2.6.js
+++ /dev/null
@@ -1 +0,0 @@
-../../lib/packages/jquery/jquery-1.2.6.js \ No newline at end of file