c3a989e32fb4ef526070e77d7cb9bc024decf7ec angie Mon Jan 10 16:49:42 2011 -0800 Moved almost all functionality of toggleTrackGroupVisibility fromhgTracks.js into utils.js's setTableRowVisibility so hgc can use it too. diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index c8e8ec4..d5a0ea9 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -343,56 +343,34 @@ // Set up so that they can drag out to define a new item on a makeItems track. var img = $("#img_data_" + trackName); if(img != undefined && img.length != 0) { var trackImgTbl = $('#imgTbl'); var imgHeight = trackImgTbl.height(); jQuery(img.imgAreaSelect( { selectionColor: 'green', outerColor: '', minHeight: imgHeight, maxHeight: imgHeight, onSelectEnd: makeItemsEnd, autoHide: true, movable: false})); } } function toggleTrackGroupVisibility(button, prefix) { // toggle visibility of a track group; prefix is the prefix of all the id's of tr's in the // relevant group. This code also modifies the corresponding hidden fields and the gif of the +/- img tag. - var retval = true; - var hidden = $("input[name='hgtgroup_"+prefix+"_close']"); - var newVal=1; // we're going - => + - if($(button) != undefined && $(hidden) != undefined && $(hidden).length > 0) { - var oldSrc = $(button).attr("src"); if(arguments.length > 2) - newVal = arguments[2] ? 0 : 1; + return setTableRowVisibility(button, prefix, "hgtgroup", "group", false, arguments[2]); else - newVal = oldSrc.indexOf("/remove") > 0 ? 1 : 0; - - var newSrc; - if(newVal == 1) { - newSrc = oldSrc.replace("/remove", "/add"); - $(button).attr('title','Expand this group'); - $("tr[id^='"+prefix+"-']").hide(); - } else { - newSrc = oldSrc.replace("/add", "/remove"); - $(button).attr('title','Collapse this group'); - $("tr[id^='"+prefix+"-']").show(); - } - $(button).attr("src",newSrc); - $(hidden).val(newVal); - // setCartVar("hgtgroup_" + prefix + "_close", newVal); - retval = false; - } - return retval; + return setTableRowVisibility(button, prefix, "hgtgroup", "group", false); } function setAllTrackGroupVisibility(newState) { // Set visibility of all track groups to newState (true means expanded). // This code also modifies the corresponding hidden fields and the gif's of the +/- img tag. $("img[id$='_button']").each( function (i) { if(this.src.indexOf("/remove") > 0 || this.src.indexOf("/add") > 0) toggleTrackGroupVisibility(this,this.id.substring(0,this.id.length - 7),newState); // clip '_button' suffix }); return false; } ///////////////////////////////////////////////////// // Chrom Drag/Zoom/Expand code