custom.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. $(document).ready(function() {
  2. $.fn.editable.defaults.mode = 'inline';
  3. $.fn.editableform.buttons =
  4. '<button type="submit" class="btn btn-primary btn-sm editable-submit">'+
  5. '<i class="fa fa-fw fa-check"></i>'+
  6. '</button>'+
  7. '<button type="button" class="btn btn-default btn-sm editable-cancel">'+
  8. '<i class="fa fa-fw fa-times"></i>'+
  9. '</button>';
  10. $('.editable-element-text').editable({
  11. escape: false,
  12. success: function(response, newValue) {
  13. console.log(response); // Debug output from ajax.php
  14. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  15. },
  16. error: function (xhr, status, error) {
  17. //var err = eval("(" + xhr.responseText + ")");
  18. return xhr.statusText;
  19. },
  20. params: function(params) {
  21. params.action = 'updateMailaccounts';
  22. return params;
  23. }
  24. });
  25. $('.editable-element-select-protocol').editable({
  26. defaultValue: 'imap',
  27. source: [
  28. {value: 'imap', text: 'IMAP'},
  29. {value: 'pop3', text: 'POP3'}
  30. ],
  31. success: function(response, newValue) {
  32. console.log(response); // Debug output from ajax.php
  33. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  34. },
  35. error: function (xhr, status, error) {
  36. //var err = eval("(" + xhr.responseText + ")");
  37. return xhr.statusText;
  38. },
  39. params: function(params) {
  40. params.action = 'updateMailaccounts';
  41. return params;
  42. }
  43. });
  44. $('.editable-element-select-use-ssl').editable({
  45. defaultValue: '1',
  46. source: [
  47. {value: '1', text: 'On'},
  48. {value: '0', text: 'Off'}
  49. ],
  50. success: function(response, newValue) {
  51. console.log(response); // Debug output from ajax.php
  52. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  53. },
  54. error: function (xhr, status, error) {
  55. //var err = eval("(" + xhr.responseText + ")");
  56. return xhr.statusText;
  57. },
  58. params: function(params) {
  59. params.action = 'updateMailaccounts';
  60. return params;
  61. }
  62. });
  63. $('.editable-element-select-no-valid-cert').editable({
  64. defaultValue: '0',
  65. source: [
  66. {value: '0', text: 'On'},
  67. {value: '1', text: 'Off'}
  68. ],
  69. success: function(response, newValue) {
  70. console.log(response); // Debug output from ajax.php
  71. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  72. },
  73. error: function (xhr, status, error) {
  74. //var err = eval("(" + xhr.responseText + ")");
  75. return xhr.statusText;
  76. },
  77. params: function(params) {
  78. params.action = 'updateMailaccounts';
  79. return params;
  80. }
  81. });
  82. $('#add-mailaccount').on('click', function(e) {
  83. e.preventDefault();
  84. var uId = $(this).attr('data-uid');
  85. $.ajax({
  86. url: 'ajax.php',
  87. type: 'POST',
  88. data: {'action': 'addDefaultMailaccount', 'user-id': uId},
  89. success: function (result) {
  90. console.log(result);
  91. location.reload();
  92. }
  93. });
  94. });
  95. $('.remove-mailaccount').on('click', function(e) {
  96. e.preventDefault();
  97. var id = $(this).attr('data-id');
  98. $.ajax({
  99. url: 'ajax.php',
  100. type: 'POST',
  101. data: {'action': 'removeMailaccount', 'id': id},
  102. success: function (result) {
  103. console.log(result);
  104. location.reload();
  105. }
  106. });
  107. });
  108. });