mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
Use the new wiki.makeWidget() method where we can
This commit is contained in:
parent
4eebe7388d
commit
14d7d5ea59
@ -41,18 +41,7 @@ Command.prototype.execute = function() {
|
|||||||
tiddlers = wiki.filterTiddlers(filter);
|
tiddlers = wiki.filterTiddlers(filter);
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
var parser = wiki.new_parseTiddler(template),
|
var parser = wiki.new_parseTiddler(template),
|
||||||
parseTreeNode = parser ? {type: "widget", children: [{
|
widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}});
|
||||||
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
|
|
||||||
});
|
|
||||||
var container = $tw.document.createElement("div");
|
var container = $tw.document.createElement("div");
|
||||||
widgetNode.render(container,null);
|
widgetNode.render(container,null);
|
||||||
var text = type === "text/html" ? container.innerHTML : container.textContent;
|
var text = type === "text/html" ? container.innerHTML : container.textContent;
|
||||||
|
@ -65,12 +65,8 @@ exports.parse = function() {
|
|||||||
return parser.tree;
|
return parser.tree;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, render to the rendertype and return in a <PRE> tag
|
// Otherwise, render to the rendertype and return in a <PRE> tag
|
||||||
var parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
|
var widgetNode = this.parser.wiki.makeWidget(parser),
|
||||||
widgetNode = new widget.widget(parseTreeNode,{
|
container = $tw.document.createElement("div");
|
||||||
wiki: $tw.wiki,
|
|
||||||
document: $tw.document
|
|
||||||
});
|
|
||||||
var container = $tw.document.createElement("div");
|
|
||||||
widgetNode.render(container,null);
|
widgetNode.render(container,null);
|
||||||
var text = renderType === "text/html" ? container.innerHTML : container.textContent;
|
var text = renderType === "text/html" ? container.innerHTML : container.textContent;
|
||||||
return [{
|
return [{
|
||||||
|
@ -105,12 +105,7 @@ exports.startup = function() {
|
|||||||
// Display the PageTemplate
|
// Display the PageTemplate
|
||||||
var templateTitle = "$:/core/ui/PageTemplate",
|
var templateTitle = "$:/core/ui/PageTemplate",
|
||||||
parser = $tw.wiki.new_parseTiddler(templateTitle),
|
parser = $tw.wiki.new_parseTiddler(templateTitle),
|
||||||
parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
|
widgetNode = $tw.wiki.makeWidget(parser,{document: document, parentWidget: $tw.rootWidget});
|
||||||
widgetNode = new widget.widget(parseTreeNode,{
|
|
||||||
wiki: $tw.wiki,
|
|
||||||
parentWidget: $tw.rootWidget,
|
|
||||||
document: document
|
|
||||||
});
|
|
||||||
$tw.new_pageContainer = document.createElement("div");
|
$tw.new_pageContainer = document.createElement("div");
|
||||||
$tw.utils.addClass($tw.new_pageContainer,"tw-page-container");
|
$tw.utils.addClass($tw.new_pageContainer,"tw-page-container");
|
||||||
document.body.insertBefore($tw.new_pageContainer,document.body.firstChild);
|
document.body.insertBefore($tw.new_pageContainer,document.body.firstChild);
|
||||||
|
@ -74,24 +74,14 @@ Modal.prototype.display = function(title,options) {
|
|||||||
titleText = title;
|
titleText = title;
|
||||||
}
|
}
|
||||||
var headerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",titleText,{parseAsInline: true}),
|
var headerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",titleText,{parseAsInline: true}),
|
||||||
headerParseTreeNode = headerParser ? {type: "widget", children: headerParser.tree} : undefined,
|
headerWidgetNode = this.wiki.makeWidget(headerParser,{parentWidget: $tw.rootWidget, document: document});
|
||||||
headerWidgetNode = new widget.widget(headerParseTreeNode,{
|
|
||||||
wiki: this.wiki,
|
|
||||||
parentWidget: $tw.rootWidget,
|
|
||||||
document: document
|
|
||||||
});
|
|
||||||
headerWidgetNode.render(modalHeader,null);
|
headerWidgetNode.render(modalHeader,null);
|
||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
headerWidgetNode.refresh(changes,modalHeader,null);
|
headerWidgetNode.refresh(changes,modalHeader,null);
|
||||||
});
|
});
|
||||||
// Render the body of the message
|
// Render the body of the message
|
||||||
var bodyParser = this.wiki.new_parseTiddler(title),
|
var bodyParser = this.wiki.new_parseTiddler(title),
|
||||||
bodyParseTreeNode = bodyParser ? {type: "widget", children: bodyParser.tree} : undefined,
|
bodyWidgetNode = this.wiki.makeWidget(bodyParser,{parentWidget: $tw.rootWidget, document: document});
|
||||||
bodyWidgetNode = new widget.widget(bodyParseTreeNode,{
|
|
||||||
wiki: this.wiki,
|
|
||||||
parentWidget: $tw.rootWidget,
|
|
||||||
document: document
|
|
||||||
});
|
|
||||||
bodyWidgetNode.render(modalBody,null);
|
bodyWidgetNode.render(modalBody,null);
|
||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
bodyWidgetNode.refresh(changes,modalBody,null);
|
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>';
|
footerText = '<$button message="tw-close-tiddler" class="btn btn-primary">Close</$button>';
|
||||||
}
|
}
|
||||||
var footerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",footerText,{parseAsInline: true}),
|
var footerParser = this.wiki.new_parseText("text/vnd.tiddlywiki",footerText,{parseAsInline: true}),
|
||||||
footerParseTreeNode = footerParser ? {type: "widget", children: footerParser.tree} : undefined,
|
footerWidgetNode = this.wiki.makeWidget(footerParser,{parentWidget: $tw.rootWidget, document: document});
|
||||||
footerWidgetNode = new widget.widget(footerParseTreeNode,{
|
|
||||||
wiki: this.wiki,
|
|
||||||
parentWidget: $tw.rootWidget,
|
|
||||||
document: document
|
|
||||||
});
|
|
||||||
footerWidgetNode.render(modalFooterButtons,null);
|
footerWidgetNode.render(modalFooterButtons,null);
|
||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
footerWidgetNode.refresh(changes,modalFooterButtons,null);
|
footerWidgetNode.refresh(changes,modalFooterButtons,null);
|
||||||
|
@ -38,12 +38,7 @@ Notifier.prototype.display = function(title,options) {
|
|||||||
$tw.utils.addClass(notification,"tw-notification");
|
$tw.utils.addClass(notification,"tw-notification");
|
||||||
// Render the body of the notification
|
// Render the body of the notification
|
||||||
var parser = this.wiki.new_parseTiddler(title),
|
var parser = this.wiki.new_parseTiddler(title),
|
||||||
parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
|
widgetNode = this.wiki.makeWidget(parser,{parentWidget: $tw.rootWidget, document: document});
|
||||||
widgetNode = new widget.widget(parseTreeNode,{
|
|
||||||
wiki: this.wiki,
|
|
||||||
parentWidget: $tw.rootWidget,
|
|
||||||
document: document
|
|
||||||
});
|
|
||||||
widgetNode.render(notification,null);
|
widgetNode.render(notification,null);
|
||||||
this.wiki.addEventListener("change",function(changes) {
|
this.wiki.addEventListener("change",function(changes) {
|
||||||
widgetNode.refresh(changes,notification,null);
|
widgetNode.refresh(changes,notification,null);
|
||||||
|
Loading…
Reference in New Issue
Block a user