From 6366fac6254efdb8580ef71e29f6100a16123a73 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 22 Dec 2009 21:56:01 -0700 Subject: [PATCH] Improve AJAX exception handling in main dimp screen --- imp/js/DimpBase.js | 13 +++++++++++++ imp/templates/javascript_defs_dimp.php | 1 + 2 files changed, 14 insertions(+) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index e30bb297d..451d5f760 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -2926,6 +2926,16 @@ var DimpBase = { if (DimpCore.is_ie6) { this._resizeIE6(); } + }, + + /* Extend AJAX exception handling. */ + onAjaxException: function(parentfunc, r, e) + { + /* Make sure loading images are closed. */ + this.loadingImg('msg', false); + this.loadingImg('viewport', false); + DimpCore.showNotifications([ { type: 'horde.error', message: DIMP.text.ajax_error } ]); + parentfunc(r, e); } }; @@ -3048,5 +3058,8 @@ DimpCore.clickHandler = DimpCore.clickHandler.wrap(DimpBase.clickHandler.bind(Di DimpCore.contextOnClick = DimpCore.contextOnClick.wrap(DimpBase.contextOnClick.bind(DimpBase)); DimpCore.contextOnShow = DimpCore.contextOnShow.wrap(DimpBase.contextOnShow.bind(DimpBase)); +/* Extend AJAX exception handling. */ +DimpCore.doActionOpts.onException = DimpCore.doActionOpts.onException.wrap(DimpBase.onAjaxException.bind(DimpBase)); + /* Initialize onload handler. */ document.observe('dom:loaded', DimpBase.onDomLoad.bind(DimpBase)); diff --git a/imp/templates/javascript_defs_dimp.php b/imp/templates/javascript_defs_dimp.php index 7db58a6e7..69c4edf15 100644 --- a/imp/templates/javascript_defs_dimp.php +++ b/imp/templates/javascript_defs_dimp.php @@ -115,6 +115,7 @@ $code['conf'] = array_filter(array( /* Gettext strings used in core javascript files. */ $code['text'] = array( + 'ajax_error' => _("Error when communicating with the server."), 'ajax_recover' => _("The connection to the server has been restored."), 'ajax_timeout' => _("There has been no contact with the server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored."), 'badaddr' => _("Invalid Address"), -- 2.11.0