mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 02:56:29 +00:00
Fix search autofocus
This commit is contained in:
parent
c25aa507d3
commit
06945f433b
2 changed files with 7 additions and 7 deletions
|
@ -61,14 +61,16 @@ proc genCheckbox*(pref, label: string; state: bool): VNode =
|
||||||
else: input(name=pref, `type`="checkbox")
|
else: input(name=pref, `type`="checkbox")
|
||||||
span(class="checkbox")
|
span(class="checkbox")
|
||||||
|
|
||||||
proc genInput*(pref, label, state, placeholder: string; class=""; autofocus=false): VNode =
|
proc genInput*(pref, label, state, placeholder: string; class=""): VNode =
|
||||||
let s = xmltree.escape(state)
|
let s = xmltree.escape(state)
|
||||||
let p = xmltree.escape(placeholder)
|
let p = xmltree.escape(placeholder)
|
||||||
let a = if autofocus: "autofocus" else: ""
|
|
||||||
buildHtml(tdiv(class=("pref-group pref-input " & class))):
|
buildHtml(tdiv(class=("pref-group pref-input " & class))):
|
||||||
if label.len > 0:
|
if label.len > 0:
|
||||||
label(`for`=pref): text label
|
label(`for`=pref): text label
|
||||||
input(name=pref, `type`="text", placeholder=p, value=s): text a
|
if s.len == 0:
|
||||||
|
input(name=pref, `type`="text", placeholder=p, value=s, autofocus="")
|
||||||
|
else:
|
||||||
|
input(name=pref, `type`="text", placeholder=p, value=s)
|
||||||
|
|
||||||
proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
|
proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
|
||||||
buildHtml(tdiv(class="pref-group pref-input")):
|
buildHtml(tdiv(class="pref-group pref-input")):
|
||||||
|
|
|
@ -58,8 +58,7 @@ proc renderSearchPanel*(query: Query): VNode =
|
||||||
let action = if user.len > 0: &"/{user}/search" else: "/search"
|
let action = if user.len > 0: &"/{user}/search" else: "/search"
|
||||||
buildHtml(form(`method`="get", action=action, class="search-field")):
|
buildHtml(form(`method`="get", action=action, class="search-field")):
|
||||||
hiddenField("f", "tweets")
|
hiddenField("f", "tweets")
|
||||||
genInput("q", "", query.text, "Enter search...",
|
genInput("q", "", query.text, "Enter search...", class="pref-inline")
|
||||||
class="pref-inline", autofocus=true)
|
|
||||||
button(`type`="submit"): icon "search"
|
button(`type`="submit"): icon "search"
|
||||||
if isPanelOpen(query):
|
if isPanelOpen(query):
|
||||||
input(id="search-panel-toggle", `type`="checkbox", checked="")
|
input(id="search-panel-toggle", `type`="checkbox", checked="")
|
||||||
|
@ -110,8 +109,7 @@ proc renderUserSearch*(results: Result[Profile]; prefs: Prefs): VNode =
|
||||||
tdiv(class="timeline-header"):
|
tdiv(class="timeline-header"):
|
||||||
form(`method`="get", action="/search", class="search-field"):
|
form(`method`="get", action="/search", class="search-field"):
|
||||||
hiddenField("f", "users")
|
hiddenField("f", "users")
|
||||||
genInput("q", "", results.query.text, "Enter username...",
|
genInput("q", "", results.query.text, "Enter username...", class="pref-inline")
|
||||||
class="pref-inline", autofocus=true)
|
|
||||||
button(`type`="submit"): icon "search"
|
button(`type`="submit"): icon "search"
|
||||||
|
|
||||||
renderSearchTabs(results.query)
|
renderSearchTabs(results.query)
|
||||||
|
|
Loading…
Reference in a new issue