diff --git a/fec/fec/static/js/legal.js b/fec/fec/static/js/legal.js index 04ad75b9b..e6f5f2cdb 100644 --- a/fec/fec/static/js/legal.js +++ b/fec/fec/static/js/legal.js @@ -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'); }; /** diff --git a/fec/fec/static/js/modules/calendar.js b/fec/fec/static/js/modules/calendar.js index bdda2ea1c..d1820a06e 100644 --- a/fec/fec/static/js/modules/calendar.js +++ b/fec/fec/static/js/modules/calendar.js @@ -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 } }; diff --git a/fec/fec/static/js/modules/dropdowns.js b/fec/fec/static/js/modules/dropdowns.js index 0d1c0762f..0d4466525 100644 --- a/fec/fec/static/js/modules/dropdowns.js +++ b/fec/fec/static/js/modules/dropdowns.js @@ -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; }; @@ -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 @@ -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 diff --git a/fec/fec/static/js/modules/election-map.js b/fec/fec/static/js/modules/election-map.js index d893b1ca3..db09ee92b 100644 --- a/fec/fec/static/js/modules/election-map.js +++ b/fec/fec/static/js/modules/election-map.js @@ -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 diff --git a/fec/fec/static/js/modules/filters/date-filter.js b/fec/fec/static/js/modules/filters/date-filter.js index 6b3d3163e..d7c453995 100644 --- a/fec/fec/static/js/modules/filters/date-filter.js +++ b/fec/fec/static/js/modules/filters/date-filter.js @@ -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() { @@ -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) { @@ -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 diff --git a/fec/fec/static/js/modules/filters/filter-typeahead.js b/fec/fec/static/js/modules/filters/filter-typeahead.js index 8827e5fca..ecbe37543 100644 --- a/fec/fec/static/js/modules/filters/filter-typeahead.js +++ b/fec/fec/static/js/modules/filters/filter-typeahead.js @@ -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); } }; diff --git a/fec/fec/static/js/modules/form-nav.js b/fec/fec/static/js/modules/form-nav.js index 099fdf498..7802dbe83 100644 --- a/fec/fec/static/js/modules/form-nav.js +++ b/fec/fec/static/js/modules/form-nav.js @@ -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(); }; diff --git a/fec/fec/static/js/modules/helpers.js b/fec/fec/static/js/modules/helpers.js index 66689869f..4aa183a4c 100644 --- a/fec/fec/static/js/modules/helpers.js +++ b/fec/fec/static/js/modules/helpers.js @@ -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)); diff --git a/fec/fec/static/js/modules/maps.js b/fec/fec/static/js/modules/maps.js index 09b1f9b5a..20f6bc522 100644 --- a/fec/fec/static/js/modules/maps.js +++ b/fec/fec/static/js/modules/maps.js @@ -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); diff --git a/fec/fec/static/js/modules/search.js b/fec/fec/static/js/modules/search.js index 07340a9d0..12a9ff52d 100644 --- a/fec/fec/static/js/modules/search.js +++ b/fec/fec/static/js/modules/search.js @@ -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 } }); diff --git a/fec/fec/static/js/modules/skip-nav.js b/fec/fec/static/js/modules/skip-nav.js index f2b315c0f..d8b1e2028 100644 --- a/fec/fec/static/js/modules/skip-nav.js +++ b/fec/fec/static/js/modules/skip-nav.js @@ -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 } diff --git a/fec/fec/static/js/modules/typeahead.js b/fec/fec/static/js/modules/typeahead.js index 135bd5687..665cf1939 100644 --- a/fec/fec/static/js/modules/typeahead.js +++ b/fec/fec/static/js/modules/typeahead.js @@ -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'); }; diff --git a/fec/fec/static/js/pages/datatable-audit.js b/fec/fec/static/js/pages/datatable-audit.js index f872d823d..1a1bd6741 100644 --- a/fec/fec/static/js/pages/datatable-audit.js +++ b/fec/fec/static/js/pages/datatable-audit.js @@ -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(); diff --git a/fec/fec/templates/base.html b/fec/fec/templates/base.html index 6930afcbd..f69ec697e 100644 --- a/fec/fec/templates/base.html +++ b/fec/fec/templates/base.html @@ -34,7 +34,7 @@