PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.1
Forumax – AI Powered Advanced Community Forum Plugin v2.5.1
2.5.1 2.5.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 All 31 releases
← All changes | assets/admin/js/admin-main.js +690 -483 1.3.3 → 2.5.1 View file →
@@ -1,484 +1,691 @@
1 -(function ($) {
2 - 'use strict';
3 -
4 - /*------------ Cookie functions and color js ------------*/
5 - function createCookie(name, value, days) {
6 - var expires = '';
7 - if (days) {
8 - var date = new Date();
9 - date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
10 - expires = '; expires=' + date.toUTCString();
11 - }
12 - document.cookie = name + '=' + value + expires + '; path=/';
13 - }
14 -
15 - function readCookie(name) {
16 - var nameEQ = name + '=';
17 - var ca = document.cookie.split(';');
18 - for (var i = 0; i < ca.length; i++) {
19 - var c = ca[i];
20 - while (c.charAt(0) == ' ') c = c.substring(1, c.length);
21 - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
22 - }
23 - return null;
24 - }
25 -
26 - function eraseCookie(name) {
27 - createCookie(name, '', -1);
28 - }
29 -
30 - var prefersDark =
31 - window.matchMedia &&
32 - window.matchMedia('(prefers-color-scheme: dark)').matches;
33 - var selectedNightTheme = readCookie('body_dark');
34 -
35 - if (
36 - selectedNightTheme == 'true' ||
37 - (selectedNightTheme === null && prefersDark)
38 - ) {
39 - applyNight();
40 - $('.dark_mode_switcher').prop('checked', true);
41 - } else {
42 - applyDay();
43 - $('.dark_mode_switcher').prop('checked', false);
44 - }
45 -
46 - function applyNight() {
47 - if ($('.js-darkmode-btn .ball').length) {
48 - $('.js-darkmode-btn .ball').css('left', '45px');
49 - }
50 - $('body').addClass('body_dark');
51 - }
52 -
53 - function applyDay() {
54 - if ($('.js-darkmode-btn .ball').length) {
55 - $('.js-darkmode-btn .ball').css('left', '4px');
56 - }
57 - $('body').removeClass('body_dark');
58 - }
59 -
60 - $('.dark_mode_switcher').change(function () {
61 - if ($(this).is(':checked')) {
62 - applyNight();
63 - createCookie('body_dark', true, 999);
64 - } else {
65 - applyDay();
66 - createCookie('body_dark', false, 999);
67 - }
68 - });
69 -
70 - // Filter Select
71 - $('select').niceSelect();
72 -
73 - // Sidebar Tabs [COOKIE]
74 - $(document).on('click', '.tab-menu .easydocs-navitem', function () {
75 - const target = $(this).attr('data-rel');
76 - const $siblings = $(this).siblings();
77 -
78 - if (!$(this).hasClass('is-active')) {
79 - $siblings.removeClass('is-active');
80 - $(this).addClass('is-active');
81 -
82 - $('#' + target)
83 - .fadeIn('slow')
84 - .siblings('.easydocs-tab')
85 - .hide();
86 -
87 - createCookie('eazydocs_doc_current_tab', target, 999);
88 - }
89 - });
90 -
91 - // Restore last active tab
92 - function keep_last_active_doc_tab() {
93 - const lastTab = readCookie('eazydocs_doc_current_tab');
94 - if (lastTab) {
95 - const $tab = $(`.tab-menu .easydocs-navitem[data-rel="${lastTab}"]`);
96 - if ($tab.length && !$tab.hasClass('is-active')) {
97 - $tab.siblings().removeClass('is-active');
98 - $tab.addClass('is-active');
99 -
100 - $('.easydocs-tab-content .easydocs-tab').removeClass('tab-active');
101 - $(`#${lastTab}`).addClass('tab-active');
102 - }
103 - }
104 - }
105 - keep_last_active_doc_tab();
106 -
107 - $('.tab-menu .easydocs-navitem .parent-delete').on('click', function () {
108 - return false;
109 - });
110 -
111 - $(document).ready(function () {
112 -
113 - if ( $('#bbpc-search').length ) {
114 - $('#bbpc-search').on('keyup', function () {
115 - var value = $(this).val().toLowerCase();
116 - $('.easydocs-accordion-item').filter(function () {
117 - $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
118 - });
119 - });
120 -
121 - // Dropdown Classic UI Filter
122 - let bbpc_classic_ui = document.getElementById('bbpc_classic_ui');
123 -
124 - function swithToLink() {
125 - window.location.href = this.value;
126 - }
127 -
128 - bbpc_classic_ui.onchange = swithToLink;
129 - }
130 - })
131 -
132 - $(document).ready(function (e) {
133 - function t(t) {
134 - e(t).bind('click', function (t) {
135 - t.preventDefault();
136 - e(this).parent().fadeOut();
137 - });
138 - }
139 -
140 - e('.header-notify-icon').click(function () {
141 - var t = e(this)
142 - .parents('.easydocs-notification')
143 - .children('.easydocs-dropdown')
144 - .is(':hidden');
145 - e('.easydocs-notification .easydocs-dropdown').hide();
146 - e('.easydocs-notification .header-notify-icon').removeClass('active');
147 - if (t) {
148 - e(this)
149 - .parents('.easydocs-notification')
150 - .children('.easydocs-dropdown')
151 - .toggle()
152 - .parents('.easydocs-notification')
153 - .children('.header-notify-icon')
154 - .addClass('active');
155 - }
156 - });
157 - e(document).bind('click', function (t) {
158 - var n = e(t.target);
159 - if (!n.parents().hasClass('easydocs-notification'))
160 - e('.easydocs-notification .easydocs-dropdown').hide();
161 - });
162 - e(document).bind('click', function (t) {
163 - var n = e(t.target);
164 - if (!n.parents().hasClass('easydocs-notification'))
165 - e('.easydocs-notification .header-notify-icon').removeClass('active');
166 - });
167 -
168 - // CREATE FORUM
169 - function create_forum() {
170 - $(document).on('click', '#bbpc-forum', function (e) {
171 - e.preventDefault();
172 - Swal.fire({
173 - title: bbp_core_local_object.create_forum_title,
174 - input: 'text',
175 - showCancelButton: true,
176 - inputAttributes: {
177 - name: 'bbp_forum_title',
178 - },
179 - }).then((result) => {
180 - if (result.value) {
181 - $.ajax({
182 - url: bbp_core_local_object.ajaxurl,
183 - type: 'POST',
184 - data: {
185 - action: 'bbp_create_forum',
186 - bbp_forum_title: result.value,
187 - bbpc_nonce: bbp_core_local_object.nonce
188 - },
189 - beforeSend: function () {
190 - Swal.fire({
191 - title: 'Creating Forum...',
192 - icon: 'question',
193 - allowOutsideClick: false,
194 - showConfirmButton: true,
195 - didOpen: () => {
196 - Swal.showLoading();
197 - },
198 - });
199 - },
200 - success: function (response) {
201 - if (response.success) {
202 - location.reload();
203 - } else {
204 - Swal.fire({
205 - title: 'Error!',
206 - text: response.data,
207 - icon: 'error',
208 - });
209 - }
210 - },
211 - error: function () {
212 - Swal.fire({
213 - title: 'Error!',
214 - text: 'Something went wrong. Please try again.',
215 - icon: 'error',
216 - });
217 - },
218 - });
219 - }
220 - });
221 - });
222 - }
223 - create_forum();
224 -
225 - // CREATE TOPIC
226 - function create_topic() {
227 - $(document).on('click', '#bbpc-topic', function (e) {
228 - e.preventDefault();
229 - let forumID = $(this).attr('bbp_forum_id');
230 - Swal.fire({
231 - title: bbp_core_local_object.create_topic_title,
232 - input: 'text',
233 - showCancelButton: true,
234 - inputAttributes: {
235 - name: 'bbp_topic_title',
236 - },
237 - }).then((result) => {
238 - if (result.value) {
239 - $.ajax({
240 - url: bbp_core_local_object.ajaxurl,
241 - type: 'POST',
242 - data: {
243 - action: 'bbp_create_topic',
244 - bbp_topic_title: result.value,
245 - forum_id: forumID,
246 - bbpc_nonce: bbp_core_local_object.nonce
247 - },
248 - beforeSend: function () {
249 - Swal.fire({
250 - title: 'Creating Topic...',
251 - icon: 'question',
252 - allowOutsideClick: false,
253 - showConfirmButton: true,
254 - didOpen: () => {
255 - Swal.showLoading();
256 - },
257 - });
258 - },
259 - success: function (response) {
260 - if (response.success) {
261 - location.reload();
262 - } else {
263 - Swal.fire({
264 - title: 'Error!',
265 - text: response.data,
266 - icon: 'error',
267 - });
268 - }
269 - },
270 - error: function () {
271 - Swal.fire({
272 - title: 'Error!',
273 - text: 'Something went wrong. Please try again.',
274 - icon: 'error',
275 - });
276 - },
277 - });
278 - }
279 - });
280 - });
281 - }
282 - create_topic();
283 -
284 - // DELETE FORUM
285 - function delete_forum() {
286 - $('.forum-delete').on('click', function (e) {
287 - e.preventDefault();
288 - var forumID = $(this).attr('bbp_forum_id');
289 - Swal.fire({
290 - title: bbp_core_local_object.forum_delete_title,
291 - text: bbp_core_local_object.forum_delete_desc,
292 - icon: 'question',
293 - showCancelButton: true,
294 - confirmButtonColor: '#3085d6',
295 - cancelButtonColor: '#d33',
296 - confirmButtonText: 'Yes'
297 - }).then((result) => {
298 - if (result.value) {
299 - $.ajax({
300 - url: bbp_core_local_object.ajaxurl,
301 - type: 'POST',
302 - data: {
303 - action: 'bbp_delete_forum',
304 - forum_id: forumID,
305 - bbpc_nonce: bbp_core_local_object.nonce
306 - },
307 - beforeSend: function () {
308 - Swal.fire({
309 - title: 'Deleting Forum...',
310 - icon: 'question',
311 - allowOutsideClick: false,
312 - showConfirmButton: false,
313 - didOpen: () => {
314 - Swal.showLoading();
315 - },
316 - });
317 - },
318 - success: function (response) {
319 - console.log(response);
320 - if (response.success) {
321 - location.reload();
322 - } else {
323 - console.log(response)
324 - Swal.fire({
325 - title: 'Error!',
326 - text: response.data || 'Unexpected error occurred.',
327 - icon: 'error',
328 - });
329 - }
330 - },
331 - error: function () {
332 - Swal.fire({
333 - title: 'Error!',
334 - text: 'Something went wrong. Please try again.',
335 - icon: 'error',
336 - });
337 - },
338 - });
339 - }
340 - });
341 - });
342 - }
343 - delete_forum();
344 -
345 -
346 - // DELETE TOPIC
347 - function delete_topic() {
348 - $('.section-delete').on('click', function (e) {
349 - e.preventDefault();
350 - var topicID = $(this).attr('bbp_topic_id');
351 - Swal.fire({
352 - title: bbp_core_local_object.forum_delete_title,
353 - text: bbp_core_local_object.topic_delete_desc,
354 - icon: 'question',
355 - showCancelButton: true,
356 - confirmButtonColor: '#3085d6',
357 - cancelButtonColor: '#d33',
358 - confirmButtonText: 'Yes',
359 - }).then((result) => {
360 - if (result.value) {
361 - $.ajax({
362 - url: bbp_core_local_object.ajaxurl,
363 - type: 'POST',
364 - data: {
365 - action: 'bbp_delete_topic',
366 - topic_id: topicID,
367 - bbpc_nonce: bbp_core_local_object.nonce
368 - },
369 - beforeSend: function () {
370 - Swal.fire({
371 - title: 'Deleting Topic...',
372 - icon: 'question',
373 - allowOutsideClick: false,
374 - showConfirmButton: false,
375 - didOpen: () => {
376 - Swal.showLoading();
377 - },
378 - });
379 - },
380 - success: function (response) {
381 - console.log(response);
382 - if (response.success) {
383 - location.reload();
384 - } else {
385 - console.log(response)
386 - Swal.fire({
387 - title: 'Error!',
388 - text: response.data || 'Unexpected error occurred.',
389 - icon: 'error',
390 - });
391 - }
392 - },
393 - error: function () {
394 - Swal.fire({
395 - title: 'Error!',
396 - text: 'Something went wrong. Please try again.',
397 - icon: 'error',
398 - });
399 - },
400 - });
401 - }
402 - });
403 - });
404 - }
405 -
406 - delete_topic();
407 -
408 - // Notification pro alert
409 - $('.easydocs-notification.bbp-core-pro-notification').on(
410 - 'click',
411 - function (e) {
412 - e.preventDefault();
413 - let href = $(this).attr('href');
414 - let assets = bbp_core_local_object.BBPC_ASSETS;
415 - Swal.fire({
416 - title: 'Notification is a Premium feature',
417 - html:
418 - '<span class="pro-notification-body-text">You need to Upgrade the Premium Version to use this feature</span><video height="400px" autoplay="autoplay" loop="loop" src="' +
419 - assets +
420 - '/videos/noti.mp4"></video>',
421 - icon: false,
422 - buttons: false,
423 - dangerMode: true,
424 - showCloseButton: true,
425 - confirmButtonText:
426 - '<a href="admin.php?page=bbp-core-pricing">Upgrade to Premium</a>',
427 - footer:
428 - '<a href="https://spider-themes.net/bbp-core/" target="_blank"> Learn More </a>',
429 - customClass: {
430 - title: 'upgrade-premium-heading',
431 - confirmButton: 'upgrade-premium-button',
432 - footer: 'notification-pro-footer-wrap',
433 - },
434 - confirmButtonColor: '#f1bd6c',
435 - Borderless: true,
436 - });
437 - }
438 - );
439 - });
440 -
441 - // Click pending replies count to show pending replies.
442 - $('[click-target]').click(function () {
443 - let id = $(this).attr('click-target');
444 - $(`[click-target=${id}]`).toggleClass('active');
445 - $(`[reply-target=${id}]`).toggle();
446 - });
447 -
448 - // Sidebar Tabs [COOKIE]
449 - $(document).on('click', '[cookie-id]', function () {
450 - let target = $(this).attr('cookie-id');
451 - let item = `[cookie-id=${target}]`;
452 - $('[cookie-id]').removeClass('is-active mixitup-control-active');
453 - $(item).addClass('is-active mixitup-control-active');
454 - $(target).fadeIn('slow').siblings('.easydocs-tab').hide();
455 -
456 - let isActiveTab = $(this).hasClass('is-active');
457 - if (isActiveTab === true) {
458 - createCookie('bbpc_current_filter', target, 999);
459 - }
460 -
461 - return true;
462 - });
463 -
464 - $(document).ready(function () {
465 - // Keep Last filter item active
466 - function keepLastFilterActive() {
467 - let bbpcLastActiveFilter = readCookie('bbpc_current_filter');
468 - if (bbpcLastActiveFilter) {
469 - // Tab item
470 - $('[cookie-id]').removeClass('is-active mixitup-control-active');
471 - $(`[cookie-id="${bbpcLastActiveFilter}"]`).click();
472 - }
473 - }
474 -
475 - keepLastFilterActive();
476 -
477 - });
478 -
479 -})(jQuery);
480 -
481 -function menuToggle() {
482 - const toggleMenu = document.querySelector('.easydocs-dropdown');
483 - toggleMenu.classList.toggle('is-active');
1 +(function ($) {
2 + 'use strict';
3 +
4 + /*------------ Cookie functions and color js ------------*/
5 + function createCookie(name, value, days) {
6 + var expires = '';
7 + if (days) {
8 + var date = new Date();
9 + date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
10 + expires = '; expires=' + date.toUTCString();
11 + }
12 + document.cookie = name + '=' + value + expires + '; path=/';
13 + }
14 +
15 + function readCookie(name) {
16 + var nameEQ = name + '=';
17 + var ca = document.cookie.split(';');
18 + for (var i = 0; i < ca.length; i++) {
19 + var c = ca[i];
20 + while (c.charAt(0) == ' ') c = c.substring(1, c.length);
21 + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
22 + }
23 + return null;
24 + }
25 +
26 + function eraseCookie(name) {
27 + createCookie(name, '', -1);
28 + }
29 +
30 + var prefersDark =
31 + window.matchMedia &&
32 + window.matchMedia('(prefers-color-scheme: dark)').matches;
33 + var selectedNightTheme = readCookie('body_dark');
34 +
35 + if (
36 + selectedNightTheme == 'true' ||
37 + (selectedNightTheme === null && prefersDark)
38 + ) {
39 + applyNight();
40 + $('.dark_mode_switcher').prop('checked', true);
41 + } else {
42 + applyDay();
43 + $('.dark_mode_switcher').prop('checked', false);
44 + }
45 +
46 + function applyNight() {
47 + if ($('.js-darkmode-btn .ball').length) {
48 + $('.js-darkmode-btn .ball').css('left', '45px');
49 + }
50 + $('body').addClass('body_dark');
51 + }
52 +
53 + function applyDay() {
54 + if ($('.js-darkmode-btn .ball').length) {
55 + $('.js-darkmode-btn .ball').css('left', '4px');
56 + }
57 + $('body').removeClass('body_dark');
58 + }
59 +
60 + $('.dark_mode_switcher').change(function () {
61 + if ($(this).is(':checked')) {
62 + applyNight();
63 + createCookie('body_dark', true, 999);
64 + } else {
65 + applyDay();
66 + createCookie('body_dark', false, 999);
67 + }
68 + });
69 +
70 + // Filter Select
71 + $('select').frmxNiceSelect();
72 +
73 + // Sidebar Tabs [COOKIE]
74 + $(document).on('click', '.tab-menu .easydocs-navitem', function () {
75 + const target = $(this).attr('data-rel');
76 +
77 + if (!$(this).hasClass('is-active')) {
78 + // Remove active state from ALL forum items (parent and sub-forums)
79 + $('.tab-menu .easydocs-navitem').removeClass('is-active');
80 + $(this).addClass('is-active');
81 +
82 + $('#' + target)
83 + .fadeIn('slow')
84 + .siblings('.easydocs-tab')
85 + .hide();
86 +
87 + createCookie('eazydocs_doc_current_tab', target, 999);
88 +
89 + // When switching to a new forum tab, reset filters so the first
90 + // filter item ("All Topics") is always active for the new content.
91 + eraseCookie('bbpc_current_filter');
92 + const $activeTab = $('#' + target);
93 + const $firstFilter = $activeTab.find('.single-item-filter .easydocs-btn').first();
94 + if ($firstFilter.length) {
95 + $('[cookie-id]').removeClass('is-active mixitup-control-active active');
96 + $firstFilter.click();
97 + }
98 + }
99 + });
100 +
101 +
102 + // Restore last active tab
103 + function keep_last_active_doc_tab() {
104 + const lastTab = readCookie('eazydocs_doc_current_tab');
105 + if (lastTab) {
106 + const $tab = $(`.tab-menu .easydocs-navitem[data-rel="${lastTab}"]`);
107 + if ($tab.length && !$tab.hasClass('is-active')) {
108 + // Remove active state from ALL forum items (parent and sub-forums)
109 + $('.tab-menu .easydocs-navitem').removeClass('is-active');
110 + $tab.addClass('is-active');
111 +
112 + $('.easydocs-tab-content .easydocs-tab').removeClass('tab-active');
113 + $(`#${lastTab}`).addClass('tab-active');
114 + }
115 + }
116 + }
117 + keep_last_active_doc_tab();
118 +
119 +
120 + $('.tab-menu .easydocs-navitem .parent-delete').on('click', function () {
121 + return false;
122 + });
123 +
124 + $(document).ready(function () {
125 +
126 + if ($('#bbpc-search').length) {
127 + $('#bbpc-search').on('keyup', function () {
128 + var value = $(this).val().toLowerCase();
129 + $('.easydocs-accordion-item').filter(function () {
130 + $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
131 + });
132 + });
133 +
134 + // Dropdown Classic UI Filter
135 + let bbpc_classic_ui = document.getElementById('bbpc_classic_ui');
136 +
137 + function swithToLink() {
138 + window.location.href = this.value;
139 + }
140 +
141 + bbpc_classic_ui.onchange = swithToLink;
142 + }
143 + })
144 +
145 + $(document).ready(function (e) {
146 + function t(t) {
147 + e(t).bind('click', function (t) {
148 + t.preventDefault();
149 + e(this).parent().fadeOut();
150 + });
151 + }
152 +
153 + e('.header-notify-icon').click(function () {
154 + var t = e(this)
155 + .parents('.easydocs-notification')
156 + .children('.easydocs-dropdown')
157 + .is(':hidden');
158 + e('.easydocs-notification .easydocs-dropdown').hide();
159 + e('.easydocs-notification .header-notify-icon').removeClass('active');
160 + if (t) {
161 + e(this)
162 + .parents('.easydocs-notification')
163 + .children('.easydocs-dropdown')
164 + .toggle()
165 + .parents('.easydocs-notification')
166 + .children('.header-notify-icon')
167 + .addClass('active');
168 + }
169 + });
170 + e(document).bind('click', function (t) {
171 + var n = e(t.target);
172 + if (!n.parents().hasClass('easydocs-notification'))
173 + e('.easydocs-notification .easydocs-dropdown').hide();
174 + });
175 + e(document).bind('click', function (t) {
176 + var n = e(t.target);
177 + if (!n.parents().hasClass('easydocs-notification'))
178 + e('.easydocs-notification .header-notify-icon').removeClass('active');
179 + });
180 +
181 + // CREATE FORUM
182 + function create_forum() {
183 + $(document).on('click', '#bbpc-forum', function (e) {
184 + e.preventDefault();
185 + Swal.fire({
186 + title: forumax_local_object.create_forum_title,
187 + input: 'text',
188 + showCancelButton: true,
189 + inputAttributes: {
190 + name: 'bbp_forum_title',
191 + },
192 + }).then((result) => {
193 + if (result.value) {
194 + $.ajax({
195 + url: forumax_local_object.ajaxurl,
196 + type: 'POST',
197 + data: {
198 + action: 'forumax_create_forum',
199 + bbp_forum_title: result.value,
200 + bbpc_nonce: forumax_local_object.nonce
201 + },
202 + beforeSend: function () {
203 + Swal.fire({
204 + title: 'Creating Forum...',
205 + icon: 'question',
206 + allowOutsideClick: false,
207 + showConfirmButton: true,
208 + didOpen: () => {
209 + Swal.showLoading();
210 + },
211 + });
212 + },
213 + success: function (response) {
214 + if (response.success) {
215 + location.reload();
216 + } else {
217 + Swal.fire({
218 + title: 'Error!',
219 + text: response.data,
220 + icon: 'error',
221 + });
222 + }
223 + },
224 + error: function () {
225 + Swal.fire({
226 + title: 'Error!',
227 + text: 'Something went wrong. Please try again.',
228 + icon: 'error',
229 + });
230 + },
231 + });
232 + }
233 + });
234 + });
235 + }
236 + create_forum();
237 +
238 + // CREATE SUB-FORUM
239 + function create_subforum() {
240 + $(document).on('click', '.add-subforum', function (e) {
241 + e.preventDefault();
242 + e.stopPropagation();
243 + let parentForumID = $(this).attr('bbp_parent_forum_id');
244 + let parentTitle = $(this).closest('.easydocs-navitem').find('.easydocs-forums-title').text();
245 +
246 + Swal.fire({
247 + title: forumax_local_object.create_subforum_title || 'Create Sub-Forum',
248 + html: '<p style="color: #666; margin-bottom: 15px;">Creating sub-forum under: <strong>' + parentTitle + '</strong></p>',
249 + input: 'text',
250 + showCancelButton: true,
251 + inputPlaceholder: 'Enter sub-forum name...',
252 + inputAttributes: {
253 + name: 'bbp_subforum_title',
254 + },
255 + confirmButtonColor: '#7c3aed',
256 + confirmButtonText: 'Create Sub-Forum',
257 + }).then((result) => {
258 + if (result.value) {
259 + $.ajax({
260 + url: forumax_local_object.ajaxurl,
261 + type: 'POST',
262 + data: {
263 + action: 'forumax_create_subforum',
264 + bbp_subforum_title: result.value,
265 + parent_forum_id: parentForumID,
266 + bbpc_nonce: forumax_local_object.nonce
267 + },
268 + beforeSend: function () {
269 + Swal.fire({
270 + title: 'Creating Sub-Forum...',
271 + icon: 'info',
272 + allowOutsideClick: false,
273 + showConfirmButton: false,
274 + didOpen: () => {
275 + Swal.showLoading();
276 + },
277 + });
278 + },
279 + success: function (response) {
280 + if (response.success) {
281 + Swal.fire({
282 + title: 'Success!',
283 + text: 'Sub-forum created successfully.',
284 + icon: 'success',
285 + timer: 1500,
286 + showConfirmButton: false
287 + }).then(() => {
288 + location.reload();
289 + });
290 + } else {
291 + Swal.fire({
292 + title: 'Error!',
293 + text: response.data || 'Failed to create sub-forum.',
294 + icon: 'error',
295 + });
296 + }
297 + },
298 + error: function () {
299 + Swal.fire({
300 + title: 'Error!',
301 + text: 'Something went wrong. Please try again.',
302 + icon: 'error',
303 + });
304 + },
305 + });
306 + }
307 + });
308 + });
309 + }
310 + create_subforum();
311 +
312 + // IMPORT DEMO DATA
313 + function import_demo_data() {
314 + $(document).on('click', '#forumax-import-demo', function (e) {
315 + e.preventDefault();
316 + Swal.fire({
317 + title: 'Import Demo Data?',
318 + html: '<p>This will import comprehensive sample forums, topics, and replies to help you explore all Forumax features.</p><p><strong>Includes:</strong> 5 Forums, 14 Topics, 22 Replies, 1 Attachment</p><p><strong>Features:</strong> Closed topics, threaded replies, solved topics, featured images</p>',
319 + icon: 'question',
320 + showCancelButton: true,
321 + confirmButtonColor: '#7c3aed',
322 + cancelButtonColor: '#6b7280',
323 + confirmButtonText: 'Yes, Import Demo Data',
324 + cancelButtonText: 'Cancel'
325 + }).then((result) => {
326 + if (result.isConfirmed) {
327 + $.ajax({
328 + url: forumax_local_object.ajaxurl,
329 + type: 'POST',
330 + data: {
331 + action: 'forumax_import_demo_data',
332 + nonce: forumax_local_object.nonce
333 + },
334 + beforeSend: function () {
335 + Swal.fire({
336 + title: 'Importing Demo Data...',
337 + html: '<p>Please wait while we import comprehensive sample forums, topics, and replies.</p><p>This may take a moment.</p>',
338 + icon: 'info',
339 + allowOutsideClick: false,
340 + showConfirmButton: false,
341 + didOpen: () => {
342 + Swal.showLoading();
343 + },
344 + });
345 + },
346 + success: function (response) {
347 + if (response.success) {
348 + Swal.fire({
349 + title: 'Success!',
350 + text: response.data.message,
351 + icon: 'success',
352 + timer: 2000,
353 + showConfirmButton: false
354 + }).then(() => {
355 + location.reload();
356 + });
357 + } else {
358 + Swal.fire({
359 + title: 'Error!',
360 + text: response.data.message || 'Failed to import demo data.',
361 + icon: 'error',
362 + });
363 + }
364 + },
365 + error: function () {
366 + Swal.fire({
367 + title: 'Error!',
368 + text: 'Something went wrong. Please try again.',
369 + icon: 'error',
370 + });
371 + },
372 + });
373 + }
374 + });
375 + });
376 + }
377 + import_demo_data();
378 +
379 + // CREATE TOPIC
380 + function create_topic() {
381 + $(document).on('click', '#bbpc-topic', function (e) {
382 + e.preventDefault();
383 + let forumID = $(this).attr('bbp_forum_id');
384 + Swal.fire({
385 + title: forumax_local_object.create_topic_title,
386 + input: 'text',
387 + showCancelButton: true,
388 + inputAttributes: {
389 + name: 'bbp_topic_title',
390 + },
391 + }).then((result) => {
392 + if (result.value) {
393 + $.ajax({
394 + url: forumax_local_object.ajaxurl,
395 + type: 'POST',
396 + data: {
397 + action: 'forumax_create_topic',
398 + bbp_topic_title: result.value,
399 + forum_id: forumID,
400 + bbpc_nonce: forumax_local_object.nonce
401 + },
402 + beforeSend: function () {
403 + Swal.fire({
404 + title: 'Creating Topic...',
405 + icon: 'question',
406 + allowOutsideClick: false,
407 + showConfirmButton: true,
408 + didOpen: () => {
409 + Swal.showLoading();
410 + },
411 + });
412 + },
413 + success: function (response) {
414 + if (response.success) {
415 + location.reload();
416 + } else {
417 + Swal.fire({
418 + title: 'Error!',
419 + text: response.data,
420 + icon: 'error',
421 + });
422 + }
423 + },
424 + error: function () {
425 + Swal.fire({
426 + title: 'Error!',
427 + text: 'Something went wrong. Please try again.',
428 + icon: 'error',
429 + });
430 + },
431 + });
432 + }
433 + });
434 + });
435 + }
436 + create_topic();
437 +
438 + // DELETE FORUM
439 + function delete_forum() {
440 + $('.forum-delete').on('click', function (e) {
441 + e.preventDefault();
442 + var forumID = $(this).attr('bbp_forum_id');
443 + Swal.fire({
444 + title: forumax_local_object.forum_delete_title,
445 + text: forumax_local_object.forum_delete_desc,
446 + icon: 'question',
447 + showCancelButton: true,
448 + confirmButtonColor: '#3085d6',
449 + cancelButtonColor: '#d33',
450 + confirmButtonText: 'Yes'
451 + }).then((result) => {
452 + if (result.value) {
453 + $.ajax({
454 + url: forumax_local_object.ajaxurl,
455 + type: 'POST',
456 + data: {
457 + action: 'forumax_delete_forum',
458 + forum_id: forumID,
459 + bbpc_nonce: forumax_local_object.nonce
460 + },
461 + beforeSend: function () {
462 + Swal.fire({
463 + title: 'Deleting Forum...',
464 + icon: 'question',
465 + allowOutsideClick: false,
466 + showConfirmButton: false,
467 + didOpen: () => {
468 + Swal.showLoading();
469 + },
470 + });
471 + },
472 + success: function (response) {
473 + console.log(response);
474 + if (response.success) {
475 + location.reload();
476 + } else {
477 + console.log(response)
478 + Swal.fire({
479 + title: 'Error!',
480 + text: response.data || 'Unexpected error occurred.',
481 + icon: 'error',
482 + });
483 + }
484 + },
485 + error: function () {
486 + Swal.fire({
487 + title: 'Error!',
488 + text: 'Something went wrong. Please try again.',
489 + icon: 'error',
490 + });
491 + },
492 + });
493 + }
494 + });
495 + });
496 + }
497 + delete_forum();
498 +
499 +
500 + // DELETE TOPIC
501 + function delete_topic() {
502 + $('.section-delete').on('click', function (e) {
503 + e.preventDefault();
504 + var topicID = $(this).attr('bbp_topic_id');
505 + Swal.fire({
506 + title: forumax_local_object.forum_delete_title,
507 + text: forumax_local_object.topic_delete_desc,
508 + icon: 'question',
509 + showCancelButton: true,
510 + confirmButtonColor: '#3085d6',
511 + cancelButtonColor: '#d33',
512 + confirmButtonText: 'Yes',
513 + }).then((result) => {
514 + if (result.value) {
515 + $.ajax({
516 + url: forumax_local_object.ajaxurl,
517 + type: 'POST',
518 + data: {
519 + action: 'forumax_delete_topic',
520 + topic_id: topicID,
521 + bbpc_nonce: forumax_local_object.nonce
522 + },
523 + beforeSend: function () {
524 + Swal.fire({
525 + title: 'Deleting Topic...',
526 + icon: 'question',
527 + allowOutsideClick: false,
528 + showConfirmButton: false,
529 + didOpen: () => {
530 + Swal.showLoading();
531 + },
532 + });
533 + },
534 + success: function (response) {
535 + console.log(response);
536 + if (response.success) {
537 + location.reload();
538 + } else {
539 + console.log(response)
540 + Swal.fire({
541 + title: 'Error!',
542 + text: response.data || 'Unexpected error occurred.',
543 + icon: 'error',
544 + });
545 + }
546 + },
547 + error: function () {
548 + Swal.fire({
549 + title: 'Error!',
550 + text: 'Something went wrong. Please try again.',
551 + icon: 'error',
552 + });
553 + },
554 + });
555 + }
556 + });
557 + });
558 + }
559 +
560 + delete_topic();
561 +
562 + // Notification pro alert
563 + $('.easydocs-notification.forumax-pro-notification').on(
564 + 'click',
565 + function (e) {
566 + e.preventDefault();
567 + let href = $(this).attr('href');
568 + let assets = forumax_local_object.forumax_assets;
569 + Swal.fire({
570 + title: 'Notification is a Premium feature',
571 + html:
572 + '<span class="pro-notification-body-text">You need to Upgrade the Premium Version to use this feature</span><video height="400px" autoplay="autoplay" loop="loop" src="' +
573 + assets +
574 + '/videos/noti.mp4"></video>',
575 + icon: false,
576 + buttons: false,
577 + dangerMode: true,
578 + showCloseButton: true,
579 + confirmButtonText:
580 + '<a href="admin.php?page=forumax-pricing">Upgrade to Premium</a>',
581 + footer:
582 + '<a href="https://forumax.spider-themes.net/" target="_blank"> Learn More </a>',
583 + customClass: {
584 + title: 'upgrade-premium-heading',
585 + confirmButton: 'upgrade-premium-button',
586 + footer: 'notification-pro-footer-wrap',
587 + },
588 + confirmButtonColor: '#f1bd6c',
589 + Borderless: true,
590 + });
591 + }
592 + );
593 + });
594 +
595 + // Click pending replies count to show pending replies.
596 + $('[click-target]').click(function () {
597 + let id = $(this).attr('click-target');
598 + $(`[click-target=${id}]`).toggleClass('active');
599 + $(`[reply-target=${id}]`).toggle();
600 + });
601 +
602 + // Sidebar Tabs [COOKIE]
603 + $(document).on('click', '[cookie-id]', function () {
604 + let target = $(this).attr('cookie-id');
605 + let item = `[cookie-id="${target}"]`;
606 + $('[cookie-id]').removeClass('is-active mixitup-control-active active');
607 + $(item).addClass('is-active mixitup-control-active active');
608 + $(target).fadeIn('slow').siblings('.easydocs-tab').hide();
609 +
610 + let isActiveTab = $(this).hasClass('is-active');
611 + if (isActiveTab === true) {
612 + createCookie('bbpc_current_filter', target, 999);
613 + }
614 +
615 + return true;
616 + });
617 +
618 + $(document).ready(function () {
619 + // Keep Last filter item active
620 + function keepLastFilterActive() {
621 + let bbpcLastActiveFilter = readCookie('bbpc_current_filter');
622 + if (bbpcLastActiveFilter) {
623 + // Tab item
624 + $('[cookie-id]').removeClass('is-active mixitup-control-active active');
625 + $(`[cookie-id="${bbpcLastActiveFilter}"]`).click();
626 + } else {
627 + // On initial load with no cookie, click the first filter item
628 + $('.single-item-filter .easydocs-btn').first().click();
629 + }
630 + }
631 +
632 + keepLastFilterActive();
633 +
634 + // SUB-FORUM TOGGLE
635 + function initSubforumToggles() {
636 + // Restore collapsed states from cookie
637 + const collapsedForums = readCookie('forumax_collapsed_forums');
638 + const collapsedIds = collapsedForums ? collapsedForums.split(',') : [];
639 +
640 + collapsedIds.forEach(function (id) {
641 + if (id) {
642 + const $container = $(`.easydocs-subforum-container[data-parent="${id}"]`);
643 + const $toggle = $(`.easydocs-navitem[data-id="${id}"] .subforum-toggle`);
644 + if ($container.length) {
645 + $container.addClass('is-collapsed');
646 + $toggle.attr('aria-expanded', 'false');
647 + }
648 + }
649 + });
650 +
651 + // Toggle click handler
652 + $(document).on('click', '.subforum-toggle', function (e) {
653 + e.preventDefault();
654 + e.stopPropagation();
655 +
656 + const $navItem = $(this).closest('.easydocs-navitem');
657 + const forumId = $navItem.data('id');
658 + const $container = $(`.easydocs-subforum-container[data-parent="${forumId}"]`);
659 + const isExpanded = $(this).attr('aria-expanded') === 'true';
660 +
661 + if (isExpanded) {
662 + $container.addClass('is-collapsed');
663 + $(this).attr('aria-expanded', 'false');
664 + } else {
665 + $container.removeClass('is-collapsed');
666 + $(this).attr('aria-expanded', 'true');
667 + }
668 +
669 + // Save state to cookie
670 + saveCollapsedState();
671 + });
672 + }
673 +
674 + function saveCollapsedState() {
675 + const collapsedIds = [];
676 + $('.easydocs-subforum-container.is-collapsed').each(function () {
677 + collapsedIds.push($(this).data('parent'));
678 + });
679 + createCookie('forumax_collapsed_forums', collapsedIds.join(','), 30);
680 + }
681 +
682 + initSubforumToggles();
683 +
684 + });
685 +
686 +})(jQuery);
687 +
688 +function menuToggle() {
689 + const toggleMenu = document.querySelector('.easydocs-dropdown');
690 + toggleMenu.classList.toggle('is-active');
484 691 }