Merge Ajax exception handler from DIMP.
authorJan Schneider <jan@horde.org>
Wed, 23 Dec 2009 14:24:22 +0000 (15:24 +0100)
committerJan Schneider <jan@horde.org>
Wed, 23 Dec 2009 14:24:22 +0000 (15:24 +0100)
kronolith/js/kronolith.js
kronolith/lib/Kronolith.php

index 352b35d..f1a2a33 100644 (file)
@@ -35,7 +35,7 @@ KronolithCore = {
     mapInitialized: false,
 
     doActionOpts: {
-        onException: function(r, e) { KronolithCore.debug('onException', e); },
+        onException: this.onAjaxException.bind(this),
         onFailure: function(t, o) { KronolithCore.debug('onFailure', t); },
         evalJS: false,
         evalJSON: true
@@ -3587,6 +3587,19 @@ KronolithCore = {
         }
     },
 
+    /* Extend AJAX exception handling. */
+    onAjaxException: function(parentfunc, r, e)
+    {
+        /* Make sure loading images are closed. */
+        this.loading--;
+        if (!this.loading) {
+                $('kronolithLoading').hide();
+        }
+        this._closeRedBox();
+        this.showNotifications([ { type: 'horde.error', message: Kronolith.text.ajax_error } ]);
+        KronolithCore.debug('onException', e);
+    }
+
     toggleCalendar: function(elm)
     {
         elm.toggleClassName('on');
index c741e0b..c92d170 100644 (file)
@@ -298,6 +298,7 @@ class Kronolith
 
         /* Gettext strings used in core javascript files. */
         $code['text'] = array(
+            'ajax_error' => _("Error when communicating with the server."),
             'ajax_timeout' => _("There has been no contact with the calendar 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."),
             'ajax_recover' => _("The connection to the calendar server has been restored."),
             'alarm' => _("Alarm:"),