1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +00:00

Set the colour of the tag pills

We no longer need the old setstyle widget
This commit is contained in:
Jeremy Ruston 2013-10-14 21:38:12 +01:00
parent 0e037e3c5b
commit 707024a118
2 changed files with 8 additions and 2 deletions

View File

@ -46,6 +46,8 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
}
}
domNode.className = classes.join(" ");
// Assign classes
domNode.setAttribute("style",this.style);
// Add a click event handler
domNode.addEventListener("click",function (event) {
var handled = false;
@ -114,6 +116,7 @@ ButtonWidget.prototype.execute = function() {
this.hover = this.getAttribute("hover");
this.qualifyTiddlerTitles = this.getAttribute("qualifyTiddlerTitles");
this["class"] = this.getAttribute("class","");
this.style = this.getAttribute("style");
this.selectedClass = this.getAttribute("selectedClass");
// Qualify tiddler titles if required
if(this.qualifyTiddlerTitles) {
@ -134,7 +137,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
ButtonWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.qualifyTiddlerTitles || changedAttributes["class"] || changedAttributes.selectedClass || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup])) {
if(changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.qualifyTiddlerTitles || changedAttributes["class"] || changedAttributes.selectedClass || changedAttributes.style || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup])) {
this.refreshSelf();
return true;
}

View File

@ -1,6 +1,9 @@
title: $:/core/ui/TagTemplate
<$button popup="$:/state/tagpopup" qualifyTiddlerTitles="yes" class="btn-invisible"><$setstyle name="background-color" value={{!!color}} class="tw-tag-label"><$transclude title={{!!icon}}/> <$view field="title" format="text" /></$setstyle></$button>
\define tag-styles()
background-color:$(backgroundColor)$;
\end
<$setvariable name="backgroundColor" value={{!!color}}><$button popup="$:/state/tagpopup" qualifyTiddlerTitles="yes" class="btn-invisible tw-tag-label" style=<<tag-styles>>><$transclude title={{!!icon}}/> <$view field="title" format="text" /></$button></$setvariable>
<$reveal state="$:/state/tagpopup" type="popup" position="below" qualifyTiddlerTitles="yes" ><div class="tw-drop-down">
<$view field="title" format="link" />
----