Skip to content

Commit

Permalink
MDL-52086 output renderers: show subtree only when tab is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
bostelm committed Nov 18, 2015
1 parent 6114fab commit fab5233
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions lib/outputrenderers.php
Expand Up @@ -3671,32 +3671,34 @@ protected function render_tabobject(tabobject $tabobject) {
return $str;
}

// Print subtree
$str .= html_writer::start_tag('ul', array('class' => 'tabrow'. $tabobject->level));
$cnt = 0;
foreach ($tabobject->subtree as $tab) {
$liclass = '';
if (!$cnt) {
$liclass .= ' first';
}
if ($cnt == count($tabobject->subtree) - 1) {
$liclass .= ' last';
}
if ((empty($tab->subtree)) && (!empty($tab->selected))) {
$liclass .= ' onerow';
}
// Print subtree.
if ($tabobject->level == 0 || $tabobject->selected || $tabobject->activated) {
$str .= html_writer::start_tag('ul', array('class' => 'tabrow'. $tabobject->level));
$cnt = 0;
foreach ($tabobject->subtree as $tab) {
$liclass = '';
if (!$cnt) {
$liclass .= ' first';
}
if ($cnt == count($tabobject->subtree) - 1) {
$liclass .= ' last';
}
if ((empty($tab->subtree)) && (!empty($tab->selected))) {
$liclass .= ' onerow';
}

if ($tab->selected) {
$liclass .= ' here selected';
} else if ($tab->activated) {
$liclass .= ' here active';
}
if ($tab->selected) {
$liclass .= ' here selected';
} else if ($tab->activated) {
$liclass .= ' here active';
}

// This will recursively call function render_tabobject() for each item in subtree
$str .= html_writer::tag('li', $this->render($tab), array('class' => trim($liclass)));
$cnt++;
// This will recursively call function render_tabobject() for each item in subtree.
$str .= html_writer::tag('li', $this->render($tab), array('class' => trim($liclass)));
$cnt++;
}
$str .= html_writer::end_tag('ul');
}
$str .= html_writer::end_tag('ul');

return $str;
}
Expand Down

0 comments on commit fab5233

Please sign in to comment.