Commit 7adb7d89 authored by Nigel McNie's avatar Nigel McNie
Browse files

Added javascript file to handle JS for site options page. Enforces reload of...

Added javascript file to handle JS for site options page. Enforces reload of the page if certain settings are changed. Fixes #718.
parent cf6087e4
/**
* Forces full reload of the page if certain site options have been changed
*
* Author: Nigel McNie
* Copyright: (C) 2008 Catalyst IT Ltd.
* Licensed under the GNU GPL 3.0 or later
*/
// Add here as appropriate
var forceReloadElements = ['sitename', 'lang', 'theme'];
var isReloadRequired = false;
// Disconnects the pieform submit handler and changes the form target back to
// the page itself (rather than pieform's hidden iframe), so a full post/reload
// cycle will happen when the form is submitted
function reloadRequired() {
isReloadRequired = true;
disconnectAll('siteoptions');
$('siteoptions').target = '';
}
// Wires up appropriate elements to cause a full page reload if they're changed
function connectElements() {
forEach(forceReloadElements, function(element) {
if ($('siteoptions_' + element)) {
connect('siteoptions_' + element, 'onchange', reloadRequired);
}
});
}
// Javascript success handler for the form. Re-wires up the elements
function checkReload(form, data) {
isReloadRequired = false;
connectElements();
formSuccess(form, data);
}
addLoadEvent(connectElements);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment