49ab86f5c5c65a60ff9ad81b8cca11d415c3c436 chmalee Fri Nov 17 08:10:14 2023 -0800 Make +/- buttons change when expanding/collapsing search results, refs #31501 diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index fcab8c4..5e4a301 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -520,57 +520,61 @@ newListObj += match.position; printedPos = true; } if (match.description) { if (printedPos) {newListObj += " - ";} newListObj += match.description; } newListObj += "</li>"; list.innerHTML += newListObj; printCount += 1; } }); } function showMoreResults() { - var trackName = this.id.replace(/Results_.*/, ""); - var isHidden = $("." + trackName + "_hidden")[0].style.display === "none"; + let trackName = this.id.replace(/Results_.*/, ""); + let isHidden = $("." + trackName + "_hidden")[0].style.display === "none"; + let btnId = this.id.replace(/Link/, "Button"); _.each($("." + trackName + "_hidden"), function(hiddenLi) { if (isHidden) { hiddenLi.style = "display:"; } else { hiddenLi.style = "display: none"; } }); if (isHidden) { if (this.nextSibling) { // click on the '+' icon newText = this.nextSibling.innerHTML.replace(/Show/,"Hide"); this.nextSibling.innerHTML = newText; this.src = "../images/remove_sm.gif"; } else { // click on the link text this.innerHTML = this.innerHTML.replace(/Show/,"Hide"); + let img = document.getElementById(btnId); + img.src = "../images/remove_sm.gif"; } } else { if (this.nextSibling) { // click on the '-' icon newText = this.nextSibling.innerHTML.replace(/Hide/,"Show"); this.nextSibling.innerHTML = newText; this.src = "../images/add_sm.gif"; } else { - this.innerHTML = this.innerHTML.replace(/Hide/,"Show"); + let img = document.getElementById(btnId); + img.src = "../images/add_sm.gif"; } } } function collapseNode() { var toCollapse = this.parentNode.childNodes[3]; var isHidden = toCollapse.style.display === "none"; if (isHidden) { toCollapse.style = 'display:'; this.src = "../images/remove_sm.gif"; } else { toCollapse.style = 'display: none';