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

// @codingStandardsIgnoreFile

/** @var $block \Magento\Checkout\Block\Cart\Sidebar */
$_portohelper = $this->helper('Smartwave\Porto\Helper\Data');
$cart_design = $_portohelper->getConfig('porto_design/header/header_minicart_design');
?>

<div data-block="minicart" class="minicart-wrapper cart-design-<?php echo $cart_design ? $cart_design: '1'?>">
    <a class="action showcart" href="<?php echo $block->getShoppingCartUrl(); ?>"
       data-bind="scope: 'minicart_content'">
       <i class="minicart-icon porto-icon-shopping-cart"></i>
        <span class="text"><?php echo __('Cart'); ?></span>
        <span class="counter qty empty"
              data-bind="css: { empty: !!getCartParam('summary_count') == false }, blockLoader: isLoading">
            <span class="counter-number">
            <!-- ko if: getCartParam('summary_count') --><!-- ko text: getCartParam('summary_count') --><!-- /ko --><!-- /ko -->
            <!-- ko ifnot: getCartParam('summary_count') -->0<!-- /ko -->
            </span>
            <span class="counter-label">
                <!-- ko i18n: 'items' --><!-- /ko -->
            </span>
        </span>
    </a>
    <a class="showcart action-subtotal d-none" href="<?php echo $block->getShoppingCartUrl(); ?>"
       data-bind="scope: 'minicart_content'">
        <span class="cart-subtotal">
          <?php echo __('Shopping Cart'); ?>
          <span class="cart-price">
            <span class="amount" data-bind="html: getCartParam('subtotal_excl_tax')">
              <!-- ko if: !getCartParam('subtotal_excl_tax') -->
                  <!-- ko i18n: '€ 0.00' --><!-- /ko -->
              <!-- /ko -->
            </span>
          </span>
        </span>
    </a>
    <?php if ($block->getIsNeedToDisplaySideBar()): ?>
        <div class="block block-minicart empty"
             data-role="dropdownDialog"
             data-mage-init='{"dropdownDialog":{
                "appendTo":"[data-block=minicart]",
                "triggerTarget":".showcart",
                "timeout": "2000",
                "closeOnMouseLeave": false,
                "closeOnEscape": true,
                "triggerClass":"active",
                "parentClass":"active",
                "buttons":[]}}'>
            <div id="minicart-content-wrapper" data-bind="scope: 'minicart_content'">
                <!-- ko template: getTemplate() --><!-- /ko -->
            </div>
        </div>
    <?php endif ?>
    <script>
        window.checkout = <?php echo \Zend_Json::encode($block->getConfig()); ?>;
    </script>
    <script type="text/x-magento-init">
    {
        "[data-block='minicart']": {
            "Magento_Ui/js/core/app": <?php echo $block->getJsLayout();?>
        },
        "*": {
            "Magento_Ui/js/block-loader": "<?php echo $block->getViewFileUrl('images/loader-1.gif'); ?>"
        }
    }
    </script>
</div>
