mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 17:28:31 +02:00
Added get-gov-admin.js
This commit is contained in:
parent
6ac5852546
commit
df090b06f4
1 changed files with 37 additions and 0 deletions
37
src/registrar/assets/js/get-gov-admin.js
Normal file
37
src/registrar/assets/js/get-gov-admin.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @file get-gov-admin.js includes custom code for the .gov registrar admin portal.
|
||||
*
|
||||
* Constants and helper functions are at the top.
|
||||
* Event handlers are in the middle.
|
||||
* Initialization (run-on-load) stuff goes at the bottom.
|
||||
*/
|
||||
|
||||
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
|
||||
// Helper functions.
|
||||
/** Either sets attribute target="_blank" to a given element, or removes it */
|
||||
function openInNewTab(el, removeAttribute = false){
|
||||
if(removeAttribute){
|
||||
el.setAttribute("target", "_blank");
|
||||
}else{
|
||||
el.removeAttribute("target", "_blank");
|
||||
}
|
||||
};
|
||||
|
||||
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
|
||||
// Event handlers.
|
||||
|
||||
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
|
||||
// Initialization code.
|
||||
|
||||
/** An IIFE for pages in DjangoAdmin which may need custom JS implementation.
|
||||
* Currently only appends target="_blank" to the domain_form object,
|
||||
* but this can be expanded.
|
||||
*/
|
||||
(function prepareDjangoAdmin(){
|
||||
let domainFormElement = document.getElementById("domain_form");
|
||||
let domainSubmitButton = document.getElementById("manageDomainSubmitButton");
|
||||
if(domainSubmitButton && domainFormElement){
|
||||
domainSubmitButton.addEventListener("mouseover", () => openInNewTab(domainFormElement, true));
|
||||
domainSubmitButton.addEventListener("mouseout", () => openInNewTab(domainFormElement, false));
|
||||
}
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue