<?php
/**
 * Magiccart 
 * @category 	Magiccart 
 * @copyright 	Copyright (c) 2014 Magiccart (http://www.magiccart.net/) 
 * @license 	http://www.magiccart.net/license-agreement.html
 * @Author: DOng NGuyen<nguyen@dvn.com>
 * @@Create Date: 2016-01-08 22:57:12
 * @@Modify Date: 2018-03-14 23:54:41
 * @@Function:
 */
 ?>
<?php if($this->getStatus() == 2) return; ?>
<?php $selector = 'alo-content-'.rand(0,999999999); ?>
<div class= "<?php /* @escapeNotVerified */ echo $selector?> magicproduct magiccategory magiccategory-countdown">
<?php
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_category = $_objectManager->create('Magento\Catalog\Model\Category')->load($this->getCategoryId());
$tabs = $this->getTabs();
$numTabs = count($tabs);
if($numTabs): ?>
    <div class="magic-category">
	    <div class="block-title-tabs clearfix">
		    <!-- <h3 class="title"><?php //echo __($this->getTitle()); ?></h3 -->
		    <span class="toggle-tab mobile" style="display:none"><i class="fa fa-bars"></i></span>
			<ul class="magictabs toggle-content clearfix" data-ajax ='<?php /* @escapeNotVerified */ echo $this->getAjaxCfg() ?>'>
			<?php $activated = $this->getTabActivated();
				$limit = $this->getLimit();
				$single = ($numTabs ==1) ? 'single' : '';
				foreach ($tabs as $type => $name):
					$status  = (!$this->getAjax() || $activated ==$type) ? 'loaded' : '';
					$status .= ($type == $activated) ? " activated $single" : '';
					/* @escapeNotVerified */ echo '<li class="item '.$status.'" data-type ="'.$type.'"><span class ="title">'.__($name).'</span></li>';
				endforeach;
			?>
			<li class="item item-view"><a href="<?php /* @escapeNotVerified */ echo $_category->getUrl() ?>" title="<?php /* @escapeNotVerified */ echo __('View All') ?>" class="cat-view-all"><?php echo __('View All') ?></a>
			</li>
			</ul>
	    </div>
	</div>
<?php endif ?>
	<div class="ajax_loading" style="display:none" data-url="<?php /* @escapeNotVerified */ echo $this->getUrl('magicproduct/index/category', array('_type' => 'direct_link', '_secure'=>$this->getRequest()->isSecure()))?>"></div>
	<div class="box-product-content clearfix">
	    <?php if($image = $this->getImage()): ?>
	    <div class="box-product-adv">
			<div class="promotion">
				<img src="<?php /* @escapeNotVerified */ echo $this->getMediaUrl() . $this->getImage();?>">
			</div>
	    </div> 
		<?php endif ?>
	    <div class="box-product">
			<div class="content-products" 
			<?php foreach ($this->getFrontendCfg() as $opt) :?>
				data-<?php /* @escapeNotVerified */ echo $opt ?>='<?php /* @escapeNotVerified */ echo $this->getData($opt) ?>'
			<?php endforeach;?>        
			>
			<?php 
				$timer = $this->getTimer();
				if($timer) echo $this->getContent('category/gridtimer.phtml');	
				else echo $this->getContent('category/grid-countdown.phtml');	
			?>
			</div>
		</div>
	</div>	
</div>

<script type="text/javascript">
	require([
		'jquery',
		'magiccart/slick',
		'magicproduct'
		], function($, slick, magicproduct){
			$(".<?php echo $selector?>").magicproduct({
				selector : ".<?php echo $selector?>", // Selector product grid
			});
		});
</script>
