Last active
January 17, 2020 21:17
-
-
Save videlais/8681773 to your computer and use it in GitHub Desktop.
No-click Twine (1.4) using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, create a reference to the Wikifier.createInternalLink function. | |
// (Internally, this is what Twine uses to connect passages together. | |
// It is the last step in parsing double-bracked content into links.) | |
var oldCreateInternalLink = Wikifier.createInternalLink; | |
// Then, create a new function that mimics its functionality. | |
Wikifier.createInternalLink = function(place, title) { | |
// By calling the old function, it returns | |
// the DOM element (the link) it was about to | |
// add to a passage. | |
link = oldCreateInternalLink(place, title); | |
// Using jQuery, add a listener for a 'mouseover' event. | |
// When it happens, call the anonymous function to | |
// 'Click' the link itself. | |
$(link).on('mouseover', function() { | |
this.click(); | |
}); | |
// Finally, return the link so that it can be added to a passage | |
return link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment