| 1 |
/** |
| 2 |
* @package ama-core |
| 3 |
* Ama Ajax actions for forums and everything necessary |
| 4 |
*/ |
| 5 |
;(function ($) { |
| 6 |
'use strict' |
| 7 |
$(document).ready(function () { |
| 8 |
|
| 9 |
let ajax_url = bbpc_localize_script.ajaxurl |
| 10 |
|
| 11 |
$('.single-filter-item a').on('click', function (e) { |
| 12 |
e.preventDefault(); |
| 13 |
|
| 14 |
var data_id = $(this).parent().parent().parent().attr('data_id'); |
| 15 |
let forum_value = $(this).attr('data-forum'); |
| 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: 'bbpc_ajax_forum', |
| 25 |
data_forum: forum_value, |
| 26 |
}, |
| 27 |
beforeSend: function () { |
| 28 |
$('.forum-post-widget[data_id="'+data_id+'"] #aj-post-filter-widget').html( |
| 29 |
'<?xml version="1.0" encoding="utf-8"?>\n' + |
| 30 |
'<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' + |
| 31 |
'<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' + |
| 32 |
' <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0 50 50;360 50 50"></animateTransform>\n' + |
| 33 |
'</circle>\n' + |
| 34 |
'</svg>', |
| 35 |
) |
| 36 |
}, |
| 37 |
success: function (data) { |
| 38 |
$('.forum-post-widget[data_id="'+data_id+'"] #aj-post-filter-widget').html(data) |
| 39 |
}, |
| 40 |
error: function () { |
| 41 |
console.log('Oops! Something wrong, try again!') |
| 42 |
} |
| 43 |
, |
| 44 |
}); |
| 45 |
}); |
| 46 |
|
| 47 |
function bbp_forums() { |
| 48 |
$('.collapse-btn-wrap').on('click', function (e) { |
| 49 |
var data_id = $(this).parent('.more-communities').attr('data_id'); |
| 50 |
|
| 51 |
e.preventDefault(); |
| 52 |
$(this).toggleClass('active'); |
| 53 |
$('.more-communities[data_id="'+data_id+'"] > .collapse-wrap[data_id="'+data_id+'"]').slideToggle(500); |
| 54 |
}); |
| 55 |
} |
| 56 |
bbp_forums(); |
| 57 |
}); |
| 58 |
})(jQuery); |