custom.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. function fancyBoxLoader() {
  96. $.ajax({
  97. url: 'ajax.php',
  98. data: {'action': 'getMailAccountsByUid', 'uId': $('.manage-mailboxfolder').attr('data-uid')},
  99. type: 'GET',
  100. global: false,
  101. async: true,
  102. dataType: 'json',
  103. success: function(data) {
  104. result = data;
  105. $('.editable-element-select-mailaccount').editable({
  106. //defaultValue: '0',
  107. source: result,
  108. success: function(response, newValue) {
  109. console.log(response); // Debug output from ajax.php
  110. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  111. },
  112. error: function (xhr, status, error) {
  113. //var err = eval("(" + xhr.responseText + ")");
  114. return xhr.statusText;
  115. },
  116. params: function(params) {
  117. params.action = 'updateMailfolder';
  118. return params;
  119. }
  120. });
  121. }
  122. });
  123. $('.editable-element-text').editable({
  124. escape: false,
  125. success: function(response, newValue) {
  126. console.log(response); // Debug output from ajax.php
  127. if(response.status == 'error') return response.msg; //msg will be shown in editable form
  128. },
  129. error: function (xhr, status, error) {
  130. //var err = eval("(" + xhr.responseText + ")");
  131. return xhr.statusText;
  132. },
  133. params: function(params) {
  134. params.action = 'updateMailfolder';
  135. return params;
  136. }
  137. });
  138. }
  139. $('.remove-mailaccount').on('click', function(e) {
  140. e.preventDefault();
  141. var id = $(this).attr('data-id');
  142. $.ajax({
  143. url: 'ajax.php',
  144. type: 'POST',
  145. data: {'action': 'removeMailaccount', 'id': id},
  146. success: function (result) {
  147. console.log(result);
  148. location.reload();
  149. }
  150. });
  151. });
  152. $('.remove-mailboxfolder').on('click', function(e) {
  153. e.preventDefault();
  154. var id = $(this).attr('data-id');
  155. $.ajax({
  156. url: 'ajax.php',
  157. type: 'POST',
  158. data: {'action': 'removeMailboxFolder', 'id': id},
  159. success: function (result) {
  160. console.log(result);
  161. location.reload();
  162. }
  163. });
  164. });
  165. $('.manage-mailboxfolder').on('click', function(e) {
  166. e.preventDefault();
  167. $.get($(this).attr('href'), function(r) {
  168. editBox = $.parseJSON(r);
  169. console.log(editBox);
  170. });
  171. });
  172. $('#add-mailboxfolder').on('click', function(e) {
  173. e.preventDefault();
  174. var uId = $(this).attr('data-uid');
  175. var lId = $(this).attr('data-lid');
  176. $.ajax({
  177. url: 'ajax.php',
  178. type: 'POST',
  179. data: {'action': 'addDefaultMailfolder', 'user-id': uId, 'label-id': lId},
  180. success: function (result) {
  181. console.log(result);
  182. location.reload();
  183. },
  184. error: function(result) {
  185. console.log(result);
  186. }
  187. });
  188. });
  189. $('#new-document').fancybox({
  190. beforeShow : fancyBoxLoader,
  191. maxWidth : 800,
  192. maxHeight : 600,
  193. fitToView : false,
  194. width : '50%',
  195. height : '70%',
  196. autoSize : false,
  197. closeClick : false,
  198. openEffect : 'none',
  199. closeEffect : 'none'
  200. });
  201. });