<?php
/**
 * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
 * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
 *
 * Glory to Ukraine! Glory to the heroes!
 */
?>
<?php
/**
 * Blog sidebar search form template
 *
 * @var $block \Magefan\Blog\Block\Sidebar\Search
 */
?>

<div class="widget block blog-search" data-bind="scope: 'blog-search'">
	<div class="block-content">
		<form class="form" id="blog_search_mini_form" action="<?php echo $block->getFormUrl() ?>" method="get">
            <div class="field search">
                <label class="label" for="blog_search">
                    <span><?php echo __('Search') ?></span>
                </label>
                <div class="control">
                    <input id="blog_search" type="text" name="q" value="<?php echo $block->escapeHtml($block->getQuery()) ?>" placeholder="<?php echo __('Search posts here...') ?>" class="input-text" maxlength="128" role="combobox" aria-haspopup="false" aria-autocomplete="both" autocomplete="off">
                </div>
            </div>
            <div class="actions">
                <button type="submit" onclick="return goBlogSearch(this);" title="<?php echo __('Search') ?>" class="action search">
                    <span><?php echo __('Search') ?></span>
                </button>
            </div>
        </form>
	</div>
</div>
<script type="text/javascript">
	function goBlogSearch(e)
	{
		var value = document.getElementById('blog_search').value;
		if (value) {
			window.location = e.form.action + value + '/';
		}
		return false;
	}
</script>