Finish display of notification messages. Embedded HTML doesn't work well yet.
authorJan Schneider <jan@horde.org>
Mon, 29 Nov 2010 17:01:26 +0000 (18:01 +0100)
committerJan Schneider <jan@horde.org>
Mon, 29 Nov 2010 17:01:34 +0000 (18:01 +0100)
horde/js/mobile.js
horde/themes/default/mobile.css [new file with mode: 0644]
imp/templates/mobile/notice.html.php
kronolith/templates/mobile/notice.html.php

index 116aa62..6edfb0a 100644 (file)
         $.mobile.pageLoading(true);
     },
 
-    showNotifications: function(m)
+    showNotifications: function(msgs)
     {
-        $.each(m, function(key, msg) {
-            if (msg.type == 'horde.ajaxtimeout') {
-                HordeMobile.logout(msg.message);
+        if (!msgs.length || HordeMobile.is_logout) {
+            return;
+        }
+
+        var list = $('#horde-notification'), li;
+        list.html('');
+
+        $.each(msgs, function(key, m) {
+            switch (m.type) {
+            case 'horde.ajaxtimeout':
+                HordeMobile.logout(m.message);
+                return false;
+
+            case 'horde.error':
+            case 'horde.warning':
+            case 'horde.message':
+            case 'horde.success':
+                li = $('<li class="' + m.type.replace('.', '-') + '">');
+                if (m.flags && $.inArray('content.raw', m.flags) != -1) {
+                    // TODO: This needs some fixing:
+                    li.html(m.message.replace('<a href=', '<a rel="external" href='));
+                } else {
+                    li.text(m.message);
+                }
+                list.append(li);
+                break;
             }
         });
+        if (list.html()) {
+            $.mobile.changePage('notification');
+            list.listview('refresh');
+        }
     },
 
     logout: function(url)
diff --git a/horde/themes/default/mobile.css b/horde/themes/default/mobile.css
new file mode 100644 (file)
index 0000000..aa621a4
--- /dev/null
@@ -0,0 +1,29 @@
+.horde-message, .horde-success, .horde-warning, .horde-error {
+    padding-left: 40px !important;
+    background-position: 14px center !important;
+    background-repeat: no-repeat !important;
+    color: #fff !important;
+    text-shadow: 0 1px 1px #000 !important;
+}
+.horde-error {
+    background-color: #e81222 !important;
+    background-image: url("graphics/alerts/error.png") !important;
+}
+.horde-message {
+    background-color: #369 !important;
+    background-image: url("graphics/alerts/message.png") !important;
+}
+.horde-success  {
+    background-color: #5db110 !important;
+    background-image: url("graphics/alerts/success.png") !important;
+}
+.horde-warning {
+    background-color: #ebe20c !important;
+    background-image: url("graphics/alerts/warning.png") !important;
+    color: #444 !important;
+    text-shadow: 0 1px 1px #f6f6f6 !important;
+}
+.horde-alarm {
+    background-color: orange !important;
+    background-image: url("graphics/alerts/alarm.png") !important;
+}
index b00cab5..9711346 100644 (file)
@@ -3,5 +3,7 @@
     <h1><?php echo _("Notice")?></h1>
   </div>
   <div data-role="content" class="ui-body">
+    <ul id="horde-notification" data-role="listview">
+    </ul>
   </div>
 </div>
\ No newline at end of file
index b00cab5..9711346 100644 (file)
@@ -3,5 +3,7 @@
     <h1><?php echo _("Notice")?></h1>
   </div>
   <div data-role="content" class="ui-body">
+    <ul id="horde-notification" data-role="listview">
+    </ul>
   </div>
 </div>
\ No newline at end of file