| 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'); |
| 691 |
} |