Skip to content

Commit

Permalink
JENKINS-73971 Extract event handlers in NestedViewsSearch/search-resu…
Browse files Browse the repository at this point in the history
…lts (#48)

* JENKINS-73971  Extract event handlers in NestedViewsSearch/search-results.jelly

* Adding onClick dynamically

moving adjunct after creation of elements

* replaced return false by  event.preventDefault();
  • Loading branch information
judovana authored Oct 18, 2024
1 parent 78604f5 commit 1aea594
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<l:layout title="${%Search for} '${q}'">
<l:side-panel>
<h2><l:icon class="icon-help icon-sm" /> Search help</h2>
<a onclick="document.getElementById('button_expand_2_1').style.display = 'none'; document.getElementById('button_collapse_2_1').style.display = 'inline'; document.getElementById('details_2_1').style.display = 'block'; return false;"
style="font-size: smaller; display: inline" href="#" id="button_expand_2_1">Search History (expand)</a>
<a onclick="document.getElementById('button_collapse_2_1').style.display = 'none';document.getElementById('details_2_1').style.display = 'none';document.getElementById('button_expand_2_1').style.display = 'inline'; return false;"
style="font-size: smaller; display: none" href="#" id="button_collapse_2_1">Search History (collapse)</a>
<a style="font-size: smaller; display: inline" href="#" id="button_expand_2_1">Search History (expand)</a>
<a style="font-size: smaller; display: none" href="#" id="button_collapse_2_1">Search History (collapse)</a>
<st:adjunct includes="hudson.plugins.nested_view.NestedViewsSearch.searchscripts"/>
<div style="display: none" id="details_2_1">
<ol>
<j:forEach var="hist" items="${it.getHistory()}">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <![CDATA[

function nvwp_showHide_button_2_1_show(event) {
document.getElementById('button_expand_2_1').style.display = 'none';
document.getElementById('button_collapse_2_1').style.display = 'inline';
document.getElementById('details_2_1').style.display = 'block';
event.preventDefault();
}
function nvwp_showHide_button_2_1_hide(event) {
document.getElementById('button_collapse_2_1').style.display = 'none';
document.getElementById('details_2_1').style.display = 'none';
document.getElementById('button_expand_2_1').style.display = 'inline';
event.preventDefault();
}

const exEl = document.getElementById("button_expand_2_1");
exEl.addEventListener("click", nvwp_showHide_button_2_1_show);

const colEl = document.getElementById("button_collapse_2_1");
colEl.addEventListener("click", nvwp_showHide_button_2_1_hide);



// ]]>

0 comments on commit 1aea594

Please sign in to comment.