2015-10-28 01:05:28 +00:00
|
|
|
/*
|
|
|
|
Copyright 2015 OpenMarket Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var React = require('react');
|
|
|
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
|
|
|
var sdk = require('matrix-react-sdk');
|
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: 'SearchBar',
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return ({
|
2015-10-30 18:21:54 +00:00
|
|
|
scope: 'Room'
|
2015-10-28 01:05:28 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onThisRoomClick: function() {
|
2015-10-30 18:21:54 +00:00
|
|
|
this.setState({ scope: 'Room' });
|
2015-10-28 01:05:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onAllRoomsClick: function() {
|
2015-10-30 18:21:54 +00:00
|
|
|
this.setState({ scope: 'All' });
|
2015-10-28 01:05:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onSearchChange: function(e) {
|
2015-10-30 18:22:21 +00:00
|
|
|
if (e.keyCode === 13) { // on enter...
|
2015-10-29 02:03:04 +00:00
|
|
|
this.props.onSearch(this.refs.search_term.getDOMNode().value, this.state.scope);
|
2015-10-28 19:41:23 +00:00
|
|
|
}
|
2015-10-28 01:05:28 +00:00
|
|
|
},
|
2015-10-28 19:41:23 +00:00
|
|
|
|
2015-10-28 01:05:28 +00:00
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<div className="mx_SearchBar">
|
2015-10-29 02:03:04 +00:00
|
|
|
<input ref="search_term" className="mx_SearchBar_input" type="text" autoFocus={true} placeholder="Search..." onKeyDown={this.onSearchChange}/>
|
2015-10-30 18:21:54 +00:00
|
|
|
<div className={"mx_SearchBar_button" + (this.state.scope !== 'Room' ? " mx_SearchBar_unselected" : "")} onClick={this.onThisRoomClick}>This Room</div>
|
|
|
|
<div className={"mx_SearchBar_button" + (this.state.scope !== 'All' ? " mx_SearchBar_unselected" : "")} onClick={this.onAllRoomsClick}>All Rooms</div>
|
2015-10-28 01:05:28 +00:00
|
|
|
<img className="mx_SearchBar_cancel" src="img/cancel-black.png" width="18" height="18" onClick={this.props.onCancelClick} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|