mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +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:
		| @@ -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"} | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -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); | ||||||
|  | 	} | ||||||
|  | 	// 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"; | 			tagName = "input"; | ||||||
| 			attributes.type = "text"; | 			attributes.type = "text"; | ||||||
| 			attributes.value = edit.value; | 			attributes.value = edit.value; | ||||||
| 	} else { | 			break; | ||||||
| 		tagName = "textarea"; |  | ||||||
| 		content.push($tw.Tree.Text(edit.value)); |  | ||||||
| 	} | 	} | ||||||
| 	// 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)],{ | ||||||
|   | |||||||
| @@ -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>> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								core/templates/SearchResultTemplate.tid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								core/templates/SearchResultTemplate.tid
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | title: $:/templates/SearchResultTemplate | ||||||
|  |  | ||||||
|  | <<view title link>> | ||||||
| @@ -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> |  | ||||||
| @@ -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`)// | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston