diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-08 20:01:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-08 20:01:57 +0900 |
commit | 8b9125871b59d915324176ab959bb0aed20a727a (patch) | |
tree | a10db125bd25c1447bb08de2ef156c010243f019 /src/console/components/console.js | |
parent | bbf90e77e99846c970118744066fbc21006761b5 (diff) | |
parent | 7ac00fce6f6c431f96c531179c6af3796df7e07a (diff) |
Merge pull request #24 from ueokande/yank-url
Yank url
Diffstat (limited to 'src/console/components/console.js')
-rw-r--r-- | src/console/components/console.js | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/console/components/console.js b/src/console/components/console.js index 9023d91..93802f8 100644 --- a/src/console/components/console.js +++ b/src/console/components/console.js @@ -16,7 +16,7 @@ export default class ConsoleComponent { input.addEventListener('keyup', this.onKeyUp.bind(this)); this.hideCommand(); - this.hideError(); + this.hideMessage(); } onBlur() { @@ -72,17 +72,16 @@ export default class ConsoleComponent { update() { let state = this.store.getState(); - if (!this.prevState.commandShown && state.commandShown) { + if (this.prevState.mode !== 'command' && state.mode === 'command') { this.showCommand(state.commandText); - } else if (!state.commandShown) { + } else if (state.mode !== 'command') { this.hideCommand(); } - if (state.errorShown) { - this.setErrorText(state.errorText); - this.showError(); + if (state.mode === 'error' || state.mode === 'info') { + this.showMessage(state.mode, state.messageText); } else { - this.hideError(); + this.hideMessage(); } if (state.groupSelection >= 0 && state.itemSelection >= 0) { @@ -128,21 +127,21 @@ export default class ConsoleComponent { input.value = this.completionOrigin; } - setErrorText(text) { + showMessage(mode, text) { let doc = this.wrapper.ownerDocument; - let error = doc.querySelector('#vimvixen-console-error'); + let error = doc.querySelector('#vimvixen-console-message'); + error.classList.remove( + 'vimvixen-console-info', + 'vimvixen-console-error' + ); + error.classList.add('vimvixen-console-' + mode); error.textContent = text; - } - - showError() { - let doc = this.wrapper.ownerDocument; - let error = doc.querySelector('#vimvixen-console-error'); error.style.display = 'block'; } - hideError() { + hideMessage() { let doc = this.wrapper.ownerDocument; - let error = doc.querySelector('#vimvixen-console-error'); + let error = doc.querySelector('#vimvixen-console-message'); error.style.display = 'none'; } } |