move mod JS

This commit is contained in:
Thibault Duplessis 2018-04-07 21:16:55 +02:00
parent e0d9c3c576
commit 7bc80ed779
2 changed files with 20 additions and 21 deletions

View file

@ -2,29 +2,13 @@ $(function() {
$('div.user_show .mod_zone_toggle').each(function() {
function start($mod) {
$mod.find('form.xhr').submit(function() {
$(this).find('input').attr('disabled', true);
$.ajax({
url: $(this).attr('action'),
method: $(this).attr('method'),
success: function(html) {
start($mod.html(html));
}
})
return false;
});
}
$(this).click(function() {
var $zone = $('div.user_show .mod_zone');
if ($zone.is(':visible')) $zone.hide();
else {
$zone.html(lichess.spinnerHtml).show();
lichess.loadCss('/assets/stylesheets/user-mod.css');
$zone.load($(this).attr('href'), function() {
start($zone);
});
$zone.load($(this).attr('href'));
}
return false;
});

View file

@ -1,13 +1,28 @@
var tablesort = require('tablesort');
lichess.pubsub.emit('content_loaded')();
var $zone = $("div.user_show .mod_zone");
function start($mod) {
$zone.find('form.xhr').submit(function() {
$(this).find('input').attr('disabled', true);
$.ajax({
url: $(this).attr('action'),
method: $(this).attr('method'),
success: function(html) {
start($mod.html(html));
}
})
return false;
});
}
start($zone);
$zone.find('form.fide_title select').on('change', function() {
$(this).parent('form').submit();
});
lichess.pubsub.emit('content_loaded')();
var $modLog = $zone.find('.mod_log ul').children();
if ($modLog.length > 20) {
@ -49,8 +64,8 @@ $zone.find('li.ip').slice(0, 2).each(function() {
tablesort.extend('number', function(item) {
return item.match(/^-?[£\x24Û¢´€]?\d+\s*([,\.]\d{0,2})/) || // Prefixed currency
item.match(/^-?\d+\s*([,\.]\d{0,2})?[£\x24Û¢´€]/) || // Suffixed currency
item.match(/^-?(\d)*-?([,\.]){0,1}-?(\d)+([E,e][\-+][\d]+)?%?$/); // Number
item.match(/^-?\d+\s*([,\.]\d{0,2})?[£\x24Û¢´€]/) || // Suffixed currency
item.match(/^-?(\d)*-?([,\.]){0,1}-?(\d)+([E,e][\-+][\d]+)?%?$/); // Number
}, function(a, b) {
a = cleanNumber(a);
b = cleanNumber(b);