search.js
1.39 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
(function($) {
// Pagination.
$('#search-content').on('click', '.pagination a', function () {
$.ajax({
url: this.href,
beforeSend: function(){$('#search-content').addClass('fetching')},
complete: function() {$('#search-content').removeClass('fetching')},
dataType: 'script'
})
return false;
});
// Sorting and Views
$('#search-filters select').change(function(){
$('form.search_form').submit();
});
// Filter submenu
$('#search-subheader select').change(function(){
$('form.search_form').submit();
});
// Form Ajax submission
$('form.search_form').submit(function () {
$.ajax({
url: this.action,
data: $(this).serialize(),
beforeSend: function(){$('#search-content').addClass('fetching')},
complete: function() {$('#search-content').removeClass('fetching')},
dataType: 'script'
})
return false;
});
// Assets links
$('#assets-menu a').click(function(e){
e.preventDefault();
window.location.href = $(this).attr("href") + '?query=' + $('#search-input').val();
});
// Real time search
// $(".search-input-with-suggestions").typeWatch({
// callback: function (value) {$('form.search_form').submit()},
// wait: 750,
// highlight: true,
// captureLength: 2
// });
$(".search-input-with-suggestions").bind('notext', function(){ $('form.search_form').submit() });
})(jQuery);