v1.18.x
barisusakli 9 years ago
parent c042d16f40
commit 910e94a690

@ -148,5 +148,6 @@
"not-in-room": "User not in room", "not-in-room": "User not in room",
"no-users-in-room": "No users in this room", "no-users-in-room": "No users in this room",
"cant-kick-self": "You can't kick yourself from the group", "cant-kick-self": "You can't kick yourself from the group",
"no-users-selected": "No user(s) selected" "no-users-selected": "No user(s) selected",
"invalid-home-page-route": "Invalid home page route"
} }

@ -9,62 +9,24 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
header.init(); header.init();
$('#submitBtn').on('click', function() { $('#submitBtn').on('click', function() {
var settings = {}; var settings = loadSettings();
$('.account').find('input, textarea, select').each(function(id, input) { if (settings.homePageRoute === 'custom' && settings.homePageCustom) {
input = $(input); $.get(config.relative_path + '/' + settings.homePageCustom, function() {
var setting = input.attr('data-property'); saveSettings(settings);
if (input.is('select')) { }).fail(function() {
settings[setting] = input.val(); app.alertError('[[error:invalid-home-page-route]]');
return; });
} } else {
saveSettings(settings);
switch (input.attr('type')) { }
case 'text':
case 'textarea':
settings[setting] = input.val();
break;
case 'checkbox':
settings[setting] = input.is(':checked') ? 1 : 0;
break;
}
});
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[success:settings-saved]]');
var requireReload = false;
for (var key in newSettings) {
if (newSettings.hasOwnProperty(key)) {
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
requireReload = true;
}
config[key] = newSettings[key];
}
}
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
app.alert({
id: 'setting-change',
message: '[[user:settings-require-reload]]',
type: 'warning',
timeout: 5000,
clickfn: function() {
ajaxify.refresh();
}
});
}
});
return false; return false;
}); });
$('#bootswatchSkin').on('change', function() { $('#bootswatchSkin').on('change', function() {
var css = $('#bootswatchCSS'), var css = $('#bootswatchCSS');
val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css'; var val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css';
css.attr('href', val); css.attr('href', val);
}); });
@ -77,8 +39,63 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
prepareSessionRevoking(); prepareSessionRevoking();
}; };
function toggleCustomRoute() { function loadSettings() {
var settings = {};
$('.account').find('input, textarea, select').each(function(id, input) {
input = $(input);
var setting = input.attr('data-property');
if (input.is('select')) {
settings[setting] = input.val();
return;
}
switch (input.attr('type')) {
case 'text':
case 'textarea':
settings[setting] = input.val();
break;
case 'checkbox':
settings[setting] = input.is(':checked') ? 1 : 0;
break;
}
});
return settings;
}
function saveSettings(settings) {
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[success:settings-saved]]');
var requireReload = false;
for (var key in newSettings) {
if (newSettings.hasOwnProperty(key)) {
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
requireReload = true;
}
config[key] = newSettings[key];
}
}
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
app.alert({
id: 'setting-change',
message: '[[user:settings-require-reload]]',
type: 'warning',
timeout: 5000,
clickfn: function() {
ajaxify.refresh();
}
});
}
});
}
function toggleCustomRoute() {
if ($('[data-property="homePageRoute"]').val() === 'custom') { if ($('[data-property="homePageRoute"]').val() === 'custom') {
$('#homePageCustom').show(); $('#homePageCustom').show();
} else { } else {
@ -89,8 +106,8 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
function prepareSessionRevoking() { function prepareSessionRevoking() {
components.get('user/sessions').on('click', '[data-action]', function() { components.get('user/sessions').on('click', '[data-action]', function() {
var parentEl = $(this).parents('[data-uuid]'), var parentEl = $(this).parents('[data-uuid]');
uuid = parentEl.attr('data-uuid'); var uuid = parentEl.attr('data-uuid');
if (uuid) { if (uuid) {
// This is done via DELETE because a user shouldn't be able to // This is done via DELETE because a user shouldn't be able to
@ -105,7 +122,7 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
parentEl.remove(); parentEl.remove();
}).fail(function(err) { }).fail(function(err) {
app.alertError(err.responseText); app.alertError(err.responseText);
}) });
} }
}); });
} }

Loading…
Cancel
Save