mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-28 04:19:56 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
529345f08b
@ -96,8 +96,11 @@ exports.getBoundingPageRect = function(element) {
|
|||||||
Saves a named password in the browser
|
Saves a named password in the browser
|
||||||
*/
|
*/
|
||||||
exports.savePassword = function(name,password) {
|
exports.savePassword = function(name,password) {
|
||||||
if(window.localStorage) {
|
try {
|
||||||
localStorage.setItem("tw5-password-" + name,password);
|
if(window.localStorage) {
|
||||||
|
localStorage.setItem("tw5-password-" + name,password);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,7 +108,11 @@ exports.savePassword = function(name,password) {
|
|||||||
Retrieve a named password from the browser
|
Retrieve a named password from the browser
|
||||||
*/
|
*/
|
||||||
exports.getPassword = function(name) {
|
exports.getPassword = function(name) {
|
||||||
return window.localStorage ? localStorage.getItem("tw5-password-" + name) : "";
|
try {
|
||||||
|
return window.localStorage ? localStorage.getItem("tw5-password-" + name) : "";
|
||||||
|
} catch(e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -67,20 +67,27 @@ Modal.prototype.display = function(title,options) {
|
|||||||
modalFooter.appendChild(modalFooterButtons);
|
modalFooter.appendChild(modalFooterButtons);
|
||||||
modalWrapper.appendChild(modalFooter);
|
modalWrapper.appendChild(modalFooter);
|
||||||
// Render the title of the message
|
// Render the title of the message
|
||||||
var titleText;
|
var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
if(tiddler && tiddler.fields && tiddler.fields.subtitle) {
|
field: "subtitle",
|
||||||
titleText = tiddler.fields.subtitle;
|
children: [{
|
||||||
} else {
|
type: "text",
|
||||||
titleText = title;
|
attributes: {
|
||||||
}
|
text: {
|
||||||
var headerParser = this.wiki.parseText("text/vnd.tiddlywiki",titleText,{parseAsInline: true}),
|
type: "string",
|
||||||
headerWidgetNode = this.wiki.makeWidget(headerParser,{parentWidget: $tw.rootWidget, document: document});
|
value: title
|
||||||
|
}}}],
|
||||||
|
parentWidget: $tw.rootWidget,
|
||||||
|
document: document
|
||||||
|
});
|
||||||
headerWidgetNode.render(headerTitle,null);
|
headerWidgetNode.render(headerTitle,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 bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{parentWidget: $tw.rootWidget, document: document});
|
var bodyWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
|
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);
|
||||||
@ -100,14 +107,31 @@ Modal.prototype.display = function(title,options) {
|
|||||||
modalFooterHelp.appendChild(link);
|
modalFooterHelp.appendChild(link);
|
||||||
modalFooterHelp.style.float = "left";
|
modalFooterHelp.style.float = "left";
|
||||||
}
|
}
|
||||||
var footerText;
|
var footerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
if(tiddler && tiddler.fields && tiddler.fields.footer) {
|
field: "footer",
|
||||||
footerText = tiddler.fields.footer;
|
children: [{
|
||||||
} else {
|
type: "button",
|
||||||
footerText = '<$button message="tw-close-tiddler" class="btn btn-primary">Close</$button>';
|
attributes: {
|
||||||
}
|
message: {
|
||||||
var footerParser = this.wiki.parseText("text/vnd.tiddlywiki",footerText,{parseAsInline: true}),
|
type: "string",
|
||||||
footerWidgetNode = this.wiki.makeWidget(footerParser,{parentWidget: $tw.rootWidget, document: document});
|
value: "tw-close-tiddler"
|
||||||
|
},
|
||||||
|
"class": {
|
||||||
|
type: "string",
|
||||||
|
value: "btn btn-primary"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
children: [{
|
||||||
|
type: "text",
|
||||||
|
attributes: {
|
||||||
|
text: {
|
||||||
|
type: "string",
|
||||||
|
value: "Close"
|
||||||
|
}}}
|
||||||
|
]}],
|
||||||
|
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);
|
||||||
|
@ -856,19 +856,30 @@ exports.makeWidget = function(parser,options) {
|
|||||||
/*
|
/*
|
||||||
Make a widget tree for transclusion
|
Make a widget tree for transclusion
|
||||||
title: target tiddler title
|
title: target tiddler title
|
||||||
options: as for wiki.makeWidget() (including parseAsInline)
|
options: as for wiki.makeWidget() plus:
|
||||||
|
options.field: optional field to transclude (defaults to "text")
|
||||||
|
options.children: optional array of children for the transclude widget
|
||||||
*/
|
*/
|
||||||
exports.makeTranscludeWidget = function(title,options) {
|
exports.makeTranscludeWidget = function(title,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var parseTree = {tree: [{
|
var parseTree = {tree: [{
|
||||||
type: "transclude",
|
type: "element",
|
||||||
attributes: {
|
tag: "div",
|
||||||
tiddler: {
|
children: [{
|
||||||
name: "tiddler",
|
type: "transclude",
|
||||||
type: "string",
|
attributes: {
|
||||||
value: title}},
|
tiddler: {
|
||||||
isBlock: !options.parseAsInline}
|
name: "tiddler",
|
||||||
|
type: "string",
|
||||||
|
value: title}},
|
||||||
|
isBlock: !options.parseAsInline}]}
|
||||||
]};
|
]};
|
||||||
|
if(options.field) {
|
||||||
|
parseTree.tree[0].children[0].attributes.field = {type: "string", value: options.field};
|
||||||
|
}
|
||||||
|
if(options.children) {
|
||||||
|
parseTree.tree[0].children[0].children = options.children;
|
||||||
|
}
|
||||||
return $tw.wiki.makeWidget(parseTree,options);
|
return $tw.wiki.makeWidget(parseTree,options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user