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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Backend\Block\Widget\Tabs */
?>
<?php if (!empty($tabs)): ?>

<div class="admin__page-nav" data-role="container" id="<?php /* @escapeNotVerified */ echo $block->getId() ?>">
    <?php if ($block->getTitle()): ?>
        <div class="admin__page-nav-title" data-role="title" <?php /* @escapeNotVerified */ echo $block->getUiId('title') ?>>
            <strong><?php /* @escapeNotVerified */ echo $block->getTitle() ?></strong>
            <span data-role="title-messages" class="admin__page-nav-title-messages"></span>
        </div>
    <?php endif ?>
    <ul <?php /* @escapeNotVerified */ echo $block->getUiId('tab', $block->getId()) ?> class="<?php /* @escapeNotVerified */ echo $block->getIsHoriz() ? 'tabs-horiz' : 'tabs admin__page-nav-items' ?>">
        <?php foreach ($tabs as $_tab): ?>

            <?php if (!$block->canShowTab($_tab)): continue;  endif; ?>
            <?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' . (preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
            <?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
            <?php $_tabHref = $block->getTabUrl($_tab) == '#' ? '#' . $block->getTabId($_tab) . '_content' : $block->getTabUrl($_tab) ?>

            <li class="admin__page-nav-item" <?php if ($block->getTabIsHidden($_tab)): ?> style="display:none"<?php endif; ?><?php /* @escapeNotVerified */ echo $block->getUiId('tab', 'item', $_tab->getId()) ?>>
                <a href="<?php /* @escapeNotVerified */ echo $_tabHref ?>" id="<?php /* @escapeNotVerified */ echo $block->getTabId($_tab) ?>" name="<?php /* @escapeNotVerified */ echo $block->getTabId($_tab, false) ?>" title="<?php /* @escapeNotVerified */ echo $block->getTabTitle($_tab) ?>"
                   class="admin__page-nav-link <?php /* @escapeNotVerified */ echo $_tabClass;?>"
                   data-tab-type="<?php /* @escapeNotVerified */ echo $_tabType;?>"
                   <?php /* @escapeNotVerified */ echo $block->getUiId('tab', 'link', $_tab->getId()) ?>>

                   <span><?php /* @escapeNotVerified */ echo $block->getTabLabel($_tab); ?></span>

                   <span class="admin__page-nav-item-messages" data-role="item-messages">
                       <span class="admin__page-nav-item-message _changed">
                           <span class="admin__page-nav-item-message-icon"></span>
                           <span class="admin__page-nav-item-message-tooltip">
                               <?php /* @escapeNotVerified */ echo __('Changes have been made to this section that have not been saved.'); ?>
                           </span>
                       </span>
                       <span class="admin__page-nav-item-message _error">
                           <span class="admin__page-nav-item-message-icon"></span>
                           <span class="admin__page-nav-item-message-tooltip">
                               <?php /* @escapeNotVerified */ echo __('This tab contains invalid data. Please resolve this before saving.'); ?>
                           </span>
                       </span>
                        <span class="admin__page-nav-item-message-loader">
                           <span class="spinner">
                               <span></span><span></span><span></span><span></span>
                               <span></span><span></span><span></span><span></span>
                           </span>
                       </span>
                   </span>
                </a>
                <div id="<?php /* @escapeNotVerified */ echo $block->getTabId($_tab) ?>_content" style="display:none;"<?php /* @escapeNotVerified */ echo $block->getUiId('tab', 'content', $_tab->getId()) ?>><?php /* @escapeNotVerified */ echo $block->getTabContent($_tab) ?></div>
            </li>
        <?php endforeach; ?>
    </ul>
</div>

<script>
require(['jquery',"mage/backend/tabs"], function($){
    $(function() {
        $('#<?php /* @escapeNotVerified */ echo $block->getId() ?>').tabs({
            active: '<?php /* @escapeNotVerified */ echo $block->getActiveTabId() ?>',
            destination: '#<?php /* @escapeNotVerified */ echo $block->getDestElementId() ?>',
            shadowTabs: <?php /* @escapeNotVerified */ echo $block->getAllShadowTabs()?>,
            tabsBlockPrefix: '<?php /* @escapeNotVerified */ echo $block->getId() ?>_',
            tabIdArgument: 'active_tab'
        });
    });
});
</script>
<?php endif; ?>
