Index: HTML/EN/html/settings.js =================================================================== --- HTML/EN/html/settings.js (revision 12258) +++ HTML/EN/html/settings.js (working copy) @@ -33,20 +33,28 @@ case "HOME": url = "[% webroot %]home.html?" break - case "BASIC_PLAYER_SETTINGS": - url = "[% webroot %]setup.html?page=BASIC_PLAYER_SETTINGS&playerid=[% playerid | uri %]" - break - case "BASIC_SERVER_SETTINGS": - url = "[% webroot %]setup.html?page=BASIC_SERVER_SETTINGS&" - break } if (option) { - window.location = url + 'player=[% playerURI %][% IF playerid %]&playerid=[% playerid | uri %][% END %]'; + // change the mouse cursor so user gets some feedback + $('settingsForm').setStyle({cursor:'wait'}); + new Ajax.Updater( { success: 'settingsRegion' }, url, { + method: 'post', + postBody: 'ajaxUpdate=1&player=[% playerURI %][% IF playerid %]&playerid=[% playerid | uri %][% END %]', + evalScripts: true, + asynchronous: true, + onFailure: function(t) { + alert('Error -- ' + t.responseText); + }, + onComplete: function(t) { + $('settingsForm').setStyle({cursor:'auto'}); + $('statusarea').update(''); + } + } ); + document.forms.settingsForm.action = url; } } -var validateAll = true; function prefValidate(myPref, sync) { new Ajax.Request('/jsonrpc.js', { method: 'post', @@ -72,7 +80,6 @@ // preference did not validate - highlight the field if (json.result.valid == '0') { myPref.style.background = '#ffcccc'; - validateAll = false; } else { new Effect.Highlight(myPref.name, { @@ -107,9 +114,9 @@ new Event.observe(window, 'load', function(){ // add event handlers to all fields which have a validator - [%- FOREACH item = validate %] - new Event.observe('[% item %]', 'blur', function(){ prefValidate($('[% item %]')); } ); - [%- END %] + [%- FOREACH pref = validate; IF pref.value %] + new Event.observe('[% pref.key %]', 'blur', function(){ prefValidate($('[% pref.key %]')); } ); + [%- END; END %] // try to redirect all form submissions by return key to the default submit button // listen for keypress events on all form elements except submit @@ -129,15 +136,36 @@ new Event.observe(window, 'resize', function(){resizeSettingsSection();}); new Event.observe('saveSettings', 'click', function(e){ - [%- FOREACH item = validate %] - prefValidate($('[% item %]'), true); - [%- END %] + $('settingsForm').setStyle({cursor:'wait'}); + Event.stop(e); + $('settingsForm').request({ + parameters: { useAJAX: 1, rescan: '' }, + onComplete: function(response) { + var results = parseData(response.responseText); - // if validation fails and user doesn't force the submit, cancel - if (!validateAll && !confirm("[% "SETUP_VALIDATION_FAILED" | string %]")) { - Event.stop(e); - validateAll = true; - } + $('statusarea').update(results['warning']); + resizeSettingsSection(); + + // highlighted fields + for (field in results) { + if ($(field)) { + if (results[field] == '0') { + $(field).style.background = '#ffcccc'; + } + else { + new Effect.Highlight(field, { + duration: 0.5, + startcolor: '#99ff99', + endcolor: '#ffffff', + restorecolor: '#ffffff' + }); + } + } + } + + $('settingsForm').setStyle({cursor:'auto'}); + } + }); }); resizeSettingsSection(); Index: HTML/EN/settings/footer.html =================================================================== --- HTML/EN/settings/footer.html (revision 12258) +++ HTML/EN/settings/footer.html (working copy) @@ -20,6 +20,7 @@ +[% IF NOT ajaxUpdate %]