From c8bc0a1ec94fb616988822231d343232ab6e5d40 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 1 Apr 2013 23:38:39 +0200
Subject: [PATCH] New: Prepare to code to support jmobile.

---
 build/debian/rules              |  1 -
 htdocs/core/getmenu_jmobile.php |  2 +-
 htdocs/main.inc.php             | 44 +++++++++++++++++++--------------
 htdocs/theme/eldy/style.css.php |  2 +-
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/build/debian/rules b/build/debian/rules
index 6b75c68b85d..5a1cfdc8ecb 100755
--- a/build/debian/rules
+++ b/build/debian/rules
@@ -104,7 +104,6 @@ clean:
 	rm -fr htdocs/includes/jquery/plugins/flot
 	rm -fr htdocs/includes/jquery/plugins/jstree
 	rm -fr htdocs/includes/jquery/plugins/lightbox
-	rm -fr htdocs/includes/jquery/plugins/mobile
 	rm -fr htdocs/includes/jquery/plugins/multiselect
 	rm -fr htdocs/includes/phpexcel/PHPExcel/Shared/PDF
 	rm -fr htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip
diff --git a/htdocs/core/getmenu_jmobile.php b/htdocs/core/getmenu_jmobile.php
index 78c46c60fbb..988dec4339a 100644
--- a/htdocs/core/getmenu_jmobile.php
+++ b/htdocs/core/getmenu_jmobile.php
@@ -50,7 +50,7 @@ $left=($langs->trans("DIRECTION")=='rtl'?'right':'left');
  * View
  */
 
-// URL http://mydolibarr/core/getmenu_jmobime?mainmenu=mainmenu&leftmenu=leftmenu can be used for tests
+// URL http://mydolibarr/core/getmenu_jmobile?mainmenu=mainmenu&leftmenu=leftmenu can be used for tests
 $arrayofjs=array('/includes/jquery/plugins/mobile/jquery.mobile-latest.min.js');
 $arrayofcss=array('/includes/jquery/plugins/mobile/jquery.mobile-latest.min.css');
 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index c254f4a74db..bae7f0de7f2 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -647,9 +647,6 @@ if (! defined('NOLOGIN'))
         $conf->css  = "/theme/".$conf->theme."/style.css.php";
     }
 
-    // If theme support option like flip-hide left menu and we use a smartphone, we force it
-    if (! empty($conf->global->MAIN_SMARTPHONE_OPTIM) && $conf->browser->phone && $conf->theme == 'eldy') $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT='forced';
-
     // Set javascript option
     if (! GETPOST('nojs'))   // If javascript was not disabled on URL
     {
@@ -949,6 +946,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             {
             	print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.css" />'."\n";
             }
+            // jQuery jMobile
+            if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || GETPOST('jmobile'))
+            {
+            	print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/mobile/jquery.mobile-latest.min.css" />'."\n";
+            }
         }
 
         print '<!-- Includes CSS for Dolibarr theme -->'."\n";
@@ -969,7 +971,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
         }
         $themeparam='?lang='.$langs->defaultlang.'&amp;theme='.$conf->theme.(GETPOST('optioncss')?'&amp;optioncss='.GETPOST('optioncss','alpha',1):'').'&amp;userid='.$user->id.'&amp;entity='.$conf->entity;
         if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
- 		//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
+        if (GETPOST('dol_hide_topmenu'))  $themeparam.='&amp;dol_hide_topmenu=1';
+        if (GETPOST('dol_hide_leftmenu')) $themeparam.='&amp;dol_hide_leftmenu=1';
+        //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
         print '<link rel="stylesheet" type="text/css" title="default" href="'.$themepath.$themeparam.'">'."\n";
 
         // CSS forced by modules (relative url starting with /)
@@ -1005,11 +1009,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
         if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
         if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="author" title="Dolibarr Development Team" href="http://www.dolibarr.org">'."\n";
 
+        $ext='.js';
+
         // Output standard javascript links
-        if (! $disablejs && ! empty($conf->use_javascript_ajax))
+        if (! defined('DISABLE_JQUERY') && ! $disablejs && ! empty($conf->use_javascript_ajax))
         {
-            $ext='.js';
-
             // JQuery. Must be before other includes
             print '<!-- Includes JS for JQuery -->'."\n";
             if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min'.$ext.'"></script>'."\n";
@@ -1101,6 +1105,21 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             {
             	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n";
             }
+            // jQuery Timepicker
+            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
+            {
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js"></script>'."\n";
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
+            }
+            // jQuery jMobile
+            if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || GETPOST('jmobile'))
+            {
+            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/mobile/jquery.mobile-latest.min.js"></script>'."\n";
+            }
+        }
+
+        if (! $disablejs && ! empty($conf->use_javascript_ajax))
+        {
             // CKEditor
             if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor'))
             {
@@ -1115,11 +1134,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
                 print '</script>'."\n";
                 print '<script type="text/javascript" src="'.$pathckeditor.'ckeditor_basic.js"></script>'."\n";
             }
-            // jQuery Timepicker
-            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
-            {
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js"></script>'."\n";
-            }
 
             // Global js function
             print '<!-- Includes JS of Dolibarr -->'."\n";
@@ -1128,12 +1142,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
             // Add datepicker default options
             print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
 
-            // add timepicker default options
-            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
-            {
-            	print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";
-            }
-
             // JS forced by modules (relative url starting with /)
             if (! empty($conf->modules_parts['js']))		// $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
         	{
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index bf87c6cb0e0..19398105406 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -356,7 +356,7 @@ td.showDragHandle {
 /* ============================================================================== */
 
 div.fiche {
-	margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?((empty($_SESSION['dol_hide_leftmenu']) && ! GETPOST('dol_hide_leftmenu')) ?'20':'4'):'24')); ?>px;
+	margin-<?php print $left; ?>: <?php print (GETPOST("optioncss") == 'print'?6:((empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?((empty($_SESSION['dol_hide_leftmenu']) && ! GETPOST('dol_hide_leftmenu'))?'20':'4'):'24')); ?>px;
 	margin-<?php print $right; ?>: <?php print (GETPOST("optioncss") == 'print'?8:(empty($conf->browser->phone)?'12':'6')); ?>px;
 }
 
-- 
GitLab