Fix adding event listener using jQuery
This commit is contained in:
parent
21011ef277
commit
07110d2580
|
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$('#private').on('ifToggled', function () {
|
$('body')
|
||||||
$(this).prop('checked') ? $('#msg').show() : $('#msg').hide();
|
.on('change', '#file', () => handleFiles())
|
||||||
});
|
.on('ifToggled', '#type-cape', () => {
|
||||||
|
MSP.clear();
|
||||||
$('#type-skin').on('ifToggled', function () {
|
handleFiles();
|
||||||
$(this).prop('checked') ? $('#skin-type').show() : $('#skin-type').hide();
|
})
|
||||||
});
|
.on('ifToggled', '#type-skin', function () {
|
||||||
|
$(this).prop('checked') ? $('#skin-type').show() : $('#skin-type').hide();
|
||||||
$('body').on('change', '#file', () => handleFiles()).on('ifToggled', '#type-cape', () => {
|
})
|
||||||
MSP.clear();
|
.on('ifToggled', '#private', function () {
|
||||||
handleFiles();
|
$(this).prop('checked') ? $('#msg').show() : $('#msg').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Real-time preview
|
// Real-time preview
|
||||||
function handleFiles(files, type) {
|
function handleFiles(files, type) {
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,17 @@ $('body').on('click', '.player', function () {
|
||||||
$(this).addClass('player-selected');
|
$(this).addClass('player-selected');
|
||||||
|
|
||||||
showPlayerTexturePreview(this.id);
|
showPlayerTexturePreview(this.id);
|
||||||
});
|
}).on('click', '#preview-switch', () => {
|
||||||
|
|
||||||
$('body').on('click', '#preview-switch', () => {
|
|
||||||
TexturePreview.previewType == '3D' ? TexturePreview.show2dPreview() : TexturePreview.show3dPreview();
|
TexturePreview.previewType == '3D' ? TexturePreview.show2dPreview() : TexturePreview.show3dPreview();
|
||||||
|
}).on('change', '#preference', function () {
|
||||||
|
fetch({
|
||||||
|
type: 'POST',
|
||||||
|
url: url('user/player/preference'),
|
||||||
|
dataType: 'json',
|
||||||
|
data: { pid: $(this).attr('pid'), preference: $(this).val() }
|
||||||
|
}).then(({ errno, msg }) => {
|
||||||
|
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
|
||||||
|
}).catch(err => showAjaxError(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
function showPlayerTexturePreview(pid) {
|
function showPlayerTexturePreview(pid) {
|
||||||
|
|
@ -44,17 +51,6 @@ function showPlayerTexturePreview(pid) {
|
||||||
}).catch(err => showAjaxError(err));
|
}).catch(err => showAjaxError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('body').on('change', '#preference', function () {
|
|
||||||
fetch({
|
|
||||||
type: 'POST',
|
|
||||||
url: url('user/player/preference'),
|
|
||||||
dataType: 'json',
|
|
||||||
data: { pid: $(this).attr('pid'), preference: $(this).val() }
|
|
||||||
}).then(({ errno, msg }) => {
|
|
||||||
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
|
|
||||||
}).catch(err => showAjaxError(err));
|
|
||||||
});
|
|
||||||
|
|
||||||
function changePlayerName(pid) {
|
function changePlayerName(pid) {
|
||||||
let newPlayerName = '';
|
let newPlayerName = '';
|
||||||
const $playerName = $(`td:contains("${pid}")`).next();
|
const $playerName = $(`td:contains("${pid}")`).next();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user