servcomp WIP, get inlines working with drag-sortable
[plstackapi.git] / planetstack / servcomp / static / js / menu-sort-2.js
diff --git a/planetstack/servcomp/static/js/menu-sort-2.js b/planetstack/servcomp/static/js/menu-sort-2.js
new file mode 100644 (file)
index 0000000..d7e3005
--- /dev/null
@@ -0,0 +1,21 @@
+jQuery(function($) {
+    $("div.inline-group").sortable({ 
+        axis: 'y',
+        placeholder: 'ui-state-highlight', 
+        forcePlaceholderSize: 'true', 
+        items: '.row1, .row2', 
+        update: update
+    });
+    $("div.inline-group").disableSelection();
+});
+function update() {
+    $('.row1, .row2').each(function(i) {
+        $(this).find('input[id$=order]').val(i+1);
+    });
+}
+jQuery(document).ready(function($){
+//    $(this).find('input[id$=order]').parent('div').parent('div').hide().parent().parent().css('cursor','move');
+    $(this).find('input[id$=order]').parent('td').hide().parent('tr').parent('tbody').parent('table').find("th:contains('Order')").hide(); 
+    $(this).find('input[id$=order]').parent('td').hide().parent('tr').parent('tbody').parent('table').css('cursor','move');
+    $('.add-row a').click(update);
+});