Last active
September 2, 2015 11:15
-
-
Save brendt/84d923808e5d20540a13 to your computer and use it in GitHub Desktop.
Vanilla JS: Wordcloud - WordInput.js #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var WordInput = { | |
init() { | |
this.rendered = false; | |
this.domElem = null; | |
this.map = {}; | |
}, | |
render() { | |
if (!this.rendered) { | |
var input = document.createElement('input'); | |
input.setAttribute('class', `word-input`); | |
input.type = 'text'; | |
this.domElem = input; | |
this.rendered = true; | |
} | |
return this.domElem; | |
}, | |
setBounds(marginLeft, width) { | |
this.domElem.style['margin-left'] = marginLeft + 'px'; | |
this.domElem.style['width'] = width + 'px'; | |
}, | |
focus() { | |
this.domElem.focus(); | |
}, | |
select() { | |
this.domElem.select(); | |
}, | |
getText() { | |
return this.domElem.value; | |
}, | |
setText(text) { | |
this.domElem.value = text; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment