Improve AJAX exception handling in main dimp screen
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 04:56:01 +0000 (21:56 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 04:56:01 +0000 (21:56 -0700)
imp/js/DimpBase.js
imp/templates/javascript_defs_dimp.php

index e30bb29..451d5f7 100644 (file)
@@ -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));
index 7db58a6..69c4edf 100644 (file)
@@ -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"),