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

delete obsolete textInput.js

parent 67f271b8
No related branches found
No related tags found
No related merge requests found
Macro.add("textinput", {
// Signifies that the macro is a container macro.
tags: null,
handler: function() {
if (this.args.length < 2) {
const errors = [];
if (this.args.length === 0) {
errors.push("variable name");
}
if (this.args.length < 2) {
errors.push("default value");
}
return this.error(`no ${errors.join(" or ")} specified`);
}
// Ensure that the variable name argument is a string.
if (typeof this.args[0] !== "string") {
return this.error("variable name argument is not a string");
}
const varName = this.args[0].trim();
// Try to ensure that we receive the variable's name (incl. sigil), not its value.
if (varName[0] !== "$" && varName[0] !== "_") {
return this.error(`variable name '${varName}' is missing its sigil ($ or _)`);
}
const that = this;
const defaultValue = this.args[1];
const el = document.createElement("textarea");
// Setup and append the textarea element to the output buffer.
jQuery(el)
.attr({
rows: 4,
// cols: 68, // instead of setting "cols" we set the `min-width` in CSS
tabindex: 0 // for accessibility
})
.addClass("macro-textarea") // "hijack" the .macro-textarea class
.on("input", function() {
Wikifier.setValue(varName, this.value);
if (that.payload[0].contents !== "") {
Wikifier.wikifyEval(that.payload[0].contents.trim());
}
})
.appendTo(this.output);
// Set the story variable and textarea element to the default value.
Wikifier.setValue(varName, defaultValue);
// Ideally, we should be setting `.defaultValue` here, but IE doesn't support it,
// so we have to use `.textContent`, which is equivalent.
el.textContent = defaultValue;
}
});
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