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

43 lines
861 B
JavaScript
Raw Normal View History

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");
// All the text boxes, yo
self.boxes = config.boxes;
// Create each textbox...
for(var i=0; i<self.boxes.length; i++){
// DOM
var textbox = document.createElement("div");
self.dom.appendChild(textbox);
// Customize
var box = self.boxes[i];
textbox.style.left = box.x+"px";
textbox.style.top = box.y+"px";
textbox.style.width = box.width+"px";
textbox.style.height = box.height+"px";
textbox.innerHTML = Words.get(box.text_id);
}
// Add...
self.add = function(INSTANT){
return _addFade(self, INSTANT);
};
// Remove...
self.remove = function(INSTANT){
return _removeFade(self, INSTANT);
};
}