<?php
/**
 * @category    Mana
 * @package     ManaPro_FilterColors
 * @copyright   Copyright (c) http://www.manadev.com
 * @license     http://www.manadev.com/license  Proprietary License
 */
/** 
 * @author Mana Team
 */
/* @var $this Mana_Filters_Block_Filter_Attribute */
/* @var $filters Mana_Filters_Helper_Data */ $filters = Mage::helper(strtolower('Mana_Filters'));
/* @var $showmore ManaPro_FilterShowMore_Helper_Data */ $showmore = Mage::helper(strtolower('ManaPro_FilterShowMore'));
/* @var $jsonHelper Mana_Core_Helper_Json */
$jsonHelper = Mage::helper('mana_core/json');
$MAX_ROW_COUNT = $showmore->getMaxRowCount(); // 20
$MAX_COLUMN_COUNT = $showmore->getMaxColumnCount(); // 4
$items = $this->getItems();
list($rowCount, $columnCount) = $showmore->getPopupDimensions($items, $MAX_ROW_COUNT, $MAX_COLUMN_COUNT);
?>
<div class="m-filter-popup">
<ol class="m-rows" data-max-rows="<?php echo $MAX_ROW_COUNT ?>">
    <?php for($rowIndex = 0; $rowIndex < $rowCount; $rowIndex++) : ?>
    <li>
        <ol class="m-columns m-filter-colors labels <?php echo $this->getFilterClass() ?>">
            <?php for ($columnIndex = 0; $columnIndex < $columnCount; $columnIndex++) : if ($columnIndex * $rowCount + $rowIndex < count($items)) : ?>
            <?php $_item = $items[$columnIndex * $rowCount + $rowIndex]; ?>
            <li  <?php echo $this->getListItemClass($_item) ?> >
                <?php if (!$this->getFilterOptions()->getDisableNoResultOptions() || $_item->getCount() || $_item->getMSelected()): ?>
                    <a href="#"
                       data-item="<?php echo $jsonHelper->encodeAttribute($_item->getSeoData()) ?>"
                       data-is-reverse="<?php echo $this->getFilterOptions()->getIsReverse() ?>"
                       data-index="<?php echo $columnIndex * $rowCount + $rowIndex ?>">
                        <div class="m-color <?php if ($_item->getMShowSelected()): ?>selected<?php endif; ?> <?php echo $this->getFilterValueClass($_item) ?>"
                             title="<?php echo $this->escapeHtml($_item->getLabel()) ?> (<?php echo $_item->getCount() ?>)">
                            <div class="m-layer1"></div>
                        </div>
                        <?php echo $this->escapeHtml($_item->getLabel()) ?>
                    </a>
                <?php else: ?>
                    <a href="javascript:void(0)">
                        <div class="m-color <?php if ($_item->getMShowSelected()): ?>selected<?php endif; ?> <?php echo $this->getFilterValueClass($_item) ?>"
                             title="<?php echo $this->escapeHtml($_item->getLabel()) ?> (<?php echo $_item->getCount() ?>)">
                            <div class="m-layer1"></div>
                        </div>
                        <?php echo $this->escapeHtml($_item->getLabel()) ?>
                    </a>
                <?php endif; ?>
                <?php if (Mage::getStoreConfigFlag('mana_filters/display/count')) : ?>
                    (<?php echo $_item->getCount() ?>)
                <?php endif; ?>
            </li>
            <?php endif; endfor; ?>
        </ol>
    </li>
    <?php endfor; ?>
</ol>
</div>
