1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-11 18:00:26 +00:00

Added setstyle widget and use it to colour the tag buttons

This commit is contained in:
Jeremy Ruston 2013-01-03 22:36:51 +00:00
parent 975711e22e
commit a43d7aed95
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,40 @@
/*\
title: $:/core/modules/widget/setstyle.js
type: application/javascript
module-type: widget
Implements the setstyle widget.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var SetStyleWidget = function(renderer) {
// Save state
this.renderer = renderer;
// Generate child nodes
this.generate();
};
SetStyleWidget.prototype.generate = function() {
// Get the parameters from the attributes
this.name = this.renderer.getAttribute("name");
this.value = this.renderer.getAttribute("value");
this["class"] = this.renderer.getAttribute("class");
// Set up the element
this.tag = this.renderer.parseTreeNode.isBlock ? "div" : "span";
this.attributes = {
style: this.name + ":" + this.value
};
if(this["class"]) {
this.attributes["class"] = this["class"];
}
this.children = this.renderer.renderTree.createRenderers(this.renderer.renderContext,this.renderer.parseTreeNode.children);
};
exports.setstyle = SetStyleWidget;
})();

View File

@ -1,6 +1,6 @@
title: $:/templates/TagTemplate
<$button popup="tagpopup" qualifyTiddlerTitles="yes" class="btn-invisible">@@.label <$view field="title" format="text" />@@</$button>
<$button popup="tagpopup" qualifyTiddlerTitles="yes" class="btn-invisible"><$setstyle name="background-color" value={{!!color}} class="label"><$view field="title" format="text" /></$setstyle></$button>
<$reveal state="tagpopup" type="popup" position="below" qualifyTiddlerTitles="yes" ><div class="open">
@@.dropdown-menu