Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-74149][JENKINS-74148] Extract inline JavaScript #224

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<font color="${job.getStatusColor()}">${job.getStatus()}</font>
<j:if test="${job.hasFailureMessage()}">
<div class="divider"/>
<button onclick="dropdown(this)" class="dropdown-button">Info</button>
<button class="dropdown-button">Info</button>
<div class="dropdown-content">
${job.getFailureMessage()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<font color="${job.getStatusColor()}">${job.getStatus()}</font>
<j:if test="${job.hasFailureMessage()}">
<div class="divider"/>
<button onclick="dropdown(this)" class="dropdown-button">Info</button>
<button class="dropdown-button">Info</button>
<div class="dropdown-content">
${job.getFailureMessage()}
</div>
Expand Down
27 changes: 27 additions & 0 deletions src/main/webapp/css/analytics.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,30 @@
.sauce-labs-statistics > p {
margin: 0;
}

.dropdown {
position: relative;
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
overflow-y: scroll;
white-space: pre;
}

.show {
display: block;
}

.divider {
width: 5px;
height: auto;
display: inline-block;
}
12 changes: 9 additions & 3 deletions src/main/webapp/js/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function dropdown(target) {
target.parentNode.getElementsByClassName("dropdown-content")[0].classList.toggle("show");
function dropdown(event) {
event.target.parentNode.getElementsByClassName("dropdown-content")[0].classList.toggle("show");
}

// close the dropdown if the user clicks outside the button or dropdown content
Expand All @@ -14,4 +14,10 @@ window.onclick = function(event) {
}
}
}
}
}

document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".dropdown-button").forEach((button) => {
button.addEventListener("click", dropdown);
});
});
Loading