Update functions.lib.php

Add feature to limit the number of tabs in a card (based on google menu practice)
function actived with MAXTABS_IN_CARD dictionnary
watch result here : http://www.dolibarr.fr/forum/12-howto--aide/52135-tuto-ajouter-a-un-doc-pdf-un-extrafields#56008
or here.
All the code is in one function, need to explode/refactoring it on diferent css
This commit is contained in:
BENKE Charles 2014-12-22 12:26:04 +01:00
parent 8e613764c5
commit b45bd06475

View File

@ -684,10 +684,26 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
} }
// Show tabs // Show tabs
$bactive=false;
// if =0 we don't use the feature
$limittoshow=($conf->global->MAXTABS_IN_CARD?$conf->global->MAXTABS_IN_CARD:99);
$displaytab=0;
for ($i = 0 ; $i <= $maxkey ; $i++) for ($i = 0 ; $i <= $maxkey ; $i++)
{ {
$isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]);
if ((is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]))
{
$isactive=true;
$bactive=true;
if ($i <=$limittoshow)
$limittoshow++;
}
else
$isactive=false;
if ($i <=$limittoshow || $isactive )
{
$out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">'; $out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">';
if (isset($links[$i][2]) && $links[$i][2] == 'image') if (isset($links[$i][2]) && $links[$i][2] == 'image')
{ {
@ -714,9 +730,37 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
} }
$out.='</div>'; $out.='</div>';
} }
else
{
$outmore.='<div class="" style="display:inherit; background-color:#f9f9f9; padding-top:5px; padding-right:15px; padding-left:12px;">';
if (isset($links[$i][2]) && $links[$i][2] == 'image')
{
if (!empty($links[$i][0]))
$outmore.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
else
$outmore.='<span class="tabspan">'.$links[$i][1].'</span>'."\n";
}
else if (! empty($links[$i][1]))
$outmore.='<a "'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
$outmore.='</div>';
}
$displaytab=$i;
}
if ($displaytab > $limittoshow)
{
$out.='<div id=moretabs class="inline-block tabsElem"><a href="" data-role="button" style="background-color: #f0f0f0;" class="tab inline-block">Plus</a>';
$out.='<div id=moretabsList style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div></div>';
$out.="</div>\n"; $out.="</div>\n";
$out.="<script>";
$out.="$('#moretabs').mouseenter( function() { $('#moretabsList').css('left','auto');});";
$out.="$('#moretabs').mouseleave( function() { $('#moretabsList').css('left','-999em');});";
$out.="</script>";
}
if (! $notab) $out.="\n".'<div class="tabBar">'."\n"; if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
return $out; return $out;