//easyui 全局默认加载错误处理 var easyuiErrorFunction = function (event, XMLHttpRequest, settings) { $.messager.progress('close'); var reponseText = ""; if ($(event.responseText)) { for (var i = 0; i < $(event.responseText).length; i++) { if ($(event.responseText)[i] && $(event.responseText)[i].innerText) { var item = $(event.responseText)[i]; if (item.innerText.indexOf("HandleResult") != -1 && item.innerText.indexOf("DetailError") != -1) { var str = item.innerText; reponseText = str.substr(str.indexOf("{")); reponseText = reponseText.substr(0, reponseText.indexOf("}") + 1); break; } } } } var errorObj = $.parseJSON(reponseText); $.exceptionThrow(errorObj, null); // if ($(event.responseText) && $(event.responseText)[1] && $(event.responseText)[1].innerHTML) { // var errorObj = $.parseJSON($(event.responseText)[1].innerHTML); // $.exceptionThrow(errorObj, null); // } }; $.fn.datagrid.defaults.onLoadError = easyuiErrorFunction; $.fn.treegrid.defaults.onLoadError = easyuiErrorFunction; $.fn.tree.defaults.onLoadError = easyuiErrorFunction; $.fn.combogrid.defaults.onLoadError = easyuiErrorFunction; $.fn.combobox.defaults.onLoadError = easyuiErrorFunction; $.fn.form.defaults.onLoadError = easyuiErrorFunction; $.fn.panel.defaults.loadingMessage = '加载中...'; $.fn.datagrid.defaults.loadMsg = '加载中...'; $.fn.window.defaults.shadow = false; //$.fn.window.defaults.modal = false; var easyuiPanelOnMove = function (left, top) { var l = left; var t = top; if (l < 1) { l = 1; } if (t < 1) { t = 1; } var width = parseInt($(this).parent().css('width')) + 14; var height = parseInt($(this).parent().css('height')) + 14; var right = l + width; var buttom = t + height; var browserWidth = $(window).width(); var browserHeight = $(window).height(); if (right > browserWidth) { l = browserWidth - width; } if (buttom > browserHeight) { t = browserHeight - height; } $(this).parent().css({/* 修正面板位置 */ left: l, top: t }); }; $.fn.dialog.defaults.onMove = easyuiPanelOnMove; $.fn.window.defaults.onMove = easyuiPanelOnMove; //$.fn.panel.defaults.onMove = easyuiPanelOnMove; //panel关闭时回收内存,主要用于layout使用iframe嵌入网页时的内存泄漏问题 $.fn.panel.defaults.onBeforeDestroy = function () { var frame = $('iframe', this); try { if (frame.length > 0) { for (var i = 0; i < frame.length; i++) { try { $(frame[i].contentWindow.document).find("div.easyui-AttachmentUploader").AttachmentUploader("destroy"); } catch (ignore) { } frame[i].contentWindow.document.write(''); frame[i].contentWindow.close(); } frame.remove(); if ($.browser.msie) { CollectGarbage(); } } } catch (e) { } };