Begin checking for errors, messages, session time out etc...
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Nov 2010 05:35:24 +0000 (00:35 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Nov 2010 05:35:24 +0000 (00:35 -0500)
kronolith/js/mobile.js
kronolith/mobile.php
kronolith/templates/mobile/notice.html.php [new file with mode: 0644]

index 25ebcdb..5545423 100644 (file)
@@ -41,6 +41,8 @@
      */
     date: null,
 
+    serverError: 0,
+
     /**
      * Perform an Ajax action
      *
      */
     doAction: function(action, params, callback)
     {
-        $.post(Kronolith.conf.URI_AJAX + action, params, callback, 'json');
+        var options = {
+            'url': Kronolith.conf.URI_AJAX + action,
+            'data': params,
+            'error': KronolithMobile.errorCallback,
+            'success': function(d, t, x) { KronolithMobile.doActionComplete(d, callback); },
+            'type': 'post'
+        };
+        $.ajax(options);
+    },
+
+    doActionComplete: function(d, callback)
+    {
+        var r = d.response;
+        if (r && $.isFunction(callback)) {
+          callback(r);
+        }
+
+        KronolithMobile.server_error = 0;
+        KronolithMobile.showNotifications(d.msgs || []);
+        KronolithMobile.inAjaxCallback = false;
+    },
+
+    showNotifications: function(m)
+    {
+        $.each(m, function(key, msg) {
+            if (msg.type == 'horde.ajaxtimeout') {
+                KronolithMobile.logout(msg.message);
+            }
+        });
+    },
+
+    logout: function(url)
+    {
+        KronolithMobile.is_logout = true;
+        window.location = (url || (Kronolith.conf.URI_AJAX + 'logOut'));
+    },
+
+    errorCallback: function(x, t, e)
+    {
+
     },
 
     /**
      */
     loadEventsCallback: function(data)
     {
-        var start = KronolithMobile.parseDate(data.response.sig.substr(0, 8)),
-            end = KronolithMobile.parseDate(data.response.sig.substr(8, 8)),
-            dates = [start, end], view = data.response.view, list, events;
+        var start = KronolithMobile.parseDate(data.sig.substr(0, 8)),
+            end = KronolithMobile.parseDate(data.sig.substr(8, 8)),
+            dates = [start, end], view = data.view, list, events;
 
-        data = data.response;
         KronolithMobile.storeCache(data.events, data.cal, dates, true);
         KronolithMobile.loadedCalendars.push(data.cal);
         KronolithMobile.insertEvents(dates, view, data.cal);
      */
     loadEventCallback: function(data)
     {
-         if (!data.response.event) {
+         if (!data.event) {
              // @TODO: Error handling.
              return;
          }
 
-         var event = data.response.event;
+         var event = data.event;
          var ul = KronolithMobile.buildEventView(event);
          $('#eventview [data-role=content]').append(ul);
     },
index b7455c3..b1391f6 100644 (file)
@@ -39,4 +39,5 @@ echo $view->render('day');
 echo $view->render('event');
 echo $view->render('month');
 echo $view->render('summary');
+echo $view->render('notice');
 $registry->get('templates', 'horde') . '/common-footer-mobile.inc';
diff --git a/kronolith/templates/mobile/notice.html.php b/kronolith/templates/mobile/notice.html.php
new file mode 100644 (file)
index 0000000..b00cab5
--- /dev/null
@@ -0,0 +1,7 @@
+<div id="notification" data-role="dialog">
+  <div data-role="header">
+    <h1><?php echo _("Notice")?></h1>
+  </div>
+  <div data-role="content" class="ui-body">
+  </div>
+</div>
\ No newline at end of file