Commit 3f78fa26 authored by Leon Arnott's avatar Leon Arnott
Browse files

Fixed a long-standing bug where clicking passage links would activate...

Fixed a long-standing bug where clicking passage links would activate (click:?Page) macros in the arrival passage.

Also improved performance of the documentation HTML in Chrome.

Closes #214.
parent 3facc58b0f7f
......@@ -22,6 +22,7 @@ Documentation is at http://twine2.neocities.org/. See below for compilation inst
* Fixed a bug where giving a blank string as the Cancel button's label to `(prompt:)` or `(confirm:)` wouldn't cause the Cancel button to disappear.
* Fixed a bug where `(link-rerun:)` behaved like `(link-repeat:)` when it was enchanted by `(enchant:)`.
* Fixed a bug where error messages would sometimes refer to temp variables named "all" as "all values of the temporary variables". The same applies to "any", "start", and "end".
* Fixed a long-standing bug where clicking passage links would activate `(click:?Page)` macros in the arrival passage.
* Fixed a bug where hidden hooks and the `(hidden:)` changer would suppress the effects of `(hook:)`.
* Fixed a bug where `...array-type` parameters to custom macros would unwittingly "flatten" the passed-in arrays, joining them all together.
* Now, dataset data should be displayed correctly in the Variables panel in Debug Mode.
......
......@@ -30,7 +30,7 @@ define(['jquery', 'macros', 'utils', 'state', 'passages', 'engine', 'datatypes/c
*/
"click.passage-link",
'tw-link',
function clickLinkEvent() {
function clickLinkEvent(e) {
const link = $(this),
/*
Since there can be a <tw-enchantment> between the parent <tw-expression>
......@@ -84,6 +84,7 @@ define(['jquery', 'macros', 'utils', 'state', 'passages', 'engine', 'datatypes/c
});
if (next) {
e.stopPropagation();
// TODO: stretchtext
Engine.goToPassage(next, { transition });
return;
......@@ -92,10 +93,12 @@ define(['jquery', 'macros', 'utils', 'state', 'passages', 'engine', 'datatypes/c
Or, a (link-undo:) or (link-fullscreen:) link.
*/
if (link.is('[undo]')) {
e.stopPropagation();
Engine.goBack({ transition });
return;
}
if (link.is('[fullscreen]')) {
e.stopPropagation();
Engine.toggleFullscreen();
/*
Notice that the presence of the handler below means that we don't have to
......
......@@ -986,7 +986,7 @@ define(['macros', 'utils', 'utils/operationutils', 'datatypes/colour', 'datatype
<div style="background:linear-gradient(0deg, rgba(191, 63, 63, 1) 0%, rgba(165, 191, 63, 1) 20%,
rgba(63, 191, 114, 1) 40%, rgba(63, 114, 191, 1) 60%, rgba(165, 63, 191, 1) 80%,
rgba(191, 63, 63, 1) 100%); height:64px;"></div>
</div>
Any angle can be given to (gradient:), including diagonal values like 40 or 66.
Details:
......
......@@ -256,7 +256,12 @@ html.on('click', '#night', function() { html.addClass('night'); $('#previewCode'
})
.on('click', '.previewButton:not(.previewCodeButton)', function(e) { previewPassage(e.target.parentNode.textContent.replace(/\\u200B/g,'')); });
$('pre > code').append("<div class='previewButton' title='Run this Harlowe code.'></div>");
}</script>
}
/* Chrome performance hack */
if (!navigator.userAgent.includes("Firefox")) {
console.log("Removed animated elements for performance reasons:", $('[style*=animation:]').remove());
}
</script>
`;
/*
Done
......
......@@ -230,28 +230,58 @@ describe("interaction macros", function() {
expect(p.attr('tabindex')).toBe('0');
});
}
if (name === "?Page" && goTo) {
it("doesn't trigger when arriving on the page by the same input method", function(done) {
createPassage("''foo''","baz");
createPassage("(" + e.name + ":"+name+",'baz')''grault''","corge");
var p = runPassage("(" + e.name + ":"+name+",'corge')");
p[e.eventMethod]();
setTimeout(function() {
expect($('tw-passage:last-child').find('b').text()).toBe("grault");
done();
},20);
});
if (e.eventMethod === "click") {
it("doesn't trigger when arriving on the page via undo", function(done) {
if (name === "?Page") {
if (goTo) {
it("doesn't trigger when arriving on the page by the same input method", function(done) {
createPassage("''foo''","baz");
runPassage("(" + e.name + ":"+name+",'baz')''grault''","corge");
runPassage("");
$('tw-sidebar [alt=Undo]')[e.eventMethod]();
createPassage("(" + e.name + ":"+name+",'baz')''grault''","corge");
var p = runPassage("(t8n-arrive:'instant')(" + e.name + ":"+name+",'corge')");
p[e.eventMethod]();
setTimeout(function() {
expect($('tw-passage:last-child').find('b').text()).toBe("grault");
done();
},20);
});
if (e.eventMethod === "click") {
it("doesn't trigger when arriving on the page via undo", function(done) {
createPassage("''foo''","baz");
runPassage("(" + e.name + ":"+name+",'baz')''grault''","corge");
runPassage("");
$('tw-sidebar [alt=Undo]')[e.eventMethod]();
setTimeout(function() {
expect($('tw-passage:last-child').find('b').text()).toBe("grault");
done();
},20);
});
}
} else if (!undo) {
it("doesn't trigger when arriving on the page by a (goto:) revealed by the same input method", function(done) {
createPassage("''foo''","baz");
createPassage("(" + e.name + ":"+name+")[=''grault''","corge");
var p = runPassage("(" + e.name + ":"+name+")[=(t8n-arrive:'instant')(goto:'corge')");
p[e.eventMethod]();
setTimeout(function() {
expect($('tw-passage:last-child').find('b').text()).not.toBe("grault");
done();
},20);
done();
});
if (e.eventMethod === "click") {
it("doesn't trigger when arriving on the page by a link", function(done) {
createPassage("''foo''","baz");
createPassage("(" + e.name + ":"+name+")[=''grault''","corge");
var p = runPassage("(t8n-arrive:'instant')[[corge]]");
p.find('tw-link')[e.eventMethod]();
setTimeout(function() {
expect($('tw-passage:last-child').find('b').text()).not.toBe("grault");
done();
},20);
});
}
}
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment