1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +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: { params: {
field: {byPos: 0, type: "text"}, field: {byPos: 0, type: "text"},
tiddler: {byName: true, type: "tiddler"}, tiddler: {byName: true, type: "tiddler"},
singleline: {byName: true, type: "text"}, type: {byName: true, type: "text"},
"default": {byName: true, type: "text"} "default": {byName: true, type: "text"}
} }
}; };

View File

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

View File

@ -24,6 +24,28 @@ title: $:/templates/PageTemplate
* [[Docs]] * [[Docs]]
*{{divider-vertical}} *{{divider-vertical}}
<form class="form-search">
{{search-query{
<<edit tiddler:[[$:/search/text]] type:search>>
}}}
<div style="position:absolute; z-index:1000;">
<<reveal state:[[$:/search/text]] type:nomatch text:""><
<div class="open">
<div class="dropdown-menu">
<<list filter:"[searchVia[$:/search/text]!is[shadow]sort[title]limit[10]]" template:"$:/templates/SearchResultTemplate" emptyMessage:"//No results//">>
</div>
</div>
>>
</div>
</form>
<!-- Full screen button --> <!-- Full screen button -->
<<button full-screen class:"btn btn-warning"><Full screen>> <<button full-screen class:"btn btn-warning"><Full screen>>

View File

@ -0,0 +1,3 @@
title: $:/templates/SearchResultTemplate
<<view title link>>

View File

@ -1,21 +0,0 @@
title: Search
Search: <<edit tiddler:[[$:/search/text]]>>
<div style="position:absolute; z-index:1000;">
<<reveal state:[[$:/search/text]] type:nomatch text:""><
<div class="open">
<div class="dropdown-menu">
(((
[searchVia[$:/search/text]!is[shadow]sort[title]]
)) <<view title link>> )
</div>
</div>
>>
</div>

View File

@ -14,7 +14,7 @@ TiddlyWiki5 isn't yet built in to TiddlySpot but you can use it by following the
! TiddlySpot details ! TiddlySpot details
Wiki name: <<edit tiddler:[[$:/UploadName]] default:"" singleline:yes>> Wiki name: <<edit tiddler:[[$:/UploadName]] default:"" type:input>>
Password: <<password upload>> Password: <<password upload>>
@ -22,6 +22,6 @@ Password: <<password upload>>
If you're using a server other than TiddlySpot, you can set the server URL here: If you're using a server other than TiddlySpot, you can set the server URL here:
Service URL: <<edit tiddler:[[$:/UploadURL]] default:"" singleline:yes>> Service URL: <<edit tiddler:[[$:/UploadURL]] default:"" type:input>>
//(by default, the server URL is `http://<wikiname>.tiddlyspot.com/store.cgi`)// //(by default, the server URL is `http://<wikiname>.tiddlyspot.com/store.cgi`)//