EasyUI.Config.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //easyui 全局默认加载错误处理
  2. var easyuiErrorFunction = function (event, XMLHttpRequest, settings) {
  3. $.messager.progress('close');
  4. var reponseText = "";
  5. if ($(event.responseText)) {
  6. for (var i = 0; i < $(event.responseText).length; i++) {
  7. if ($(event.responseText)[i] && $(event.responseText)[i].innerText) {
  8. var item = $(event.responseText)[i];
  9. if (item.innerText.indexOf("HandleResult") != -1 && item.innerText.indexOf("DetailError") != -1) {
  10. var str = item.innerText;
  11. reponseText = str.substr(str.indexOf("{"));
  12. reponseText = reponseText.substr(0, reponseText.indexOf("}") + 1);
  13. break;
  14. }
  15. }
  16. }
  17. }
  18. var errorObj = $.parseJSON(reponseText);
  19. $.exceptionThrow(errorObj, null);
  20. // if ($(event.responseText) && $(event.responseText)[1] && $(event.responseText)[1].innerHTML) {
  21. // var errorObj = $.parseJSON($(event.responseText)[1].innerHTML);
  22. // $.exceptionThrow(errorObj, null);
  23. // }
  24. };
  25. $.fn.datagrid.defaults.onLoadError = easyuiErrorFunction;
  26. $.fn.treegrid.defaults.onLoadError = easyuiErrorFunction;
  27. $.fn.tree.defaults.onLoadError = easyuiErrorFunction;
  28. $.fn.combogrid.defaults.onLoadError = easyuiErrorFunction;
  29. $.fn.combobox.defaults.onLoadError = easyuiErrorFunction;
  30. $.fn.form.defaults.onLoadError = easyuiErrorFunction;
  31. $.fn.panel.defaults.loadingMessage = '加载中...';
  32. $.fn.datagrid.defaults.loadMsg = '加载中...';
  33. $.fn.window.defaults.shadow = false;
  34. //$.fn.window.defaults.modal = false;
  35. var easyuiPanelOnMove = function (left, top) {
  36. var l = left;
  37. var t = top;
  38. if (l < 1) {
  39. l = 1;
  40. }
  41. if (t < 1) {
  42. t = 1;
  43. }
  44. var width = parseInt($(this).parent().css('width')) + 14;
  45. var height = parseInt($(this).parent().css('height')) + 14;
  46. var right = l + width;
  47. var buttom = t + height;
  48. var browserWidth = $(window).width();
  49. var browserHeight = $(window).height();
  50. if (right > browserWidth) {
  51. l = browserWidth - width;
  52. }
  53. if (buttom > browserHeight) {
  54. t = browserHeight - height;
  55. }
  56. $(this).parent().css({/* 修正面板位置 */
  57. left: l,
  58. top: t
  59. });
  60. };
  61. $.fn.dialog.defaults.onMove = easyuiPanelOnMove;
  62. $.fn.window.defaults.onMove = easyuiPanelOnMove;
  63. //$.fn.panel.defaults.onMove = easyuiPanelOnMove;
  64. //panel关闭时回收内存,主要用于layout使用iframe嵌入网页时的内存泄漏问题
  65. $.fn.panel.defaults.onBeforeDestroy = function () {
  66. var frame = $('iframe', this);
  67. try {
  68. if (frame.length > 0) {
  69. for (var i = 0; i < frame.length; i++) {
  70. try {
  71. $(frame[i].contentWindow.document).find("div.easyui-AttachmentUploader").AttachmentUploader("destroy");
  72. } catch (ignore) { }
  73. frame[i].contentWindow.document.write('');
  74. frame[i].contentWindow.close();
  75. }
  76. frame.remove();
  77. if ($.browser.msie) {
  78. CollectGarbage();
  79. }
  80. }
  81. } catch (e) {
  82. }
  83. };