}
});
$('#quickedit input').trigger('change');
+ $('.search-results').empty();
+ $('.search-field').on('submit', function() {
+ var value = $('input[name=q]').val();
+ $.ajax({url: '/ajax/search/', data: {q: value}}).done(function(data) {
+ $('.search-results').empty();
+ for (const hit of data.data) {
+ var $a_hit = $('<a>', {text: hit.title, href: hit.url});
+ var $li_hit = $('<li>');
+ $li_hit.append($a_hit);
+ $('.search-results').append($li_hit);
+ }
+ });
+ return false;
+ });
});
color: white;
}
}
+
+#search {
+ label {
+ position: absolute;
+ right: 1em;
+ }
+ #search-enable, .search-results {
+ display: none;
+ }
+ #search-enable + label::after {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background: #eee;
+ border: 1px solid #aaa;
+ width: 2em;
+ height: 28px;
+ content: "🔍";
+ border-radius: 5px;
+ }
+ #search-enable:checked {
+ + label {
+ &::after {
+ content: "×";
+ }
+ }
+ ~ .search-field {
+ height: 30px;
+ }
+ ~ .search-results {
+ display: block;
+ }
+ }
+ .search-field {
+ height: 0;
+ transition: all ease 0.2s;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ margin-right: 50px;
+ input {
+ height: 30px;
+ }
+ }
+ .search-results {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ li {
+ margin: 0;
+ padding: 0;
+ a {
+ display: block;
+ padding: 0.5rem 1rem;
+ border: 1px solid $link-color;
+ margin-top: -1px;
+ &:hover {
+ background: #eee;
+ }
+ }
+ }
+ }
+}
<span><a href="/">rdio.space - gestion radio</a></span>
</header>
<main class="{% block content-class %}{% endblock %}">
+ <div id="search">
+ <input type="checkbox" id="search-enable">
+ <label for="search-enable"></label>
+ <form class="search-field">
+ <input name="q" type="search">
+ </form>
+ <ul class="search-results">
+ </ul>
+ </div>
{% block body %}
{% endblock %}
</main>