1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 18:47:20 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/LinkWidget.tid

73 lines
2.1 KiB
Plaintext
Raw Normal View History

title: LinkWidget
tags: docs widget
2013-03-04 14:42:41 +00:00
The `link` widget generates links to tiddlers and external URIs. Optionally, hovering over a link can trigger the display of another tiddler as a popup.
! Attributes
2013-03-04 14:42:41 +00:00
* `to` - link target can be a URL
* `hover` - the title of a tiddler containing the popup state to set when hovering over the link
* `qualifyHoverTitles` - if this attribute is present then the title of the hover state tiddler is qualified as described in the PopupMechanism
2013-03-04 14:42:41 +00:00
The `to` attribute is interpreted as an external link if it matches this regular expression:
```
/(?:file|http|https|mailto|ftp|irc|news|data):[^\s'"]+(?:\/|\b)/i
```
! Examples
The `hover` attribute is part of the PopupMechanism.
For example:
```
`$:/MyHover` is {{$:/MyHover}}
<$link to="HelloThere" hover="$:/MyHover">Hover me to see ~HelloThere!</$link>
<$reveal state="$:/MyHover" type="popup">
<div class="tw-drop-down">
{{HelloThere}}
</div>
</$reveal>
```
Renders as:
`$:/MyHover` is {{$:/MyHover}}
<$link to="HelloThere" hover="$:/MyHover">Hover me to see ~HelloThere!</$link>
<$reveal state="$:/MyHover" type="popup">
<div class="tw-drop-down">
{{HelloThere}}
</div>
</$reveal>
! CSS Classes
2013-03-04 14:42:41 +00:00
* `tw-tiddlylink` - applied to all links
* `tw-tiddlylink-external` - applied to external, non-tiddler links
* `tw-tiddlylink-internal` - applied to tiddler links
* `tw-tiddlylink-missing` - applied to tiddler links where the target tiddler doesn't exist
* `tw-tiddlylink-resolves` - applied to tiddler links when the target tiddler does exist
! Configuration macros
Configuration macros can be used to modify the behaviour of the link widget.
!! tw-wikilinks
Links are suppressed if the macro `tw-wikilinks` evaluates to the string `no`. For example:
```
\define tw-wikilinks() no
```
!! tw-wikilink-template
Link targets default to the URL encoded title of the tiddler. The `href` can be templated by defining the configuration macro `tw-wikilink-template`, and including within it the token `$uri_encoded$`. For example:
```
\define tw-wikilink-template() http://tiddlywiki.com/#$uri_encoded$
```