Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6410 jQuery Deprecations #6411

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b2ebd92
jQuery deprecations - submit
rfultz Aug 5, 2024
e36023c
jQuery deprecations - keyCode
rfultz Aug 5, 2024
205dd66
jQuery deprecations - change
rfultz Aug 5, 2024
4a3778d
jQuery deprecations - click
rfultz Aug 5, 2024
6d453c2
jQuery deprecations - focus
rfultz Aug 5, 2024
e68bc59
jQuery deprecations - blur
rfultz Aug 5, 2024
45265d9
jQuery deprecations - hover
rfultz Aug 5, 2024
711fbfc
jQuery deprecations - change
rfultz Aug 5, 2024
fa8dd62
jQuery deprecations - bind
rfultz Aug 5, 2024
ee16b66
jQuery deprecations - unbind
rfultz Aug 5, 2024
cf60484
jQuery deprecations
rfultz Aug 5, 2024
7c43130
jQuery deprecations
rfultz Aug 5, 2024
f0ae6e4
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Aug 27, 2024
0d5e04e
Remove unused getCookie
rfultz Sep 5, 2024
ae48d5d
Documentation, formatting
rfultz Sep 6, 2024
c4bf2d2
Turn off failing tests, add TODO
rfultz Sep 6, 2024
934b00b
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Sep 6, 2024
6c3f148
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Oct 7, 2024
533a936
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Oct 24, 2024
96fc917
Updating deprecated jQuery functions
rfultz Oct 24, 2024
a719175
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Oct 31, 2024
8c823bf
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Nov 27, 2024
fbe736d
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Dec 11, 2024
ebbe743
Merge branch 'develop' into feature/6410-jquery-deprecations
rfultz Jan 6, 2025
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
4 changes: 2 additions & 2 deletions fec/fec/static/js/legal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};

/**
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/audit-category-sub-category.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'], {
Expand Down
8 changes: 4 additions & 4 deletions fec/fec/static/js/modules/audit_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/calendar-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
13 changes: 8 additions & 5 deletions fec/fec/static/js/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
};

Expand All @@ -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');
});
};
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function download(url, init, focus) {
}

if (focus) {
item.$button.focus(); // TODO: jQuery deprecation
item.$button.trigger('focus');
}

return item;
Expand Down
24 changes: 15 additions & 9 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 @@ -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');
}
};

Expand All @@ -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');
}
};

Expand Down Expand Up @@ -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');
}
};

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
.uniqueSort()
.value();
var stateDistricts = _filter(districtFeatures.features, function(
feature
Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/election-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
};

Expand Down
112 changes: 59 additions & 53 deletions fec/fec/static/js/modules/filters/date-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down 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() {
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() {
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 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) {
Expand Down Expand Up @@ -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');
}
};

Expand Down
8 changes: 4 additions & 4 deletions fec/fec/static/js/modules/filters/election-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
};

Expand Down
2 changes: 1 addition & 1 deletion fec/fec/static/js/modules/filters/filter-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
4 changes: 2 additions & 2 deletions fec/fec/static/js/modules/filters/filter-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
};

Expand All @@ -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;
Expand Down
Loading