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

Minor tweaks to #3052

This commit is contained in:
Jermolene 2017-12-12 12:30:34 +00:00
parent 661bff4f5b
commit 38fbc4f35a
2 changed files with 9 additions and 10 deletions

View File

@ -64,7 +64,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
var domNode = this.document.createElement(tag); var domNode = this.document.createElement(tag);
// Assign classes // Assign classes
var classes = []; var classes = [];
if(this.enforceClasses === undefined) { if(this.overrideClasses === undefined)
classes.push("tc-tiddlylink"); classes.push("tc-tiddlylink");
if(this.isShadow) { if(this.isShadow) {
classes.push("tc-tiddlylink-shadow"); classes.push("tc-tiddlylink-shadow");
@ -77,9 +77,8 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
} }
} }
classes.push(this.linkClasses); classes.push(this.linkClasses);
} } else if(this.overrideClasses !== "")
else if (this.enforceClasses !== "") { classes.push(this.overrideClasses)
classes.push(this.enforceClasses);
} }
if(classes.length > 0) { if(classes.length > 0) {
domNode.setAttribute("class",classes.join(" ")); domNode.setAttribute("class",classes.join(" "));
@ -174,7 +173,7 @@ LinkWidget.prototype.execute = function() {
this.tooltip = this.getAttribute("tooltip"); this.tooltip = this.getAttribute("tooltip");
this["aria-label"] = this.getAttribute("aria-label"); this["aria-label"] = this.getAttribute("aria-label");
this.linkClasses = this.getAttribute("class"); this.linkClasses = this.getAttribute("class");
this.enforceClasses = this.getAttribute("setClass");; this.overrideClasses = this.getAttribute("overrideClass");
this.tabIndex = this.getAttribute("tabindex"); this.tabIndex = this.getAttribute("tabindex");
this.draggable = this.getAttribute("draggable","yes"); this.draggable = this.getAttribute("draggable","yes");
this.linkTag = this.getAttribute("tag","a"); this.linkTag = this.getAttribute("tag","a");

View File

@ -16,8 +16,8 @@ The `link` widget generates links to tiddlers. (Use the HTML `<a>` element to ge
|tabindex |Optional numeric [[tabindex|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex]] | |tabindex |Optional numeric [[tabindex|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex]] |
|draggable |"yes" to enable the link to be draggable (defaults to "yes") | |draggable |"yes" to enable the link to be draggable (defaults to "yes") |
|tag |Optional tag to override the default "a" element | |tag |Optional tag to override the default "a" element |
|class|Optional css classes __in addition to__ the default classes (see below)| |class|Optional CSS classes //in addition to// the default classes (see below)|
|setClass|Optional css classes __instead of__ the default classes <<.from-version "5.1.16">>| |overrideClass|<<.from-version "5.1.16">> Optional CSS classes //instead of// the default classes |
The content of the link widget is rendered within the `<a>` tag. The draggable functionality is equivalent to using the DraggableWidget with the ''tiddler'' attribute set to the link target. The content of the link widget is rendered within the `<a>` tag. The draggable functionality is equivalent to using the DraggableWidget with the ''tiddler'' attribute set to the link target.
@ -64,11 +64,11 @@ The link widget automatically determines and applies the following classes to li
* `tc-tiddlylink-missing` - applied to tiddler links where the target tiddler doesn't exist * `tc-tiddlylink-missing` - applied to tiddler links where the target tiddler doesn't exist
* `tc-tiddlylink-resolves` - applied to tiddler links when the target tiddler does exist * `tc-tiddlylink-resolves` - applied to tiddler links when the target tiddler does exist
Use the `class` attribute to specify additional css classes, or `setClass` to apply only that but not the above defaults, e.g. when used in a LinkCatcherWidget: Use the `class` attribute to specify additional css classes, or `overrideClass` to apply only that but not the above defaults, e.g. when used in a LinkCatcherWidget:
<<wikitext-example-without-html """*<$link class="example">Here</$link> the `example` class is added. <<wikitext-example-without-html """*<$link class="example">Here</$link> the `example` class is added.
*<$link setClass="example">Here</$link> only the `example` class applies. *<$link overrideClass="example">Here</$link> only the `example` class applies.
*<$link setClass="">Here</$link> no class is set.""">> *<$link overrideClass="">Here</$link> no class is set.""">>
! `href` generation ! `href` generation