src/hg/js/hgTracks.js 1.29

1.29 2009/06/27 20:10:53 tdreszer
Tweeks to get post on click to work in IE
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.28
retrieving revision 1.29
diff -b -B -U 4 -r1.28 -r1.29
--- src/hg/js/hgTracks.js	26 Jun 2009 23:35:15 -0000	1.28
+++ src/hg/js/hgTracks.js	27 Jun 2009 20:10:53 -0000	1.29
@@ -237,17 +237,34 @@
     });
     return false;
 }
 
+function imgTblSetOrder(table)
+{
+// Sets the 'order' value for the image table after a drag reorder
+    $("input[name$='_imgOrd']").each(function (i) {
+        var tr = $(this).parents('tr');
+        if($(this).val() != $(tr).attr('rowIndex')) {
+            //alert('Reordered '+$(this).val() + " to "+$(tr).attr('rowIndex'));
+            $(this).val($(tr).attr('rowIndex'));
+        }
+    });
+}
 $(document).ready(function()
 {
     // Convert map AREA gets to post the form, ensuring that cart variables are kept up to date
     $('a,area').not("[href*='#']").filter("[target='']").click(function(i) {
         if(startDragZoom != null)
             return false;
         var thisForm=$(this).parents('form');
-        if(thisForm != undefined && thisForm.length == 1)
+        if(thisForm == undefined || $(thisForm).length == 0)
+            thisForm=$("FORM");
+        if($(thisForm).length > 1)
+            thisForm=$(thisForm)[0];
+        if(thisForm != undefined && $(thisForm).length == 1) {
+            //alert("posting form:"+$(thisForm).attr('name'));
             return postTheForm($(thisForm).attr('name'),this.href);
+        }
 
         return true;
     });
     if($('#imgTbl').length == 1) {
@@ -255,17 +272,22 @@
         // Make imgTbl allow draw reorder of imgTrack rows
         if($(".tableWithDragAndDrop").length > 0) {
             $(".tableWithDragAndDrop").tableDnD({
                 onDragClass: "trDrag",
-                dragHandle: "dragHandle"
+                dragHandle: "dragHandle",
+                onDrop: function(table, row) {
+                        if(imgTblSetOrder) {
+                            imgTblSetOrder(table);
+                        }
+                    }
                 });
         }
 
         // Turn on drag scrolling.
         //$(".panDivScroller").panImages($(".panDivScroller").width(),0,0);
 
         // Temporary warning while new imageV2 code is being worked through
-        if($('#map').children().length > 0) {
+        if($('#map').children("AREA").length > 0) {
             alert('Using imageV2, but old map is not empty!');
         }
     }
 });