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:
parent
6b67a3f3c2
commit
a5a2c718b1
@ -73,6 +73,10 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
|||||||
wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
|
wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
|
||||||
wikiLinkText = wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
|
wikiLinkText = wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
|
||||||
domNode.setAttribute("href",wikiLinkText);
|
domNode.setAttribute("href",wikiLinkText);
|
||||||
|
// Set the title
|
||||||
|
if(this.tooltip) {
|
||||||
|
domNode.setAttribute("title",this.tooltip);
|
||||||
|
}
|
||||||
// Add a click event handler
|
// Add a click event handler
|
||||||
$tw.utils.addEventListeners(domNode,[
|
$tw.utils.addEventListeners(domNode,[
|
||||||
{name: "click", handlerObject: this, handlerMethod: "handleClickEvent"},
|
{name: "click", handlerObject: this, handlerMethod: "handleClickEvent"},
|
||||||
@ -162,6 +166,8 @@ Compute the internal state of the widget
|
|||||||
LinkWidget.prototype.execute = function() {
|
LinkWidget.prototype.execute = function() {
|
||||||
// Get the target tiddler title
|
// Get the target tiddler title
|
||||||
this.to = this.getAttribute("to",this.getVariable("currentTiddler"));
|
this.to = this.getAttribute("to",this.getVariable("currentTiddler"));
|
||||||
|
// Get the link title
|
||||||
|
this.tooltip = this.getAttribute("tooltip");
|
||||||
// Determine the link characteristics
|
// Determine the link characteristics
|
||||||
this.isMissing = !this.wiki.tiddlerExists(this.to);
|
this.isMissing = !this.wiki.tiddlerExists(this.to);
|
||||||
this.isShadow = this.wiki.isShadowTiddler(this.to);
|
this.isShadow = this.wiki.isShadowTiddler(this.to);
|
||||||
|
@ -7,6 +7,7 @@ The `link` widget generates links to tiddlers.
|
|||||||
|
|
||||||
|!Attribute |!Description |
|
|!Attribute |!Description |
|
||||||
|to |The title of the target tiddler for the link (defaults to the [[WidgetVariable: currentTiddler]]) |
|
|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.
|
The content of the link widget is rendered within the `<a>` tag.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user