mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Refinements to 87fa7f972c
This commit is contained in:
parent
5aba7292e7
commit
8e02bde938
@ -49,7 +49,10 @@ exports.startup = function() {
|
||||
$tw.wiki.removeEventListener("change",refreshHandler);
|
||||
},false);
|
||||
// Set up the styles
|
||||
var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{document: $tw.fakeDocument, variables: variables}),
|
||||
var styleWidgetNode = $tw.wiki.makeTranscludeWidget("$:/core/ui/PageStylesheet",{
|
||||
document: $tw.fakeDocument,
|
||||
variables: variables,
|
||||
importPageMacros: true}),
|
||||
styleContainer = $tw.fakeDocument.createElement("style");
|
||||
styleWidgetNode.render(styleContainer,null);
|
||||
var styleElement = srcDocument.createElement("style");
|
||||
|
@ -81,14 +81,16 @@ Modal.prototype.display = function(title,options) {
|
||||
}}}],
|
||||
parentWidget: $tw.rootWidget,
|
||||
document: document,
|
||||
variables: variables
|
||||
variables: variables,
|
||||
importPageMacros: true
|
||||
});
|
||||
headerWidgetNode.render(headerTitle,null);
|
||||
// Render the body of the message
|
||||
var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||
parentWidget: $tw.rootWidget,
|
||||
document: document,
|
||||
variables: variables
|
||||
variables: variables,
|
||||
importPageMacros: true
|
||||
});
|
||||
bodyWidgetNode.render(modalBody,null);
|
||||
// Setup the link if present
|
||||
@ -128,7 +130,8 @@ Modal.prototype.display = function(title,options) {
|
||||
]}],
|
||||
parentWidget: $tw.rootWidget,
|
||||
document: document,
|
||||
variables: variables
|
||||
variables: variables,
|
||||
importPageMacros: true
|
||||
});
|
||||
footerWidgetNode.render(modalFooterButtons,null);
|
||||
// Set up the refresh handler
|
||||
|
@ -41,7 +41,11 @@ Notifier.prototype.display = function(title,options) {
|
||||
// Create the variables
|
||||
var variables = $tw.utils.extend({currentTiddler: title},options.variables);
|
||||
// Render the body of the notification
|
||||
var widgetNode = this.wiki.makeTranscludeWidget(title,{parentWidget: $tw.rootWidget, document: document, variables: variables});
|
||||
var widgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||
parentWidget: $tw.rootWidget,
|
||||
document: document,
|
||||
variables: variables,
|
||||
importPageMacros: true});
|
||||
widgetNode.render(notification,null);
|
||||
refreshHandler = function(changes) {
|
||||
widgetNode.refresh(changes,notification,null);
|
||||
|
@ -904,44 +904,54 @@ options: as for wiki.makeWidget() plus:
|
||||
options.field: optional field to transclude (defaults to "text")
|
||||
options.mode: transclusion mode "inline" or "block"
|
||||
options.children: optional array of children for the transclude widget
|
||||
options.importVariables: optional importvariables filter string for macros to be included
|
||||
options.importPageMacros: optional boolean; if true, equivalent to passing "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" to options.importVariables
|
||||
*/
|
||||
exports.makeTranscludeWidget = function(title,options) {
|
||||
options = options || {};
|
||||
var parseTree = {tree: [{
|
||||
var parseTreeDiv = {tree: [{
|
||||
type: "element",
|
||||
tag: "div",
|
||||
children: [{
|
||||
children: []}]},
|
||||
parseTreeImportVariables = {
|
||||
type: "importvariables",
|
||||
attributes: {
|
||||
filter: {
|
||||
name: "filter",
|
||||
type: "string",
|
||||
value: "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]"
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
tag: "$importvariables",
|
||||
isBlock: false,
|
||||
children: [{
|
||||
children: []},
|
||||
parseTreeTransclude = {
|
||||
type: "transclude",
|
||||
attributes: {
|
||||
tiddler: {
|
||||
name: "tiddler",
|
||||
type: "string",
|
||||
value: title}},
|
||||
isBlock: !options.parseAsInline}
|
||||
]
|
||||
}]}
|
||||
]};
|
||||
isBlock: !options.parseAsInline};
|
||||
if(options.importVariables || options.importPageMacros) {
|
||||
if(options.importVariables) {
|
||||
parseTreeImportVariables.attributes.filter.value = options.importVariables;
|
||||
} else if(options.importPageMacros) {
|
||||
parseTreeImportVariables.attributes.filter.value = "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]";
|
||||
}
|
||||
parseTreeDiv.tree[0].children.push(parseTreeImportVariables);
|
||||
parseTreeImportVariables.children.push(parseTreeTransclude);
|
||||
} else {
|
||||
parseTreeDiv.tree[0].children.push(parseTreeTransclude);
|
||||
}
|
||||
if(options.field) {
|
||||
parseTree.tree[0].children[0].attributes.field = {type: "string", value: options.field};
|
||||
parseTreeTransclude.attributes.field = {type: "string", value: options.field};
|
||||
}
|
||||
if(options.mode) {
|
||||
parseTree.tree[0].children[0].attributes.mode = {type: "string", value: options.mode};
|
||||
parseTreeTransclude.attributes.mode = {type: "string", value: options.mode};
|
||||
}
|
||||
if(options.children) {
|
||||
parseTree.tree[0].children[0].children = options.children;
|
||||
parseTreeTransclude.children = options.children;
|
||||
}
|
||||
return $tw.wiki.makeWidget(parseTree,options);
|
||||
return $tw.wiki.makeWidget(parseTreeDiv,options);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -122,7 +122,10 @@ Slicer.prototype.getSourceHtmlDocument = function(tiddler) {
|
||||
};
|
||||
|
||||
Slicer.prototype.getSourceWikiDocument = function(tiddler) {
|
||||
var widgetNode = this.wiki.makeTranscludeWidget(this.sourceTitle,{document: $tw.fakeDocument, parseAsInline: false}),
|
||||
var widgetNode = this.wiki.makeTranscludeWidget(this.sourceTitle,{
|
||||
document: $tw.fakeDocument,
|
||||
parseAsInline: false,
|
||||
importPageMacros: true}),
|
||||
container = $tw.fakeDocument.createElement("div");
|
||||
widgetNode.render(container,null);
|
||||
return container;
|
||||
|
Loading…
Reference in New Issue
Block a user