Fix tabs using current bootstrap documentation

ofaj
jmontoya 10 years ago
parent 314c5e1345
commit a43ff833f8
  1. 29
      main/inc/lib/display.lib.php

@ -979,42 +979,47 @@ class Display
$( "#tabs" ).tabs(); $( "#tabs" ).tabs();
}); });
</script> </script>
* @param array list of the tab titles * @param array $headers list of the tab titles
* @param array content that will be showed * @param array $items
* @param string the id of the container of the tab in the example "tabs" * @param string $id id of the container of the tab in the example "tabs"
* @param array attributes for the ul * @param array $attributes for the ul
* @param array $ul_attributes
* *
* @return string
*/ */
public static function tabs($header_list, $content_list, $id = 'tabs', $attributes = array(), $ul_attributes = array()) public static function tabs($headers, $items, $id = 'tabs', $attributes = array(), $ul_attributes = array())
{ {
if (empty($header_list) || count($header_list) == 0 ) { if (empty($headers) || count($headers) == 0 ) {
return ''; return '';
} }
$lis = ''; $lis = '';
$i = 1; $i = 1;
foreach ($header_list as $item) { foreach ($headers as $item) {
$active = ''; $active = '';
if ($i == 1) { if ($i == 1) {
$active = ' active'; $active = ' active';
} }
$item = self::tag('a', $item, array('href'=>'#'.$id.'-'.$i, 'role'=> 'tab')); $item = self::tag('a', $item, array('href'=>'#'.$id.'-'.$i, 'role'=> 'tab', 'data-toggle' => 'tab'));
$ul_attributes['data-toggle'] = 'tab';
$ul_attributes['role'] = 'presentation'; $ul_attributes['role'] = 'presentation';
$ul_attributes['class'] = $active; $ul_attributes['class'] = $active;
$lis .= self::tag('li', $item, $ul_attributes); $lis .= self::tag('li', $item, $ul_attributes);
$i++; $i++;
} }
$ul = self::tag('ul', $lis, ['class' => 'nav nav-tabs', 'role'=> 'tablist']); $ul = self::tag('ul', $lis, ['class' => 'nav nav-tabs', 'role'=> 'tablist', 'id' => 'ul_'.$id]);
$i = 1; $i = 1;
$divs = ''; $divs = '';
foreach ($content_list as $content) { foreach ($items as $content) {
$active = ''; $active = '';
if ($i == 1) { if ($i == 1) {
$active = ' active'; $active = ' active';
} }
$divs .= self::tag('div', $content, array('id'=> $id.'-'.$i, 'class' => 'tab-pane '.$active, 'role' => 'tabpanel')); $divs .= self::tag(
'div',
$content,
array('id' => $id.'-'.$i, 'class' => 'tab-pane '.$active, 'role' => 'tabpanel')
);
$i++; $i++;
} }

Loading…
Cancel
Save