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,6 +9,37 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
header.init(); header.init();
$('#submitBtn').on('click', function() { $('#submitBtn').on('click', function() {
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');
var val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css';
css.attr('href', val);
});
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
toggleCustomRoute();
components.get('user/sessions').find('.timeago').timeago();
prepareSessionRevoking();
};
function loadSettings() {
var settings = {}; var settings = {};
$('.account').find('input, textarea, select').each(function(id, input) { $('.account').find('input, textarea, select').each(function(id, input) {
@ -30,6 +61,10 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
} }
}); });
return settings;
}
function saveSettings(settings) {
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) { socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
@ -58,27 +93,9 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
}); });
} }
}); });
}
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';
css.attr('href', val);
});
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
toggleCustomRoute();
components.get('user/sessions').find('.timeago').timeago();
prepareSessionRevoking();
};
function toggleCustomRoute() { 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