Skip to content

Commit

Permalink
feat(district): Adds the new button to the download ZIP page
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Jan 24, 2024
1 parent 6e891ce commit 799afcf
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/content_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ ContentDelegate.prototype.onDownloadAllSubmit = async function (event) {
document.getElementById('recap-download').click();
}
history.pushState({ content: document.body.innerHTML }, '');
$('body').css('cursor', 'pointer');
}
}
);
Expand Down Expand Up @@ -717,21 +718,35 @@ ContentDelegate.prototype.handleZipFilePageView = function () {
}

// imperatively manipulate hte dom elements without injecting a script
const forms = [...document.querySelectorAll('form')];
forms.map((form) => {
form.removeAttribute('action');
const input = form.querySelector('input');
input.removeAttribute('onclick');
input.disabled = true;
form.hidden = true;
const div = document.createElement('div');
const button = document.createElement('button');
button.textContent = 'Download Documents';
button.addEventListener('click', () => window.postMessage({ id: url }));
div.appendChild(button);
const parentNode = form.parentNode;
parentNode.insertBefore(div, form);
});
if (PACER.hasFilingCookie(document.cookie)) {
const inputs = [...document.querySelectorAll("form > input[type='button']")];
inputs.map((input) => {
let button = createRecapButtonForFilers('Download and RECAP Documents');
button.addEventListener('click', (event) => {
event.preventDefault();
window.postMessage({ id: url });
});
// insert new button next to the "Download Documents" button
input.after(button);
});
} else {
// imperatively manipulate html dom elements without injecting a script
const forms = [...document.querySelectorAll('form')];
forms.map((form) => {
form.removeAttribute('action');
const input = form.querySelector('input');
input.removeAttribute('onclick');
input.disabled = true;
form.hidden = true;
const div = document.createElement('div');
const button = document.createElement('button');
button.textContent = 'Download Documents';
button.addEventListener('click', () => window.postMessage({ id: url }));
div.appendChild(button);
const parentNode = form.parentNode;
parentNode.insertBefore(div, form);
});
}
// When we receive the message from the above submit method, submit the form
// via fetch so we can get the document before the browser does.
window.addEventListener('message', this.onDownloadAllSubmit.bind(this));
Expand Down

0 comments on commit 799afcf

Please sign in to comment.