From a5a2c718b1d5671652d01e3567dba1c6795b7521 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 6 Mar 2014 12:38:47 +0000 Subject: [PATCH] Add support for a tooltip on the link widget --- core/modules/widgets/link.js | 6 ++++++ editions/tw5.com/tiddlers/widgets/LinkWidget.tid | 1 + 2 files changed, 7 insertions(+) diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index 03f462e7b..52f9fb7e4 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -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); diff --git a/editions/tw5.com/tiddlers/widgets/LinkWidget.tid b/editions/tw5.com/tiddlers/widgets/LinkWidget.tid index ad481db99..1d41ddaca 100644 --- a/editions/tw5.com/tiddlers/widgets/LinkWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/LinkWidget.tid @@ -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 `` tag.