src/hg/js/hgTracks.js 1.47

1.47 2009/11/23 07:56:56 larrym
some browser specific changes for right-click code (currently dead code)
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.46
retrieving revision 1.47
diff -b -B -U 4 -r1.46 -r1.47
--- src/hg/js/hgTracks.js	20 Nov 2009 23:36:32 -0000	1.46
+++ src/hg/js/hgTracks.js	23 Nov 2009 07:56:56 -0000	1.47
@@ -12,9 +12,8 @@
 var newWinWidth;
 var imageV2 = false;
 var imgBoxPortal = false;
 var blockUseMap = false;
-var mapHtml;
 var mapItems;
 var trackImg;               // jQuery element for the track image
 var trackImgTbl;            // jQuery element used for image table under imageV2
 var imgAreaSelect;          // jQuery element used for imgAreaSelect
@@ -226,14 +225,14 @@
     loadImgAreaSelect(true);
 
     // Don't load contextMenu if jquery.contextmenu.js hasn't been loaded
     if(trackImg && jQuery.fn.contextMenu) {
+        $('#hgTrackUiDialog').hide();
         if(imageV2) {
             $("map[name!=ideoMap]").each( function(t) { parseMap($(this,false));});
         } else {
             // XXXX still under debate whether we have to remove the map
             parseMap($('#map'),true);
-            mapHtml = $('#map').html();
             $('#map').empty();
         }
 
         originalImgTitle = trackImg.attr("title");
@@ -941,8 +940,9 @@
         // when we have a hit in the left hand elements (which do not have relative coordinates).
         // XXXX still trying to figure this out.
         var pos = $(e.target).position();
         if(e.target.tagName == "IMG") {
+            // msie
             // alert("img: x: " + x + ", y:" + y);
             // alert("pageX: " + e.pageX + "; offsetLeft: " + pos.left);
             x = e.pageX - pos.left;
             y = e.pageY - pos.top;
@@ -961,22 +961,25 @@
     var retval = -1;
     for(var i=0;i<mapItems.length;i++)
     {
         if(mapItems[i].obj && e.target === mapItems[i].obj) {
+            // e.target is AREA tag under FF and Safari;
             // This never occurs under IE
             // console.log("Found match by objects comparison");
             retval = i;
             break;
         } else if (!imageV2 || browser == "msie") {
-            //
+            // Under IE, target is the IMG tag for the map's img and y is relative to the top of that,
+            // so we must use the target's src to make sure we are looking at the right map.
             // We start falling through to here under safari under imageV2 once something has been modified
-            if(mapItems[i].r.contains(x, y)) {
+            // (that's a bug I still haven't figured out how to fix).
+            if(mapItems[i].r.contains(x, y) && mapItems[i].src == $(e.target).attr('src')) {
                 retval = i;
                 break;
             }
         }
     }
-    // showWarning(x + " " + y + " " + retval + " " + $(e.target).attr('src'));
+    // showWarning(x + " " + y + " " + retval + " " + e.target.tagName + " " + $(e.target).attr('src'));
     // console.log("findMapItem:", e.clientX, e.clientY, x, y, pos.left, pos.top, retval, mapItems.length, e.target.tagName);
     // console.log(e.clientX, pos);
     return retval;
 }
@@ -1121,9 +1124,9 @@
             // Safari has the following bug: if we update the local map dynamically, the changes don't get registered (even
             // though if you look in the DOM the changes are there); so we have to do a full form submission when the
             // user changes visibility settings.
             jQuery('body').css('cursor', 'wait');
-            document.TrackForm.submit();
+            document.TrackHeaderForm.submit();
         } else {
             var data = "hgt.trackImgOnly=1&" + id + "=" + cmd + "&hgsid=" + getHgsid();
             if(imageV2) {
 	        data += "&hgt.trackNameFilter=" + id;
@@ -1251,14 +1254,17 @@
             mapItems = new Array();
         }
         if(ele) {
                 var i = mapItems.length;
+                // src is necessary under msie
+                var src = ele.next().attr('src');
                 ele.children().each(function() {
                                       mapItems[i++] = {
                                           r : new Rectangle(this.coords),
                                           href : this.href,
                                           title : this.title,
                                           id : this.id,
+                                          src : src,
                                           obj : this
                                       };
                                   });
     }
@@ -1292,9 +1298,9 @@
                                    cache: true
                                },
                                resizable: true,
                                bgiframe: true,
-                               height: 450,
+                               height: 600,
                                width: 600,
                                modal: true,
                                closeOnEscape: true,
                                autoOpen: false,
@@ -1345,8 +1351,9 @@
                $("map[name!=ideoMap]").each( function(t) { parseMap($(this, false));});
                loadImgAreaSelect(false);
                // Do NOT reload context menu (otherwise we get the "context menu sticks" problem).
                // loadContextMenu($('#tr_' + id));
+               trackImgTbl.tableDnDUpdate();
           } else {
                showWarning("Couldn't parse out new image");
           }
     } else {
@@ -1386,10 +1393,10 @@
 
                        // After much debugging, I found the best way to have imgAreaSelect continue to work
                        // was to reload it:
                        loadImgAreaSelect(false);
-                       // XXX this doesn't work (i.e. does't make the re-sized row draggable).
-                       jQuery.tableDnD.updateTables();
+                       // XXX this doesn't work (i.e. does't make the re-sized row draggable under safari).
+                       trackImgTbl.tableDnD();
                    }
             } else {
                 showWarning("Couldn't parse out new image");
             }