ncase.me-trust/js/core/TextBox.js

45 lines
935 B
JavaScript
Raw Normal View History

2017-07-10 15:38:20 +00:00
/*
*/
2017-06-26 19:52:49 +00:00
function TextBox(config){
var self = this;
self.id = config.id;
// Create DOM
self.dom = document.createElement("div");
self.dom.className = "object";
self.dom.classList.add("fader");
self.dom.classList.add("textbox");
2017-07-10 18:06:22 +00:00
// Customize
self.dom.style.left = config.x+"px";
self.dom.style.top = config.y+"px";
self.dom.style.width = config.width+"px";
self.dom.style.height = config.height+"px";
// Optional params
if(config.align) self.dom.style.textAlign = config.align;
if(config.size) self.dom.style.fontSize = config.size;
// Set Text!
self.setText = function(words){
self.dom.innerHTML = words;
};
self.setTextID = function(id){
self.text_id = id;
self.setText(Words.get(self.text_id));
};
self.setTextID(config.text_id);
2017-06-26 19:52:49 +00:00
// Add...
self.add = function(INSTANT){
return _addFade(self, INSTANT);
};
// Remove...
self.remove = function(INSTANT){
return _removeFade(self, INSTANT);
};
2017-07-10 15:38:20 +00:00
}