_search.js
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Search Filter
import jquery from 'jquery';
var Search = (function($) {
function init() {
$(".side-menu li:has(.children) > a").addClass("has-children closed");
$(".side-menu li .children .current_page_ancestor a").removeClass("closed").addClass("opened");
$(document).on("click", ".side-menu li:has(.children) > a.has-children.closed", function(e){
e.preventDefault();
$(this).removeClass("closed");
$(this).addClass("opened");
$(this).next(".children").slideDown();
return false;
});
$(document).on("click", ".side-menu li:has(.children) > a.has-children.opened", function(e){
e.preventDefault();
$(this).removeClass("opened");
$(this).addClass("closed");
$(this).next(".children").slideUp();
return false;
});
$(".searchandfilter ul li:contains('hidden')").hide();
$('<li class="sf-field-reset"><input type="submit" class="search-filter-reset-custom" value="CLEAR ALL" "></li>').appendTo( jQuery( '#advance-search-modal .searchandfilter ul:first-child ' ) );
$(document).on("click", ".search-filter-reset-custom", function(e){
e.preventDefault();
$(this).closest('.searchandfilter')[0].reset();
return false;
});
$(document).on("click", ".advance-search-button", function(e){
$('#search-box-content').addClass('show');
$('.search-box').addClass('show');
});
var myModal = document.getElementById('advance-search-modal');
myModal.addEventListener('hidden.bs.modal', function () {
$('#search-box-content').removeClass('show');
$('.search-box').removeClass('show');
})
if ($(window).width() < 960) {
$( ".search-result .entry-summary" ).each(function() {
var yourString = $(this).text();
var maxLength = 160;
if (yourString.length > maxLength) {
var trimmedString = yourString.substr(0, maxLength);
trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")));
$(this).text(trimmedString + "...");
}
});
}
}
return {
init: init
};
}(jquery));
jquery(document).ready(Search.init);
export { Search };