diff --git a/js/10-base.js b/js/10-base.js index 82b1d82a6..52b413058 100644 --- a/js/10-base.js +++ b/js/10-base.js @@ -36,6 +36,13 @@ Liberapay.init = function() { }); $('.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) { diff --git a/style/base/navbar.scss b/style/base/navbar.scss index bf9e63003..8aa83f445 100644 --- a/style/base/navbar.scss +++ b/style/base/navbar.scss @@ -54,6 +54,9 @@ & > .level2 > a { padding-left: 30px; } + .form-group { + margin: 0 10px; + } } .dropdown-hover .dropdown-menu { border-top-left-radius: 0; diff --git a/templates/base.html b/templates/base.html index 4cd81cd2d..aa96e4d5c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,6 +20,7 @@ % from 'templates/nav.html' import icon_span, nav, nav_about, nav_explore with context +% from 'templates/search.html' import search_form with context
@@ -37,6 +38,9 @@ }), ('/search', _('Search'), { 'icon': 'glyphicon glyphicon-search', + 'form': True, + 'role': 'search', + 'subnav': search_form(), }), ('/about/', _('About'), { 'icon': 'glyphicon glyphicon-question-sign', diff --git a/templates/nav.html b/templates/nav.html index 84f19b2e4..b8886ca8a 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -11,14 +11,18 @@ % set icon = icon_span(icon) if icon else '' % if options['subnav'] + % set button_extra_cls = 'dropdown-toggle-form' if options['form'] else '' % else {{ icon }} {{ item[1] }} diff --git a/templates/search-box.html b/templates/search-box.html deleted file mode 100644 index 0a39f8bb3..000000000 --- a/templates/search-box.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
- -
- -
-
-
-
diff --git a/templates/search.html b/templates/search.html new file mode 100644 index 000000000..a4b107c2d --- /dev/null +++ b/templates/search.html @@ -0,0 +1,16 @@ +% macro search_form(autofocus=False) + +% endmacro diff --git a/www/explore/index.html.spt b/www/explore/index.html.spt index c71806e2a..4dbc5b163 100644 --- a/www/explore/index.html.spt +++ b/www/explore/index.html.spt @@ -14,12 +14,14 @@ top_communities = query_cache.all(""" title = _("Explore") [-----------------------------] +% from 'templates/search.html' import search_form with context + % extends "templates/explore.html" % block content

{{ _("Whose work do you appreciate? See if they're on Liberapay:") }}

- % include "templates/search-box.html" + {{ search_form() }}

{{ _("You can also pledge to people who haven't joined Liberapay yet:") }}

% include "templates/jump.html" diff --git a/www/search.spt b/www/search.spt index 010f6023b..b4af94138 100644 --- a/www/search.spt +++ b/www/search.spt @@ -72,6 +72,7 @@ if query: [---] text/html % extends "templates/base.html" % from 'templates/avatar-url.html' import avatar_url, avatar_img with context +% from 'templates/search.html' import search_form with context % block content % set usernames = results.get('usernames') @@ -84,7 +85,7 @@ if query: ) }}

% endif - % include "templates/search-box.html" + {{ search_form(autofocus=True) }}
% if usernames