include search form in navbar dropdown
This commit is contained in:
parent
acad701b64
commit
22e6998479
@ -36,6 +36,13 @@ Liberapay.init = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.navbar .dropdown-hover').removeClass('dropdown-hover');
|
$('.navbar .dropdown-hover').removeClass('dropdown-hover');
|
||||||
|
|
||||||
|
$('.dropdown-toggle-form').click(function() {
|
||||||
|
var $this = $(this);
|
||||||
|
setTimeout(function() {
|
||||||
|
$this.siblings('.dropdown-menu').find('input').eq(0).focus();
|
||||||
|
}, 10);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Liberapay.error = function(jqXHR, textStatus, errorThrown) {
|
Liberapay.error = function(jqXHR, textStatus, errorThrown) {
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
& > .level2 > a {
|
& > .level2 > a {
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
}
|
}
|
||||||
|
.form-group {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.dropdown-hover .dropdown-menu {
|
.dropdown-hover .dropdown-menu {
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
% from 'templates/nav.html' import icon_span, nav, nav_about, nav_explore with context
|
% from 'templates/nav.html' import icon_span, nav, nav_about, nav_explore with context
|
||||||
|
% from 'templates/search.html' import search_form with context
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
@ -37,6 +38,9 @@
|
|||||||
}),
|
}),
|
||||||
('/search', _('Search'), {
|
('/search', _('Search'), {
|
||||||
'icon': 'glyphicon glyphicon-search',
|
'icon': 'glyphicon glyphicon-search',
|
||||||
|
'form': True,
|
||||||
|
'role': 'search',
|
||||||
|
'subnav': search_form(),
|
||||||
}),
|
}),
|
||||||
('/about/', _('About'), {
|
('/about/', _('About'), {
|
||||||
'icon': 'glyphicon glyphicon-question-sign',
|
'icon': 'glyphicon glyphicon-question-sign',
|
||||||
|
@ -11,14 +11,18 @@
|
|||||||
% set icon = icon_span(icon) if icon else ''
|
% set icon = icon_span(icon) if icon else ''
|
||||||
<li{% if slug.strip('/') == current %} class="active"{% endif %}>
|
<li{% if slug.strip('/') == current %} class="active"{% endif %}>
|
||||||
% if options['subnav']
|
% if options['subnav']
|
||||||
|
% set button_extra_cls = 'dropdown-toggle-form' if options['form'] else ''
|
||||||
<div class="dropdown dropdown-hover">
|
<div class="dropdown dropdown-hover">
|
||||||
<button class="dropdown-toggle navbar-btn" type="button"
|
<button class="dropdown-toggle navbar-btn {{ button_extra_cls }}"
|
||||||
data-toggle="dropdown" aria-expanded="true">
|
data-toggle="dropdown" aria-expanded="true">
|
||||||
{{ icon }}
|
{{ icon }}
|
||||||
<span>{{ item[1] }}</span>
|
<span>{{ item[1] }}</span>
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
</button>
|
||||||
|
% if options['role']
|
||||||
|
<div class="dropdown-menu" role="{{ options['role'] }}">{{ options['subnav'] }}</div>
|
||||||
|
% else
|
||||||
<ul class="dropdown-menu" role="menu">{{ options['subnav'] }}</ul>
|
<ul class="dropdown-menu" role="menu">{{ options['subnav'] }}</ul>
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
% else
|
% else
|
||||||
<a href="{{ base }}{{ slug }}">{{ icon }} {{ item[1] }}</a>
|
<a href="{{ base }}{{ slug }}">{{ icon }} {{ item[1] }}</a>
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<form action="/search" method="get">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" name="q" class="form-control" placeholder="{{ _('Search Liberapay') }}"
|
|
||||||
value="{{ query or '' }}" {{ 'autofocus' if request.path.raw.startswith('/search') else '' }} />
|
|
||||||
<div class="input-group-btn">
|
|
||||||
<button class="btn btn-default">{{ _("Go") }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
16
templates/search.html
Normal file
16
templates/search.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
% macro search_form(autofocus=False)
|
||||||
|
<form action="/search" class="search" method="get">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="q" class="form-control"
|
||||||
|
style="width: 250px;"
|
||||||
|
placeholder="{{ _('Search Liberapay') }}"
|
||||||
|
value="{{ query or '' }}"
|
||||||
|
{{ 'autofocus' if autofocus else '' }} />
|
||||||
|
<div class="input-group-btn">
|
||||||
|
<button class="btn btn-default">{{ _("Go") }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
% endmacro
|
@ -14,12 +14,14 @@ top_communities = query_cache.all("""
|
|||||||
title = _("Explore")
|
title = _("Explore")
|
||||||
|
|
||||||
[-----------------------------]
|
[-----------------------------]
|
||||||
|
% from 'templates/search.html' import search_form with context
|
||||||
|
|
||||||
% extends "templates/explore.html"
|
% extends "templates/explore.html"
|
||||||
|
|
||||||
% block content
|
% block content
|
||||||
|
|
||||||
<p>{{ _("Whose work do you appreciate? See if they're on Liberapay:") }}</p>
|
<p>{{ _("Whose work do you appreciate? See if they're on Liberapay:") }}</p>
|
||||||
% include "templates/search-box.html"
|
{{ search_form() }}
|
||||||
|
|
||||||
<p>{{ _("You can also pledge to people who haven't joined Liberapay yet:") }}</p>
|
<p>{{ _("You can also pledge to people who haven't joined Liberapay yet:") }}</p>
|
||||||
% include "templates/jump.html"
|
% include "templates/jump.html"
|
||||||
|
@ -72,6 +72,7 @@ if query:
|
|||||||
[---] text/html
|
[---] text/html
|
||||||
% extends "templates/base.html"
|
% extends "templates/base.html"
|
||||||
% from 'templates/avatar-url.html' import avatar_url, avatar_img with context
|
% from 'templates/avatar-url.html' import avatar_url, avatar_img with context
|
||||||
|
% from 'templates/search.html' import search_form with context
|
||||||
% block content
|
% block content
|
||||||
|
|
||||||
% set usernames = results.get('usernames')
|
% set usernames = results.get('usernames')
|
||||||
@ -84,7 +85,7 @@ if query:
|
|||||||
) }}</p>
|
) }}</p>
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% include "templates/search-box.html"
|
{{ search_form(autofocus=True) }}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
% if usernames
|
% if usernames
|
||||||
|
Loading…
x
Reference in New Issue
Block a user