662230aa0e0fdf46f8bb8a990ac99d812dfe9e9b tdreszer Thu Feb 10 11:28:22 2011 -0800 Fixed another of my bugs found be Larry. The popup box is no longer executing close(), so I forced the cleanup before a rightClick diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 61fd5cc..7a6879b 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -1727,49 +1727,53 @@ }; } 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() { + popUpBoxCleanup(); // Popup box is not getting closed properly so must do it here + var menu = []; 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 (select.length > 1) // Not really needed if $('#hgTrackUiDialog').html(""); has worked + select = [ $(select)[0] ]; + var cur = $(select).val(); if(cur) { - select.children().each(function(index, o) { + $(select).children().each(function(index, o) { var title = $(this).val(); 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 @@ -1968,30 +1972,41 @@ data: data, dataType: "html", trueSuccess: handleUpdateTrackMap, success: catchErrorOrDispatch, error: errorHandler, cmd: 'refresh', loadingId: loadingId, id: trackName, cache: false }); } var popUpTrackName = ""; var popUpTrackDescriptionOnly = false; var popSaveAllVars = null; + +function popUpBoxCleanup() +{ // Clean out the popup box on close + if ($('#hgTrackUiDialog').html().length > 0 ) { + $('#hgTrackUiDialog').html(""); // clear out html after close to prevent problems caused by duplicate html elements + popUpTrackName = ""; //set to defaults + popUpTrackDescriptionOnly = false; + popSaveAllVars = null; + } +} + function _hgTrackUiPopUp(trackName,descriptionOnly) { // popup cfg dialog popUpTrackName = trackName; var myLink = "../cgi-bin/hgTrackUi?g=" + trackName + "&hgsid=" + getHgsid() + "&db=" + getDb(); popUpTrackDescriptionOnly = descriptionOnly; if(popUpTrackDescriptionOnly) myLink += "&descriptionOnly=1"; var rec = trackDbJson[trackName]; if(!descriptionOnly && rec != null && rec["configureBy"] != null) { if (rec["configureBy"] == 'none') return; else if (rec["configureBy"] == 'clickThrough') { jQuery('body').css('cursor', 'wait'); window.location = myLink; @@ -2117,36 +2132,34 @@ minWidth: 700, modal: true, closeOnEscape: true, autoOpen: false, buttons: { "OK": function() { if( ! popUpTrackDescriptionOnly ) hgTrackUiPopCfgOk($('#pop'), popUpTrackName); $(this).dialog("close"); }}, // popup.ready() doesn't seem to work in open. So there is no need for open at this time. //open: function() { // var subtrack = tdbIsSubtrack(trackDbJson[popUpTrackName]) ? popUpTrackName :""; // If subtrack then vis rules differ // popSaveAllVars = getAllVars( $('#pop'), subtrack ); //}, close: function() { - $('#hgTrackUiDialog').html(""); // clear out html after close to prevent problems caused by duplicate html elements - popUpTrackName = ""; //set to defaults - popUpTrackDescriptionOnly = false; - popSaveAllVars = null; + popUpBoxCleanup(); } }); + // FIXME: Why are open and close no longer working!!! if(popUpTrackDescriptionOnly) { var myWidth = $(window).width() - 300; if(myWidth > 900) myWidth = 900; $('#hgTrackUiDialog').dialog("option", "maxWidth", myWidth); $('#hgTrackUiDialog').dialog("option", "width", myWidth); $('#hgTrackUiDialog').dialog('option' , 'title' , trackDbJson[popUpTrackName].shortLabel + " Track Description"); $('#hgTrackUiDialog').dialog('open'); var buttOk = $('button.ui-state-default'); if($(buttOk).length == 1) $(buttOk).focus(); } else { $('#hgTrackUiDialog').dialog('option' , 'title' , trackDbJson[popUpTrackName].shortLabel + " Track Settings"); $('#hgTrackUiDialog').dialog('open'); }