1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add support for a tooltip on the link widget

This commit is contained in:
Jermolene 2014-03-06 12:38:47 +00:00
parent 6b67a3f3c2
commit a5a2c718b1
2 changed files with 7 additions and 0 deletions

View File

@ -73,6 +73,10 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
wikiLinkText = wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
domNode.setAttribute("href",wikiLinkText);
// Set the title
if(this.tooltip) {
domNode.setAttribute("title",this.tooltip);
}
// Add a click event handler
$tw.utils.addEventListeners(domNode,[
{name: "click", handlerObject: this, handlerMethod: "handleClickEvent"},
@ -162,6 +166,8 @@ Compute the internal state of the widget
LinkWidget.prototype.execute = function() {
// Get the target tiddler title
this.to = this.getAttribute("to",this.getVariable("currentTiddler"));
// Get the link title
this.tooltip = this.getAttribute("tooltip");
// Determine the link characteristics
this.isMissing = !this.wiki.tiddlerExists(this.to);
this.isShadow = this.wiki.isShadowTiddler(this.to);

View File

@ -7,6 +7,7 @@ The `link` widget generates links to tiddlers.
|!Attribute |!Description |
|to |The title of the target tiddler for the link (defaults to the [[WidgetVariable: currentTiddler]]) |
|tooltip |Optional tooltip text |
The content of the link widget is rendered within the `<a>` tag.