701a85b9260e1a356e216789b300aa5b02a97f60 tdreszer Wed Nov 23 10:40:33 2011 -0800 Imported BUTTON_BY_CSS from branch because it goes with MATRIX_SQUEEZE diff --git src/hg/js/utils.js src/hg/js/utils.js index 19f09fe..eeedfbf 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -465,47 +465,65 @@ $(divit).children('table').addClass(bgClass); } } $(divit).toggle(); // jQuery hide/show return false; } function setTableRowVisibility(button, prefix, hiddenPrefix, titleDesc, doAjax) { // Show or hide one or more table rows whose id's begin with prefix followed by "-". // This code also modifies the corresponding hidden field (cart variable) and the // src of the +/- img button. var retval = true; var hidden = $("input[name='"+hiddenPrefix+"_"+prefix+"_close']"); if($(button) != undefined && $(hidden) != undefined && $(hidden).length > 0) { - var oldSrc = $(button).attr("src"); - var newVal; + var newVal = -1; if(arguments.length > 5) newVal = arguments[5] ? 0 : 1; - else + var oldSrc = $(button).attr("src"); + if (oldSrc != undefined && oldSrc.length > 0) { + // Old img version of the toggleButton + if (newVal == -1) newVal = oldSrc.indexOf("/remove") > 0 ? 1 : 0; - var newSrc; + if(newVal == 1) + $(button).attr("src", oldSrc.replace("/remove", "/add") ); + else + $(button).attr("src", oldSrc.replace("/add", "/remove") ); + } else { + // new BUTTONS_BY_CSS + if (newVal == -1) { + oldSrc = $(button).text(); + if (oldSrc != undefined && oldSrc.length == 1) + newVal = $(button).text() == "+" ? 0 : 1; + else { + warn("Uninterpretable toggleButton!"); + newVal = 0; + } + } + if(newVal == 1) + $(button).text('+'); + else + $(button).text('-'); + } if(newVal == 1) { - newSrc = oldSrc.replace("/remove", "/add"); $(button).attr('title', 'Expand this '+titleDesc); $("tr[id^='"+prefix+"-']").hide(); } else { - newSrc = oldSrc.replace("/add", "/remove"); $(button).attr('title', 'Collapse this '+titleDesc); $("tr[id^='"+prefix+"-']").show(); } - $(button).attr("src", newSrc); $(hidden).val(newVal); if (doAjax) { setCartVar(hiddenPrefix+"_"+prefix+"_close", newVal); } retval = false; } return retval; } function warnBoxJsSetup() { // Sets up warnBox if not already established. This is duplicated from htmshell.c var html = ""; html += "<center>"; html += "<div id='warnBox' style='display:none; background-color:Beige; "; html += "border: 3px ridge DarkRed; width:640px; padding:10px; margin:10px; "; @@ -2240,30 +2258,31 @@ $(element).attr('name','hgt_mdbVal' + rowNum); if ($(element).hasClass('filterBy')) { $(element).attr('id',''); // removing id ensures renumbering id ddcl.reinit([ element ],true); } } // A couple more things element = $(this).find("td[id^='isLike']")[0]; if (element != undefined) $(element).attr('id','isLike' + rowNum); element = $(this).find("td[id^='hgt_mdbVal']")[0]; if (element != undefined) $(element).attr('id','hgt_mdbVal' + rowNum); }); + return mdbSelectRows.length; } return 0; }, switchTabs: function (ui) { // switching tabs on findTracks page if( ui.panel.id == 'simpleTab' && $('div#found').length < 1) { setTimeout("$('input#simpleSearch').focus();",20); // delay necessary, since select event not afterSelect event } else if( ui.panel.id == 'advancedTab') { // Advanced tab has DDCL wigets which were sized badly because the hidden width was unknown // delay necessary, since select event not afterSelect event setTimeout("ddcl.reinit($('div#advancedTab').find('select.filterBy'),false);",20); }