import { registerComponent, Components } from 'meteor/vulcan:core'; import React, { PropTypes, Component } from 'react'; import { intlShape } from 'meteor/vulcan:i18n'; import Formsy from 'formsy-react'; import FRC from 'formsy-react-components'; import { withRouter, Link } from 'react-router' const Input = FRC.Input; // see: http://stackoverflow.com/questions/1909441/jquery-keyup-delay const delay = (function(){ var timer = 0; return function(callback, ms){ clearTimeout (timer); timer = setTimeout(callback, ms); }; })(); class SearchForm extends Component{ constructor(props) { super(props); this.search = this.search.bind(this); this.state = { search: props.router.location.query.query || '' } } // note: why do we need this? componentWillReceiveProps(nextProps) { this.setState({ search: this.props.router.location.query.query || '' }); } search(data) { const router = this.props.router; const routerQuery = _.clone(router.location.query); delete routerQuery.query; const query = data.searchQuery === '' ? routerQuery : {...routerQuery, query: data.searchQuery}; delay(() => { router.push({pathname: "/", query: query}); }, 700 ); } render() { const resetQuery = _.clone(this.props.location.query); delete resetQuery.query; return (