fixes ysod overlay for ajax errors

This commit is contained in:
Shannon
2014-04-24 14:23:17 +10:00
parent c32cae16db
commit 12170fd787
3 changed files with 37 additions and 2 deletions

View File

@@ -256,7 +256,21 @@
contentType: 'application/json; charset=utf-8',
error: function (x, t, e) {
if (x.status.toString().startsWith("500")) {
$u.Sys.ApiMgr.getApp().handleAjaxException(x, t, e);
//show ysod overlay if we can
if (UmbClientMgr) {
var startIndex = x.responseText.indexOf("<body");
var endIndex = x.responseText.lastIndexOf("</body>");
var body = x.responseText.substring(startIndex, endIndex + 7);
var $div = $(body.replace("<body bgcolor=\"white\">", "<div style='display:none;overflow:auto;height:613px;'>").replace("</body>", "</div>"));
$div.appendTo($(UmbClientMgr.mainWindow().document.getElementsByTagName("body")[0]));
UmbClientMgr.openModalWindowForContent($div, "ysod", true, 640, 640, null, null, null, function() {
//remove the $div
$div.closest(".umbModalBox").remove();
});
}
else {
alert("Unhandled exception occurred.\nStatus: " + x.status + "\nMessage: " + x.statusText + "\n\n" + x.responseText);
}
}
}
});

View File

@@ -175,6 +175,26 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
}
}
},
openModalWindowForContent: function (jQueryElement, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) {
//need to create the modal on the top window if the top window has a client manager, if not, create it on the current window
//if this is the top window, or if the top window doesn't have a client manager, create the modal in this manager
if (window == this.mainWindow() || !this.mainWindow().UmbClientMgr) {
var m = new Umbraco.Controls.ModalWindow();
this._modal.push(m);
m.show(jQueryElement, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback);
}
else {
//if the main window has a client manager, then call the main window's open modal method whilst keeping the context of it's manager.
if (this.mainWindow().UmbClientMgr) {
this.mainWindow().UmbClientMgr.openModalWindowForContent.apply(this.mainWindow().UmbClientMgr,
[jQueryElement, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback]);
}
else {
return; //exit recurse.
}
}
},
closeModalWindow: function(rVal) {
/// <summary>
/// will close the latest open modal window.

View File

@@ -118,6 +118,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
/// The callback will receive one parameter with 2 properties:
/// modalContent = the jQuery object for the popup window to query against
/// outVal = the value passed to the close window method that was used to close the window (if it was specified)
/// </param>
/// <returns>The generated jquery object bound to the modal window</returns>
@@ -355,7 +356,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
$.fn.jqmAddClose = function(e) { return hs(this, e, 'jqmHide'); };
$.fn.jqmAddTrigger = function(e) { return hs(this, e, 'jqmShow'); };
$.fn.jqmShow = function(t) { return this.each(function() { $.jqm.open(this._jqm, t); }); };
$.fn.jqmHide = function(t) { return this.each(function() { $.jqm.close(this._jqm, t) }); };
$.fn.jqmHide = function(t) { return this.each(function() { $.jqm.close(this._jqm, t); }); };
$.jqm = {
hash: {},