PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.6
Forumax – AI Powered Advanced Community Forum Plugin v1.2.6
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / assets / frontend / js / frontend.js

frontend.js in Forumax – AI Powered Advanced Community Forum Plugin 1.2.6, at assets/frontend/js/frontend.js

127 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 $(document).ready(function () {
3 const overlay = $('.bbpc-search-overlay');
4
5 $('#searchInput, #bbpc-search-result, .bbpc-search-keyword ul li a').on('click', function () {
6 overlay.css('display', 'block');
7 overlay.addClass('active');
8
9 overlay.on('click', function () {
10 overlay.css('display', 'none');
11 overlay.removeClass('active');
12 });
13
14 // Focus in search input
15 $('.bbpc_search_form_wrapper').focusin(function () {
16 $('.body_dark #searchInput').addClass('input_focused');
17 if ($('#bbpc-search-result.ajax-search').length > 0) {
18 $('.body_dark #searchInput').addClass('input_focused');
19 }
20 });
21
22 // Focus out search input
23 $('.bbpc_search_form_wrapper').focusout(function () {
24 if ($('#bbpc-search-result.ajax-search').length > 0) {
25 $('.body_dark #searchInput').addClass('input_focused');
26 } else {
27 $('.body_dark #searchInput').removeClass('input_focused');
28 }
29 });
30
31 $('#searchInput').keyup(function () {
32 $('.click_capture').css({ 'opacity': '0', 'visibility': 'hidden' });
33 });
34
35 // Keyup in search input
36 $('#searchInput').keyup(function () {
37 $('.not-found-text').css('display', 'none');
38 var searchInput = $(this).val();
39 var ajax_url = bbpc_localize_script.ajaxurl;
40
41 if (searchInput != '') {
42 $.ajax({
43 url: ajax_url,
44 method: 'POST',
45 data: {
46 action: 'bbpc_search_data_fetch',
47 keyword: searchInput
48 },
49 beforeSend: function () {
50 $('.spinner').css('display', 'block');
51 },
52 success: function (data) {
53 $('#bbpc-search-result').html(data).addClass('ajax-search');
54 $('.spinner').css('display', 'none');
55
56 var no_result = $('.tab-item.active.all-active').attr('data-noresult');
57 if (no_result) {
58 no_result = no_result.replace("-", " ");
59 no_result = no_result.replace("-", " ");
60 $('#bbpc-search-result').html('<h5 class="bbpc-not-found-text">' + no_result + '</h5>');
61 $('.bbpc-not-found-text').css('display', 'block');
62 }
63 },
64 error: function (xhr, status, error) {
65 // Handle the error
66 }
67 });
68 }
69 });
70
71 // Keywords
72 $('.bbpc-search-keyword ul li a').on('click', function (e) {
73 e.preventDefault();
74 var content = $(this).text();
75 $('#searchInput').val(content).focus();
76 var ajax_url = bbpc_localize_script.ajaxurl;
77
78 if (content != '') {
79 $.ajax({
80 url: ajax_url,
81 method: 'POST',
82 data: {
83 action: 'bbpc_search_data_fetch',
84 keyword: content
85 },
86 beforeSend: function () {
87 $('.spinner').css('display', 'block');
88 },
89 success: function (data) {
90 $('#bbpc-search-result').html(data).addClass('ajax-search');
91 $('.spinner').css('display', 'none');
92
93 var no_result = $('.tab-item.active.all-active').attr('data-noresult');
94 if (no_result) {
95 no_result = no_result.replace("-", " ");
96 no_result = no_result.replace("-", " ");
97 $('#bbpc-search-result').html('<h5 class="bbpc-not-found-text">' + no_result + '</h5>');
98 $('.bbpc-not-found-text').css('display', 'block');
99 }
100 },
101 error: function (xhr, status, error) {
102 // Handle the error
103 }
104 });
105 }
106 });
107
108 // Clear search input
109 $('#searchInput').on('input', function (e) {
110 if ('' == this.value) {
111 $('#bbpc-search-result').removeClass('ajax-search');
112 }
113 });
114 });
115
116 $("#searchInput").focus(function () {
117 $('body').addClass('bbpc-search-overlay');
118 $('form.bbpc_search_form_wrapper').css('z-index', '999');
119 })
120
121 $(".bbpc-search-overlay").click(function () {
122 $('body').removeClass('bbpc-search-overlay');
123 $('form.bbpc_search_form_wrapper').css('z-index', 'unset');
124 })
125 });
126 })(jQuery);
127