From: Michael M Slusarz Date: Wed, 1 Sep 2010 05:41:33 +0000 (-0600) Subject: Improved error handling if server sends back totally invalid response (e.g. 500 code) X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1ac099e1d83671aa9c790f431cab65e6660ae12b;p=horde.git Improved error handling if server sends back totally invalid response (e.g. 500 code) --- diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index f5be1f2d4..e8f05b223 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -191,7 +191,6 @@ var DimpCompose = { } } - c.setStyle({ cursor: 'wait' }); this.skip_spellcheck = false; if (action == 'addAttachment') { @@ -207,7 +206,12 @@ var DimpCompose = { // Use an AJAX submit here so that we can do javascript-y stuff // before having to close the window on success. - DimpCore.doAction(action, c.serialize(true), { callback: this.uniqueSubmitCallback.bind(this) }); + DimpCore.doAction(action, c.serialize(true), { + ajaxopts: { + onFailure: this.uniqueSubmitFailure.bind(this) + }, + callback: this.uniqueSubmitCallback.bind(this) + }); // Can't disable until we send the message - or else nothing // will get POST'ed. @@ -315,17 +319,26 @@ var DimpCompose = { } this.setDisabled(false); + }, - $((d.action == 'redirectMessage') ? 'redirect' : 'compose').setStyle({ cursor: null }); + uniqueSubmitFailure: function(t, o) + { + if (this.disabled) { + this.setDisabled(false); + DimpCore.doActionOpts.onFailure(t, o); + } }, setDisabled: function(disable) { + var redirect = $('redirect'); + this.disabled = disable; - if ($('redirect').visible()) { + if (redirect.visible()) { DimpCore.loadingImg('sendingImg', 'redirect', disable); - DimpCore.toggleButtons($('redirect').select('DIV.dimpActions A'), disable); + DimpCore.toggleButtons(redirect.select('DIV.dimpActions A'), disable); + redirect.setStyle({ cursor: disable ? null : 'wait' }); } else { DimpCore.loadingImg('sendingImg', 'composeMessageParent', disable); DimpCore.toggleButtons($('compose').select('DIV.dimpActions A'), disable); @@ -336,6 +349,8 @@ var DimpCompose = { if (IMP_Compose_Base.editor_on) { this.RTELoading(disable ? 'show' : 'hide', true); } + + $('compose').setStyle({ cursor: disable ? null : 'wait' }); } }, diff --git a/imp/js/dimpcore.js b/imp/js/dimpcore.js index 3c4b0b0d9..cf7ae940e 100644 --- a/imp/js/dimpcore.js +++ b/imp/js/dimpcore.js @@ -18,7 +18,10 @@ var DimpCore = { doActionOpts: { onException: function(r, e) { DimpCore.debug('onException', e); }, - onFailure: function(t, o) { DimpCore.debug('onFailure', t); }, + onFailure: function(t, o) { + DimpCore.debug('onFailure', t); + DimpCore.showNotifications([ { type: 'horde.error', message: DIMP.text.ajax_error } ]); + }, evalJS: false, evalJSON: true },