Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    This file is part of Moodle - http://moodle.org/
3
 
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.
8
 
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.
13
 
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/>.
16
}}
17
{{!
18
    @template core/search_input_navbar
19
 
20
    Navbar search input template.
21
 
22
    Example context (json):
23
    {
24
        "action": "https://moodle.local/admin/search.php",
25
        "inputname": "search",
26
        "searchstring": "Search",
27
        "hiddenfields": [
28
            {
29
                "name": "cmid",
30
                "value": "11"
31
            }
32
        ]
33
    }
34
}}
35
<div id="searchinput-navbar-{{uniqid}}" class="simplesearchform m-0">
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">
38
            {{#hiddenfields}}
39
                <input type="hidden" name="{{ name }}" value="{{ value }}">
40
            {{/hiddenfields}}
41
 
42
                    <div class="search-input-group d-inline-flex justify-content-between w-100">
43
                        <label for="searchinput-{{uniqid}}">
44
                            <span class="sr-only">{{{ searchstring }}}</span>
45
                        </label>
46
 
47
                        <span class="search-input-icon">
48
                            <svg width="22" height="22" fill="none" viewBox="0 0 24 24">
49
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.25 19.25L15.5 15.5M4.75 11C4.75 7.54822 7.54822 4.75 11 4.75C14.4518 4.75 17.25 7.54822 17.25 11C17.25 14.4518 14.4518 17.25 11 17.25C7.54822 17.25 4.75 14.4518 4.75 11Z"></path>
50
                            </svg>
51
                        </span>
52
 
53
                        <input type="text"
54
                        id="searchinput-{{uniqid}}"
55
                        class="search-input w-100"
56
                        placeholder="{{ searchstring }}"
57
                        aria-label="{{ searchstring }}"
58
                        name="{{ inputname }}"
59
                        data-region="input"
60
                        autocomplete="off"
61
                        value="{{ query }}"
62
                        >
63
                        <a class="btn btn-close mr-1"
64
                            data-action="closesearch"
65
                            data-toggle="collapse"
66
                            href="#searchform-navbar"
67
                            role="button"
68
                        >
69
                            <svg width="18" height="18" fill="none" viewBox="0 0 24 24">
70
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M17.25 6.75L6.75 17.25"></path>
71
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M6.75 6.75L17.25 17.25"></path>
72
                            </svg>
73
                            <span class="sr-only">{{#str}} closebuttontitle {{/str}}</span>
74
                        </a>
75
                        <button type="submit" class="search-input-btn">
76
                            <svg width="22" height="22" fill="none" viewBox="0 0 24 24">
77
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.75 6.75L19.25 12L13.75 17.25"></path>
78
                                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 12H4.75"></path>
79
                            </svg>
80
                            <span class="sr-only">{{ searchstring }}</span>
81
                        </button>
82
 
83
                    </div>
84
 
85
 
86
        </form>
87
    </div>
88
 
89
        <a
90
            class="rui-topbar-special-btn"
91
            data-toggle="collapse"
92
            data-action="opensearch"
93
            href="#searchform-navbar"
94
            role="button"
95
            aria-expanded="false"
96
            aria-controls="searchform-navbar"
97
        >
98
            <svg width="20" height="20" fill="none" viewBox="0 0 24 24">
99
                <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19.25 19.25L15.5 15.5M4.75 11C4.75 7.54822 7.54822 4.75 11 4.75C14.4518 4.75 17.25 7.54822 17.25 11C17.25 14.4518 14.4518 17.25 11 17.25C7.54822 17.25 4.75 14.4518 4.75 11Z"></path>
100
            </svg>
101
            <span class="sr-only">{{#str}} togglesearch {{/str}}</span>
102
        </a>
103
 
104
</div>
105
 
106
{{#js}}
107
require(
108
[
109
    'jquery',
110
],
111
function(
112
    $
113
) {
114
    var uniqid = "{{uniqid}}";
115
    var container = $('#searchinput-navbar-' + uniqid);
116
    var opensearch = container.find('[data-action="opensearch"]');
117
    var input = container.find('[data-region="input"]');
118
    var submit = container.find('[data-action="submit"]');
119
 
120
    submit.on('click', function(e) {
121
        if (input.val() === '') {
122
            e.preventDefault();
123
        }
124
    });
125
    container.on('hidden.bs.collapse', function() {
126
        opensearch.removeClass('d-none');
127
        input.val('');
128
    });
129
    container.on('show.bs.collapse', function() {
130
        opensearch.addClass('d-none');
131
    });
132
    container.on('shown.bs.collapse', function() {
133
        input.focus();
134
    });
135
});
136
{{/js}}