6fc760cff45eec0e4d45a071653632a57b816c02
[moodle.git] / mod / forum / templates / big_search_form.mustache
1 {{!
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/>.
16 }}
17 {{!
18     @template mod_forum/big_search_form
20     Big search form.
22     Example context (json):
23     {
24         "actionurl": "https://example.com/mod/forum/search.php",
25         "courseid": "2",
26         "words": "apples",
27         "phrase": "Lorem ipsum dolor",
28         "notwords": "Not these words",
29         "showfullwords": [
30             {
31                 "fullwords": "Exactly"
32             }
33         ],
34         "datefromchecked": 1,
35         "datetochecked": "",
36         "forumoptions": [
37             {
38                 "name": "Forum One",
39                 "value": "23"
40             },
41             {
42                 "name": "Forum Two",
43                 "value": "34"
44             }
45         ],
46         "subject": "Help me please",
47         "user": "Helpy McUser"
48     }
49 }}
50 <div id="intro" class="box searchbox boxaligncenter">
51     {{#str}}searchforumintro, forum{{/str}}
52 </div>
53 <div class="box generalbox boxaligncenter">
54     <form id="searchform" action="{{actionurl}}" method="get">
55         <table class="searchbox table" id="form">
56             <tr>
57                 <td class="c0">
58                     <label for="words">{{#str}}searchwords, forum{{/str}}</label>
59                     <input type="hidden" value="{{courseid}}" name="id">
60                 </td>
61                 <td class="c1">
62                     <input type="text" size="35" name="words" id="words" value="{{words}}">
63                 </td>
64             </tr>
65             <tr>
66                 <td class="c0">
67                     <label for="phrase">{{#str}}searchphrase, forum{{/str}}</label>
68                 </td>
69                 <td class="c1">
70                     <input type="text" size="35" name="phrase" id="phrase" value="{{phrase}}">
71                 </td>
72             </tr>
73             <tr>
74                 <td class="c0">
75                     <label for="notwords">{{#str}}searchnotwords, forum{{/str}}</label>
76                 </td>
77                 <td class="c1">
78                     <input type="text" size="35" name="notwords" id="notwords" value="{{notwords}}">
79                 </td>
80             </tr>
81             {{#showfullwords}}
82                 <tr>
83                     <td class="c0">
84                         <label for="fullwords">{{#str}}searchfullwords, forum{{/str}}</label>
85                     </td>
86                     <td class="c1">
87                         <input type="text" size="35" name="fullwords" id="fullwords" value="{{fullwords}}">
88                     </td>
89                 </tr>
90             {{/showfullwords}}
91             <tr>
92                 <td class="c0">
93                     {{#str}}searchdatefrom, forum{{/str}}
94                 </td>
95                 <td class="c1">
96                     <input type="checkbox" name="timefromrestrict" value="1" {{#datefromchecked}}checked{{/datefromchecked}}>
97                     {{{datefromfields}}}
98                     <input type="hidden" name="hfromday" value="0">
99                     <input type="hidden" name="hfrommonth" value="0">
100                     <input type="hidden" name="hfromyear" value="0">
101                     <input type="hidden" name="hfromhour" value="0">
102                     <input type="hidden" name="hfromminute" value="0">
103                 </td>
104             </tr>
105             <tr>
106                 <td class="c0">
107                     {{#str}}searchdateto, forum{{/str}}
108                 </td>
109                 <td class="c1">
110                     <input type="checkbox" name="timetorestrict" value="1" {{#datetochecked}}checked{{/datetochecked}}>
111                     {{{datetofields}}}
112                     <input type="hidden" name="htoday" value="0">
113                     <input type="hidden" name="htomonth" value="0">
114                     <input type="hidden" name="htoyear" value="0">
115                     <input type="hidden" name="htohour" value="0">
116                     <input type="hidden" name="htominute" value="0">
117                 </td>
118             </tr>
119             <tr>
120                 <td class="c0">
121                     <label for="menuforumid">{{#str}}searchwhichforums, forum{{/str}}</label>
122                 </td>
123                 <td class="c1">
124                     <select name="forumid" id="menuforumid">
125                         {{#forumoptions}}
126                             <option value="{{value}}">{{name}}</option>
127                         {{/forumoptions}}
128                     </select>
129                 </td>
130             </tr>
131             <tr>
132                 <td class="c0">
133                     <label for="subject">{{#str}}searchsubject, forum{{/str}}</label>
134                 </td>
135                 <td class="c1">
136                     <input type="text" size="35" name="subject" id="subject" value="{{subject}}">
137                 </td>
138             </tr>
139             <tr>
140                 <td class="c0">
141                     <label for="user">{{#str}}searchuser, forum{{/str}}</label>
142                 </td>
143                 <td class="c1">
144                     <input type="text" size="35" name="user" id="user" value="{{user}}">
145                 </td>
146             </tr>
147             <tr>
148                 <td colspan="2" class="submit">
149                     <div class="text-center">
150                         <input type="submit" value={{#quote}}{{#str}}searchforums, forum{{/str}}{{/quote}}>
151                     </div>
152                 </td>
153             </tr>
154         </table>
155     </form>
156 </div>
157 {{#js}}
158     require(['jquery'], function($) {
159         var toggleDateFields = function(prefix, disabled) {
160             $('#searchform select[name^=' + prefix + ']').prop('disabled', disabled);
161             $('#searchform input[name^=h' + prefix + ']').val(disabled ? 1 : 0);
162         };
164         toggleDateFields('from', !$("#searchform input[name='timefromrestrict']").prop('checked'));
165         $("#searchform input[name='timefromrestrict']").click(function() {
166             toggleDateFields('from', !this.checked);
167         });
169         toggleDateFields('to', !$("#searchform input[name='timetorestrict']").prop('checked'));
170         $("#searchform input[name='timetorestrict']").click(function() {
171             toggleDateFields('to', !this.checked);
172         });
173     });
174 {{/js}}