Add support for a tooltip on the link widget

print-window-tiddler
Jermolene 2014-03-06 12:38:47 +00:00
rodzic 6b67a3f3c2
commit a5a2c718b1
2 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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.