diff --git a/app/views/coach/show.scala b/app/views/coach/show.scala index 3e30a78cf6..f33ec4a370 100644 --- a/app/views/coach/show.scala +++ b/app/views/coach/show.scala @@ -34,7 +34,7 @@ object show { moreJs = frag( jsAt("vendor/bar-rating/dist/jquery.barrating.min.js"), ctx.isAuth option embedJsUnsafeLoadThen("""$(".bar-rating").barrating(); -$('.coach-review-form .toggle').click(function() { +$('.coach-review-form .toggle').on('click', function() { $(this).remove(); $('.coach-review-form form').show(); })""") diff --git a/public/javascripts/inquiry.js b/public/javascripts/inquiry.js index 73bd613be8..fd47e556fe 100644 --- a/public/javascripts/inquiry.js +++ b/public/javascripts/inquiry.js @@ -2,7 +2,7 @@ $(function() { $('#inquiry .notes').on('mouseenter', function() { $(this).find('textarea')[0].focus(); }); - $('#inquiry .costello').click(function() { + $('#inquiry .costello').on('click', () => { $('#inquiry').toggleClass('hidden'); $('body').toggleClass('no-inquiry'); }); diff --git a/public/javascripts/plan.js b/public/javascripts/plan.js index 618e9285e5..1e10096501 100644 --- a/public/javascripts/plan.js +++ b/public/javascripts/plan.js @@ -2,7 +2,7 @@ $(function() { $table = $('.plan table.all'); $change = $table.find('.change'); - $change.find('a').click(function() { + $change.find('a').on('click', function() { var f = $(this).data('form'); $change.find('form:not(.' + f + ')').hide(); $change.find('form.' + f).toggle(); diff --git a/public/javascripts/public-chat.js b/public/javascripts/public-chat.js index 5998ec3695..1ac656d20b 100644 --- a/public/javascripts/public-chat.js +++ b/public/javascripts/public-chat.js @@ -12,7 +12,7 @@ $(function() { var onPageReload = function() { $("#communication").append( - $('Auto refresh').click(function() { + $('Auto refresh').on('click', () => { autoRefreshEnabled = !autoRefreshEnabled; renderButton(); }) diff --git a/ui/ceval/src/main.ts b/ui/ceval/src/main.ts index 482b34bb65..eee293a7ef 100644 --- a/ui/ceval/src/main.ts +++ b/ui/ceval/src/main.ts @@ -10,6 +10,6 @@ export { ctrl, view, winningChances }; // as the ctrl can be instanciated several times. // gotta do the click on the toggle to have it visually change. window.lichess.storage.make('ceval.pool.start').listen(_ => { - const toggle = document.getElementById('analyse-toggle-ceval'); - if (toggle && (toggle as HTMLInputElement).checked) toggle.click(); + const toggle = document.getElementById('analyse-toggle-ceval') as HTMLInputElement | undefined; + if (toggle?.checked) toggle.click(); }); diff --git a/ui/lobby/src/setup.ts b/ui/lobby/src/setup.ts index 577a714957..c0d816348c 100644 --- a/ui/lobby/src/setup.ts +++ b/ui/lobby/src/setup.ts @@ -123,7 +123,7 @@ export default class Setup { cantBeRated = (timeMode == '1' && variantId != '1' && limit < 0.5 && inc == 0) || (variantId != '1' && timeMode != '1'); if (cantBeRated && rated) { - $casual.click(); + $casual.trigger('click'); return toggleButtons(); } $rated.prop('disabled', !!cantBeRated).siblings('label').toggleClass('disabled', cantBeRated); @@ -222,7 +222,7 @@ export default class Setup { } return false; }; - $submits.click(function(this: HTMLElement) { + $submits.on('click', function(this: HTMLElement) { return ajaxSubmit($(this).val()); }).prop('disabled', false); $form.submit(function() { @@ -342,7 +342,7 @@ export default class Setup { $fenPosition.toggle(isFen); $modeChoicesWrap.toggle(!isFen); if (isFen) { - $casual.click(); + $casual.trigger('click'); requestAnimationFrame(() => document.body.dispatchEvent(new Event('chessground.resize'))); } showRating(); diff --git a/ui/lobby/src/view/realTime/chart.ts b/ui/lobby/src/view/realTime/chart.ts index 721536f01a..7aeee4075d 100644 --- a/ui/lobby/src/view/realTime/chart.ts +++ b/ui/lobby/src/view/realTime/chart.ts @@ -58,7 +58,7 @@ function renderPlot(ctrl: LobbyController, hook: Hook) { }).data('powertipjq', $(renderHook(ctrl, hook))) .on({ powerTipRender() { - $('#hook .inner-clickable').click(() => ctrl.clickHook(hook.id)); + $('#hook .inner-clickable').on('click', () => ctrl.clickHook(hook.id)); } }); setTimeout(function() { diff --git a/ui/lobby/src/view/realTime/filter.ts b/ui/lobby/src/view/realTime/filter.ts index cfcb958335..9aacc9a3f6 100644 --- a/ui/lobby/src/view/realTime/filter.ts +++ b/ui/lobby/src/view/realTime/filter.ts @@ -24,12 +24,12 @@ function initialize(ctrl: LobbyController, el: HTMLElement) { save(); } $div.find('input').change(save); - $div.find('button.reset').click(function() { + $div.find('button.reset').on('click', () => { ctrl.filter.set(null); ctrl.filter.open = false; ctrl.redraw(); }); - $div.find('button.apply').click(function() { + $div.find('button.apply').on('click', () => { ctrl.filter.open = false; ctrl.redraw(); }); diff --git a/ui/round/src/boot.ts b/ui/round/src/boot.ts index 79ecb14aca..e186beb5c1 100644 --- a/ui/round/src/boot.ts +++ b/ui/round/src/boot.ts @@ -86,6 +86,6 @@ export default function(opts: RoundOpts): void { }); if (location.pathname.lastIndexOf('/round-next/', 0) === 0) history.replaceState(null, '', '/' + data.game.id); - $('#zentog').click(() => li.pubsub.emit('zen')); + $('#zentog').on('click', () => li.pubsub.emit('zen')); li.storage.make('reload-round-tabs').listen(li.reload); } diff --git a/ui/round/src/plugins/nvui.ts b/ui/round/src/plugins/nvui.ts index 3af6bf2d5d..647e74128e 100644 --- a/ui/round/src/plugins/nvui.ts +++ b/ui/round/src/plugins/nvui.ts @@ -179,10 +179,10 @@ function onCommand(ctrl: RoundController, notify: (txt: string) => void, c: stri const lowered = c.toLowerCase(); if (lowered == 'c' || lowered == 'clock') notify($('.nvui .botc').text() + ', ' + $('.nvui .topc').text()); else if (lowered == 'l' || lowered == 'last') notify($('.lastMove').text()); - else if (lowered == 'abort') $('.nvui button.abort').click(); - else if (lowered == 'resign') $('.nvui button.resign-confirm').click(); - else if (lowered == 'draw') $('.nvui button.draw-yes').click(); - else if (lowered == 'takeback') $('.nvui button.takeback-yes').click(); + else if (lowered == 'abort') $('.nvui button.abort').trigger('click'); + else if (lowered == 'resign') $('.nvui button.resign-confirm').trigger('click'); + else if (lowered == 'draw') $('.nvui button.draw-yes').trigger('click'); + else if (lowered == 'takeback') $('.nvui button.takeback-yes').trigger('click'); else if (lowered == 'o' || lowered == 'opponent') notify(playerText(ctrl, ctrl.data.opponent)); else { const pieces = ctrl.chessground.state.pieces; diff --git a/ui/simul/src/view/created.ts b/ui/simul/src/view/created.ts index 79b8284ebd..220a8183be 100644 --- a/ui/simul/src/view/created.ts +++ b/ui/simul/src/view/created.ts @@ -42,7 +42,7 @@ export default function(showText: (ctrl: SimulCtrl) => VNode) { xhr.join(ctrl.data.id, ctrl.data.variants[0].key); else { modal($('.simul .continue-with')); - $('#modal-wrap .continue-with a').click(function(this: HTMLElement) { + $('#modal-wrap .continue-with a').on('click', function(this: HTMLElement) { modal.close(); xhr.join(ctrl.data.id, $(this).data('variant')); }); diff --git a/ui/site/src/checkout.ts b/ui/site/src/checkout.ts index 09462e5799..aa2002dc0e 100644 --- a/ui/site/src/checkout.ts +++ b/ui/site/src/checkout.ts @@ -9,8 +9,8 @@ export default function(publicKey: string) { }; var min = 100, max = 100 * 100000; - if (location.hash === '#onetime') $('#freq_onetime').click(); - if (location.hash === '#lifetime') $('#freq_lifetime').click(); + if (location.hash === '#onetime') $('#freq_onetime').trigger('click'); + if (location.hash === '#lifetime') $('#freq_lifetime').trigger('click'); const getFreq = function() { return $checkout.find('group.freq input:checked').val(); @@ -19,7 +19,7 @@ export default function(publicKey: string) { // Other is selected but no amount specified // happens with backward button if (!$checkout.find('.amount_choice group.amount input:checked').data('amount')) - $checkout.find('#plan_monthly_1000').click(); + $checkout.find('#plan_monthly_1000').trigger('click'); const selectAmountGroup = function() { var freq = getFreq(); @@ -41,7 +41,7 @@ export default function(publicKey: string) { var cents = Math.round(amount * 100); if (!cents) { $(this).text($(this).data('trans-other')); - $checkout.find('#plan_monthly_1000').click(); + $checkout.find('#plan_monthly_1000').trigger('click'); return false; } if (cents < min) cents = min; diff --git a/ui/site/src/clas.ts b/ui/site/src/clas.ts index 61a2788260..89af73404f 100644 --- a/ui/site/src/clas.ts +++ b/ui/site/src/clas.ts @@ -11,7 +11,7 @@ window.lichess.load.then(() => { descending: true }); }); - $('.name-regen').click(function(this: HTMLAnchorElement) { + $('.name-regen').on('click', function(this: HTMLAnchorElement) { xhr.text(this.href).then(name => $('#form3-create-username').val(name)); return false; }); diff --git a/ui/site/src/coach-form.ts b/ui/site/src/coach-form.ts index 99458b9c1b..4ac78d3162 100644 --- a/ui/site/src/coach-form.ts +++ b/ui/site/src/coach-form.ts @@ -51,7 +51,7 @@ window.lichess.load.then(() => { }; })(); - $editor.find('.tabs > div').click(function(this: HTMLElement) { + $editor.find('.tabs > div').on('click', function(this: HTMLElement) { $editor.find('.tabs > div').removeClass('active'); $(this).addClass('active'); $editor.find('.panel').removeClass('active'); @@ -73,10 +73,10 @@ window.lichess.load.then(() => { }); if ($editor.find('.reviews .review').length) - $editor.find('.tabs div[data-tab=reviews]').click(); + $editor.find('.tabs div[data-tab=reviews]').trigger('click'); const $reviews = $editor.find('.reviews'); - $reviews.find('.actions a').click(function(this: HTMLAnchorElement) { + $reviews.find('.actions a').on('click', function(this: HTMLAnchorElement) { const $review = $(this).parents('.review'); xhr.text( $review.data('action') + '?v=' + $(this).data('value'), diff --git a/ui/site/src/component/announce.ts b/ui/site/src/component/announce.ts index 68fa87c7e5..7b06a87252 100644 --- a/ui/site/src/component/announce.ts +++ b/ui/site/src/component/announce.ts @@ -18,7 +18,7 @@ const announce = (d: LichessAnnouncement) => { (d.date ? '' : '') + '
X
' + '' - ).find('#announce .close').click(kill); + ).find('#announce .close').on('click', kill); timeout = setTimeout(kill, d.date ? new Date(d.date).getTime() - Date.now() : 5000); if (d.date) pubsub.emit('content_loaded'); } diff --git a/ui/site/src/component/top-bar.ts b/ui/site/src/component/top-bar.ts index 51b977236a..b15cd31b54 100644 --- a/ui/site/src/component/top-bar.ts +++ b/ui/site/src/component/top-bar.ts @@ -39,7 +39,7 @@ export default function() { instance = window.LichessChallenge($el[0], { data, show() { - if (!$('#challenge-app').is(':visible')) $toggle.click(); + if (!$('#challenge-app').is(':visible')) $toggle.trigger('click'); }, setCount(nb: number) { $toggle.find('span').attr('data-count', nb); @@ -54,7 +54,7 @@ export default function() { if (!instance) load(data); else instance.update(data); }); - pubsub.on('challenge-app.open', () => $toggle.click()); + pubsub.on('challenge-app.open', () => $toggle.trigger('click')); } { // notifyApp @@ -76,7 +76,7 @@ export default function() { $toggle.find('span').attr('data-count', nb); }, show() { - if (!isVisible()) $toggle.click(); + if (!isVisible()) $toggle.trigger('click'); }, setNotified() { window.lichess.socket.send('notified'); @@ -88,7 +88,7 @@ export default function() { ); }; - $toggle.one('mouseover click', () => load()).click(() => { + $toggle.one('mouseover click', () => load()).on('click', () => { if ('Notification' in window) Notification.requestPermission(); setTimeout(() => { if (instance && isVisible()) instance.setVisible(); diff --git a/ui/site/src/coordinate.ts b/ui/site/src/coordinate.ts index 3437f25ca5..5f6259d131 100644 --- a/ui/site/src/coordinate.ts +++ b/ui/site/src/coordinate.ts @@ -132,7 +132,7 @@ window.lichess.load.then(() => { else stop(); }; - $start.click(function() { + $start.on('click', () => { $explanation.remove(); $trainer.addClass('play').removeClass('init'); showColor(); @@ -146,7 +146,7 @@ window.lichess.load.then(() => { startAt = new Date(); ground.set({ events: { - select: function(key) { + select(key) { var hit = key == $coords[0].text(); if (hit) { score++; diff --git a/ui/site/src/forum.ts b/ui/site/src/forum.ts index cb23c35977..0ef2158a1d 100644 --- a/ui/site/src/forum.ts +++ b/ui/site/src/forum.ts @@ -12,7 +12,7 @@ window.lichess.load.then(() => { return false; }); - $('.edit.button').add('.edit-post-cancel').click(function(this: HTMLButtonElement, e) { + $('.edit.button').add('.edit-post-cancel').on('click', function(this: HTMLButtonElement, e) { e.preventDefault(); const post = $(this).closest('.forum-post'), @@ -76,7 +76,7 @@ window.lichess.load.then(() => { }); }); - $('.forum').click('.reactions-auth button', e => { + $('.forum').on('click', '.reactions-auth button', e => { const href = e.target.getAttribute('data-href'); if (href) { const $rels = $(e.target).parent(); diff --git a/ui/site/src/mod-user.ts b/ui/site/src/mod-user.ts index eba1938936..a771397626 100644 --- a/ui/site/src/mod-user.ts +++ b/ui/site/src/mod-user.ts @@ -52,7 +52,7 @@ window.lichess.load.then(() => { } } - $toggle.click(function() { + $toggle.on('click', () => { if ($zone.hasClass('none')) loadZone(); else unloadZone(); return false; @@ -103,8 +103,8 @@ window.lichess.load.then(() => { tablesort(el, { descending: true }); }); makeReady('#mz_identification .spy_filter', el => { - $(el).find('.button').click(function(this: HTMLAnchorElement) { - xhr.text(this.getAttribute('href')!, { method: 'post' }); + $(el).find('.button').on('click', function(this: HTMLAnchorElement) { + xhr.text(this.href!, { method: 'post' }); $(this).parent().parent().toggleClass('blocked'); return false; }); @@ -120,7 +120,7 @@ window.lichess.load.then(() => { tablesort(el, { descending: true }); }, 'ready-sort'); makeReady('#mz_others .more-others', el => { - $(el).addClass('.ready').click(() => { + $(el).addClass('.ready').on('click', () => { nbOthers = 1000; reloadZone(); }); @@ -140,8 +140,8 @@ window.lichess.load.then(() => { extendTablesortNumber(); - if (location.search.startsWith('?mod')) $toggle.click(); + if (location.search.startsWith('?mod')) $toggle.trigger('click'); - window.Mousetrap.bind('m', () => $toggle.click()); - window.Mousetrap.bind('i', () => $zone.find('button.inquiry').click()); + window.Mousetrap.bind('m', () => $toggle.trigger('click')); + window.Mousetrap.bind('i', () => $zone.find('button.inquiry').trigger('click')); }); diff --git a/ui/site/src/site.ts b/ui/site/src/site.ts index 824dd1557a..46cd5b9eb1 100644 --- a/ui/site/src/site.ts +++ b/ui/site/src/site.ts @@ -96,9 +96,9 @@ li.load.then(() => { loadInfiniteScroll('.infinitescroll'); - $('a.delete, input.delete').click(() => confirm('Delete?')); - $('input.confirm, button.confirm').click(function(this: HTMLElement) { - return confirm($(this).attr('title') || 'Confirm this action?'); + $('a.delete, input.delete').on('click', () => confirm('Delete?')); + $('input.confirm, button.confirm').on('click', function(this: HTMLElement) { + return confirm(this.title || 'Confirm this action?'); }); $('#main-wrap').on('click', 'a.bookmark', function(this: HTMLAnchorElement) { @@ -186,7 +186,7 @@ li.load.then(() => { 'Pause' + 'Resume' + '' - ).find('#announce .withdraw').click(function(this: HTMLAnchorElement) { + ).find('#announce .withdraw').on('click', function(this: HTMLAnchorElement) { xhr.text(this.href, { method: 'post' }); $('#announce').remove(); return false; diff --git a/ui/site/src/user.ts b/ui/site/src/user.ts index af50d4d576..7216f0cfd6 100644 --- a/ui/site/src/user.ts +++ b/ui/site/src/user.ts @@ -6,15 +6,13 @@ import loadInfiniteScroll from "./component/infinite-scroll"; window.lichess.load.then(() => { $(".user-show .note-zone-toggle").each(function(this: HTMLElement) { - $(this).click(function(this: HTMLElement) { - $(".user-show .note-zone").toggle(); - }); - if (location.search.includes('note')) $(this).click(); + $(this).on('click', () => $(".user-show .note-zone").toggle()); + if (location.search.includes('note')) $(this).trigger('click'); }); $(".user-show .claim_title_zone").each(function(this: HTMLElement) { - var $zone = $(this); - $zone.find('.actions a').click(function(this: HTMLAnchorElement) { + const $zone = $(this); + $zone.find('.actions a').on('click', function(this: HTMLAnchorElement) { xhr.text(this.href, { method: 'post' }); $zone.remove(); return false;