1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-05 08:18:06 +00:00

Search improvements

1. Extended edit macro to allow a search-styled input to be used
2. Moved search box into nav bar
This commit is contained in:
Jeremy Ruston
2012-10-17 18:03:17 +01:00
parent fbc9211688
commit 42d4be3f20
6 changed files with 51 additions and 32 deletions

View File

@@ -17,7 +17,7 @@ exports.info = {
params: {
field: {byPos: 0, type: "text"},
tiddler: {byName: true, type: "tiddler"},
singleline: {byName: true, type: "text"},
type: {byName: true, type: "text"},
"default": {byName: true, type: "text"}
}
};

View File

@@ -56,14 +56,29 @@ TextEditor.prototype.getChild = function() {
},
tagName,
content = [];
// Make a textarea for text fields and an input box for other fields
if(edit.field !== "text" || this.macroNode.hasParameter("singleline")) {
tagName = "input";
attributes.type = "text";
attributes.value = edit.value;
} else {
tagName = "textarea";
content.push($tw.Tree.Text(edit.value));
if(this.macroNode.classes) {
$tw.utils.pushTop(attributes["class"],this.macroNode.classes);
}
// Figure out what element to use for this editor
var type = this.macroNode.params.type;
if(type === undefined) {
type = edit.field === "text" ? "textarea" : "input";
}
switch(type) {
case "textarea":
tagName = "textarea";
content.push($tw.Tree.Text(edit.value));
break;
case "search":
tagName = "input";
attributes.type = "search";
attributes.value = edit.value;
break;
default: // "input"
tagName = "input";
attributes.type = "text";
attributes.value = edit.value;
break;
}
// Wrap the editor control in a div
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content)],{