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

@ -148,5 +148,6 @@
"not-in-room": "User not in room",
"no-users-in-room": "No users in this room",
"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();
$('#submitBtn').on('click', function() {
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;
}
});
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();
}
});
}
});
var settings = loadSettings();
if (settings.homePageRoute === 'custom' && settings.homePageCustom) {
$.get(config.relative_path + '/' + settings.homePageCustom, function() {
saveSettings(settings);
}).fail(function() {
app.alertError('[[error:invalid-home-page-route]]');
});
} else {
saveSettings(settings);
}
return false;
});
$('#bootswatchSkin').on('change', function() {
var css = $('#bootswatchCSS'),
val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css';
var css = $('#bootswatchCSS');
var val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css';
css.attr('href', val);
});
@ -77,8 +39,63 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
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') {
$('#homePageCustom').show();
} else {
@ -89,8 +106,8 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
function prepareSessionRevoking() {
components.get('user/sessions').on('click', '[data-action]', function() {
var parentEl = $(this).parents('[data-uuid]'),
uuid = parentEl.attr('data-uuid');
var parentEl = $(this).parents('[data-uuid]');
var uuid = parentEl.attr('data-uuid');
if (uuid) {
// 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();
}).fail(function(err) {
app.alertError(err.responseText);
})
});
}
});
}

Loading…
Cancel
Save