Issue #4: font-size option now available in options

This commit is contained in:
Belga 2014-10-30 09:51:57 +01:00
parent 11d8cbd48d
commit 66e2975bed
2 changed files with 28 additions and 7 deletions

View file

@ -33,6 +33,9 @@ OptionsManager.prototype.types = {
}, },
"checkbox": function(elem) { "checkbox": function(elem) {
return elem.checked; return elem.checked;
},
"number": function(elem) {
return elem.value;
} }
}, },
"set": { "set": {
@ -48,6 +51,9 @@ OptionsManager.prototype.types = {
} else { } else {
elem.setAttribute('checked'); elem.setAttribute('checked');
} }
},
"number": function(elem, val) {
elem.value = val;
} }
} }
}; };
@ -151,3 +157,10 @@ OptionsManager.prototype.setElemValue = function(elem, val) {
this.types.set[type](elem, val); this.types.set[type](elem, val);
} }
}; };
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}

10
lib/tab.nsui.js Normal file → Executable file
View file

@ -22,6 +22,8 @@ var Tab = function(name) {
this.buff_len = 1000; this.buff_len = 1000;
this.history_index = 0; this.history_index = 0;
this.history = []; this.history = [];
this.options = new OptionsManager();
this.options.restore();
this.initListElement(); this.initListElement();
this.initBodyElement(); this.initBodyElement();
}; };
@ -65,13 +67,18 @@ Tab.prototype.initBodyElement = function() {
this.chat_input = document.createElement("input"); this.chat_input = document.createElement("input");
this.chat_input.placeholder = "Some text here..."; this.chat_input.placeholder = "Some text here...";
this.chat_log = document.createElement("p"); this.chat_log = document.createElement("p");
this.chat_log.classList.add("chat-log"); this.chat_log.classList.add("chat-log");
this.chat_log.style.fontSize = this.options.values["chat-size"] + "px";
this.el_body = document.createElement("div"); this.el_body = document.createElement("div");
this.el_body.classList.add("tab-body"); this.el_body.classList.add("tab-body");
this.el_body.id = this.name; this.el_body.id = this.name;
this.el_body.style.display = "none"; this.el_body.style.display = "none";
chat_input_w.classList.add("chat-input-wrapper"); chat_input_w.classList.add("chat-input-wrapper");
this.chat_input.classList.add("chat-input"); this.chat_input.classList.add("chat-input");
this.chat_input.setAttribute("type", "text"); this.chat_input.setAttribute("type", "text");
this.chat_input.addEventListener("keyup", (function(elem) { this.chat_input.addEventListener("keyup", (function(elem) {
@ -126,6 +133,7 @@ Tab.prototype.hide = function() {
}; };
Tab.prototype.show = function() { Tab.prototype.show = function() {
this.options.restore();
if (typeof this.showHandler !== "undefined") { if (typeof this.showHandler !== "undefined") {
this.showHandler(); this.showHandler();
} }
@ -133,6 +141,7 @@ Tab.prototype.show = function() {
this.el_lst.classList.add("tab-current"); this.el_lst.classList.add("tab-current");
this.el_body.style.display = "block"; this.el_body.style.display = "block";
this.chat_log.scrollTop = 42000; this.chat_log.scrollTop = 42000;
this.chat_log.style.fontSize = this.options.values["chat-size"] + "px";
this.chat_input.focus(); this.chat_input.focus();
}; };
@ -160,7 +169,6 @@ Tab.prototype.appendMessage = function(msg) {
if (!(typeof msg.login !== "undefined" && msg.login !== null)) { if (!(typeof msg.login !== "undefined" && msg.login !== null)) {
this.history.push(msg.message); this.history.push(msg.message);
} }
this.flushText(); this.flushText();
this.chat_log.scrollTop = 42 * this.buff_len; this.chat_log.scrollTop = 42 * this.buff_len;
}; };