mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-19 16:24:51 +00:00
Switched stitchElement parameter from className to classes
It's shorter, and looks better
This commit is contained in:
parent
f4d530a114
commit
56e701b326
30
js/Utils.js
30
js/Utils.js
@ -246,7 +246,7 @@ utils.stringify = function(s) {
|
||||
// are processed to attr="name1:value1;name2:value2;"
|
||||
// The options include:
|
||||
// content: a string to include as content in the element (also generates closing tag)
|
||||
// classNames: an array of classnames to apply to the element
|
||||
// classes: an array of classnames to apply to the element
|
||||
// selfClosing: causes the element to be rendered with a trailing /, as in <br />
|
||||
// insertAfterAttributes: a string to insert after the attribute section of the element
|
||||
utils.stitchElement = function(element,attributes,options) {
|
||||
@ -275,8 +275,8 @@ utils.stitchElement = function(element,attributes,options) {
|
||||
if(options.insertAfterAttributes) {
|
||||
output.push(options.insertAfterAttributes);
|
||||
}
|
||||
if(options.classNames) {
|
||||
output.push(" class='",options.classNames.join(" "),"'");
|
||||
if(options.classes) {
|
||||
output.push(" class='",options.classes.join(" "),"'");
|
||||
}
|
||||
output.push(">");
|
||||
if("content" in options) {
|
||||
@ -295,7 +295,7 @@ utils.stitchSlider = function(type,label,tooltip,body) {
|
||||
}
|
||||
var labelNode = utils.stitchElement("a",labelAttrs,{
|
||||
content: label,
|
||||
classNames: ["tw-slider-label"]
|
||||
classes: ["tw-slider-label"]
|
||||
}),
|
||||
bodyNode = utils.stitchElement("div",{
|
||||
style: {
|
||||
@ -303,11 +303,11 @@ utils.stitchSlider = function(type,label,tooltip,body) {
|
||||
}
|
||||
},{
|
||||
content: body,
|
||||
classNames: ["tw-slider-body"]
|
||||
classes: ["tw-slider-body"]
|
||||
});
|
||||
return utils.stitchElement("div",null,{
|
||||
content: labelNode + bodyNode,
|
||||
classNames: ["tw-slider"]
|
||||
classes: ["tw-slider"]
|
||||
});
|
||||
} else if(type === "text/plain") {
|
||||
return label + "\n" + body;
|
||||
@ -332,30 +332,30 @@ The custom template function should push the string rendering of the node to the
|
||||
utils.renderObject = function(output,type,node,customTemplates) {
|
||||
var renderNodeHtml,
|
||||
renderArrayHtml = function(output,tree) {
|
||||
output.push(utils.stitchElement("ul",null,{classNames: ["treeArray"]}));
|
||||
output.push(utils.stitchElement("ul",null,{classes: ["treeArray"]}));
|
||||
for(var t=0; t<tree.length; t++) {
|
||||
output.push(utils.stitchElement("li",null,{classNames: ["treeArrayMember"]}));
|
||||
output.push(utils.stitchElement("li",null,{classes: ["treeArrayMember"]}));
|
||||
renderNodeHtml(output,tree[t]);
|
||||
output.push("</li>");
|
||||
}
|
||||
output.push("</ul>");
|
||||
},
|
||||
renderFieldHtml = function(output,name,value) {
|
||||
output.push(utils.stitchElement("li",null,{classNames: ["treeNodeField"]}));
|
||||
output.push(utils.stitchElement("li",null,{classes: ["treeNodeField"]}));
|
||||
if(typeof value === "object") {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["label"],
|
||||
classes: ["label"],
|
||||
content: utils.htmlEncode(name)
|
||||
}));
|
||||
renderNodeHtml(output,value);
|
||||
} else {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabel"],
|
||||
classes: ["splitLabel"],
|
||||
content: utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabelLeft"],
|
||||
classes: ["splitLabelLeft"],
|
||||
content: utils.htmlEncode(name)
|
||||
}) + utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabelRight"],
|
||||
classes: ["splitLabelRight"],
|
||||
content: utils.htmlEncode(value)
|
||||
})
|
||||
}));
|
||||
@ -367,7 +367,7 @@ utils.renderObject = function(output,type,node,customTemplates) {
|
||||
renderArrayHtml(output,node);
|
||||
} else if (typeof node === "string") {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["treeNode","label"],
|
||||
classes: ["treeNode","label"],
|
||||
content: utils.htmlEncode(node)
|
||||
}));
|
||||
} else {
|
||||
@ -378,7 +378,7 @@ utils.renderObject = function(output,type,node,customTemplates) {
|
||||
}
|
||||
}
|
||||
if(!custom) {
|
||||
output.push(utils.stitchElement("ul",null,{classNames: ["treeNode"]}));
|
||||
output.push(utils.stitchElement("ul",null,{classes: ["treeNode"]}));
|
||||
for(var f in node) {
|
||||
renderFieldHtml(output,f,node[f]);
|
||||
}
|
||||
|
@ -288,14 +288,14 @@ WikiTextParseTree.prototype.toString = function(type) {
|
||||
function(output,type,node) { // Text nodes
|
||||
if(node.type === "text") {
|
||||
output.push(utils.stitchElement("div",null,
|
||||
{classNames: ["treeNode","splitLabel"]}));
|
||||
{classes: ["treeNode","splitLabel"]}));
|
||||
output.push(utils.stitchElement("span",{"data-tw-treenode-type": "text"},{
|
||||
content: node.type,
|
||||
classNames: ["splitLabelLeft"]
|
||||
classes: ["splitLabelLeft"]
|
||||
}));
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
content: utils.htmlEncode(node.value).replace(/\n/g,"<br>"),
|
||||
classNames: ["splitLabelRight"]
|
||||
classes: ["splitLabelRight"]
|
||||
}));
|
||||
output.push("</div>");
|
||||
return true;
|
||||
@ -307,15 +307,15 @@ WikiTextParseTree.prototype.toString = function(type) {
|
||||
output.push(utils.stitchElement("span",
|
||||
{"data-tw-treenode-type": "macro"},{
|
||||
content: utils.htmlEncode(node.name),
|
||||
classNames: ["treeNode","label"]
|
||||
classes: ["treeNode","label"]
|
||||
}));
|
||||
for(var f in node.params) {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabel"]
|
||||
classes: ["splitLabel"]
|
||||
}));
|
||||
output.push(utils.stitchElement("span",{"data-tw-treenode-type": "param"},{
|
||||
content: utils.htmlEncode(f),
|
||||
classNames: ["splitLabelLeft"]
|
||||
classes: ["splitLabelLeft"]
|
||||
}));
|
||||
var v = node.params[f].value;
|
||||
if(node.params[f].type === "string") {
|
||||
@ -325,19 +325,19 @@ WikiTextParseTree.prototype.toString = function(type) {
|
||||
}
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
content: utils.htmlEncode(v),
|
||||
classNames: ["splitLabelRight"]
|
||||
classes: ["splitLabelRight"]
|
||||
}));
|
||||
output.push("</span>");
|
||||
}
|
||||
output.push(utils.stitchElement("span",null,
|
||||
{classNames: ["treeNode","splitLabel"]}));
|
||||
{classes: ["treeNode","splitLabel"]}));
|
||||
output.push(utils.stitchElement("span",{"data-tw-treenode-type": "renderStepDependencies"},{
|
||||
content: "dependencies",
|
||||
classNames: ["splitLabelLeft"]
|
||||
classes: ["splitLabelLeft"]
|
||||
}));
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
content: utils.htmlEncode(node.dependencies === null ? "*" : node.dependencies.join(", ")),
|
||||
classNames: ["splitLabelRight"]
|
||||
classes: ["splitLabelRight"]
|
||||
}));
|
||||
output.push("</span>");
|
||||
if(node.children) {
|
||||
@ -352,11 +352,11 @@ WikiTextParseTree.prototype.toString = function(type) {
|
||||
output.push(utils.stitchElement("span",
|
||||
{"data-tw-treenode-type": "html"},{
|
||||
content: node.type,
|
||||
classNames: ["treeNode","label"]
|
||||
classes: ["treeNode","label"]
|
||||
}));
|
||||
for(var f in node.attributes) {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["treeNode"]
|
||||
classes: ["treeNode"]
|
||||
}));
|
||||
var v = node.attributes[f];
|
||||
if(typeof v === "string") {
|
||||
@ -366,18 +366,18 @@ WikiTextParseTree.prototype.toString = function(type) {
|
||||
}
|
||||
if(typeof v === "object") {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["label"],
|
||||
classes: ["label"],
|
||||
content: utils.htmlEncode(f)
|
||||
}));
|
||||
utils.renderObject(output,type,v);
|
||||
} else {
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabel"],
|
||||
classes: ["splitLabel"],
|
||||
content: utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabelLeft"],
|
||||
classes: ["splitLabelLeft"],
|
||||
content: utils.htmlEncode(f)
|
||||
}) + utils.stitchElement("span",null,{
|
||||
classNames: ["splitLabelRight"],
|
||||
classes: ["splitLabelRight"],
|
||||
content: utils.htmlEncode(v)
|
||||
})
|
||||
}));
|
||||
|
@ -37,28 +37,28 @@ WikiTextRenderer.prototype.toString = function(type) {
|
||||
output.push(utils.stitchElement("span",
|
||||
{"data-tw-treenode-type": "renderStep"},{
|
||||
content: node.step.toString(),
|
||||
classNames: ["treeNode","label"]
|
||||
classes: ["treeNode","label"]
|
||||
}));
|
||||
output.push(utils.stitchElement("span",null,
|
||||
{classNames: ["treeNode","splitLabel"]}));
|
||||
{classes: ["treeNode","splitLabel"]}));
|
||||
output.push(utils.stitchElement("span",{"data-tw-treenode-type": "renderStepDependencies"},{
|
||||
content: "dependencies",
|
||||
classNames: ["splitLabelLeft"]
|
||||
classes: ["splitLabelLeft"]
|
||||
}));
|
||||
output.push(utils.stitchElement("span",null,{
|
||||
content: utils.htmlEncode(node.dependencies === null ? "*" : node.dependencies.join(", ")),
|
||||
classNames: ["splitLabelRight"]
|
||||
classes: ["splitLabelRight"]
|
||||
}));
|
||||
output.push("</span>");
|
||||
output.push(utils.stitchElement("span",null,
|
||||
{classNames: ["treeNode","splitLabel"]}));
|
||||
{classes: ["treeNode","splitLabel"]}));
|
||||
output.push(utils.stitchElement("span",{"data-tw-treenode-type": "renderStepHandler"},{
|
||||
content: "handler",
|
||||
classNames: ["splitLabelLeft"]
|
||||
classes: ["splitLabelLeft"]
|
||||
}));
|
||||
output.push(utils.stitchElement("code",null,{
|
||||
content: utils.htmlEncode(node.handler.toString()).replace(/\n/g,"<br>"),
|
||||
classNames: ["splitLabelRight"]
|
||||
classes: ["splitLabelRight"]
|
||||
}));
|
||||
output.push("</span>");
|
||||
return true;
|
||||
|
@ -22,7 +22,7 @@ exports.macro = {
|
||||
href: params.target
|
||||
},{
|
||||
content: content,
|
||||
classNames: store.adjustClassesForLink([],params.target)
|
||||
classes: store.adjustClassesForLink([],params.target)
|
||||
});
|
||||
} else if (type === "text/plain") {
|
||||
return content;
|
||||
|
Loading…
Reference in New Issue
Block a user