NEW Better behaviour when using a text browser

This commit is contained in:
Laurent Destailleur 2017-11-14 15:10:46 +01:00
parent 0e2f64af72
commit a50589c3c9
5 changed files with 24 additions and 13 deletions

View File

@ -1023,7 +1023,11 @@ class FormOther
$selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1);
if (empty($conf->use_javascript_ajax)) $selectboxlist.=' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">';
$selectboxlist.='</form>';
$selectboxlist.=ajax_combobox("boxcombo");
if (! empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$selectboxlist.=ajax_combobox("boxcombo");
}
}
// Javascript code for dynamic actions

View File

@ -298,7 +298,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
print '</div>'."\n";
}
if (is_array($moredata) && ! empty($moredata['searchform']))
if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page
{
print "\n";
print "<!-- Begin SearchForm -->\n";

View File

@ -484,7 +484,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
print '</div>'."\n";
}
if (is_array($moredata) && ! empty($moredata['searchform']) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page
{
print "\n";
print "<!-- Begin SearchForm -->\n";

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This file is a modified version of datepicker.php from phpBSM to fix some
* bugs, to add new features and to dramatically increase speed.
@ -20,7 +20,7 @@
/**
* \file htdocs/core/search_page.php
* \brief File to return search box
* \brief File to return a page with search boxes
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
@ -78,7 +78,8 @@ if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile
else
{
$usedbyinclude = 1; // Used into next include
include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
$showtitlebefore = GETPOST('showtitlebefore','int');
include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
$accesskeyalreadyassigned=array();
foreach($arrayresult as $key => $val)
@ -94,7 +95,7 @@ else
$accesskey=$val['label'][0];
$accesskeyalreadyassigned[$accesskey]=$accesskey;
}
$searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1));
$searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore);
}
}
@ -112,11 +113,9 @@ print "\n";
print "<!-- Begin SearchForm -->\n";
print '<div class="center" align="center"><div align="center" style="padding: 6px;">';
print '<style>.menu_titre { padding-top: 7px; }</style>';
//print '<div id="distance"></div><div id="container" class="center">';
print '<div id="blockvmenusearch">'."\n";
print $searchform;
print '</div>'."\n";
//print '</div></div>';
print '</div></div>';
print "\n<!-- End SearchForm -->\n";

View File

@ -1589,9 +1589,9 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
print "\n".'<!-- Begin side-nav id-left -->'."\n".'<div class="side-nav"><div id="id-left">'."\n";
print "\n";
if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ?
if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone
print "\n";
if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
{
if (! is_object($form)) $form=new Form($db);
@ -1621,7 +1621,13 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra
}
else $searchform=$hookmanager->resPrint;
if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
// Force special value for $searchform
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$urltosearch=DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1';
$searchform='<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="'.$urltosearch.'" alt="'.dol_escape_htmltag($langs->trans("ShowSearchFields")).'">'.$langs->trans("Search").'...</a></div>';
}
elseif ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM))
{
$searchform='<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="#" alt="'.dol_escape_htmltag($langs->trans("ShowSearchFields")).'">'.$langs->trans("Search").'...</a></div><div id="divsearchforms2" style="display: none">'.$searchform.'</div>';
$searchform.='<script type="text/javascript">
@ -1814,9 +1820,10 @@ function getHelpParamFor($helppagename,$langs)
* @param string $accesskey Accesskey
* @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page
* @param string $img Image to use
* @param string $showtitlebefore Show title before input text instead of into placeholder. This can be set when output is dedicated for text browsers.
* @return string
*/
function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='',$img='')
function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='',$img='', $showtitlebefore=0)
{
global $conf,$langs,$user;
@ -1829,6 +1836,7 @@ function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinpu
$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$ret.='<input type="hidden" name="mode" value="search">';
$ret.='<input type="hidden" name="savelogin" value="'.dol_escape_htmltag($user->login).'">';
if ($showtitlebefore) $ret.=$title.' ';
$ret.='<input type="text" class="flat '.$htmlmorecss.'"';
$ret.=' style="text-indent: 22px; background-image: url(\''.$img.'\'); background-repeat: no-repeat; background-position: 3px;"';
$ret.=($accesskey?' accesskey="'.$accesskey.'"':'');