PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.4.0
Forumax – AI Powered Advanced Community Forum Plugin v2.4.0
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 / ajax.js

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

57 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* eslint-disable jsdoc/require-param-type, jsdoc/empty-tags */
2 (function ($) {
3 'use strict';
4 $(document).ready(function () {
5 /* eslint-disable camelcase, no-undef */
6 const ajax_url = forumax_localize_script.ajaxurl;
7
8 $('.single-filter-item a').on('click', function (e) {
9 e.preventDefault();
10
11 // Prefer the custom data_id attribute on the closest widget, fall back to the element id
12 const $widget = $(this).closest('.forum-post-widget');
13 const data_id = $widget.attr('data_id') || $widget.attr('id');
14 const forum_value = $(this).attr('data-forum');
15 const nonce = forumax_localize_script.nonce;
16
17 $('.forum-post-widget[data_id=' + data_id + '] .single-filter-item a').removeClass('data-active');
18 $(this).addClass('data-active');
19
20 $.ajax({
21 url: ajax_url,
22 method: 'POST',
23 data: {
24 action: 'forumax_ajax_forum',
25 data_forum: forum_value,
26 nonce,
27 },
28 beforeSend() {
29 $('.forum-post-widget[data_id="' + data_id + '"] #aj-post-filter-widget').html(
30 '<?xml version="1.0" encoding="utf-8"?>\n' +
31 '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background: none; display: block; shape-rendering: auto;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">\n' +
32 '<circle class="bbpc-preloader" cx="50" cy="50" r="18" stroke-width="2" stroke="#11a683" stroke-dasharray="28.274333882308138 28.274333882308138" fill="none" stroke-linecap="round">\n' +
33 ' <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0 50 50;360 50 50"></animateTransform>\n' +
34 '</circle>\n' +
35 '</svg>'
36 );
37 },
38 success(data) {
39 $('.forum-post-widget[data_id="' + data_id + '"] #aj-post-filter-widget').html(data);
40 },
41 error() {
42 /* eslint-disable no-console */
43 console.log('Oops! Something wrong, try again!');
44 /* eslint-enable no-console */
45 },
46 });
47 });
48
49 $('.collapse-btn-wrap, .forumax-collapse-btn-wrap').on('click', function (e) {
50 e.preventDefault();
51 $(this).toggleClass('active');
52 // Target the corresponding collapse-wrap within the same parent
53 $(this).siblings('.collapse-wrap, .forumax-collapse-wrap').slideToggle(500);
54 });
55
56 });
57 })(jQuery);