Add new mobile view to login screen.
authorJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 22:48:24 +0000 (23:48 +0100)
committerJan Schneider <jan@horde.org>
Mon, 15 Nov 2010 22:48:24 +0000 (23:48 +0100)
imp/js/login.js
imp/lib/Application.php
imp/lib/Auth.php

index 41325d5..6c5a459 100644 (file)
@@ -26,8 +26,9 @@ var ImpLogin = {
         var s = $('imp_select_view');
         if (s) {
             s.down('option[value=dimp]').show();
-            if (this.dimp_sel) {
-                s.selectedIndex = s.down('option[value=dimp]').index;
+            s.down('option[value=mobile]').show();
+            if (this.pre_sel) {
+                s.selectedIndex = s.down('option[value=' + this.pre_sel + ']').index;
             }
         }
     }
index a142a60..5919819 100644 (file)
@@ -345,10 +345,14 @@ class IMP_Application extends Horde_Registry_Application
             if (!($view_cookie = Horde_Util::getFormData('imp_select_view'))) {
                 $view_cookie = isset($_COOKIE['default_imp_view'])
                     ? $_COOKIE['default_imp_view']
-                    : ($GLOBALS['browser']->isMobile() ? 'mimp' : 'imp');
+                    : ($GLOBALS['browser']->isMobile()
+                       ? ($GLOBALS['browser']->getBrowser() == 'webkit'
+                          ? 'mimp'
+                          : 'mobile')
+                       : 'imp');
             }
 
-            $js_code['-ImpLogin.dimp_sel'] = intval($view_cookie == 'dimp');
+            $js_code['ImpLogin.pre_sel'] = $view_cookie;
 
             $params['imp_select_view'] = array(
                 'label' => _("Mode"),
@@ -361,7 +365,10 @@ class IMP_Application extends Horde_Registry_Application
                     'dimp' => array(
                         'hidden' => true,
                         'name' => _("Dynamic")
-                        // Dimp selected is handled by javascript (dimp_sel)
+                    ),
+                    'mobile' => array(
+                        'hidden' => true,
+                        'name' => _("Mobile (Smartphone)")
                     ),
                     'mimp' => array(
                         'name' => _("Mobile"),
index eb83730..fd5edb3 100644 (file)
@@ -532,9 +532,14 @@ class IMP_Auth
     static public function setViewMode($view)
     {
         /* Enforce minimum browser standards for DIMP. */
-        if (($view == 'dimp') && !Horde::ajaxAvailable()) {
-            $view = 'imp';
-            $GLOBALS['notification']->push(_("Your browser is too old to display the dynamic mode. Using traditional mode instead."), 'horde.warning');
+        if (($view == 'dimp' || $view == 'mobile') && !Horde::ajaxAvailable()) {
+            if ($view == 'dimp') {
+                $view = 'imp';
+                $GLOBALS['notification']->push(_("Your browser is too old to display the dynamic mode. Using traditional mode instead."), 'horde.warning');
+            } else {
+                $view = 'mimp';
+                $GLOBALS['notification']->push(_("Your browser is too old to display the smartphone mode. Using mobile mode instead."), 'horde.warning');
+            }
         }
 
         $GLOBALS['session']->set('imp', 'view', $view);