<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var $block \Magento\Config\Block\System\Config\Tabs */
?>

<?php if ($block->getTabs()): ?>
    <div id="<?php /* @escapeNotVerified */ echo $block->getId() ?>" class="config-nav">
        <?php
        /** @var $_tab \Magento\Config\Model\Config\Structure\Element\Tab */
        foreach ($block->getTabs() as $_tab):
            ?>

            <?php
                $activeCollapsible = false;
                foreach ($_tab->getChildren() as $_section) {
                    if ($block->isSectionActive($_section)) {
                        $activeCollapsible = true;
                    }
                }
            ?>

            <div class="config-nav-block admin__page-nav _collapsed
                <?php if ($_tab->getClass()): ?>
                    <?php /* @escapeNotVerified */ echo $_tab->getClass() ?>
                <?php endif ?>"
                 data-mage-init='{"collapsible":{"active": "<?php /* @escapeNotVerified */ echo $activeCollapsible;?>",
                 "openedState": "_show",
                 "closedState": "_hide",
                 "collapsible": true,
                 "animate": 200}}'>
                <div class="admin__page-nav-title title _collapsible" data-role="title">
                    <strong><?php /* @escapeNotVerified */ echo $_tab->getLabel() ?></strong>
                </div>

                <ul class="admin__page-nav-items items" data-role="content">
                    <?php $_iterator = 1; ?>
                    <?php
                    /** @var $_section \Magento\Config\Model\Config\Structure\Element\Section */
                    foreach ($_tab->getChildren() as $_section): ?>
                        <li class="admin__page-nav-item item
                            <?php /* @escapeNotVerified */ echo $_section->getClass() ?>
                            <?php if ($block->isSectionActive($_section)): ?> _active<?php endif ?>
                            <?php echo $_tab->getChildren()->isLast($_section) ? ' _last' : '' ?>">
                            <a href="<?php /* @escapeNotVerified */ echo $block->getSectionUrl($_section) ?>"
                               class="admin__page-nav-link item-nav">
                               <span><?php /* @escapeNotVerified */ echo $_section->getLabel() ?></span>
                            </a>
                        </li>
                        <?php $_iterator++; ?>
                    <?php endforeach; ?>
                </ul>

            </div>
        <?php
        endforeach;
        ?>
    </div>
<?php endif; ?>
