compatibility with cash.js WIP

range-slider
Thibault Duplessis 2020-09-09 14:57:36 +02:00
parent 09ae915899
commit 1d6efcab0e
21 changed files with 50 additions and 52 deletions

View File

@ -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();
})""")

View File

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

View File

@ -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();

View File

@ -12,7 +12,7 @@ $(function() {
var onPageReload = function() {
$("#communication").append(
$('<a id="auto_refresh" class="button">Auto refresh</a>').click(function() {
$('<a id="auto_refresh" class="button">Auto refresh</a>').on('click', () => {
autoRefreshEnabled = !autoRefreshEnabled;
renderButton();
})

View File

@ -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();
});

View File

@ -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();

View File

@ -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() {

View File

@ -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();
});

View File

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

View File

@ -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;

View File

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

View File

@ -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;

View File

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

View File

@ -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'),

View File

@ -18,7 +18,7 @@ const announce = (d: LichessAnnouncement) => {
(d.date ? '<time class="timeago" datetime="' + d.date + '"></time>' : '') +
'<div class="actions"><a class="close">X</a></div>' +
'</div>'
).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');
}

View File

@ -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();

View File

@ -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++;

View File

@ -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();

View File

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

View File

@ -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(() => {
'<a class="withdraw text" href="' + url + '/withdraw" data-icon="Z">Pause</a>' +
'<a class="text" href="' + url + '" data-icon="G">Resume</a>' +
'</div></div>'
).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;

View File

@ -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;