personal.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. $(document).ready(function(){
  7. $("#passwordbutton").click( function(){
  8. if ($('#pass1').val() != '' && $('#pass2').val() != '') {
  9. // Serialize the data
  10. var post = $( "#passwordform" ).serialize();
  11. $('#passwordchanged').hide();
  12. $('#passworderror').hide();
  13. // Ajax foo
  14. $.post( 'ajax/changepassword.php', post, function(data){
  15. if( data.status == "success" ){
  16. $('#pass1').val('');
  17. $('#pass2').val('');
  18. $('#passwordchanged').show();
  19. }
  20. else{
  21. $('#passworderror').html( data.data.message );
  22. $('#passworderror').show();
  23. }
  24. });
  25. return false;
  26. } else {
  27. $('#passwordchanged').hide();
  28. $('#passworderror').show();
  29. return false;
  30. }
  31. });
  32. $('#lostpassword #email').blur(function(event){
  33. if ($(this).val() == this.defaultValue){
  34. return;
  35. }
  36. event.preventDefault();
  37. this.defaultValue = $(this).val();
  38. OC.msg.startSaving('#lostpassword .msg');
  39. var post = $( "#lostpassword" ).serialize();
  40. $.post( 'ajax/lostpassword.php', post, function(data){
  41. OC.msg.finishedSaving('#lostpassword .msg', data);
  42. });
  43. });
  44. $("#languageinput").chosen();
  45. $("#languageinput").change( function(){
  46. // Serialize the data
  47. var post = $( "#languageinput" ).serialize();
  48. // Ajax foo
  49. $.post( 'ajax/setlanguage.php', post, function(data){
  50. if( data.status == "success" ){
  51. location.reload();
  52. }
  53. else{
  54. $('#passworderror').html( data.data.message );
  55. }
  56. });
  57. return false;
  58. });
  59. } );
  60. OC.msg={
  61. startSaving:function(selector){
  62. $(selector)
  63. .html( t('settings', 'Saving...') )
  64. .removeClass('success')
  65. .removeClass('error')
  66. .stop(true, true)
  67. .show();
  68. },
  69. finishedSaving:function(selector, data){
  70. if( data.status == "success" ){
  71. $(selector).html( data.data.message )
  72. .addClass('success')
  73. .stop(true, true)
  74. .delay(3000)
  75. .fadeOut(600);
  76. }else{
  77. $(selector).html( data.data.message ).addClass('error');
  78. }
  79. }
  80. };