Initial mailbox loading.
authorJan Schneider <jan@horde.org>
Tue, 16 Nov 2010 23:35:35 +0000 (00:35 +0100)
committerJan Schneider <jan@horde.org>
Tue, 16 Nov 2010 23:35:49 +0000 (00:35 +0100)
imp/js/mobile.js
imp/lib/Injector/Factory/MailboxList.php
imp/templates/mobile/mailbox.html.php

index 12a31b5..18245e6 100644 (file)
@@ -31,7 +31,35 @@ var ImpMobile = {
     toMailbox: function(mailbox, label)
     {
         $('#imp-mailbox-header').text(label);
+        $('#imp-mailbox-list').empty();
         $.mobile.changePage('#mailbox', 'slide', false, true);
+        $.mobile.pageLoading();
+        ImpMobile.doAction(
+            'viewPort',
+            { view: mailbox, initial: 1, slice: '1', requestid: 1, after: 25 },
+            ImpMobile.messagesLoaded);
+    },
+
+    /**
+     * Callback method after message list has been loaded.
+     *
+     * @param object r  The Ajax response object.
+     */
+    messagesLoaded: function(r)
+    {
+        var list = $('#imp-mailbox-list');
+        $.mobile.pageLoading(true);
+        if (r.response && r.response.ViewPort) {
+            $.each(r.response.ViewPort.data, function(key, data) {
+                list.append(
+                    $('<li>').append(
+                        $('<h3>').append(
+                            $('<a href="#">').text(data.subject))).append(
+                        $('<p class="ui-li-aside">').text(data.date)).append(
+                        $('<p>').text(data.from)));
+            });
+            list.listview('refresh');
+        }
     },
 
     /**
index 1c10969..3ed83de 100644 (file)
@@ -62,6 +62,7 @@ class IMP_Injector_Factory_MailboxList
         if (!isset($this->_instances[$mailbox])) {
             switch ($mode) {
             case 'dimp':
+            case 'mobile':
                 $ob = new IMP_Mailbox_List($mailbox);
                 break;
 
index 797744d..dc4efdf 100644 (file)
@@ -9,7 +9,7 @@
     <?php endif ?>
   </div>
   <div data-role="content">
-    <ul data-role="listview">
+    <ul id="imp-mailbox-list" data-role="listview">
       <li>
          <h3><a href="#message">Subject 1</a></h3>
          <p class="ui-li-aside">99</p>