<?php

// Id
$settings['id'] = substr(uniqid(), -3);

?>

<?php if ($settings['position'] == 'top' || $settings['position'] == 'bottom') : ?>

<div id="<?php echo $settings['id'] ?>" class="tm-event-tabs uk-flex uk-flex-column <?php echo $settings['class'] ?>">

    <?php if ($settings['position'] == 'top') : ?>
    <?php echo $this->render('plugins/widgets/' . $widget->getConfig('name') . '/views/_nav.php', compact('items', 'settings')); ?>
    <?php endif ?>

    <?php echo $this->render('plugins/widgets/' . $widget->getConfig('name') . '/views/_content.php', compact('items', 'settings')); ?>

    <?php if ($settings['position'] == 'bottom') : ?>
    <?php echo $this->render('plugins/widgets/' . $widget->getConfig('name') . '/views/_nav.php', compact('items', 'settings')); ?>
    <?php endif ?>

<?php else : ?>

<div id="<?php echo $settings['id'] ?>" class="tm-event-tabs uk-grid uk-grid-collapse uk-grid-match <?php echo $settings['class']; ?>" data-uk-grid-match="{target:'> div > ul'}">

    <div class="uk-width-medium-1-10 uk-position-relative <?php echo ($settings['position'] == 'right') ? 'uk-float-right uk-flex-order-last' : ''; ?>">
        <?php echo $this->render('plugins/widgets/' . $widget->getConfig('name') . '/views/_nav.php', compact('items', 'settings')); ?>
    </div>

    <div class="uk-width-medium-9-10">
        <?php echo $this->render('plugins/widgets/' . $widget->getConfig('name') . '/views/_content.php', compact('items', 'settings', 'min_height')); ?>
    </div>

<?php endif ?>

</div>

<script>
jQuery(function($) {
    var switcher = $('#<?php echo $settings['id'] ?>'),
        container = switcher.parent();

    if (container.is('.uk-panel')) {
        $.UIkit.$win.on('load resize', UIkit.Utils.debounce((function() {

            var fn = function() {
                UIkit.Utils.matchHeights([switcher[0], container[0]]);
                return fn;
            }

            return fn();

        })(), 50));
    }
});
</script>
