Skip to content

Commit a98da04

Browse files
committed
refactor: updated deprecated jquery methods
Signed-off-by: rafaeljohn9 <rafaeljohb@gmail.com>
1 parent cb66948 commit a98da04

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

assets/js/application.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ $(document).ready(function() {
4343

4444
function onPopState(fn) {
4545
if (window.history && window.history.pushState) {
46-
return $(window).bind('popstate', function(event) {
47-
var section;
46+
return $(window).on('popstate', function () {
4847
initialPop = !popped && location.href === initialURL;
4948
popped = true;
5049
if (initialPop) {
@@ -115,7 +114,7 @@ var GitTurns20 = {
115114
} else {
116115
let start = 0
117116
let count = 0
118-
$("#tagline").click(e => {
117+
$("#tagline").on('click', e => {
119118
if (count === 0 || e.timeStamp > start + count * 1000) {
120119
start = e.timeStamp;
121120
count = 1;
@@ -181,20 +180,20 @@ var Search = {
181180
},
182181

183182
observeFocus: function() {
184-
$('form#search input').focus(function() {
183+
$('form#search input').on('focus', function () {
185184
$(this).parent('form#search').switchClass("", "focus", 200);
186185
});
187-
$('form#search input').blur(function() {
186+
$('form#search input').on('blur', function () {
188187
Search.resetForm();
189188
});
190189
},
191190

192191
observeTextEntry: function() {
193-
$('form#search input').keyup(function(e) {
192+
$('form#search input').on('keyup', function () {
194193
Search.runSearch();
195194
});
196195

197-
$('form#search input').keydown(function(e) {
196+
$('form#search input').on('keydown', function (e) {
198197
if ($('#search-results').not(':visible') && e.which != 27) {
199198
$('#search-results').fadeIn(0.2);
200199
Search.highlight(Search.selectedIndex);
@@ -220,16 +219,16 @@ var Search = {
220219
},
221220

222221
observeResultsClicks: function() {
223-
$('#search-results').mousedown(function(e) {
222+
$('#search-results').on('mousedown', function (e) {
224223
e.preventDefault();
225224
});
226225
},
227226

228227
installKeyboardShortcuts: function() {
229-
$(document).keydown(function(e) {
228+
$(document).on('keydown', function (e) {
230229
if (e.target.tagName.toUpperCase() !== 'INPUT' && ['s', 'S', '/'].includes(e.key)) {
231230
e.preventDefault();
232-
$('form#search input').focus();
231+
$('form#search input').trigger('focus');
233232
}
234233
else if (e.target.tagName.toUpperCase() !== 'INPUT') GitTurns20.keydown(e);
235234
});
@@ -491,7 +490,7 @@ var Forms = {
491490
},
492491

493492
observeCopyableInputs: function() {
494-
$('input.copyable').click(function() {
493+
$('input.copyable').on('click', function () {
495494
$(this).select();
496495
});
497496
}
@@ -545,7 +544,7 @@ var Downloads = {
545544
},
546545

547546
observeGUIOSFilter: function() {
548-
$('a.gui-os-filter').click(function(e) {
547+
$('a.gui-os-filter').on('click', function (e) {
549548
e.preventDefault();
550549
var os = $(this).attr('data-os');
551550

@@ -565,7 +564,7 @@ var Downloads = {
565564
},
566565

567566
observePopState: function() {
568-
onPopState(function() {
567+
onPopState(function () {
569568
Downloads.filterGUIS();
570569
});
571570
},
@@ -648,7 +647,7 @@ var DarkMode = {
648647
}
649648
button.css("display", "block");
650649

651-
button.click(function(e) {
650+
button.on('click', function (e) {
652651
e.preventDefault();
653652
let theme
654653
if (prefersDarkScheme) {
@@ -780,12 +779,12 @@ var PostelizeAnchor = {
780779

781780
// Scroll to Top
782781
$('#scrollToTop').removeClass('no-js');
783-
$(window).scroll(function() {
782+
$(window).on('scroll', function () {
784783
$(this).scrollTop() > 150
785784
? $('#scrollToTop').fadeIn()
786785
: $('#scrollToTop').fadeOut();
787786
});
788-
$('#scrollToTop').click(function(e) {
787+
$('#scrollToTop').on('click', function (e) {
789788
e.preventDefault();
790789
$("html, body").animate({
791790
scrollTop: 0

0 commit comments

Comments
 (0)