diff --git a/fec/fec/static/js/legal.js b/fec/fec/static/js/legal.js index 04ad75b9be..b0bc814091 100644 --- a/fec/fec/static/js/legal.js +++ b/fec/fec/static/js/legal.js @@ -44,9 +44,9 @@ function KeywordModal() { */ KeywordModal.prototype.handleSubmit = function(e) { e.preventDefault(); - var queryString = this.generateQueryString(); + const 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/audit-category-sub-category.js b/fec/fec/static/js/modules/audit-category-sub-category.js index 72033de171..d61e07ef72 100644 --- a/fec/fec/static/js/modules/audit-category-sub-category.js +++ b/fec/fec/static/js/modules/audit-category-sub-category.js @@ -7,7 +7,7 @@ import { buildUrl } from './helpers.js'; export function auditCategorySubcategory() { - $('#primary_category_id').change(function() { // TODO: jQuery deprecation + $('#primary_category_id').on('change', function() { var $select = $('#sub_category_id'); $.getJSON( buildUrl(['audit-category'], { diff --git a/fec/fec/static/js/modules/audit_tags.js b/fec/fec/static/js/modules/audit_tags.js index c1b1edd26a..799ad20be7 100644 --- a/fec/fec/static/js/modules/audit_tags.js +++ b/fec/fec/static/js/modules/audit_tags.js @@ -6,7 +6,7 @@ import { default as auditCategoryTemplate } from '../templates/audit_tags.hbs'; export default function auditTags() { $('.data-container__tags').prepend(auditCategoryTemplate); $('.tag__category.sub').css('visibility', 'hidden'); - $('#primary_category_id').change(function() { // TODO: jQuery deprecation + $('#primary_category_id').on('change', function() { const current_category = $('#primary_category_id option:selected').text(); $('.tag__category.sub').css('visibility', 'hidden'); $('.tag__item.primary').contents()[0].nodeValue = `Findings and issue category: ${current_category}`; @@ -15,17 +15,17 @@ export default function auditTags() { : $('.tag__item.primary button').show(); }); - $('#sub_category_id').change(function() { // TODO: jQuery deprecation + $('#sub_category_id').on('change', function() { const current_sub = $('#sub_category_id option:selected').text(); $('.tag__item.sub').contents()[0].nodeValue = `Sub Category: ${current_sub}`; }); - $('.js-close_sub').click(function() { // TODO: jQuery deprecation + $('.js-close_sub').on('click', function() { $('#primary_category_id').trigger('change'); $('#sub_category_id').val('all'); }); - $('.js-close_primary').click(function() { // TODO: jQuery deprecation + $('.js-close_primary').on('click', function() { $('#primary_category_id').val('all'); $('#primary_category_id').trigger('change'); $('.tag__item.primary button').hide(); diff --git a/fec/fec/static/js/modules/calendar-tooltip.js b/fec/fec/static/js/modules/calendar-tooltip.js index 3b087e968a..99afb82cbe 100644 --- a/fec/fec/static/js/modules/calendar-tooltip.js +++ b/fec/fec/static/js/modules/calendar-tooltip.js @@ -34,6 +34,6 @@ CalendarTooltip.prototype.close = function() { this.$content.remove(); this.exportDropdown.destroy(); this.$container.removeClass('is-active'); - this.$container.focus(); // TODO: jQuery deprecation + this.$container.trigger('focus'); this.events.clear(); }; diff --git a/fec/fec/static/js/modules/calendar.js b/fec/fec/static/js/modules/calendar.js index bdda2ea1cb..c693d74e1e 100644 --- a/fec/fec/static/js/modules/calendar.js +++ b/fec/fec/static/js/modules/calendar.js @@ -336,10 +336,13 @@ Calendar.prototype.handleEventClick = function(calEvent, jsEvent) { } }; -// Simulate clicks when hitting enter on certain full-calendar elements +/** +* Simulate clicks when hitting enter on certain full-calendar elements +* @param {jQuery.event} e +*/ Calendar.prototype.simulateClick = function(e) { - if (e.keyCode === 13) { - $(e.target).click(); // TODO: jQuery deprecation + if (e.which === 13) { + $(e.target).trigger('click'); } }; @@ -350,8 +353,8 @@ Calendar.prototype.managePopoverControl = function(e) { $popover .find('.fc-close') .attr('tabindex', '0') - .focus() // TODO: jQuery deprecation + .trigger('focus') .on('click', function() { - $target.focus(); // TODO: jQuery deprecation + $target.trigger('focus'); }); }; diff --git a/fec/fec/static/js/modules/download.js b/fec/fec/static/js/modules/download.js index c130dd4226..e0b9d80d2a 100644 --- a/fec/fec/static/js/modules/download.js +++ b/fec/fec/static/js/modules/download.js @@ -36,7 +36,7 @@ export function download(url, init, focus) { } if (focus) { - item.$button.focus(); // TODO: jQuery deprecation + item.$button.trigger('focus'); } return item; diff --git a/fec/fec/static/js/modules/dropdowns.js b/fec/fec/static/js/modules/dropdowns.js index 0d1c0762f1..0040c03dc5 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; }; @@ -116,20 +116,26 @@ Dropdown.prototype.handleFocusAway = function(e) { } }; +/** + * @param {JQuery.Event} 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 + this.$button.trigger('focus'); } } }; +/** + * @param {JQuery.Event} 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 + .trigger('change'); } }; @@ -145,7 +151,7 @@ Dropdown.prototype.handleDropdownItemClick = function(e) { const $input = this.$selected.find('#' + $button.data('label')); if (!$button.hasClass('is-checked')) { - $input.click(); // TODO: jQuery deprecation + $input.trigger('click'); } }; @@ -221,14 +227,14 @@ Dropdown.prototype.selectItem = function($input) { if (next.length) { $(next[0]) .find('input[type="checkbox"]') - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } else if (prev.length) { $(prev[0]) .find('input[type="checkbox"]') - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } } else { - this.$selected.find('input[type="checkbox"]').focus(); // TODO: jQuery deprecation + this.$selected.find('input[type="checkbox"]').trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/election-map.js b/fec/fec/static/js/modules/election-map.js index d893b1ca35..f716ad32ac 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 + .uniqueSort() .value(); var stateDistricts = _filter(districtFeatures.features, function( feature diff --git a/fec/fec/static/js/modules/election-search.js b/fec/fec/static/js/modules/election-search.js index a81dac7970..9fd8523095 100644 --- a/fec/fec/static/js/modules/election-search.js +++ b/fec/fec/static/js/modules/election-search.js @@ -220,7 +220,7 @@ ElectionSearch.prototype.getUpcomingElections = function() { * Handle a change event on the zip code fields */ ElectionSearch.prototype.handleZipChange = function() { - this.$state.val('').change(); // TODO: jQuery deprecation + this.$state.val('').trigger('change'); this.$district.val(''); }; diff --git a/fec/fec/static/js/modules/filters/date-filter.js b/fec/fec/static/js/modules/filters/date-filter.js index 6b3d3163ed..e66200cde3 100644 --- a/fec/fec/static/js/modules/filters/date-filter.js +++ b/fec/fec/static/js/modules/filters/date-filter.js @@ -136,8 +136,8 @@ DateFilter.prototype.fromQuery = function(query) { DateFilter.prototype.setValue = function(value) { value = ensureArray(value); - this.$minDate.val(value[0]).change(); // TODO: jQuery deprecation - this.$maxDate.val(value[1]).change(); // TODO: jQuery deprecation + this.$minDate.val(value[0]).trigger('change'); + this.$maxDate.val(value[1]).trigger('change'); }; DateFilter.prototype.handleModifyEvent = function(e, opts) { @@ -146,12 +146,12 @@ DateFilter.prototype.handleModifyEvent = function(e, opts) { if (opts.filterName === this.name) { this.maxYear = parseInt(opts.filterValue); this.minYear = this.maxYear - 1; - this.$minDate.val('01/01/' + this.minYear.toString()).change(); // TODO: jQuery deprecation + this.$minDate.val('01/01/' + this.minYear.toString()).trigger('change'); if (this.maxYear === today.getFullYear()) { today = moment(today).format('MM/DD/YYYY'); - this.$maxDate.val(today).change(); // TODO: jQuery deprecation + this.$maxDate.val(today).trigger('change'); } else { - this.$maxDate.val('12/31/' + this.maxYear.toString()).change(); // TODO: jQuery deprecation + this.$maxDate.val('12/31/' + this.maxYear.toString()).trigger('change'); } this.validate(); } @@ -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() { + 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'); + } } - }, - 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 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'); + } } - }, - 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,10 +337,10 @@ 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 + $nextItem.trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/filters/election-filter.js b/fec/fec/static/js/modules/filters/election-filter.js index 99d2df03e0..a1ead5b6ed 100644 --- a/fec/fec/static/js/modules/filters/election-filter.js +++ b/fec/fec/static/js/modules/filters/election-filter.js @@ -43,7 +43,7 @@ ElectionFilter.prototype.fromQuery = function(query) { this.$cycles .find('input[value="' + cycle + ':' + full + '"]') .prop('checked', true) - .change(); // TODO: jQuery deprecation + .trigger('change'); } return this; }; @@ -80,7 +80,7 @@ ElectionFilter.prototype.handleElectionChange = function(e) { .find('input') .eq(0) .prop('checked', true) - .change(); // TODO: jQuery deprecation + .trigger('change'); }; ElectionFilter.prototype.handleCycleChange = function(e) { @@ -89,9 +89,9 @@ ElectionFilter.prototype.handleCycleChange = function(e) { .split(':'); this.$cycle .val(selected[0]) - .change() // TODO: jQuery deprecation + .trigger('change') .attr('checked', true); - this.$full.val(selected[1]).change(); // TODO: jQuery deprecation + this.$full.val(selected[1]).trigger('change'); this.setTag(); }; diff --git a/fec/fec/static/js/modules/filters/filter-base.js b/fec/fec/static/js/modules/filters/filter-base.js index 4ae6169ff2..1cd852f82f 100644 --- a/fec/fec/static/js/modules/filters/filter-base.js +++ b/fec/fec/static/js/modules/filters/filter-base.js @@ -84,7 +84,7 @@ Filter.prototype.setValue = function(value) { const $input = this.$input.data('temp') ? this.$elm.find('#' + this.$input.data('temp')) : this.$input; - $input.val(prepareValue($input, value)).change(); // TODO: jQuery deprecation + $input.val(prepareValue($input, value)).trigger('change'); return this; }; diff --git a/fec/fec/static/js/modules/filters/filter-panel.js b/fec/fec/static/js/modules/filters/filter-panel.js index afd68691f3..38d49f7169 100644 --- a/fec/fec/static/js/modules/filters/filter-panel.js +++ b/fec/fec/static/js/modules/filters/filter-panel.js @@ -65,7 +65,7 @@ FilterPanel.prototype.show = function(focus) { this.$body .find('input, select, button:not(.js-filter-close)') .first() - .focus(); // TODO: jQuery deprecation + .trigger('focus'); } }; @@ -76,7 +76,7 @@ FilterPanel.prototype.hide = function() { } this.$body.removeClass('is-open'); this.$content.attr('aria-hidden', true); - this.$focus.focus(); // TODO: jQuery deprecation + this.$focus.trigger('focus'); removeTabindex(this.$form); $('body').removeClass('is-showing-filters'); this.isOpen = false; diff --git a/fec/fec/static/js/modules/filters/filter-set.js b/fec/fec/static/js/modules/filters/filter-set.js index c7f1e3829c..bc1108b604 100644 --- a/fec/fec/static/js/modules/filters/filter-set.js +++ b/fec/fec/static/js/modules/filters/filter-set.js @@ -166,7 +166,7 @@ FilterSet.prototype.handleTagRemoved = function(e, opts) { const type = $input.get(0).type; if (type === 'checkbox' || type === 'radio') { - $input.click(); // TODO: jQuery deprecation + $input.trigger('click'); } else if (type === 'text') { $input.val(''); $input.get(0).dispatchEvent(new Event('change', { bubbles: true })); diff --git a/fec/fec/static/js/modules/filters/filter-typeahead.js b/fec/fec/static/js/modules/filters/filter-typeahead.js index 9a99cb7e75..c71f9f5101 100644 --- a/fec/fec/static/js/modules/filters/filter-typeahead.js +++ b/fec/fec/static/js/modules/filters/filter-typeahead.js @@ -160,7 +160,8 @@ FilterTypeahead.prototype.handleSelected = function(e, datum) { this.$elm.find('label[for="' + id + '"]').addClass('is-loading'); - this.$button.focus().addClass('is-loading'); + this.$button.trigger('focus'); + this.$button.addClass('is-loading'); }; FilterTypeahead.prototype.handleAutocomplete = function(e, datum) { @@ -179,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') { this.handleSubmit(e); } }; @@ -275,7 +276,7 @@ FilterTypeahead.prototype.appendCheckbox = function(opts) { } else { const checkbox = $(template_checkbox(data)); checkbox.appendTo(this.$selected); - checkbox.find('input').change(); // TODO: jQuery deprecation + checkbox.find('input').trigger('change'); this.clearInput(); } }; diff --git a/fec/fec/static/js/modules/filters/select-filter.js b/fec/fec/static/js/modules/filters/select-filter.js index 7616cc2182..bb0b2f0ce0 100644 --- a/fec/fec/static/js/modules/filters/select-filter.js +++ b/fec/fec/static/js/modules/filters/select-filter.js @@ -29,7 +29,7 @@ SelectFilter.prototype.fromQuery = function(query) { SelectFilter.prototype.setValue = function(value) { this.$input.find('option[selected]').prop('selected', false); this.$input.find('option[value="' + value + '"]').prop('selected', true); - this.$input.change(); // TODO: jQuery deprecation + this.$input.trigger('change'); }; SelectFilter.prototype.handleChange = function(e) { diff --git a/fec/fec/static/js/modules/filters/text-filter.js b/fec/fec/static/js/modules/filters/text-filter.js index b424cf8b33..0c9a2fe966 100644 --- a/fec/fec/static/js/modules/filters/text-filter.js +++ b/fec/fec/static/js/modules/filters/text-filter.js @@ -63,7 +63,7 @@ TextFilter.prototype.handleChange = function() { // set the button focus within a timeout // to prevent change event from firing twice setTimeout(function() { - button.focus(); // TODO: jQuery deprecation + button.trigger('focus'); }, 0); if (value.length > 0) { @@ -145,7 +145,7 @@ TextFilter.prototype.appendCheckbox = function(value) { }; const checkbox = $(template_checkbox(opts)); checkbox.appendTo(this.checkboxList.$elm); - checkbox.find('input').change(); + checkbox.find('input').trigger('change'); this.$input.val(''); this.checkboxIndex++; }; diff --git a/fec/fec/static/js/modules/filters/toggle-filter.js b/fec/fec/static/js/modules/filters/toggle-filter.js index cf2cf68577..383d92d364 100644 --- a/fec/fec/static/js/modules/filters/toggle-filter.js +++ b/fec/fec/static/js/modules/filters/toggle-filter.js @@ -16,7 +16,7 @@ ToggleFilter.prototype.fromQuery = function(query) { this.$elm .find('input[value="' + query[this.name] + '"]') .prop('checked', true) - .change(); // TODO: jQuery deprecation + .trigger('change'); }; ToggleFilter.prototype.handleChange = function(e) { diff --git a/fec/fec/static/js/modules/filters/validate-date-filters.js b/fec/fec/static/js/modules/filters/validate-date-filters.js index 0a487be86c..16117e9cda 100644 --- a/fec/fec/static/js/modules/filters/validate-date-filters.js +++ b/fec/fec/static/js/modules/filters/validate-date-filters.js @@ -121,8 +121,8 @@ ValidateDateFilter.prototype.fromQuery = function(query) { ? query['min_' + this.name] : defaultStart; var maxDate = query['max_' + this.name] ? query['max_' + this.name] : now; - this.$minDate.val(minDate).change(); // TODO: jQuery deprecation - this.$maxDate.val(maxDate).change(); // TODO: jQuery deprecation + this.$minDate.val(minDate).trigger('change'); + this.$maxDate.val(maxDate).trigger('change'); return this; }; diff --git a/fec/fec/static/js/modules/form-nav.js b/fec/fec/static/js/modules/form-nav.js index 099fdf4980..1a397c3c5d 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.trigger('submit'); }; diff --git a/fec/fec/static/js/modules/helpers.js b/fec/fec/static/js/modules/helpers.js index 66689869fd..d52affd79d 100644 --- a/fec/fec/static/js/modules/helpers.js +++ b/fec/fec/static/js/modules/helpers.js @@ -610,22 +610,6 @@ export function sanitizeQueryParams(query) { return query; } -export function getCookie(name) { - let cookieValue = null; - if (document.cookie && document.cookie != '') { - let 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 - // 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)); - break; - } - } - } - return cookieValue; -} - /** * Passive listeners on touchstart and scroll events improve page performance * but could crash non-supportive browsers. diff --git a/fec/fec/static/js/modules/maps.js b/fec/fec/static/js/modules/maps.js index 09b1f9b5ab..20f6bc5224 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 07340a9d0a..009d07edfa 100644 --- a/fec/fec/static/js/modules/search.js +++ b/fec/fec/static/js/modules/search.js @@ -31,8 +31,8 @@ export default function Search($el, opts) { $(document.body).on('keyup', function(e) { // Focus search on "/" - if (e.keyCode === KEYCODE_SLASH) { - $input.first().focus(); // TODO: jQuery deprecation + if (e.which === KEYCODE_SLASH) { + $input.first().trigger('focus'); } }); } diff --git a/fec/fec/static/js/modules/skip-nav.js b/fec/fec/static/js/modules/skip-nav.js index f2b315c0f2..8c2a19f9cc 100644 --- a/fec/fec/static/js/modules/skip-nav.js +++ b/fec/fec/static/js/modules/skip-nav.js @@ -23,11 +23,14 @@ Skipnav.prototype.findTarget = function() { .filter(':visible')[0]; }; +/** + * @param {JQuery.Event} e + */ 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 + this.$target.trigger('focus'); } }; diff --git a/fec/fec/static/js/modules/tables.js b/fec/fec/static/js/modules/tables.js index 08dc278b93..f3ea1a925c 100644 --- a/fec/fec/static/js/modules/tables.js +++ b/fec/fec/static/js/modules/tables.js @@ -235,7 +235,7 @@ export function modalRenderFactory(template, fetch) { $modal.find('.js-pdf_url').remove(); } // Set focus on the close button - $('.js-hide').focus(); // TODO: jQuery deprecation + $('.js-hide').trigger('focus'); // When under $large-screen // TODO figure way to share these values with CSS. @@ -260,7 +260,7 @@ export function modalRenderFactory(template, fetch) { } function hidePanel(api, $modal) { - $('.row-active .js-panel-button').focus(); // TODO: jQuery deprecation + $('.row-active .js-panel-button').trigger('focus'); $('.js-panel-toggle tr').toggleClass('row-active', false); $('body').toggleClass('panel-active', false); $modal.attr('aria-hidden', 'true'); @@ -660,7 +660,7 @@ DataTable_FEC.prototype.checkFromQuery = function() { // …if they are not already checked for (let box of queryBoxes) { if (!($(box).is(':checked'))) { - $(box).prop('checked', true).change(); // TODO: jQuery deprecation + $(box).prop('checked', true).trigger('change'); } } $('button.is-loading, label.is-loading').removeClass('is-loading'); @@ -673,7 +673,7 @@ DataTable_FEC.prototype.checkFromQuery = function() { // ...if they are not already checked for (let box of queryBoxes) { if (!($(box).is(':checked'))) { - $(box).prop('checked', true).change(); // TODO: jQuery deprecation + $(box).prop('checked', true).trigger('change'); } } } diff --git a/fec/fec/static/js/modules/top-entities.js b/fec/fec/static/js/modules/top-entities.js index 27315fa53e..f079f3d6e5 100644 --- a/fec/fec/static/js/modules/top-entities.js +++ b/fec/fec/static/js/modules/top-entities.js @@ -119,7 +119,7 @@ TopEntities.prototype.updateElectionYearOptions = function(office) { if (currentOption.css('display') == 'none') { $('#election-year') .val(minFutureYear) - .change(); // TODO: jQuery deprecation + .trigger('change'); } } else { // show all options/enable for Safari! diff --git a/fec/fec/static/js/modules/typeahead.js b/fec/fec/static/js/modules/typeahead.js index 1dc2e3f5c9..6ce749afb4 100644 --- a/fec/fec/static/js/modules/typeahead.js +++ b/fec/fec/static/js/modules/typeahead.js @@ -445,5 +445,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/contact-form.js b/fec/fec/static/js/pages/contact-form.js index e46aab7aaa..96e84f681f 100644 --- a/fec/fec/static/js/pages/contact-form.js +++ b/fec/fec/static/js/pages/contact-form.js @@ -43,8 +43,8 @@ ContactForm.prototype.initTypeahead = function() { //focus away to prompt removal of error state, if present. Could only focus into... //...another field, Attempts to focusout, or focus onto body, did not work. $('#id_u_contact_title') - .focus() // TODO: jQuery deprecation - .blur(); // TODO: jQuery deprecation + .trigger('focus') + .trigger('blur'); }); }; diff --git a/fec/fec/static/js/pages/datatable-audit.js b/fec/fec/static/js/pages/datatable-audit.js index f872d823d1..946561dfbd 100644 --- a/fec/fec/static/js/pages/datatable-audit.js +++ b/fec/fec/static/js/pages/datatable-audit.js @@ -7,7 +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 +$(document).on( 'ready ajaxComplete', '#sub_category_id', showSubCategory diff --git a/fec/fec/static/js/pages/election-reporting-dates-tables.js b/fec/fec/static/js/pages/election-reporting-dates-tables.js index 5559239165..cc2ce5a874 100644 --- a/fec/fec/static/js/pages/election-reporting-dates-tables.js +++ b/fec/fec/static/js/pages/election-reporting-dates-tables.js @@ -350,7 +350,7 @@ ReportingDates.prototype.mediaQueryResponse = function(mql) { for (const close of jsmodalClose) { close.addEventListener('click', () => { jsmodal[0].setAttribute('aria-hidden', 'true'); - close.focus(); // TODO: jQuery deprecation + close.trigger('focus'); }); } }); diff --git a/fec/fec/static/js/pages/reporting-dates-tables.js b/fec/fec/static/js/pages/reporting-dates-tables.js index 8c9f2a48e5..03e1039fc7 100644 --- a/fec/fec/static/js/pages/reporting-dates-tables.js +++ b/fec/fec/static/js/pages/reporting-dates-tables.js @@ -336,7 +336,7 @@ ReportingDates.prototype.mediaQueryResponse = function(mql) { for (const close of jsmodalClose) { close.addEventListener('click', () => { jsmodal[0].setAttribute('aria-hidden', 'true'); - close.focus(); // TODO: jQuery deprecation + close.trigger('focus'); }); } }); diff --git a/fec/fec/templates/404.html b/fec/fec/templates/404.html index 33caac1a3e..368385762c 100644 --- a/fec/fec/templates/404.html +++ b/fec/fec/templates/404.html @@ -7,8 +7,7 @@
diff --git a/fec/fec/templates/500.html b/fec/fec/templates/500.html index dcc3d79d7c..85c0f8c529 100644 --- a/fec/fec/templates/500.html +++ b/fec/fec/templates/500.html @@ -7,9 +7,8 @@