edit.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. $(document).ready(function() {
  2. if ($("#goto_null").is(":checked")) {
  3. $('#textarea_alias_goto').prop('disabled', true);
  4. }
  5. $("#goto_null").click(function( event ) {
  6. if ($("#goto_null").is(":checked")) {
  7. $('#textarea_alias_goto').prop('disabled', true);
  8. }
  9. else {
  10. $("#textarea_alias_goto").removeAttr('disabled');
  11. }
  12. });
  13. $("#script_data").numberedtextarea({allowTabChar: true});
  14. });
  15. if ($("#multiple_bookings_select").val() == "custom") {
  16. $("#multiple_bookings_custom_div").show();
  17. $("#multiple_bookings").val($("#multiple_bookings_custom").val());
  18. }
  19. $("#multiple_bookings_select").change(function() {
  20. $("#multiple_bookings").val($("#multiple_bookings_select").val());
  21. if ($("#multiple_bookings").val() == "custom") {
  22. $("#multiple_bookings_custom_div").show();
  23. }
  24. else {
  25. $("#multiple_bookings_custom_div").hide();
  26. }
  27. });
  28. $("#multiple_bookings_custom").bind("change keypress keyup blur", function() {
  29. $("#multiple_bookings").val($("#multiple_bookings_custom").val());
  30. });
  31. jQuery(function($){
  32. // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
  33. function validateEmail(email) {
  34. var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  35. return re.test(email);
  36. }
  37. function draw_wl_policy_domain_table() {
  38. ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_domain_table', {
  39. "columns": [
  40. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
  41. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  42. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  43. {"name":"object","title":"Scope"}
  44. ],
  45. "empty": lang.empty,
  46. "rows": $.ajax({
  47. dataType: 'json',
  48. url: '/api/v1/get/policy_wl_domain/' + table_for_domain,
  49. jsonp: false,
  50. error: function () {
  51. console.log('Cannot draw mailbox policy wl table');
  52. },
  53. success: function (data) {
  54. $.each(data, function (i, item) {
  55. if (!validateEmail(item.object)) {
  56. item.chkbox = '<input type="checkbox" data-id="policy_wl_domain" name="multi_select" value="' + item.prefid + '" />';
  57. }
  58. else {
  59. item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
  60. }
  61. });
  62. }
  63. }),
  64. "paging": {
  65. "enabled": true,
  66. "limit": 5,
  67. "size": pagination_size
  68. },
  69. "sorting": {
  70. "enabled": true
  71. }
  72. });
  73. }
  74. function draw_bl_policy_domain_table() {
  75. ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_domain_table', {
  76. "columns": [
  77. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
  78. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  79. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  80. {"name":"object","title":"Scope"}
  81. ],
  82. "empty": lang.empty,
  83. "rows": $.ajax({
  84. dataType: 'json',
  85. url: '/api/v1/get/policy_bl_domain/' + table_for_domain,
  86. jsonp: false,
  87. error: function () {
  88. console.log('Cannot draw mailbox policy bl table');
  89. },
  90. success: function (data) {
  91. $.each(data, function (i, item) {
  92. if (!validateEmail(item.object)) {
  93. item.chkbox = '<input type="checkbox" data-id="policy_bl_domain" name="multi_select" value="' + item.prefid + '" />';
  94. }
  95. else {
  96. item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
  97. }
  98. });
  99. }
  100. }),
  101. "paging": {
  102. "enabled": true,
  103. "limit": 5,
  104. "size": pagination_size
  105. },
  106. "sorting": {
  107. "enabled": true
  108. }
  109. });
  110. }
  111. draw_wl_policy_domain_table();
  112. draw_bl_policy_domain_table();
  113. });