2 This file is part of Moodle - http://moodle.org/
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 @template core/search_input_navbar
20 Navbar search input template.
22 Example context (json):
24 "action": "https://moodle.local/admin/search.php",
25 "inputname": "search",
26 "searchstring": "Search",
35 <div id="searchinput-navbar-{{uniqid}}" class="simplesearchform">
36 <div class="collapse" id="searchform-navbar">
37 <form autocomplete="off" action="{{{ action }}}" method="get" accept-charset="utf-8" class="mform form-inline searchform-navbar">
39 <input type="hidden" name="{{ name }}" value="{{ value }}">
41 <div class="input-group">
42 <label for="searchinput-{{uniqid}}">
43 <span class="sr-only">{{{ searchstring }}}</span>
46 id="searchinput-{{uniqid}}"
47 class="form-control withclear"
48 placeholder="{{{ searchstring }}}"
49 aria-label="{{{ searchstring }}}"
50 name="{{{ inputname }}}"
54 <a class="btn btn-close"
55 data-action="closesearch"
56 data-toggle="collapse"
57 href="#searchform-navbar"
60 {{#pix}} e/cancel, core {{/pix}}
61 <span class="sr-only">{{#str}} closebuttontitle {{/str}}</span>
63 <div class="input-group-append">
64 <button type="submit" class="btn btn-submit" data-action="submit">
65 {{#pix}} a/search, core {{/pix}}
66 <span class="sr-only">{{{ searchstring }}}</span>
73 class="btn btn-open rounded-0 nav-link"
74 data-toggle="collapse"
75 data-action="opensearch"
76 href="#searchform-navbar"
79 aria-controls="searchform-navbar"
80 title="{{#str}} togglesearch {{/str}}"
82 {{#pix}} a/search, core {{/pix}}
83 <span class="sr-only">{{#str}} togglesearch {{/str}}</span>
95 var uniqid = "{{uniqid}}";
96 var container = $('#searchinput-navbar-' + uniqid);
97 var opensearch = container.find('[data-action="opensearch"]');
98 var input = container.find('[data-region="input"]');
99 var submit = container.find('[data-action="submit"]');
101 submit.on('click', function(e) {
102 if (input.val() === '') {
106 container.on('hidden.bs.collapse', function() {
107 opensearch.removeClass('d-none');
110 container.on('show.bs.collapse', function() {
111 opensearch.addClass('d-none');
113 container.on('shown.bs.collapse', function() {