1 | /* |
---|
2 | * Copyright (C) 2014 CLARIN |
---|
3 | * |
---|
4 | * This program 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 | * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | */ |
---|
17 | |
---|
18 | $(document).ready(function() { |
---|
19 | |
---|
20 | /* facet collapse/expand */ |
---|
21 | $("a.expandfacet").click(function(event) { |
---|
22 | event.preventDefault(); |
---|
23 | var p = $(this).parent(".collapsedfacet"); |
---|
24 | p.addClass("expandedfacet"); |
---|
25 | p.removeClass("collapsedfacet"); |
---|
26 | }); |
---|
27 | $("a.collapsefacet").click(function(event) { |
---|
28 | event.preventDefault(); |
---|
29 | var p = $(this).parent(".expandedfacet"); |
---|
30 | p.addClass("collapsedfacet"); |
---|
31 | p.removeClass("expandedfacet"); |
---|
32 | }); |
---|
33 | |
---|
34 | /* facet filter */ |
---|
35 | $(".filterform").toggle(); |
---|
36 | |
---|
37 | $("a.filtertoggle").click(function(event) { |
---|
38 | // toggle link clicked, show or hide filter box and focus on input |
---|
39 | event.preventDefault(); |
---|
40 | var form = $(this).parent(".sidebaritem").find(".filterform"); |
---|
41 | form.siblings(".sbilinks").find("li").show(); |
---|
42 | form.toggle(function(event) { |
---|
43 | var input = form.children("input"); |
---|
44 | input.val(''); |
---|
45 | input.focus(); |
---|
46 | }); |
---|
47 | }); |
---|
48 | |
---|
49 | var filterHandler = function(event) { |
---|
50 | // filter text entered, update result list |
---|
51 | var links = $(this).parent(".filterform").siblings(".sbilinks").find("li"); |
---|
52 | var match = $(this).val().toUpperCase(); |
---|
53 | if (match.length === 0) { |
---|
54 | links.show(); |
---|
55 | } else { |
---|
56 | // hide all results |
---|
57 | links.hide(); |
---|
58 | // show all matching results |
---|
59 | links.filter(function(index) { |
---|
60 | // case insensitive match |
---|
61 | return links[index].textContent.toUpperCase().indexOf(match) >= 0; |
---|
62 | }).show(); |
---|
63 | } |
---|
64 | }; |
---|
65 | |
---|
66 | $(".filterform input").on('input', filterHandler); |
---|
67 | |
---|
68 | /* Facet values popup */ |
---|
69 | |
---|
70 | $(".more-link").click(function(event){ |
---|
71 | event.preventDefault(); |
---|
72 | $("#facetvalues").toggle(); |
---|
73 | }); |
---|
74 | |
---|
75 | $("#facetvalues a").click(function(event){ |
---|
76 | event.preventDefault(); |
---|
77 | $("#facetvalues").toggle(); |
---|
78 | }); |
---|
79 | }); |
---|