blockUI.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. // or see http://www.gnu.org/
  16. //
  17. //
  18. // \file htdocs/core/js/blockUI.js
  19. // \brief File that include javascript functions for blockUI default options
  20. //
  21. // Examples
  22. $(document).ready(function() {
  23. // override these in your code to change the default behavior and style
  24. $.blockUI.events = {
  25. // styles applied when using $.growlUI
  26. dolEventValidCSS: {
  27. width: '350px',
  28. top: '10px',
  29. left: '',
  30. right: '10px',
  31. border: 'none',
  32. padding: '5px',
  33. opacity: 0.8,
  34. cursor: 'default',
  35. color: '#fff',
  36. backgroundColor: '#e3f0db',
  37. '-webkit-border-radius': '10px',
  38. '-moz-border-radius': '10px',
  39. 'border-radius': '10px'
  40. },
  41. // styles applied when using $.growlUI
  42. dolEventErrorCSS: {
  43. width: '350px',
  44. top: '10px',
  45. left: '',
  46. right: '10px',
  47. border: 'none',
  48. padding: '5px',
  49. opacity: 0.8,
  50. cursor: 'default',
  51. color: '#a72947',
  52. backgroundColor: '#d79eac',
  53. '-webkit-border-radius': '10px',
  54. '-moz-border-radius': '10px',
  55. 'border-radius': '10px'
  56. }
  57. };
  58. $.dolEventValid = function(title, message, timeout, onClose) {
  59. var $m = $('<div class="dolEventValid"></div>');
  60. if (title) $m.append('<h1>'+title+'</h1>');
  61. if (message) $m.append('<h2>'+message+'</h2>');
  62. if (timeout == undefined) timeout = 3000;
  63. $.blockUI({
  64. message: $m, fadeIn: 200, fadeOut: 700, centerY: false,
  65. timeout: timeout, showOverlay: false,
  66. onUnblock: onClose,
  67. css: $.blockUI.events.dolEventValidCSS
  68. });
  69. };
  70. $.dolEventError = function(title, message, timeout, onClose) {
  71. var $m = $('<div class="dolEventError"></div>');
  72. if (title) $m.append('<h1>'+title+'</h1>');
  73. if (message) $m.append('<h2>'+message+'</h2>');
  74. if (timeout == undefined) timeout = 0;
  75. $.blockUI({
  76. message: $m, fadeIn: 200, centerY: false,
  77. timeout: timeout, showOverlay: false,
  78. onUnblock: onClose,
  79. css: $.blockUI.events.dolEventErrorCSS
  80. });
  81. $('.dolEventError').click($.unblockUI);
  82. };
  83. $.pleaseBePatient = function(message) {
  84. $.blockUI({
  85. message: message,
  86. css: {
  87. border: 'none',
  88. padding: '15px',
  89. background: '#000 url(' + indicatorBlockUI + ') no-repeat 10px center',
  90. '-webkit-border-radius': '10px',
  91. '-moz-border-radius': '10px',
  92. 'border-radius': '10px',
  93. opacity: .5,
  94. color: '#fff'
  95. }
  96. });
  97. }
  98. });