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);
|
$tw.wiki.removeEventListener("change",refreshHandler);
|
||||||
},false);
|
},false);
|
||||||
// Set up the styles
|
// 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");
|
styleContainer = $tw.fakeDocument.createElement("style");
|
||||||
styleWidgetNode.render(styleContainer,null);
|
styleWidgetNode.render(styleContainer,null);
|
||||||
var styleElement = srcDocument.createElement("style");
|
var styleElement = srcDocument.createElement("style");
|
||||||
|
@ -81,14 +81,16 @@ Modal.prototype.display = function(title,options) {
|
|||||||
}}}],
|
}}}],
|
||||||
parentWidget: $tw.rootWidget,
|
parentWidget: $tw.rootWidget,
|
||||||
document: document,
|
document: document,
|
||||||
variables: variables
|
variables: variables,
|
||||||
|
importPageMacros: true
|
||||||
});
|
});
|
||||||
headerWidgetNode.render(headerTitle,null);
|
headerWidgetNode.render(headerTitle,null);
|
||||||
// Render the body of the message
|
// Render the body of the message
|
||||||
var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
parentWidget: $tw.rootWidget,
|
parentWidget: $tw.rootWidget,
|
||||||
document: document,
|
document: document,
|
||||||
variables: variables
|
variables: variables,
|
||||||
|
importPageMacros: true
|
||||||
});
|
});
|
||||||
bodyWidgetNode.render(modalBody,null);
|
bodyWidgetNode.render(modalBody,null);
|
||||||
// Setup the link if present
|
// Setup the link if present
|
||||||
@ -128,7 +130,8 @@ Modal.prototype.display = function(title,options) {
|
|||||||
]}],
|
]}],
|
||||||
parentWidget: $tw.rootWidget,
|
parentWidget: $tw.rootWidget,
|
||||||
document: document,
|
document: document,
|
||||||
variables: variables
|
variables: variables,
|
||||||
|
importPageMacros: true
|
||||||
});
|
});
|
||||||
footerWidgetNode.render(modalFooterButtons,null);
|
footerWidgetNode.render(modalFooterButtons,null);
|
||||||
// Set up the refresh handler
|
// Set up the refresh handler
|
||||||
|
@ -41,7 +41,11 @@ Notifier.prototype.display = function(title,options) {
|
|||||||
// Create the variables
|
// Create the variables
|
||||||
var variables = $tw.utils.extend({currentTiddler: title},options.variables);
|
var variables = $tw.utils.extend({currentTiddler: title},options.variables);
|
||||||
// Render the body of the notification
|
// 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);
|
widgetNode.render(notification,null);
|
||||||
refreshHandler = function(changes) {
|
refreshHandler = function(changes) {
|
||||||
widgetNode.refresh(changes,notification,null);
|
widgetNode.refresh(changes,notification,null);
|
||||||
|
@ -328,7 +328,7 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is
|
|||||||
var result =
|
var result =
|
||||||
isNaN(x) && !isNaN(y) ? (isDescending ? -1 : 1) :
|
isNaN(x) && !isNaN(y) ? (isDescending ? -1 : 1) :
|
||||||
!isNaN(x) && isNaN(y) ? (isDescending ? 1 : -1) :
|
!isNaN(x) && isNaN(y) ? (isDescending ? 1 : -1) :
|
||||||
(isDescending ? y - x : x - y);
|
(isDescending ? y - x : x - y);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
if(sortField !== "title") {
|
if(sortField !== "title") {
|
||||||
@ -904,44 +904,54 @@ options: as for wiki.makeWidget() plus:
|
|||||||
options.field: optional field to transclude (defaults to "text")
|
options.field: optional field to transclude (defaults to "text")
|
||||||
options.mode: transclusion mode "inline" or "block"
|
options.mode: transclusion mode "inline" or "block"
|
||||||
options.children: optional array of children for the transclude widget
|
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) {
|
exports.makeTranscludeWidget = function(title,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var parseTree = {tree: [{
|
var parseTreeDiv = {tree: [{
|
||||||
type: "element",
|
type: "element",
|
||||||
tag: "div",
|
tag: "div",
|
||||||
children: [{
|
children: []}]},
|
||||||
type: "importvariables",
|
parseTreeImportVariables = {
|
||||||
attributes: {
|
type: "importvariables",
|
||||||
filter: {
|
attributes: {
|
||||||
name: "filter",
|
filter: {
|
||||||
type: "string",
|
name: "filter",
|
||||||
value: "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]"
|
type: "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tag: "$importvariables",
|
isBlock: false,
|
||||||
isBlock: false,
|
children: []},
|
||||||
children: [{
|
parseTreeTransclude = {
|
||||||
type: "transclude",
|
type: "transclude",
|
||||||
attributes: {
|
attributes: {
|
||||||
tiddler: {
|
tiddler: {
|
||||||
name: "tiddler",
|
name: "tiddler",
|
||||||
type: "string",
|
type: "string",
|
||||||
value: title}},
|
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) {
|
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) {
|
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) {
|
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) {
|
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");
|
container = $tw.fakeDocument.createElement("div");
|
||||||
widgetNode.render(container,null);
|
widgetNode.render(container,null);
|
||||||
return container;
|
return container;
|
||||||
|
Loading…
Reference in New Issue
Block a user