mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 22:16:41 +00:00
extend LinkWidget to enforce classes (#3052)
* extend ListWidget to enforce classes Previously, the undocumented *class* attribute only allowed to specify additional classes to be set. Especially for use within a LinkCatcher, you can now apply / enforce only the custom classes and avoid any of the defaults being applied depending on the link target. This will allow to implement #1161 more gracefully. * use setClass insted of exclamation mark syntax update docs & fix typo in docs
This commit is contained in:
committed by
Jeremy Ruston
parent
4d2d202935
commit
661bff4f5b
@@ -64,21 +64,26 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
||||
var domNode = this.document.createElement(tag);
|
||||
// Assign classes
|
||||
var classes = [];
|
||||
if(this.linkClasses) {
|
||||
if(this.enforceClasses === undefined) {
|
||||
classes.push("tc-tiddlylink");
|
||||
if(this.isShadow) {
|
||||
classes.push("tc-tiddlylink-shadow");
|
||||
}
|
||||
if(this.isMissing && !this.isShadow) {
|
||||
classes.push("tc-tiddlylink-missing");
|
||||
} else {
|
||||
if(!this.isMissing) {
|
||||
classes.push("tc-tiddlylink-resolves");
|
||||
}
|
||||
}
|
||||
classes.push(this.linkClasses);
|
||||
}
|
||||
classes.push("tc-tiddlylink");
|
||||
if(this.isShadow) {
|
||||
classes.push("tc-tiddlylink-shadow");
|
||||
else if (this.enforceClasses !== "") {
|
||||
classes.push(this.enforceClasses);
|
||||
}
|
||||
if(this.isMissing && !this.isShadow) {
|
||||
classes.push("tc-tiddlylink-missing");
|
||||
} else {
|
||||
if(!this.isMissing) {
|
||||
classes.push("tc-tiddlylink-resolves");
|
||||
}
|
||||
if(classes.length > 0) {
|
||||
domNode.setAttribute("class",classes.join(" "));
|
||||
}
|
||||
domNode.setAttribute("class",classes.join(" "));
|
||||
// Set an href
|
||||
var wikilinkTransformFilter = this.getVariable("tv-filter-export-link"),
|
||||
wikiLinkText;
|
||||
@@ -169,6 +174,7 @@ LinkWidget.prototype.execute = function() {
|
||||
this.tooltip = this.getAttribute("tooltip");
|
||||
this["aria-label"] = this.getAttribute("aria-label");
|
||||
this.linkClasses = this.getAttribute("class");
|
||||
this.enforceClasses = this.getAttribute("setClass");;
|
||||
this.tabIndex = this.getAttribute("tabindex");
|
||||
this.draggable = this.getAttribute("draggable","yes");
|
||||
this.linkTag = this.getAttribute("tag","a");
|
||||
|
||||
Reference in New Issue
Block a user