|
| 1 | +var ipc = require('ipc') |
| 2 | +var remote = require('remote') |
| 3 | + |
| 4 | +var React = require('react/addons') |
| 5 | + |
| 6 | +var LinkedState = require('../Mixins/LinkedState') |
| 7 | +var ExternalLink = require('../Mixins/ExternalLink') |
| 8 | +var KeyCaster = require('../Mixins/KeyCaster') |
| 9 | + |
| 10 | +module.exports = React.createClass({ |
| 11 | + mixins: [LinkedState, ExternalLink, KeyCaster('aboutModal')], |
| 12 | + propTypes: { |
| 13 | + close: React.PropTypes.func |
| 14 | + }, |
| 15 | + getInitialState: function () { |
| 16 | + var keymap = remote.getGlobal('keymap') |
| 17 | + console.log(keymap) |
| 18 | + return { |
| 19 | + currentTab: 'settings', |
| 20 | + keymap: keymap |
| 21 | + } |
| 22 | + }, |
| 23 | + onKeyCast: function (e) { |
| 24 | + switch (e.status) { |
| 25 | + case 'closeModal': |
| 26 | + this.props.close() |
| 27 | + break |
| 28 | + } |
| 29 | + }, |
| 30 | + activeSettings: function () { |
| 31 | + this.setState({currentTab: 'settings'}) |
| 32 | + }, |
| 33 | + activeAbout: function () { |
| 34 | + this.setState({currentTab: 'about'}) |
| 35 | + }, |
| 36 | + saveKeymap: function () { |
| 37 | + ipc.send('hotkeyUpdated', JSON.stringify(this.state.keymap)) |
| 38 | + }, |
| 39 | + render: function () { |
| 40 | + var content = this.state.currentTab === 'settings' ? this.renderSettingsTab() : this.renderAboutTab() |
| 41 | + |
| 42 | + return ( |
| 43 | + <div className='PreferencesModal sideNavModal modal'> |
| 44 | + <div className='leftPane'> |
| 45 | + <h1 className='modalLabel'>Preferences</h1> |
| 46 | + <nav className='tabList'> |
| 47 | + <button onClick={this.activeSettings} className={this.state.currentTab === 'settings' ? 'active' : ''}><i className='fa fa-gear fa-fw'/> Settings</button> |
| 48 | + <button onClick={this.activeAbout} className={this.state.currentTab === 'about' ? 'active' : ''}><i className='fa fa-info-circle fa-fw'/> About this app</button> |
| 49 | + </nav> |
| 50 | + </div> |
| 51 | + <div className='rightPane'> |
| 52 | + {content} |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + ) |
| 56 | + }, |
| 57 | + renderSettingsTab: function () { |
| 58 | + return ( |
| 59 | + <div className='settingsTab tab'> |
| 60 | + <div className='categoryLabel'>Hotkey</div> |
| 61 | + <div className='formField'> |
| 62 | + <label>Toggle finder</label> |
| 63 | + <input valueLink={this.linkState('keymap.toggleFinder')}/> |
| 64 | + </div> |
| 65 | + <div className='formConfirm'> |
| 66 | + <button onClick={this.saveKeymap}>Save</button> |
| 67 | + </div> |
| 68 | + <div className='example'> |
| 69 | + <h3>Example</h3> |
| 70 | + <ul> |
| 71 | + <li><code>0</code> to <code>9</code></li> |
| 72 | + <li><code>A</code> to <code>Z</code></li> |
| 73 | + <li><code>F1</code> to <code>F24</code></li> |
| 74 | + <li>Punctuations like <code>~</code>, <code>!</code>, <code>@</code>, <code>#</code>, <code>$</code>, etc.</li> |
| 75 | + <li><code>Plus</code></li> |
| 76 | + <li><code>Space</code></li> |
| 77 | + <li><code>Backspace</code></li> |
| 78 | + <li><code>Delete</code></li> |
| 79 | + <li><code>Insert</code></li> |
| 80 | + <li><code>Return</code> (or <code>Enter</code> as alias)</li> |
| 81 | + <li><code>Up</code>, <code>Down</code>, <code>Left</code> and <code>Right</code></li> |
| 82 | + <li><code>Home</code> and <code>End</code></li> |
| 83 | + <li><code>PageUp</code> and <code>PageDown</code></li> |
| 84 | + <li><code>Escape</code> (or <code>Esc</code> for short)</li> |
| 85 | + <li><code>VolumeUp</code>, <code>VolumeDown</code> and <code>VolumeMute</code></li> |
| 86 | + <li><code>MediaNextTrack</code>, <code>MediaPreviousTrack</code>, <code>MediaStop</code> and <code>MediaPlayPause</code></li> |
| 87 | + </ul> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + ) |
| 91 | + }, |
| 92 | + renderAboutTab: function () { |
| 93 | + var version = global.version |
| 94 | + return ( |
| 95 | + <div className='aboutTab tab'> |
| 96 | + <div className='about1'> |
| 97 | + <img className='logo' src='resources/favicon-230x230.png'/> |
| 98 | + <div className='appInfo'>Boost {version == null || version.length === 0 ? 'DEV version' : 'v' + version}</div> |
| 99 | + </div> |
| 100 | + |
| 101 | + <div className='about2'> |
| 102 | + <div className='externalLabel'>External links</div> |
| 103 | + <ul className='externalList'> |
| 104 | + <li><a onClick={this.openExternal} href='http://b00st.io'>Boost Homepage <i className='fa fa-external-link'/></a></li> |
| 105 | + <li><a onClick={this.openExternal} href='http://boostio.github.io/regulations.html'>Regulation <i className='fa fa-external-link'/></a></li> |
| 106 | + <li><a onClick={this.openExternal} href='http://boostio.github.io/privacypolicies.html'>Private policy <i className='fa fa-external-link'/></a></li> |
| 107 | + </ul> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + ) |
| 111 | + } |
| 112 | +}) |
0 commit comments