Skip to content

Instantly share code, notes, and snippets.

@brendt
Last active September 2, 2015 11:15
Show Gist options
  • Save brendt/84d923808e5d20540a13 to your computer and use it in GitHub Desktop.
Save brendt/84d923808e5d20540a13 to your computer and use it in GitHub Desktop.
Vanilla JS: Wordcloud - WordInput.js #1
"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