Replacing the setState method with a property

This commit is contained in:
Jeff Avallone 2014-12-16 13:34:02 -05:00
parent dbae70ce52
commit 91404ccf26
1 changed files with 6 additions and 9 deletions

View File

@ -55,14 +55,14 @@ export default class Regexper {
showExpression(expression) { showExpression(expression) {
this.field.value = expression; this.field.value = expression;
this.setState(''); this.state = '';
if (expression !== '') { if (expression !== '') {
this.setState('is-loading'); this.state = 'is-loading';
this.renderRegexp(expression.replace(/\n/g, '\\n')) this.renderRegexp(expression.replace(/\n/g, '\\n'))
.then(() => { .then(() => {
this.setState('has-results'); this.state = 'has-results';
this.updateLinks(); this.updateLinks();
}) })
.done(); .done();
@ -75,20 +75,17 @@ export default class Regexper {
bindListeners() { bindListeners() {
this.field.addEventListener('keypress', this.keypressListener.bind(this)); this.field.addEventListener('keypress', this.keypressListener.bind(this));
this.form.addEventListener('submit', this.submitListener.bind(this)); this.form.addEventListener('submit', this.submitListener.bind(this));
window.addEventListener('hashchange', this.hashchangeListener.bind(this));
this.root.addEventListener('updateStatus', this.updatePercentage.bind(this)); this.root.addEventListener('updateStatus', this.updatePercentage.bind(this));
window.addEventListener('hashchange', this.hashchangeListener.bind(this));
} }
setState(state) { set state(state) {
this.root.className = state; this.root.className = state;
} }
showError(message) { showError(message) {
this.setState('has-error'); this.state = 'has-error';
this.error.innerHTML = ''; this.error.innerHTML = '';
this.error.appendChild(document.createTextNode(message)); this.error.appendChild(document.createTextNode(message));