-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathbrowser-navbar.jsx
49 lines (38 loc) · 1.68 KB
/
browser-navbar.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function normalizedUri(input) {
var prefix = 'http://';
var prefix2 = 'https://';
if (!/^([^:\/]+)(:\/\/)/g.test(input) && (!prefix.includes(input)) && !prefix2.includes(input)) {
input = prefix + input;
}
return input;
}
var BrowserNavbarBtn = React.createClass({
render: function() {
return <a href="#" className={this.props.disabled?'disabled':''} title={this.props.title} onClick={this.props.onClick}><i className={'fa fa-'+this.props.icon} /></a>
}
})
var BrowserNavbarLocation = React.createClass({
onKeyDown: function (e) {
if (e.keyCode == 13)
this.props.onEnterLocation(normalizedUri(e.target.value))
},
onChange: function (e) {
this.props.onChangeLocation(normalizedUri(e.target.value))
},
render: function() {
return <input type="text" onKeyDown={this.onKeyDown} onChange={this.onChange} onContextMenu={this.props.onContextMenu} value={this.props.page.location} />
}
})
var BrowserNavbar = React.createClass({
render: function() {
return <div id="browser-navbar">
<BrowserNavbarBtn className="bg" title="Start/Stop" icon="bug" onClick={this.props.onClickHome}/>
<div className="jx">
<BrowserNavbarBtn title="Back" icon="angle-left fa-lg" onClick={this.props.onClickBack} disabled={!this.props.page.canGoBack} />
<BrowserNavbarBtn title="Refresh" icon="refresh" onClick={this.props.onClickRefresh} disabled={!this.props.page.canRefresh} />
</div><div className="input-group">
<BrowserNavbarLocation onEnterLocation={this.props.onEnterLocation} onChangeLocation={this.props.onChangeLocation} onContextMenu={this.props.onLocationContextMenu} page={this.props.page} />
</div>
</div>
}
})