Skip to content
Open
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
2 changes: 1 addition & 1 deletion fec/fec/static/js/legal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ KeywordModal.prototype.handleSubmit = function(e) {
e.preventDefault();
var queryString = this.generateQueryString();
this.$hiddenField.val(queryString);
this.$form.submit(); // TODO: jQuery deprecation? (.submit() )
this.$form.trigger('submit');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Calendar.prototype.handleEventClick = function(calEvent, jsEvent) {

// Simulate clicks when hitting enter on certain full-calendar elements
Calendar.prototype.simulateClick = function(e) {
if (e.keyCode === 13) {
if (e.which === 13) {
$(e.target).click(); // TODO: jQuery deprecation
}
};
Expand Down
6 changes: 3 additions & 3 deletions fec/fec/static/js/modules/dropdowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Dropdown.prototype.toggle = function(e) {
Dropdown.prototype.show = function() {
restoreTabindex(this.$panel);
this.$panel.attr('aria-hidden', 'false');
this.$panel.find('input[type="checkbox"]:first').focus(); // TODO: jQuery deprecation (:first and .focus)
this.$panel.find('input[type="checkbox"]').first().trigger('focus');
this.$button.addClass('is-active');
this.isOpen = true;
};
Expand Down Expand Up @@ -117,7 +117,7 @@ Dropdown.prototype.handleFocusAway = function(e) {
};

Dropdown.prototype.handleKeyup = function(e) {
if (e.keyCode === KEYCODE_ESC) {
if (e.which === KEYCODE_ESC) {
if (this.isOpen) {
this.hide();
this.$button.focus(); // TODO: jQuery deprecation
Expand All @@ -126,7 +126,7 @@ Dropdown.prototype.handleKeyup = function(e) {
};

Dropdown.prototype.handleCheckKeyup = function(e) {
if (e.keyCode === KEYCODE_ENTER) {
if (e.which === KEYCODE_ENTER) {
$(e.target)
.prop('checked', true)
.change(); // TODO: jQuery deprecation
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/election-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ElectionMap.prototype.drawBackgroundDistricts = function(districts) {
.map(function(district) {
return Math.floor(district / 100);
})
.unique() // TODO: jQuery deprecation
.unique()
.value();
var stateDistricts = _filter(districtFeatures.features, function(
feature
Expand Down
100 changes: 53 additions & 47 deletions fec/fec/static/js/modules/filters/date-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,29 +239,32 @@ DateFilter.prototype.handleMinDateSelect = function() {
this.$grid.find('.is-active').removeClass('is-active');
$dateBegin.addClass('is-active');

this.$grid.find('li').hover( // TODO: jQuery deprecation
function() {
var dateBeginNum = parseInt(
$(this)
.parent()
.attr('data-year') + $(this).attr('data-month')
);
var dateEndNum = parseInt(
$dateEnd.parent().attr('data-year') + $dateEnd.attr('data-month')
);

if (dateBeginNum <= dateEndNum) {
self.$grid.removeClass('is-invalid');
self.handleDateGridRange($(this), $dateEnd);
} else {
self.$grid.addClass('is-invalid');
this.$grid.find('li')
.on('mouseenter',
function() {
const dateBeginNum = parseInt(
$(this)
.parent()
.attr('data-year') + $(this).attr('data-month')
);
const dateEndNum = parseInt(
$dateEnd.parent().attr('data-year') + $dateEnd.attr('data-month')
);

if (dateBeginNum <= dateEndNum) {
self.$grid.removeClass('is-invalid');
self.handleDateGridRange($(this), $dateEnd);
} else {
self.$grid.addClass('is-invalid');
}
}
},
function() {
self.handleDateGridRange($dateBegin, $dateEnd);
$dateBegin.addClass('is-active');
}
);
)
.on('mouseleave',
function() {
self.handleDateGridRange($dateBegin, $dateEnd);
$dateBegin.addClass('is-active');
}
);
};

DateFilter.prototype.handleMaxDateSelect = function() {
Expand All @@ -276,31 +279,34 @@ DateFilter.prototype.handleMaxDateSelect = function() {
this.$grid.find('.is-active').removeClass('is-active');
$dateEnd.addClass('is-active');

this.$grid.find('li').hover( // TODO: jQuery deprecation
function() {
// turn dates to numbers for comparsion
// to make sure hover date range is valid
var dateBeginNum = parseInt(
$dateBegin.parent().attr('data-year') + $dateBegin.attr('data-month')
);
var dateEndNum = parseInt(
$(this)
.parent()
.attr('data-year') + $(this).attr('data-month')
);

if (dateBeginNum <= dateEndNum) {
self.$grid.removeClass('is-invalid');
self.handleDateGridRange($dateBegin, $(this));
} else {
self.$grid.addClass('is-invalid');
this.$grid.find('li')
.on('mouseenter',
function() {
// turn dates to numbers for comparison
// to make sure hover date range is valid
var dateBeginNum = parseInt(
$dateBegin.parent().attr('data-year') + $dateBegin.attr('data-month')
);
var dateEndNum = parseInt(
$(this)
.parent()
.attr('data-year') + $(this).attr('data-month')
);

if (dateBeginNum <= dateEndNum) {
self.$grid.removeClass('is-invalid');
self.handleDateGridRange($dateBegin, $(this));
} else {
self.$grid.addClass('is-invalid');
}
}
},
function() {
self.handleDateGridRange($dateBegin, $dateEnd);
$dateEnd.addClass('is-active');
}
);
)
.on('mouseleave',
function() {
self.handleDateGridRange($dateBegin, $dateEnd);
$dateEnd.addClass('is-active');
}
);
};

DateFilter.prototype.handleGridItemSelect = function(e) {
Expand Down Expand Up @@ -331,7 +337,7 @@ DateFilter.prototype.handleGridItemSelect = function(e) {
? this.$maxDate
: this.$submit;
this.$grid.removeClass('pick-min pick-max');
this.$grid.find('li').unbind('mouseenter mouseleave'); // TODO: jQuery deprecation (.unbind())
this.$grid.find('li').off('mouseenter mouseleave');
this.setValue(value);
this.$grid.addClass('is-invalid');
$nextItem.focus(); // TODO: jQuery deprecation
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/filters/filter-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ FilterTypeahead.prototype.handleKeypress = function(e) {
this.$field.attr('aria-expanded', 'false');
}

if (e.keyCode === 13 || e.code === 'Enter') { // 13 = enter/return but .keyCode has been deprecated
if (e.which === 13 || e.code === 'Enter') { // 13 = enter/return
this.handleSubmit(e);
}
};
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/form-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ FormNav.prototype.clearNamesIfNull = function(e) {
}
}

if (e.type == 'change') this.form.submit(); // TODO: jQuery deprecation
if (e.type == 'change') this.form.submit();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use .trigger('submit') now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so when I added the comment!

I'll check when my system is back up, but I think this.form refers to the <form> instead of the $('form'). If this.form is a jQuery element, it should be .trigger('submit'), yes, but not if it's only the <form>. (jQuery moved to .trigger([event]) to avoid collisions with now-standard things like .click(), .change(), .submit()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.form is the <form> so .submit() is correct because it isn't a jQuery object.

(and my initial // TODO: jQuery deprecation was wrong)

};
4 changes: 2 additions & 2 deletions fec/fec/static/js/modules/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ export function sanitizeQueryParams(query) {
export function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie != '') {
let cookies = document.cookie.split(';');
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
let cookie = $.trim(cookies[i]); // TODO: remove jQuery.trim as it's been deprecated
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == name + '=') {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function appendStateMap($parent, results, cached) {
return displayed.indexOf(each) === -1;
}) || _last(ids);
$parent.append(candidateStateMapTemplate(results));
const $select = $parent.find('.state-map:last select'); // TODO: jQuery deprecation (:last)
const $select = $parent.find('.state-map').last().find('select');
$select.val(value);
$select.trigger('change');
updateButtonsDisplay($parent);
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Search($el, opts) {

$(document.body).on('keyup', function(e) {
// Focus search on "/"
if (e.keyCode === KEYCODE_SLASH) {
if (e.which === KEYCODE_SLASH) {
$input.first().focus(); // TODO: jQuery deprecation
}
});
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/skip-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Skipnav.prototype.findTarget = function() {
Skipnav.prototype.focusOnTarget = function(e) {
e.preventDefault();

if (e.keyCode === 13 || e.type === 'click') {
if (e.which === 13 || e.type === 'click') {
this.$target.attr('tabindex', '0');
this.$target.focus(); // TODO: jQuery deprecation
}
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,5 +490,5 @@ Typeahead.prototype.searchSite = function(query) {
const action = $form.attr('action');
this.$input.val(query);
$form.attr('action', action);
$form.submit();
$form.trigger('submit');
};
6 changes: 1 addition & 5 deletions fec/fec/static/js/pages/datatable-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { audit as cols_audit } from '../modules/columns.js';
import { DataTable_FEC, modalRenderRow } from '../modules/tables.js';

// for sub category filter-tag and results
$(document).bind( // TODO: jQuery deprecation
'ready ajaxComplete',
'#sub_category_id',
showSubCategory
);
$(document).on('ready ajaxComplete', '#sub_category_id', showSubCategory);

$(function() {
auditCategorySubcategory();
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2>Your web browser is not supported</h2>
{% if not request.is_preview %}{% include 'partials/google-tag-manager-noscript.html' %}{% endif %}

{% wagtailuserbar %}
<a href="#main" class="skip-nav">skip navigation</a>
<a href="#main" class="skip-nav" tabindex="0">skip navigation</a>
{# env-specific banner #}
{% include 'partials/env-banner.html' %}
{# .gov banner #}
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/templates/home_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>Your web browser is not supported</h2>
{% if not request.is_preview %}{% include 'partials/google-tag-manager-noscript.html' %}{% endif %}

{% wagtailuserbar %}
<a href="#main" class="skip-nav">skip navigation</a>
<a href="#main" class="skip-nav" tabindex="0">skip navigation</a>
{# env-specific banner #}
{% include 'partials/env-banner.html' %}
{# .gov banner #}
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/tests/js/dropdowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('dropdown', function() {

it('hides on ESC', function(){
this.dropdown.show();
this.dropdown.handleKeyup({ keyCode: 27 });
this.dropdown.handleKeyup({ keyCode: 27, which: 27 }); // TODO: keyCode has been deprecated
expect(isClosed(this.dropdown)).to.be.true;
});
});
Expand Down
5 changes: 3 additions & 2 deletions fec/fec/tests/js/skip-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use(sinonChai);

import SkipNav from '../../static/js/modules/skip-nav.js';

const DOM = '<a class="skip-nav">Skip</a><main><h1>Welcome</h1></main>';
const DOM = '<a class="skip-nav" tabindex="0">Skip</a><main><h1>Welcome</h1></main>';

describe('Skip nav link', function() {
before(function() {
Expand All @@ -34,7 +34,8 @@ describe('Skip nav link', function() {
});

it('focuses on the target when enter pressed', function() {
var e = { keyCode: 13, preventDefault: function() {} }; // eslint-disable-line no-empty-function
// TODO: keyCode has been deprecated
var e = { keyCode: 13, which: 13, preventDefault: function() {} }; // eslint-disable-line no-empty-function
this.skipNav.focusOnTarget(e);
expect($(document.activeElement).is(this.skipNav.$target)).to.be.true;
});
Expand Down
4 changes: 2 additions & 2 deletions fec/fec/tests/js/typeahead-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ describe('FilterTypeahead', function() {

it('should submit on enter', function() {
var handleSubmit = spy(this.FilterTypeahead, 'handleSubmit');
this.FilterTypeahead.handleKeypress({ keyCode: 13 });
expect(handleSubmit).to.have.been.calledWith({ keyCode: 13 });
this.FilterTypeahead.handleKeypress({ keyCode: 13, which: 13 }); // TODO: keyCode has been deprecated
expect(handleSubmit).to.have.been.calledWith({ keyCode: 13, which: 13 }); // TODO: keyCode has been deprecated
this.FilterTypeahead.handleSubmit.restore();
});

Expand Down
2 changes: 1 addition & 1 deletion fec/home/templates/purgecss-homepage/banners.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head></head>
<body class="template-home-page">

<a href="#main" class="skip-nav">skip navigation</a>
<a href="#main" class="skip-nav" tabindex="0">skip navigation</a>

<div class="banner-dev">
<p class="t-sans t-small">LOCAL<br>
Expand Down
2 changes: 1 addition & 1 deletion fec/home/templates/purgecss-homepage/full.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2>Your web browser is not supported</h2>
<p>This site uses features that are not supported by this browser. For a better experience, please switch to a modern browser.</p>
</div>

<a href="#main" class="skip-nav">skip navigation</a>
<a href="#main" class="skip-nav" tabindex="0">skip navigation</a>
<div class="banner-dev">
<p class="t-sans t-small">LOCAL<br>
This site <a href="https://www.fec.gov">live site</a>.
Expand Down
2 changes: 1 addition & 1 deletion fec/home/templates/purgecss-homepage/navs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2>Your web browser is not supported</h2>
<p>This site uses features that are not supported by this browser. For a better experience, please switch to a modern browser.</p>
</div>

<a href="#main" class="skip-nav">skip navigation</a>
<a href="#main" class="skip-nav" tabindex="0">skip navigation</a>



Expand Down