It looks like you're new here. If you want to get involved, click one of these buttons!
macros.add("popup", {
version: { major: 1, minor: 0, revision: 0 },
handler: function ()
{
if (this.args.length < 2)
{
var errors = [];
if (this.args.length < 1) { errors.push("link text"); }
if (this.args.length < 2) { errors.push("passage name"); }
return this.error("no " + errors.join(" or ") + " specified");
}
var el = document.createElement("a");
el.innerHTML = this.args[0];
el.className = "link-internal link-popup";
el.setAttribute("data-passage", this.args[1]);
UISystem.addClickHandler(el, null, function(evt) {
var dialog = document.getElementById("ui-body");
$(dialog)
.empty()
.addClass("dialog popup");
new Wikifier(dialog, tale.get(evt.target.getAttribute("data-passage")).processText().trim());
return true;
});
this.output.appendChild(el);
}
});
Comments
startFn
callback toUISystem.addClickHandler()
is a tad verbose. I'd suggest usingUISystem.setup()
, like so:As to automatically opening a dialog upon passage display, that seems like it could get a little irksome, from a player perspective, if done too frequently. I don't know. /shrug
Regardless, you could do so via the following macro (since you're already using a macro for the other):
And don't worry, it definitely makes sense for the one specific instance am using it for. Won't be used for evil.