mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-28 20:12:41 +00:00
96 lines
5.8 KiB
Plaintext
96 lines
5.8 KiB
Plaintext
title: $:/core/ui/SideBarSegments/search
|
|
tags: $:/tags/SideBarSegment
|
|
|
|
\whitespace trim
|
|
|
|
\define count-popup-button()
|
|
\whitespace trim
|
|
<$button popup=<<qualify "$:/state/popup/search-dropdown">> class="tc-btn-invisible">
|
|
{{$:/core/images/down-arrow}}
|
|
<$list filter="[{$(searchTiddler)$}minlength{$:/config/Search/MinLength}limit[1]]" variable="listItem">
|
|
<$vars userInput={{{ [<searchTiddler>get[text]] }}} configTiddler={{{ [[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}] }}} replaceRegexp="limit\[\d+\]">
|
|
<$vars primaryListFilter={{{ [<configTiddler>get[first-search-filter]search-replace:g:regexp<replaceRegexp>,[]] }}} secondaryListFilter={{{ [<configTiddler>get[second-search-filter]search-replace:g:regexp<replaceRegexp>,[]] }}}>
|
|
<$set name="resultCount" value="""<$count filter="[subfilter<primaryListFilter>] [subfilter<secondaryListFilter>]"/>""">
|
|
{{$:/language/Search/Matches}}
|
|
</$set>
|
|
</$vars>
|
|
</$vars>
|
|
</$list>
|
|
</$button>
|
|
\end
|
|
|
|
\define search-results-list()
|
|
\whitespace trim
|
|
<$vars userInput={{$(searchTiddler)$}} configTiddler={{{ [[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}] }}}>
|
|
<$list filter="[<userInput>minlength{$:/config/Search/MinLength}limit[1]]" emptyMessage="""<div class="tc-search-results">{{$:/language/Search/Search/TooShort}}</div>""" variable="listItem">
|
|
|
|
<$tiddler tiddler=<<configTiddler>>>
|
|
|
|
{{$:/core/ui/SearchResults}}
|
|
|
|
</$tiddler>
|
|
|
|
</$list>
|
|
</$vars>
|
|
\end
|
|
|
|
\define cancel-search-actions() <$list filter="[<searchTiddler>get[text]!match{$:/temp/search}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/search]] [<searchTiddler>] [<searchListState>]"/>"""><$action-setfield $tiddler="$:/temp/search" text={{{ [<searchTiddler>get[text]] }}}/><$action-setfield $tiddler="$:/temp/search/refresh" text="yes"/></$list>
|
|
|
|
\define input-accept-actions() <$list filter="[{$:/config/Search/NavigateOnEnter/enable}match[yes]]" emptyMessage="""<$list filter="[<__tiddler__>get[text]!is[missing]] ~[<__tiddler__>get[text]is[shadow]]"><$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/></$list>"""><$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/></$list>
|
|
|
|
\define input-accept-variant-actions() <$list filter="[{$:/config/Search/NavigateOnEnter/enable}match[yes]]" emptyMessage="""<$list filter="[<__tiddler__>get[text]!is[missing]] ~[<__tiddler__>get[text]is[shadow]]"><$list filter="[<__tiddler__>get[text]minlength[1]]"><$action-sendmessage $message="tm-edit-tiddler" $param={{{ [<__tiddler__>get[text]] }}}/></$list></$list>"""><$list filter="[<__tiddler__>get[text]minlength[1]]"><$action-sendmessage $message="tm-edit-tiddler" $param={{{ [<__tiddler__>get[text]] }}}/></$list></$list>
|
|
|
|
\define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/search-results/sidebar" tag="$:/tags/SearchResults" beforeafter="$beforeafter$" defaultState={{$:/config/SearchResults/Default}} actions="""<$action-setfield $tiddler="$:/state/search/currentTab" text=<<nextTab>>/>"""/>
|
|
|
|
\define advanced-search-actions() <$action-setfield $tiddler="$:/temp/advancedsearch" text={{$:/temp/search/input}}/><$action-setfield $tiddler="$:/temp/advancedsearch/input" text={{$:/temp/search/input}}/><<delete-state-tiddlers>><$action-navigate $to="$:/AdvancedSearch"/><$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/><$action-sendmessage $message="tm-focus-selector" $param="""[data-tiddler-title="$:/AdvancedSearch"] .tc-search input""" preventScroll="true"/><$action-deletetiddler $filter="$:/temp/search $:/temp/search/input $:/temp/search/refresh [<searchListState>]"/>
|
|
|
|
<div class="tc-sidebar-lists tc-sidebar-search">
|
|
|
|
<$vars editTiddler="$:/temp/search" searchTiddler="$:/temp/search/input" searchListState=<<qualify "$:/state/search-list/selected-item">>>
|
|
<div class="tc-search">
|
|
<$keyboard key="((input-tab-right))" actions=<<set-next-input-tab>>>
|
|
<$keyboard key="((input-tab-left))" actions=<<set-next-input-tab "before">>>
|
|
<$keyboard key="((advanced-search-sidebar))" actions=<<advanced-search-actions>>>
|
|
<form class="tc-form-inline">
|
|
<$macrocall $name="keyboard-driven-input" tiddler=<<editTiddler>> storeTitle=<<searchTiddler>>
|
|
selectionStateTitle=<<searchListState>> refreshTitle="$:/temp/search/refresh" type="search"
|
|
tag="input" focus={{$:/config/Search/AutoFocus}} focusPopup=<<qualify "$:/state/popup/search-dropdown">>
|
|
class="tc-popup-handle" filterMinLength={{$:/config/Search/MinLength}} inputCancelActions=<<cancel-search-actions>>
|
|
inputAcceptActions=<<input-accept-actions>> inputAcceptVariantActions=<<input-accept-variant-actions>> cancelPopups="yes"
|
|
configTiddlerFilter="[[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}]"/>
|
|
</form>
|
|
</$keyboard>
|
|
</$keyboard>
|
|
</$keyboard>
|
|
<$reveal state=<<searchTiddler>> type="nomatch" text="">
|
|
<$button tooltip={{$:/language/Buttons/AdvancedSearch/Hint}} aria-label={{$:/language/Buttons/AdvancedSearch/Caption}} class="tc-btn-invisible">
|
|
<<advanced-search-actions>>
|
|
{{$:/core/images/advanced-search-button}}
|
|
</$button>
|
|
<$button class="tc-btn-invisible">
|
|
<<cancel-search-actions>><$action-sendmessage $message="tm-focus-selector" $param=".tc-search input"/>
|
|
{{$:/core/images/close-button}}
|
|
</$button>
|
|
<<count-popup-button>>
|
|
</$reveal>
|
|
<$reveal state=<<searchTiddler>> type="match" text="">
|
|
<$button to="$:/AdvancedSearch" tooltip={{$:/language/Buttons/AdvancedSearch/Hint}} aria-label={{$:/language/Buttons/AdvancedSearch/Caption}} class="tc-btn-invisible">
|
|
{{$:/core/images/advanced-search-button}}
|
|
</$button>
|
|
</$reveal>
|
|
</div>
|
|
|
|
<$reveal tag="div" class="tc-block-dropdown-wrapper" state=<<searchTiddler>> type="nomatch" text="">
|
|
|
|
<$reveal tag="div" class="tc-block-dropdown tc-search-drop-down tc-popup-handle" state=<<qualify "$:/state/popup/search-dropdown">> type="nomatch" text="" default="">
|
|
|
|
<<search-results-list>>
|
|
|
|
</$reveal>
|
|
|
|
</$reveal>
|
|
|
|
</$vars>
|
|
|
|
</div>
|