mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 22:11:36 +01:00
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:
@@ -683,42 +683,86 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
|
||||
if (count($keys)) $maxkey=max($keys);
|
||||
}
|
||||
|
||||
// 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++)
|
||||
{
|
||||
$isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]);
|
||||
|
||||
$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 ((is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]))
|
||||
{
|
||||
if (!empty($links[$i][0]))
|
||||
{
|
||||
$out.='<a data-role="button" class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<span data-role="button" class="tabspan">'.$links[$i][1].'</span>'."\n";
|
||||
}
|
||||
$isactive=true;
|
||||
$bactive=true;
|
||||
if ($i <=$limittoshow)
|
||||
$limittoshow++;
|
||||
}
|
||||
else if (! empty($links[$i][1]))
|
||||
else
|
||||
$isactive=false;
|
||||
|
||||
if ($i <=$limittoshow || $isactive )
|
||||
{
|
||||
//print "x $i $active ".$links[$i][2]." z";
|
||||
if ($isactive)
|
||||
$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')
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
if (!empty($links[$i][0]))
|
||||
{
|
||||
$out.='<a data-role="button" class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<span data-role="button" class="tabspan">'.$links[$i][1].'</span>'."\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (! empty($links[$i][1]))
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
//print "x $i $active ".$links[$i][2]." z";
|
||||
if ($isactive)
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
$out.="</div>\n";
|
||||
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.="<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";
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user