mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Modals: add navigator to handle tm-navigate (#5027)
* Wrap modal in a navigator widget to allow tm-navigate to work * Move all story list handling to Modal * Make sure any values for story list or history list sent as variables have precedence * Code clean up
This commit is contained in:
parent
ca4cdc81dd
commit
a637f7fb60
@ -13,6 +13,7 @@ Modal message mechanism
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
var widget = require("$:/core/modules/widgets/widget.js");
|
||||||
|
var navigator = require("$:/core/modules/widgets/navigator.js");
|
||||||
|
|
||||||
var Modal = function(wiki) {
|
var Modal = function(wiki) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
@ -41,7 +42,12 @@ Modal.prototype.display = function(title,options) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create the variables
|
// Create the variables
|
||||||
var variables = $tw.utils.extend({currentTiddler: title},options.variables);
|
var variables = $tw.utils.extend({
|
||||||
|
currentTiddler: title,
|
||||||
|
"tv-story-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-story-list") : ""),
|
||||||
|
"tv-history-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-history-list") : "")
|
||||||
|
},options.variables);
|
||||||
|
|
||||||
// Create the wrapper divs
|
// Create the wrapper divs
|
||||||
var wrapper = this.srcDocument.createElement("div"),
|
var wrapper = this.srcDocument.createElement("div"),
|
||||||
modalBackdrop = this.srcDocument.createElement("div"),
|
modalBackdrop = this.srcDocument.createElement("div"),
|
||||||
@ -75,6 +81,31 @@ Modal.prototype.display = function(title,options) {
|
|||||||
modalFooter.appendChild(modalFooterHelp);
|
modalFooter.appendChild(modalFooterHelp);
|
||||||
modalFooter.appendChild(modalFooterButtons);
|
modalFooter.appendChild(modalFooterButtons);
|
||||||
modalWrapper.appendChild(modalFooter);
|
modalWrapper.appendChild(modalFooter);
|
||||||
|
var navigatorTree = {
|
||||||
|
"type": "navigator",
|
||||||
|
"attributes": {
|
||||||
|
"story": {
|
||||||
|
"name": "story",
|
||||||
|
"type": "string",
|
||||||
|
"value": variables["tv-story-list"]
|
||||||
|
},
|
||||||
|
"history": {
|
||||||
|
"name": "history",
|
||||||
|
"type": "string",
|
||||||
|
"value": variables["tv-history-list"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tag": "$navigator",
|
||||||
|
"isBlock": true,
|
||||||
|
"children": []
|
||||||
|
};
|
||||||
|
var navigatorWidgetNode = new navigator.navigator(navigatorTree, {
|
||||||
|
wiki: this.wiki,
|
||||||
|
document : this.srcDocument,
|
||||||
|
parentWidget: $tw.rootWidget
|
||||||
|
});
|
||||||
|
navigatorWidgetNode.render(modalBody,null);
|
||||||
|
|
||||||
// Render the title of the message
|
// Render the title of the message
|
||||||
var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
field: "subtitle",
|
field: "subtitle",
|
||||||
@ -86,7 +117,7 @@ Modal.prototype.display = function(title,options) {
|
|||||||
type: "string",
|
type: "string",
|
||||||
value: title
|
value: title
|
||||||
}}}],
|
}}}],
|
||||||
parentWidget: $tw.rootWidget,
|
parentWidget: navigatorWidgetNode,
|
||||||
document: this.srcDocument,
|
document: this.srcDocument,
|
||||||
variables: variables,
|
variables: variables,
|
||||||
importPageMacros: true
|
importPageMacros: true
|
||||||
@ -94,11 +125,12 @@ Modal.prototype.display = function(title,options) {
|
|||||||
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: navigatorWidgetNode,
|
||||||
document: this.srcDocument,
|
document: this.srcDocument,
|
||||||
variables: variables,
|
variables: variables,
|
||||||
importPageMacros: true
|
importPageMacros: true
|
||||||
});
|
});
|
||||||
|
|
||||||
bodyWidgetNode.render(modalBody,null);
|
bodyWidgetNode.render(modalBody,null);
|
||||||
// Setup the link if present
|
// Setup the link if present
|
||||||
if(options.downloadLink) {
|
if(options.downloadLink) {
|
||||||
@ -135,7 +167,7 @@ Modal.prototype.display = function(title,options) {
|
|||||||
value: $tw.language.getString("Buttons/Close/Caption")
|
value: $tw.language.getString("Buttons/Close/Caption")
|
||||||
}}}
|
}}}
|
||||||
]}],
|
]}],
|
||||||
parentWidget: $tw.rootWidget,
|
parentWidget: navigatorWidgetNode,
|
||||||
document: this.srcDocument,
|
document: this.srcDocument,
|
||||||
variables: variables,
|
variables: variables,
|
||||||
importPageMacros: true
|
importPageMacros: true
|
||||||
|
Loading…
Reference in New Issue
Block a user