f2466fa926a779364d5d603f8b7680ebe932b0bc
tdreszer
  Thu Nov 18 11:41:57 2010 -0800
Moved rightClick slected vis check icon to front to have text of all options line up
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index afbb922..1256431 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1712,72 +1712,72 @@
 }
 
 function makeImgTag(img)
 {
 // Return img tag with explicit dimensions for img (dimensions are currently hardwired).
 // This fixes the "weird shadow problem when first loading the right-click menu" seen in FireFox 3.X,
 // which occurred b/c FF doesn't actually fetch the image until the menu is being shown.
     return "<img width='16px' height='16px' src='../images/" + img + "' />";
 }
 
 function loadContextMenu(img)
 {
     var menu = img.contextMenu(
         function() {
             var menu = [];
-            var selectedImg = " <img src='../images/greenCheck.png' height='10' width='10' />";
+            var selectedImg = makeImgTag("greenChecksm.png");
+            var blankImg    = makeImgTag("invisible16.png");
             var done = false;
             if(selectedMenuItem && selectedMenuItem.id != null) {
                 var href = selectedMenuItem.href;
                 var isHgc, isGene;
                 if(href) {
                     isGene = href.match("hgGene");
                     isHgc = href.match("hgc");
                 }
                 var id = selectedMenuItem.id;
                 var rec = trackDbJson[id];
                 // XXXX what if select is not available (b/c trackControlsOnMain is off)?
                 // Move functionality to a hidden variable?
                 var select = $("select[name=" + id + "]");
                 var cur = select.val();
                 if(cur) {
                     select.children().each(function(index, o) {
                                                var title = $(this).val();
-                                               var str = title;
-                                               if(title == cur) {
-                                                   str += selectedImg;
-                                               }
+                                               var str =blankImg + " " + title;
+                                               if(title == cur)
+                                                   str = selectedImg + " " + title;
                                                var o = new Object();
                                                o[str] = {onclick: function (menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, title); return true;}};
                                                menu.push(o);
                                            });
                     done = true;
                 } else {
                     if(rec) {
                         // XXXX check current state from a hidden variable.
                         var visibilityStrs = new Array("hide", "dense", "squish", "pack", "full");
                         for (i in visibilityStrs) {
                             // XXXX use maxVisibility and change hgTracks so it can hide subtracks
                             var o = new Object();
-                            var str = visibilityStrs[i];
-                            if(rec.canPack || (str != "pack" && str != "squish")) {
+                            var str = blankImg + " " + visibilityStrs[i];
+                            if(rec.canPack || (visibilityStrs[i] != "pack" && visibilityStrs[i] != "squish")) {
                                 if(rec.localVisibility) {
-                                    if(rec.localVisibility == str) {
-                                        str += selectedImg;
+                                    if(visibilityStrs[i] == rec.localVisibility) {
+                                        str = selectedImg + " " + visibilityStrs[i];
                                     }
-                                } else if(str == visibilityStrsOrder[rec.visibility]) {
-                                    str += selectedImg;
+                                } else if(visibilityStrs[i] == visibilityStrsOrder[rec.visibility]) {
+                                    str = selectedImg + " " + visibilityStrs[i];
                                 }
                                 o[str] = {onclick: makeContextMenuHitCallback(visibilityStrs[i])};
                                 menu.push(o);
                             }
                         }
                         done = true;
                     }
                 }
                 if(done) {
                     var o = new Object();
                     var any = false;
                     if(isGene || isHgc) {
                         var title = selectedMenuItem.title || "feature";
                         o[makeImgTag("magnify.png") + " Zoom to " +  title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "selectWholeGene"); return true; }};
                         o[makeImgTag("dnaIcon.png") + " Get DNA for " +  title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "getDna"); return true; }};
@@ -1829,36 +1829,36 @@
                 }
                 //menu.push({"view image": {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "viewImg"); return true; }}});
             }
 
             if(selectedMenuItem && rec && rec["configureBy"] != 'none') {
                 // Add cfg options at just shy of end...
                 var o = new Object();
                 if(tdbIsLeaf(rec)) {
                     o[makeImgTag("wrench.png") + " Configure " + rec.shortLabel] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_popup"); return true; }};
                     if(rec.parentTrack != undefined)
                         o[makeImgTag("folderWrench.png") + " Configure " + rec.parentLabel + " track set..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_follow"); return true; }};
                 } else
                     o[makeImgTag("folderWrench.png") + " Configure " + rec.shortLabel + " track set..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_follow"); return true; }};
                 menu.push($.contextMenu.separator);
                 menu.push(o);
-                menu.push($.contextMenu.separator);
             }
 
             // Add view image at end
             var o = new Object();
             o[makeImgTag("eye.png") + " View image"] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "viewImg"); return true; }};
+            menu.push($.contextMenu.separator);
             menu.push(o);
 
             return menu;
         },
         {
             beforeShow: function(e) {
                 // console.log(mapItems[selectedMenuItem]);
                 selectedMenuItem = findMapItem(e);
                 // XXXX? blockUseMap = true;
             },
             hideCallback: function() {
                 // this doesn't work
                 warn("hideCallback");
             }
         });