diff --git a/fec/fec/static/js/init.js b/fec/fec/static/js/init.js index 8784b9cbcc..0b8752fef9 100644 --- a/fec/fec/static/js/init.js +++ b/fec/fec/static/js/init.js @@ -59,4 +59,22 @@ $(function() { } $p.nextAll().remove(); }); + + /** + * Check for an in-page element with a classList that contains 'js-launch-fecfile-eligibility'. + * If any are found, add the js and css files for it. + * fecfile-eligibility.js will activate the launcher button + */ + let eligibilityLauncher = document.querySelector('.js-launch-fecfile-eligibility'); + if (eligibilityLauncher) { + let newScript = document.createElement('script'); + newScript.src = '/static/js/widgets/fecfile-eligibility.js'; // This could begin with 'https://www.fec.gov/' + document.body.append(newScript); + + let eligibilityStyles = document.createElement('link'); + eligibilityStyles.rel = 'stylesheet'; + eligibilityStyles.href = '/static/css/widgets/fecfile-eligibility.css'; // This could begin with 'https://www.fec.gov/' + document.body.append(eligibilityStyles); + } + eligibilityLauncher = undefined; // No reason to keep the var }); diff --git a/fec/fec/static/js/modules/calc-admin-fines.js b/fec/fec/static/js/modules/calc-admin-fines.js index 761fa3f7f1..81a5239461 100644 --- a/fec/fec/static/js/modules/calc-admin-fines.js +++ b/fec/fec/static/js/modules/calc-admin-fines.js @@ -1,7 +1,7 @@ /** // */ -import Vue from 'vue/dist/vue.esm.js'; +import Vue from 'vue-2/dist/vue.esm.js'; import { availableDates, getTotalAdminFine } from './calc-admin-fines-logic.js'; @@ -355,7 +355,7 @@ Vue.component('frames', { return this[q.showIfVar1] === q.showIfVar1ExpectedValue; } }, - frameClass: function(frameIndex, addtionalClasses) { + frameClass: function(frameIndex, additionalClasses) { return [ 'frame', { @@ -363,7 +363,7 @@ Vue.component('frames', { current: frameIndex == this.currentFrameNum, 'next off-screen': frameIndex > this.currentFrameNum }, - addtionalClasses + additionalClasses // { // viewed: this.frames[navIndex].viewed || navIndex == 0, // current: navIndex == this.currentFrameNum, @@ -652,7 +652,7 @@ new Vue({ help: `

For election sensitive reports, a committee is a non-filer if it files after this point or doesn't file at all.

A committee is a late filer if it files the report after the due date, but more than four days before the date of the applicable election.

For non-election sensitive reports, a committee is a non-filer if it files its report later than that or not at all.

-

A committee will be considerered a late filer if it files its report within 30 days after the due date.

` +

A committee will be considered a late filer if it files its report within 30 days after the due date.

` } ], viewed: false @@ -871,7 +871,7 @@ new Vue({ } else if (passedTests === true) { // If the value is undefined, this is the first time it's being set so let's advance let autoStep = this[affectedVmodel] == undefined ? true : false; - // …unless we specifially shouldn't autoadvance + // …unless we specifically shouldn't autoadvance autoStep = frameShouldAutoAdvance; // this.setBreadCrumbText(frameNum, qNum, q); diff --git a/fec/fec/static/js/widgets/fecfile-eligibility.js b/fec/fec/static/js/widgets/fecfile-eligibility.js new file mode 100644 index 0000000000..4c079b1dce --- /dev/null +++ b/fec/fec/static/js/widgets/fecfile-eligibility.js @@ -0,0 +1,961 @@ +/** + * Component to direct filers to FECfile+ or other filing applications. + * Expects a button/link in the page ( @see launcherButtonSelector ), activates it, + * and may start itself in an open state if the window.location.href sets dialog=open + */ +import { createApp } from 'vue/dist/vue.esm-bundler.js'; + +// Quick-edits +// (The full data is the last and largest section of this file) +const goalHref = 'https://fecfile.fec.gov/login'; + +export default function FecFileEligibility() { + this.launcherButtonSelector = '.js-launch-fecfile-eligibility'; // How to find the button to launch this + this.appElSelector = 'gov-fec-fecfile-eligibility'; // How to name the main Vue elements, also used in the css + this.modalDialog; // The + this.app; // The
converted into this app + this.frames; // The frames of content + this.init(); +} + +/** + * Kick it off. Finds the launcher button, adds the listener, activates it, then opens the if needed + */ +FecFileEligibility.prototype.init = function() { + let launcherButton = document.querySelector(this.launcherButtonSelector); + + if (launcherButton) { + this.buildModalDialog(); + launcherButton.classList.remove('is-disabled'); + launcherButton.addEventListener('click', this.handleOpenDialogClick.bind(this)); + } + + // Should we start in the open state? + let searchParams = new URLSearchParams(window.location.search); + if (searchParams && searchParams.get('dialog') === 'open') this.handleOpenDialogClick(); +}; + +/** + * Creates this in document.body and listens for the close button's click event + */ +FecFileEligibility.prototype.buildModalDialog = function() { + this.modalDialog = document.createElement('dialog'); + this.modalDialog.setAttribute('id', `modal-${this.appElSelector}`); + this.modalDialog.setAttribute('closedby', 'any'); + this.modalDialog.innerHTML = ` +