You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

  1. /*
  2. * Copyright 2014 XWiki SAS
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Affero General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. require.config({
  18. 'shim': {
  19. '/bower_components/modalBox/modalBox-min.js': [
  20. '/bower_components/jquery/dist/jquery.min.js'
  21. ],
  22. }
  23. });
  24. define([
  25. '/common/messages.js',
  26. '/bower_components/modalBox/modalBox-min.js'
  27. ], function (Messages) {
  28. var STYLE = [
  29. '<style>',
  30. '.modalBox {',
  31. ' padding:5px;',
  32. ' border:1px solid #CCC;',
  33. ' background:#FFF;',
  34. ' height:500px;',
  35. ' width:700px;',
  36. ' display:none;',
  37. '}',
  38. 'img.iw-closeImg {',
  39. ' width:24px;',
  40. ' height:24px',
  41. '}',
  42. '.modalFooter {',
  43. ' color:#FFF;',
  44. ' position:absolute;',
  45. ' bottom:0px',
  46. '}',
  47. '.modalFooter span {',
  48. ' cursor:pointer;',
  49. '}',
  50. '.iw-modalOverlay {',
  51. ' background:#000;',
  52. ' opacity:.5',
  53. '}',
  54. '</style>'
  55. ].join('');
  56. var CONTENT = [
  57. '<center><h2 class="errorType"></h2></center>',
  58. '<br>',
  59. '<p class="errorExplanation"></p>'
  60. ].join('');
  61. var ERROR_ADDITIONAL = [
  62. '<p class="errorMoreExplanation"></p>',
  63. '<label for="errorBox_detailsBox" class="errorDetailsLabel"></label>',
  64. '<textarea id="errorBox_detailsBox" class="errorData"></textarea>',
  65. ].join('');
  66. var showError = function (errorType, docHtml, moreInfo) {
  67. $('body').append('<div class="modalBox"></div>');
  68. var $modalbox = $('.modalBox')
  69. $modalbox.append(CONTENT + STYLE);
  70. $modalbox.find('.errorType').text(Messages['errorBox_errorType_' + errorType]);
  71. $modalbox.find('.errorExplanation').text(Messages['errorBox_errorExplanation_' + errorType]);
  72. if (moreInfo) {
  73. $modalbox.append(ERROR_ADDITIONAL);
  74. $modalbox.find('.errorMoreExplanation').text(Messages.errorBox_moreExplanation);
  75. $modalbox.find('.errorData').text(Messages['errorBox_' + errorType]);
  76. }
  77. $modalbox.modalBox({
  78. onClose: function () { $('.modalBox').remove(); }
  79. });
  80. $('.iw-modalOverlay').css({'z-index':10000});
  81. };
  82. return {
  83. show: showError
  84. };
  85. });