big_search_form.mustache 6.83 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
18
19
    @template mod_forum/big_search_form

20
    Big search form.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

    Example context (json):
    {
        "actionurl": "https://example.com/mod/forum/search.php",
        "courseid": "2",
        "words": "apples",
        "phrase": "Lorem ipsum dolor",
        "notwords": "Not these words",
        "showfullwords": [
            {
                "fullwords": "Exactly"
            }
        ],
        "datefromchecked": 1,
        "datetochecked": "",
        "forumoptions": [
            {
                "name": "Forum One",
                "value": "23"
            },
            {
                "name": "Forum Two",
                "value": "34"
            }
        ],
        "subject": "Help me please",
        "user": "Helpy McUser"
    }
49
50
51
52
53
54
}}
<div id="intro" class="box searchbox boxaligncenter">
    {{#str}}searchforumintro, forum{{/str}}
</div>
<div class="box generalbox boxaligncenter">
    <form id="searchform" action="{{actionurl}}" method="get">
55
        <table class="searchbox table table-striped" id="form">
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
            <tr>
                <td class="c0 text-xs-right">
                    <label for="words">{{#str}}searchwords, forum{{/str}}</label>
                    <input type="hidden" value="{{courseid}}" name="id">
                </td>
                <td class="c1">
                    <input type="text" class="form-control" name="words" id="words" value="{{words}}">
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    <label for="phrase">{{#str}}searchphrase, forum{{/str}}</label>
                </td>
                <td class="c1">
                    <input type="text" class="form-control" name="phrase" id="phrase" value="{{phrase}}">
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    <label for="notwords">{{#str}}searchnotwords, forum{{/str}}</label>
                </td>
                <td class="c1">
                    <input type="text" class="form-control" name="notwords" id="notwords" value="{{notwords}}">
                </td>
            </tr>
            {{#showfullwords}}
                <tr>
                    <td class="c0 text-xs-right">
                        <label for="fullwords">{{#str}}searchfullwords, forum{{/str}}</label>
                    </td>
                    <td class="c1">
                        <input type="text" class="form-control" name="fullwords" id="fullwords" value="{{fullwords}}">
                    </td>
                </tr>
            {{/showfullwords}}
            <tr>
                <td class="c0 text-xs-right">
                    {{#str}}searchdatefrom, forum{{/str}}
                </td>
                <td class="c1 text-nowrap form-inline">
96
                    <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
97
98
99
100
101
102
103
104
105
106
107
108
109
                    {{{datefromfields}}}
                    <input type="hidden" name="hfromday" value="0">
                    <input type="hidden" name="hfrommonth" value="0">
                    <input type="hidden" name="hfromyear" value="0">
                    <input type="hidden" name="hfromhour" value="0">
                    <input type="hidden" name="hfromminute" value="0">
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    {{#str}}searchdateto, forum{{/str}}
                </td>
                <td class="c1 text-nowrap form-inline">
110
                    <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
111
112
113
114
115
116
117
118
119
120
121
122
123
                    {{{datetofields}}}
                    <input type="hidden" name="htoday" value="0">
                    <input type="hidden" name="htomonth" value="0">
                    <input type="hidden" name="htoyear" value="0">
                    <input type="hidden" name="htohour" value="0">
                    <input type="hidden" name="htominute" value="0">
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    <label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
                </td>
                <td class="c1">
124
                    <select name="forumid" id="menuforumid" class="form-control">
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
                        {{#forumoptions}}
                            <option value="{{value}}">{{name}}</option>
                        {{/forumoptions}}
                    </select>
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    <label for="subject">{{#str}}searchsubject, forum{{/str}}</label>
                </td>
                <td class="c1">
                    <input type="text" class="form-control" name="subject" id="subject" value="{{subject}}">
                </td>
            </tr>
            <tr>
                <td class="c0 text-xs-right">
                    <label for="user">{{#str}}searchuser, forum{{/str}}</label>
                </td>
                <td class="c1">
                    <input type="text" class="form-control" name="user" id="user" value="{{user}}">
                </td>
            </tr>
            <tr>
                <td> </td>
                <td class="submit">
                    <button type="submit" class="btn btn-primary">{{#str}}searchforums, forum{{/str}}</button>
                </td>
            </tr>
        </table>
    </form>
</div>
156
157
158
159
160
161
162
{{#js}}
require(['jquery'], function($) {
    var toggleDateFields = function(prefix, disabled) {
        $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
        $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
    };

163
    toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
164
165
166
167
    $("#searchform input[name='timefromrestrict']").click(function() {
        toggleDateFields('from', !this.checked);
    });

168
    toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
169
170
171
172
    $("#searchform input[name='timetorestrict']").click(function() {
        toggleDateFields('to', !this.checked);
    });
});
173
{{/js}}