print-window-tiddler
Jeremy Ruston 2012-06-13 10:41:10 +01:00
rodzic caf32d9598
commit 0830cdac73
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -19,12 +19,15 @@ function TextEditor(macroNode) {
} }
TextEditor.prototype.getChild = function() { TextEditor.prototype.getChild = function() {
// Get the current tiddler and the field name
var tiddler = this.macroNode.wiki.getTiddler(this.macroNode.tiddlerTitle), var tiddler = this.macroNode.wiki.getTiddler(this.macroNode.tiddlerTitle),
field = this.macroNode.hasParameter("field") ? this.macroNode.params.field : "title", field = this.macroNode.hasParameter("field") ? this.macroNode.params.field : "title",
value; value;
// If we've got a tiddler, the value to display is the field string value
if(tiddler) { if(tiddler) {
value = tiddler.getFieldString(field); value = tiddler.getFieldString(field);
} else { } else {
// Otherwise, we need to construct a default value for the editor
switch(field) { switch(field) {
case "text": case "text":
value = "Type the text for the tiddler '" + this.macroNode.tiddlerTitle + "'"; value = "Type the text for the tiddler '" + this.macroNode.tiddlerTitle + "'";
@ -42,6 +45,7 @@ TextEditor.prototype.getChild = function() {
}, },
tagName, tagName,
content = []; content = [];
// Make a textarea for text fields and an input box for other fields
if(field === "text") { if(field === "text") {
tagName = "textarea"; tagName = "textarea";
content.push($tw.Tree.Text(value)); content.push($tw.Tree.Text(value));
@ -50,6 +54,7 @@ TextEditor.prototype.getChild = function() {
attributes.type = "text"; attributes.type = "text";
attributes.value = value; attributes.value = value;
} }
// Wrap the editor control in a div
return $tw.Tree.Element("div",{},[$tw.Tree.Element(tagName,attributes,content)]); return $tw.Tree.Element("div",{},[$tw.Tree.Element(tagName,attributes,content)]);
}; };