_search.js
4.25 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Search Filter
import jquery from 'jquery';
import LazyLoad from "vanilla-lazyload";
var Search = (function($) {
function init() {
$('.search-box').css('margin-right', $('#main-nav .container').css('margin-right'));
$('.search-box').css('opacity', '1');
$('.badge').css('margin-right', $('#main-nav .container').css('margin-right'));
$('#pojo-a11y-toolbar').css('margin-right', $('#main-nav .container').css('margin-right'));
$('.badge').css('opacity', '1');
setTimeout(() => {
$('.badge').css('transition', '4s ease-in-out');
}, "100");
$(window).on('resize', function(){
$('.search-box').css('transition', '0s ease-in-out');
$('.search-box').css('margin-right', $('#main-nav .container').css('margin-right'));
$('#pojo-a11y-toolbar').css('margin-right', $('#main-nav .container').css('margin-right'));
$('.badge').css('transition', '0s ease-in-out');
$('.badge').css('margin-right', $('#main-nav .container').css('margin-right'));
setTimeout(() => {
$('.badge').css('transition', '4s ease-in-out');
$('.search-box').css('transition', 'all 0.5s ease-in-out 0s');
}, "100");
});
$(".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", ".search-filter-reset", function(e){
e.preventDefault();
$('.searchandfilter')[0].reset();
return false;
});
$(document).on("click", ".top-go", function(e){
e.preventDefault();
$('#search-sidebar [name="_sf_search[]"]').val($('#top-search').val());
$('#search-sidebar [name="_sf_submit"]').click()
return false;
});
$(document).on("keydown", "#top-search", function(e){
if(e.keyCode == 13) {
e.preventDefault();
$('#search-sidebar [name="_sf_search[]"]').val($('#top-search').val());
$('#search-sidebar [name="_sf_submit"]').click()
return false;
}
});
$(document).on("click", '#advance-search-modal [name="_sf_submit"]', function(e){
$('#advance-search-modal .searchandfilter').hide();
$('[data-sf-form-id="399"]').trigger("submit");
//$('[data-sf-form-id="102"]').trigger("submit");
$('.searching-loading').show();
setTimeout(() => {
window.location.href = window.location.href
}, "5000");
});
$(document).on("click", ".advance-search-button", function(e){
$('#search-box-content').addClass('show');
$('.search-box').addClass('show');
$('.badge').hide();
});
var myModal = document.getElementById('advance-search-modal');
if(myModal){
myModal.addEventListener('hidden.bs.modal', function () {
$('#search-box-content').removeClass('show');
$('.search-box').removeClass('show');
$('.badge').show();
})
}
$(document).on("change",' #top-news-select input[type="radio"][name="_sft_category[]"]', function(e){
if (this.value == 'news') {
// $('form input[type="radio"][name="_sft_category[]"][value="events"]').removeAttr('checked');
// $('form input[type="radio"][name="_sft_category[]"][value="news"]').attr('checked', 'checked').trigger('change');
const search = new URLSearchParams(location.search);
search.set('_sft_category', 'news');
location.search = search.toString();
}else if (this.value == 'events') {
// $('form input[type="radio"][name="_sft_category[]"][value="news"]').removeAttr('checked');
// $('form input[type="radio"][name="_sft_category[]"][value="events"]').attr('checked', 'checked').trigger('change');
const search = new URLSearchParams(location.search);
search.set('_sft_category', 'events');
location.search = search.toString();
}
});
}
return {
init: init
};
}(jquery));
jquery(document).ready(Search.init);
export { Search };