From cd44dff5afc4fcaeaf905bd6da581077fb088c35 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sun, 11 Sep 2011 17:20:23 +0200 Subject: Better feedback for saving calendar and openid settings --- apps/calendar/js/settings.js | 8 ++------ apps/calendar/templates/settings.php | 2 +- apps/user_openid/js/settings.js | 14 ++------------ apps/user_openid/templates/settings.php | 2 +- settings/css/settings.css | 3 +++ settings/js/personal.js | 30 ++++++++++++++++++++++-------- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index b2da81b0d0f..90876389858 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -1,14 +1,10 @@ $(document).ready(function(){ $("#timezone").change( function(){ + OC.msg.startSaving('#calendar .msg') // Serialize the data var post = $( "#timezone" ).serialize(); - // Ajax foo $.post( oc_webroot + '/apps/calendar/ajax/settimezone.php', post, function(data){ - if( data.status == "success" ){ - } - else{ - $('#timezoneerror').html( data.data.message ); - } + OC.msg.finishedSaving('#calendar .msg', data); }); return false; }); diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index f0863b9cb7f..122f8a9bf93 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -31,6 +31,6 @@ echo ''; endif; endforeach;?> - + diff --git a/apps/user_openid/js/settings.js b/apps/user_openid/js/settings.js index cfecd7b1cb4..83170e6b844 100644 --- a/apps/user_openid/js/settings.js +++ b/apps/user_openid/js/settings.js @@ -1,20 +1,10 @@ $(document).ready(function(){ $('#openidform #identity').blur(function(event){ event.preventDefault(); + OC.msg.startSaving('#openidform .msg'); var post = $( "#openidform" ).serialize(); $.post( 'ajax/openid.php', post, function(data){ - if( data.status == "success" ){ - }else{ - alert('error while setting OpenID'); - } + OC.msg.finishedSaving('#openidform .msg', data); }); }); - - // reset value when edited, workaround because of .select() not working with disabled inputs - $('#openid').focus(function(event){ - openidValue = $('#openid').val(); - }); - $('#openid').blur(function(event){ - $('#openid').val(openidValue); - }); }); diff --git a/apps/user_openid/templates/settings.php b/apps/user_openid/templates/settings.php index ffcd10e0b99..7c742030ce3 100644 --- a/apps/user_openid/templates/settings.php +++ b/apps/user_openid/templates/settings.php @@ -3,6 +3,6 @@ OpenID
t('you can authenticate to other sites with this address');?>
- + diff --git a/settings/css/settings.css b/settings/css/settings.css index 429e96ddb9a..7cb29e487bc 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -5,6 +5,9 @@ input#openid, input#webdav { width:20em; } #passwordchanged { display:none; } input#identity { width:20em; } +.msg.success{ color:#fff; background-color:#0f0; padding:3px; text-shadow:1px 1px #000; } +.msg.error{ color:#fff; background-color:#f00; padding:3px; text-shadow:1px 1px #000; } + /* USERS */ form { display:inline; } diff --git a/settings/js/personal.js b/settings/js/personal.js index 65bb81b0f04..9578fb2c890 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -48,12 +48,26 @@ $(document).ready(function(){ }); return false; }); - - // reset value when edited, workaround because of .select() not working with disabled inputs - $('#webdav').focus(function(event){ - openidValue = $('#webdav').val(); - }); - $('#webdav').blur(function(event){ - $('#webdav').val(openidValue); - }); } ); + +OC.msg={ + startSaving:function(selector){ + $(selector) + .html( t('settings', 'Saving...') ) + .removeClass('success') + .removeClass('error') + .stop(true, true) + .show(); + }, + finishedSaving:function(selector, data){ + if( data.status == "success" ){ + $(selector).html( data.data.message ) + .addClass('success') + .stop(true, true) + .delay(3000) + .fadeOut(600); + }else{ + $(selector).html( data.data.message ).addClass('error'); + } + } +} -- cgit v1.2.3