<?php
/*
 * @author     M2E Pro Developers Team
 * @copyright  M2E LTD
 * @license    Commercial use is forbidden
 */

// @codingStandardsIgnoreFile

/** @var $this Ess_M2ePro_Block_Adminhtml_Widget_Grid_ModeSwitcher */

?>

<script type="text/javascript">
    var viewModeSwitcher = function() {
        var url = '<?php echo $this->getSwitchUrl(); ?>';
        url = url.replace('%view_mode%', this.value);
        setLocation(url);
    };

    var initObservers = function() {
        $('view_mode_switcher').observe('change', viewModeSwitcher);
    };

    <?php if (!$this->getRequest()->isXmlHttpRequest()): ?>
        Event.observe(window, 'load', function() {
            initObservers();
        });
    <?php else: ?>
        setTimeout(initObservers, 150);
    <?php endif; ?>
</script>
<select name="view_mode_switcher" id="view_mode_switcher" style="width: 100px;">
    <?php foreach ($this->getItems() as $item): ?>
        <option value="<?php echo Mage::helper('M2ePro')->escapeHtml($item['value']) ?>" <?php if ($this->getCurrentViewMode() == $item['value']): ?>selected="selected"<?php endif; ?>><?php echo Mage::helper('M2ePro')->escapeHtml($item['label']); ?></option>
    <?php endforeach; ?>
</select>