Skip to content
Snippets Groups Projects
Commit bd5a1fbd authored by Skriv's avatar Skriv
Browse files

textbox2

parent 4c9478af
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,8 @@ Macro.add("textbox2", {
var a = this.args[1];
var isNumber = typeof(a) === "number";
var inputElement = document.createElement("input"),
autofocus = false,
passage = void 0;
autofocus = false,
passage = void 0;
var setargs = null;
if (this.args.length > 3) {
passage = this.args[2];
......@@ -64,20 +64,20 @@ Macro.add("textbox2", {
jQuery(inputElement).attr({
id: this.name + "-" + r,
name: this.name + "-" + r,
// type: isNumber ? "number" : "text", /* TODO - hide spinner if we do this */
// type: isNumber ? "number" : "text", /* TODO - hide spinner if we do this */
tabindex: 0
}).addClass("macro-" + this.name)
.on("change", function() {
State.setVar(t, valueToNumberIfSame(this.value));
}).on("blur", function() {
State.setVar(t, valueToNumberIfSame(this.value));
if (this.value != a) { // If the value has actually changed, reload the page. Note != and not !== because types might be different
gotoPassage();
}
})
.on("keypress", function(e) {
13 === e.which && (e.preventDefault(), State.setVar(t, valueToNumberIfSame(this.value)), gotoPassage())
}).appendTo(this.output), State.setVar(t, a), inputElement.value = a, autofocus && (inputElement.setAttribute("autofocus", "autofocus"), postdisplay["#autofocus:" + inputElement.id] = function(e) {
.on("change", function() {
State.setVar(t, valueToNumberIfSame(this.value));
}).on("blur", function() {
State.setVar(t, valueToNumberIfSame(this.value));
if (this.value != a) { // If the value has actually changed, reload the page. Note != and not !== because types might be different
gotoPassage();
}
})
.on("keypress", function(e) {
13 === e.which && (e.preventDefault(), State.setVar(t, valueToNumberIfSame(this.value)), gotoPassage())
}).appendTo(this.output), State.setVar(t, a), inputElement.value = a, autofocus && (inputElement.setAttribute("autofocus", "autofocus"), postdisplay["#autofocus:" + inputElement.id] = function(e) {
delete postdisplay[e], setTimeout(function() {
return inputElement.focus()
}, Engine.minDomActionDelay)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment