-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch-detail: refactor JS code into submission.js
Move submission.html script code for toggling header info to a separate submission.js file that makes the code easy to read and ready for change in one place. The listener is moved from the 'href' to separate, explicit click listener. Signed-off-by: Raxel Gutierrez <raxel@google.com> [stephenfin: Removed existing JS href added in previous change and update commit message to reflect this] Signed-off-by: Stephen Finucane <stephen@that.guru>
- Loading branch information
1 parent
70cd37b
commit 3870d7b
Showing
2 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
$( document ).ready(function() { | ||
function toggleDiv(link_id, headers_id, label_show, label_hide) { | ||
const link = document.getElementById(link_id) | ||
const headers = document.getElementById(headers_id) | ||
|
||
const hidden = headers.style['display'] == 'none'; | ||
|
||
if (hidden) { | ||
link.innerHTML = label_hide || 'hide'; | ||
headers.style['display'] = 'block'; | ||
} else { | ||
link.innerHTML = label_show || 'show'; | ||
headers.style['display'] = 'none'; | ||
} | ||
} | ||
|
||
// Click listener to show/hide headers | ||
document.getElementById("toggle-patch-headers").addEventListener("click", function() { | ||
toggleDiv("toggle-patch-headers", "patch-headers"); | ||
}); | ||
|
||
// Click listener to expand/collapse series | ||
document.getElementById("toggle-patch-series").addEventListener("click", function() { | ||
toggleDiv("toggle-patch-series", "patch-series", "expand", "collapse"); | ||
}); | ||
|
||
// Click listener to show/hide related patches | ||
let related = document.getElementById("toggle-related"); | ||
if (related) { | ||
document.getElementById("toggle-related").addEventListener("click", function() { | ||
toggleDiv("toggle-related", "related"); | ||
}); | ||
} | ||
|
||
// Click listener to show/hide related patches from different projects | ||
let relatedOutside = document.getElementById("toggle-related-outside"); | ||
if (relatedOutside) { | ||
document.getElementById("toggle-related-outside").addEventListener("click", function() { | ||
toggleDiv("toggle-related-outside", "related-outside", "show from other projects"); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters