From 34b42ba7985cc1a456ef87752f40e4c0b55247f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Dec 2014 18:47:12 +0100 Subject: [PATCH 1/5] Truncate label different for small or big screen --- htdocs/core/class/html.form.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 08bc3b4c85e..1150b446637 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1720,11 +1720,13 @@ class Form else if ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; } $opt.= '>'; - $opt.= $objp->ref.' - '.dol_trunc($label,32).' - '; + // Truncate label for small or big screen + $trunclabel = (($conf->dol_optimize_smallscreen==1)?32:92); + $opt.= $objp->ref.' - '.dol_trunc($label, $trunclabel).' - '; $objRef = $objp->ref; if (! empty($filterkey) && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i','$1',$objRef,1); - $outval.=$objRef.' - '.dol_trunc($label,32).' - '; + $outval.=$objRef.' - '.dol_trunc($label, $trunclabel).' - '; $found=0; @@ -2004,8 +2006,10 @@ class Form $outval.=$objRef; if (! empty($objp->idprodfournprice)) $outval.=' ('.$objRefFourn.')'; $outval.=' - '; - $opt.=dol_trunc($objp->label,18).' - '; - $outval.=dol_trunc($label,18).' - '; + // Truncate label for small or big screen + $trunclabel = (($conf->dol_optimize_smallscreen==1)?18:78); + $opt.=dol_trunc($label,$trunclabel).' - '; + $outval.=dol_trunc($label,$trunclabel).' - '; if (! empty($objp->idprodfournprice)) { From 590618eb3818d962bec136185b60d71155bf14af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Dec 2014 20:17:13 +0100 Subject: [PATCH 2/5] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fb587487aae..254ab6ab99e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1789,7 +1789,8 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo global $conf; if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - + // reduce for small screen + if ($conf->dol_optimize_smallscreen==1) $size = round($size/3); // We go always here if ($trunc == 'right') { From 6a01b6982e54300637766c19cab52ec988fb87c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Dec 2014 20:20:52 +0100 Subject: [PATCH 3/5] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1150b446637..d8e05263a4e 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1720,13 +1720,11 @@ class Form else if ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; } $opt.= '>'; - // Truncate label for small or big screen - $trunclabel = (($conf->dol_optimize_smallscreen==1)?32:92); - $opt.= $objp->ref.' - '.dol_trunc($label, $trunclabel).' - '; + $opt.= $objp->ref.' - '.dol_trunc($label, 99).' - '; $objRef = $objp->ref; if (! empty($filterkey) && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i','$1',$objRef,1); - $outval.=$objRef.' - '.dol_trunc($label, $trunclabel).' - '; + $outval.=$objRef.' - '.dol_trunc($label, 99).' - '; $found=0; @@ -2006,10 +2004,8 @@ class Form $outval.=$objRef; if (! empty($objp->idprodfournprice)) $outval.=' ('.$objRefFourn.')'; $outval.=' - '; - // Truncate label for small or big screen - $trunclabel = (($conf->dol_optimize_smallscreen==1)?18:78); - $opt.=dol_trunc($label,$trunclabel).' - '; - $outval.=dol_trunc($label,$trunclabel).' - '; + $opt.=dol_trunc($label, 72).' - '; + $outval.=dol_trunc($label, 72).' - '; if (! empty($objp->idprodfournprice)) { From 66f634f2173a623be48713302f0cd71c6e28bc5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Dec 2014 20:47:54 +0100 Subject: [PATCH 4/5] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 254ab6ab99e..4c3ee24522a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1782,15 +1782,16 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', * @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap * @param string $stringencoding Tell what is source string encoding * @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation. + * @param int $display Trunc is use to display and can be changed for small screen * @return string Truncated string */ -function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0) +function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0) { global $conf; if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; // reduce for small screen - if ($conf->dol_optimize_smallscreen==1) $size = round($size/3); + if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); // We go always here if ($trunc == 'right') { From 9f1ec0e710aedf3e7a8037cc0bbfbf3c9d1d9a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 9 Dec 2014 20:52:55 +0100 Subject: [PATCH 5/5] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d8e05263a4e..bf2f1a7f2d6 100755 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1720,11 +1720,11 @@ class Form else if ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; } $opt.= '>'; - $opt.= $objp->ref.' - '.dol_trunc($label, 99).' - '; + $opt.= $objp->ref.' - '.dol_trunc($label, 99, '', '', 1).' - '; $objRef = $objp->ref; if (! empty($filterkey) && $filterkey != '') $objRef=preg_replace('/('.preg_quote($filterkey).')/i','$1',$objRef,1); - $outval.=$objRef.' - '.dol_trunc($label, 99).' - '; + $outval.=$objRef.' - '.dol_trunc($label, 99, '', '', 1).' - '; $found=0;