<?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-09-17 15:59:06
 * @@Function:
 */
 ?>
<?php if($this->getStatus() == 2) return; ?>
<?php $selector = 'alo-content-'.rand(0,999999999); ?>
<div class= "<?php /* @escapeNotVerified */ echo $selector?> magicproduct megashop +autoplay">
<?php
$tabs = $this->getTabs();
$relatedTabs = $this->getRelatedTabs();
$numTabs = count($tabs);
$isAjax = $this->getAjax();
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_category = $_objectManager->create('Magento\Catalog\Model\Category')->load($this->getCategoryId());
// echo '<h3 class="title">'.$this->getCatName().'</h3>';
if($numTabs): ?>
    <div class="block-title-tabs clearfix">
	    <?php echo '<h3 class="title">'.$this->getCatName().'</h3>'; ?>
	    <span class="toggle-tab mobile" style="display:none"><i class="fa fa-bars"></i></span>
		<ul class="magictabs toggle-content" data-ajax ='<?php /* @escapeNotVerified */ echo $this->getAjaxCfg() ?>'>
		<?php $activated = $this->getTabActivated();
			$limit = $this->getLimit();
			$single = ($numTabs ==1) ? 'single' : '';
			foreach ($tabs as $type => $name):
				$status  = (!$isAjax || $activated ==$type) ? 'loaded' : '';
				$status .= ($type == $activated) ? " activated $single" : '';
				/* @escapeNotVerified */ echo '<li class="item '.$status.'" data-type ="'.$type.'"><span class ="title">'.__($name).'</span></li>';
			endforeach;
			foreach ($relatedTabs as $cat):
				/* @escapeNotVerified */ echo $isAjax ? '<li class="item cat" data-type ="'.$cat->getEntityId().'"><span class ="title">'.$cat->getName().'</span></li>' : '<li class="item cat" data-type ="'.$cat->getEntityId().'"><a href="'.$cat->getUrl().'"><span class ="title">'.$cat->getName().'</span></a></li>';
			endforeach;
		?>
		<li class="item item-view"><a href="<?php /* @escapeNotVerified */ echo $_category->getUrl() ?>" title="<?php /* @escapeNotVerified */ echo __('View More') ?>" class="cat-view-all"><?php echo __('View More') ?></a></li>
		</ul>
    </div>
<?php endif ?>
	<?php if($image = $this->getData('image') ) : ?>
		<div class="banner-featured">
			<div class="promotion">
				<div class="item">
				    <div class="scale">
						<img src="<?php /* @escapeNotVerified */ echo $this->getImage($image);?>">
					</div>
				</div>
			</div>
		</div>
	<?php endif ?>
	<div class="ajax_loading" style="display:none" data-url="<?php /* @escapeNotVerified */ echo $this->getUrl('magicproduct/index/catalog', array('_type' => 'direct_link', '_secure'=>$this->getRequest()->isSecure()))?>"></div>
    <div class="product-featured clearfix">
	    <?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId($this->getIdentifier())->toHtml();?>
		<div class="product-featured-content">
			<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('catalog/gridtimer.phtml');	
				else echo $this->getContent('catalog/grid.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>
