1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-10 11:59:58 +00:00

Use the new wiki.makeWidget() method where we can

This commit is contained in:
Jeremy Ruston 2013-10-29 14:51:35 +00:00
parent 4eebe7388d
commit 14d7d5ea59
5 changed files with 8 additions and 48 deletions

View File

@ -41,18 +41,7 @@ Command.prototype.execute = function() {
tiddlers = wiki.filterTiddlers(filter);
$tw.utils.each(tiddlers,function(title) {
var parser = wiki.new_parseTiddler(template),
parseTreeNode = parser ? {type: "widget", children: [{
type: "setvariable",
attributes: {
name: {type: "string", value: "currentTiddler"},
value: {type: "string", value: title}
},
children: parser.tree
}]} : undefined,
widgetNode = new widget.widget(parseTreeNode,{
wiki: wiki,
document: $tw.document
});
widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}});
var container = $tw.document.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent;

View File

@ -65,12 +65,8 @@ exports.parse = function() {
return parser.tree;
} else {
// Otherwise, render to the rendertype and return in a <PRE> tag
var parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
widgetNode = new widget.widget(parseTreeNode,{
wiki: $tw.wiki,
document: $tw.document
});
var container = $tw.document.createElement("div");
var widgetNode = this.parser.wiki.makeWidget(parser),
container = $tw.document.createElement("div");
widgetNode.render(container,null);
var text = renderType === "text/html" ? container.innerHTML : container.textContent;
return [{

View File

@ -105,12 +105,7 @@ exports.startup = function() {
// Display the PageTemplate
var templateTitle = "$:/core/ui/PageTemplate",
parser = $tw.wiki.new_parseTiddler(templateTitle),
parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
widgetNode = new widget.widget(parseTreeNode,{
wiki: $tw.wiki,
parentWidget: $tw.rootWidget,
document: document
});
widgetNode = $tw.wiki.makeWidget(parser,{document: document, parentWidget: $tw.rootWidget});
$tw.new_pageContainer = document.createElement("div");
$tw.utils.addClass($tw.new_pageContainer,"tw-page-container");
document.body.insertBefore($tw.new_pageContainer,document.body.firstChild);

View File

@ -74,24 +74,14 @@ Modal.prototype.display = function(title,options) {
titleText = title;
}
var headerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",titleText,{parseAsInline: true}),
headerParseTreeNode = headerParser ? {type: "widget", children: headerParser.tree} : undefined,
headerWidgetNode = new widget.widget(headerParseTreeNode,{
wiki: this.wiki,
parentWidget: $tw.rootWidget,
document: document
});
headerWidgetNode = this.wiki.makeWidget(headerParser,{parentWidget: $tw.rootWidget, document: document});
headerWidgetNode.render(modalHeader,null);
this.wiki.addEventListener("change",function(changes) {
headerWidgetNode.refresh(changes,modalHeader,null);
});
// Render the body of the message
var bodyParser = this.wiki.new_parseTiddler(title),
bodyParseTreeNode = bodyParser ? {type: "widget", children: bodyParser.tree} : undefined,
bodyWidgetNode = new widget.widget(bodyParseTreeNode,{
wiki: this.wiki,
parentWidget: $tw.rootWidget,
document: document
});
bodyWidgetNode = this.wiki.makeWidget(bodyParser,{parentWidget: $tw.rootWidget, document: document});
bodyWidgetNode.render(modalBody,null);
this.wiki.addEventListener("change",function(changes) {
bodyWidgetNode.refresh(changes,modalBody,null);
@ -118,12 +108,7 @@ Modal.prototype.display = function(title,options) {
footerText = '<$button message="tw-close-tiddler" class="btn btn-primary">Close</$button>';
}
var footerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",footerText,{parseAsInline: true}),
footerParseTreeNode = footerParser ? {type: "widget", children: footerParser.tree} : undefined,
footerWidgetNode = new widget.widget(footerParseTreeNode,{
wiki: this.wiki,
parentWidget: $tw.rootWidget,
document: document
});
footerWidgetNode = this.wiki.makeWidget(footerParser,{parentWidget: $tw.rootWidget, document: document});
footerWidgetNode.render(modalFooterButtons,null);
this.wiki.addEventListener("change",function(changes) {
footerWidgetNode.refresh(changes,modalFooterButtons,null);

View File

@ -38,12 +38,7 @@ Notifier.prototype.display = function(title,options) {
$tw.utils.addClass(notification,"tw-notification");
// Render the body of the notification
var parser = this.wiki.new_parseTiddler(title),
parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
widgetNode = new widget.widget(parseTreeNode,{
wiki: this.wiki,
parentWidget: $tw.rootWidget,
document: document
});
widgetNode = this.wiki.makeWidget(parser,{parentWidget: $tw.rootWidget, document: document});
widgetNode.render(notification,null);
this.wiki.addEventListener("change",function(changes) {
widgetNode.refresh(changes,notification,null);