| @@ -67,17 +67,17 @@ | ||
| 67 | 67 | } |
| 68 | 68 | }); |
| 69 | 69 | |
| 70 | 70 | // Filter Select |
| 71 | - $('select').niceSelect(); | |
| 71 | + $('select').frmxNiceSelect(); | |
| 72 | 72 | |
| 73 | 73 | // Sidebar Tabs [COOKIE] |
| 74 | 74 | $(document).on('click', '.tab-menu .easydocs-navitem', function () { |
| 75 | 75 | const target = $(this).attr('data-rel'); |
| 76 | - const $siblings = $(this).siblings(); | |
| 77 | 76 | |
| 78 | 77 | if (!$(this).hasClass('is-active')) { |
| 79 | - $siblings.removeClass('is-active'); | |
| 78 | + // Remove active state from ALL forum items (parent and sub-forums) | |
| 79 | + $('.tab-menu .easydocs-navitem').removeClass('is-active'); | |
| 80 | 80 | $(this).addClass('is-active'); |
| 81 | 81 | |
| 82 | 82 | $('#' + target) |
| 83 | 83 | .fadeIn('slow') |
| @@ -84,11 +84,22 @@ | ||
| 84 | 84 | .siblings('.easydocs-tab') |
| 85 | 85 | .hide(); |
| 86 | 86 | |
| 87 | 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 | + } | |
| 88 | 98 | } |
| 89 | 99 | }); |
| 90 | 100 | |
| 101 | + | |
| 91 | 102 | // Restore last active tab |
| 92 | 103 | function keep_last_active_doc_tab() { |
| 93 | 104 | const lastTab = readCookie('eazydocs_doc_current_tab'); |
| 94 | 105 | if (lastTab) { |
| @@ -93,9 +104,10 @@ | ||
| 93 | 104 | const lastTab = readCookie('eazydocs_doc_current_tab'); |
| 94 | 105 | if (lastTab) { |
| 95 | 106 | const $tab = $(`.tab-menu .easydocs-navitem[data-rel="${lastTab}"]`); |
| 96 | 107 | if ($tab.length && !$tab.hasClass('is-active')) { |
| 97 | - $tab.siblings().removeClass('is-active'); | |
| 108 | + // Remove active state from ALL forum items (parent and sub-forums) | |
| 109 | + $('.tab-menu .easydocs-navitem').removeClass('is-active'); | |
| 98 | 110 | $tab.addClass('is-active'); |
| 99 | 111 | |
| 100 | 112 | $('.easydocs-tab-content .easydocs-tab').removeClass('tab-active'); |
| 101 | 113 | $(`#${lastTab}`).addClass('tab-active'); |
| @@ -103,8 +115,9 @@ | ||
| 103 | 115 | } |
| 104 | 116 | } |
| 105 | 117 | keep_last_active_doc_tab(); |
| 106 | 118 | |
| 119 | + | |
| 107 | 120 | $('.tab-menu .easydocs-navitem .parent-delete').on('click', function () { |
| 108 | 121 | return false; |
| 109 | 122 | }); |
| 110 | 123 | |
| @@ -109,9 +122,9 @@ | ||
| 109 | 122 | }); |
| 110 | 123 | |
| 111 | 124 | $(document).ready(function () { |
| 112 | 125 | |
| 113 | - if ( $('#bbpc-search').length ) { | |
| 126 | + if ($('#bbpc-search').length) { | |
| 114 | 127 | $('#bbpc-search').on('keyup', function () { |
| 115 | 128 | var value = $(this).val().toLowerCase(); |
| 116 | 129 | $('.easydocs-accordion-item').filter(function () { |
| 117 | 130 | $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1); |
| @@ -167,11 +180,11 @@ | ||
| 167 | 180 | |
| 168 | 181 | // CREATE FORUM |
| 169 | 182 | function create_forum() { |
| 170 | 183 | $(document).on('click', '#bbpc-forum', function (e) { |
| 171 | - e.preventDefault(); | |
| 184 | + e.preventDefault(); | |
| 172 | 185 | Swal.fire({ |
| 173 | - title: bbp_core_local_object.create_forum_title, | |
| 186 | + title: forumax_local_object.create_forum_title, | |
| 174 | 187 | input: 'text', |
| 175 | 188 | showCancelButton: true, |
| 176 | 189 | inputAttributes: { |
| 177 | 190 | name: 'bbp_forum_title', |
| @@ -178,14 +191,14 @@ | ||
| 178 | 191 | }, |
| 179 | 192 | }).then((result) => { |
| 180 | 193 | if (result.value) { |
| 181 | 194 | $.ajax({ |
| 182 | - url: bbp_core_local_object.ajaxurl, | |
| 195 | + url: forumax_local_object.ajaxurl, | |
| 183 | 196 | type: 'POST', |
| 184 | 197 | data: { |
| 185 | - action: 'bbp_create_forum', | |
| 186 | - bbp_forum_title: result.value, | |
| 187 | - bbpc_nonce: bbp_core_local_object.nonce | |
| 198 | + action: 'forumax_create_forum', | |
| 199 | + bbp_forum_title: result.value, | |
| 200 | + bbpc_nonce: forumax_local_object.nonce | |
| 188 | 201 | }, |
| 189 | 202 | beforeSend: function () { |
| 190 | 203 | Swal.fire({ |
| 191 | 204 | title: 'Creating Forum...', |
| @@ -198,9 +211,9 @@ | ||
| 198 | 211 | }); |
| 199 | 212 | }, |
| 200 | 213 | success: function (response) { |
| 201 | 214 | if (response.success) { |
| 202 | - location.reload(); | |
| 215 | + location.reload(); | |
| 203 | 216 | } else { |
| 204 | 217 | Swal.fire({ |
| 205 | 218 | title: 'Error!', |
| 206 | 219 | text: response.data, |
| @@ -218,11 +231,152 @@ | ||
| 218 | 231 | }); |
| 219 | 232 | } |
| 220 | 233 | }); |
| 221 | 234 | }); |
| 222 | - } | |
| 235 | + } | |
| 223 | 236 | create_forum(); |
| 224 | - | |
| 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 | + | |
| 225 | 379 | // CREATE TOPIC |
| 226 | 380 | function create_topic() { |
| 227 | 381 | $(document).on('click', '#bbpc-topic', function (e) { |
| 228 | 382 | e.preventDefault(); |
| @@ -227,9 +381,9 @@ | ||
| 227 | 381 | $(document).on('click', '#bbpc-topic', function (e) { |
| 228 | 382 | e.preventDefault(); |
| 229 | 383 | let forumID = $(this).attr('bbp_forum_id'); |
| 230 | 384 | Swal.fire({ |
| 231 | - title: bbp_core_local_object.create_topic_title, | |
| 385 | + title: forumax_local_object.create_topic_title, | |
| 232 | 386 | input: 'text', |
| 233 | 387 | showCancelButton: true, |
| 234 | 388 | inputAttributes: { |
| 235 | 389 | name: 'bbp_topic_title', |
| @@ -236,15 +390,15 @@ | ||
| 236 | 390 | }, |
| 237 | 391 | }).then((result) => { |
| 238 | 392 | if (result.value) { |
| 239 | 393 | $.ajax({ |
| 240 | - url: bbp_core_local_object.ajaxurl, | |
| 394 | + url: forumax_local_object.ajaxurl, | |
| 241 | 395 | type: 'POST', |
| 242 | 396 | data: { |
| 243 | - action: 'bbp_create_topic', | |
| 397 | + action: 'forumax_create_topic', | |
| 244 | 398 | bbp_topic_title: result.value, |
| 245 | - forum_id: forumID, | |
| 246 | - bbpc_nonce: bbp_core_local_object.nonce | |
| 399 | + forum_id: forumID, | |
| 400 | + bbpc_nonce: forumax_local_object.nonce | |
| 247 | 401 | }, |
| 248 | 402 | beforeSend: function () { |
| 249 | 403 | Swal.fire({ |
| 250 | 404 | title: 'Creating Topic...', |
| @@ -257,9 +411,9 @@ | ||
| 257 | 411 | }); |
| 258 | 412 | }, |
| 259 | 413 | success: function (response) { |
| 260 | 414 | if (response.success) { |
| 261 | - location.reload(); | |
| 415 | + location.reload(); | |
| 262 | 416 | } else { |
| 263 | 417 | Swal.fire({ |
| 264 | 418 | title: 'Error!', |
| 265 | 419 | text: response.data, |
| @@ -283,13 +437,13 @@ | ||
| 283 | 437 | |
| 284 | 438 | // DELETE FORUM |
| 285 | 439 | function delete_forum() { |
| 286 | 440 | $('.forum-delete').on('click', function (e) { |
| 287 | - e.preventDefault(); | |
| 288 | - var forumID = $(this).attr('bbp_forum_id'); | |
| 441 | + e.preventDefault(); | |
| 442 | + var forumID = $(this).attr('bbp_forum_id'); | |
| 289 | 443 | Swal.fire({ |
| 290 | - title: bbp_core_local_object.forum_delete_title, | |
| 291 | - text: bbp_core_local_object.forum_delete_desc, | |
| 444 | + title: forumax_local_object.forum_delete_title, | |
| 445 | + text: forumax_local_object.forum_delete_desc, | |
| 292 | 446 | icon: 'question', |
| 293 | 447 | showCancelButton: true, |
| 294 | 448 | confirmButtonColor: '#3085d6', |
| 295 | 449 | cancelButtonColor: '#d33', |
| @@ -296,14 +450,14 @@ | ||
| 296 | 450 | confirmButtonText: 'Yes' |
| 297 | 451 | }).then((result) => { |
| 298 | 452 | if (result.value) { |
| 299 | 453 | $.ajax({ |
| 300 | - url: bbp_core_local_object.ajaxurl, | |
| 454 | + url: forumax_local_object.ajaxurl, | |
| 301 | 455 | type: 'POST', |
| 302 | 456 | data: { |
| 303 | - action: 'bbp_delete_forum', | |
| 304 | - forum_id: forumID, | |
| 305 | - bbpc_nonce: bbp_core_local_object.nonce | |
| 457 | + action: 'forumax_delete_forum', | |
| 458 | + forum_id: forumID, | |
| 459 | + bbpc_nonce: forumax_local_object.nonce | |
| 306 | 460 | }, |
| 307 | 461 | beforeSend: function () { |
| 308 | 462 | Swal.fire({ |
| 309 | 463 | title: 'Deleting Forum...', |
| @@ -338,20 +492,20 @@ | ||
| 338 | 492 | }); |
| 339 | 493 | } |
| 340 | 494 | }); |
| 341 | 495 | }); |
| 342 | - } | |
| 496 | + } | |
| 343 | 497 | delete_forum(); |
| 344 | - | |
| 345 | 498 | |
| 499 | + | |
| 346 | 500 | // DELETE TOPIC |
| 347 | 501 | function delete_topic() { |
| 348 | 502 | $('.section-delete').on('click', function (e) { |
| 349 | 503 | e.preventDefault(); |
| 350 | - var topicID = $(this).attr('bbp_topic_id'); | |
| 504 | + var topicID = $(this).attr('bbp_topic_id'); | |
| 351 | 505 | Swal.fire({ |
| 352 | - title: bbp_core_local_object.forum_delete_title, | |
| 353 | - text: bbp_core_local_object.topic_delete_desc, | |
| 506 | + title: forumax_local_object.forum_delete_title, | |
| 507 | + text: forumax_local_object.topic_delete_desc, | |
| 354 | 508 | icon: 'question', |
| 355 | 509 | showCancelButton: true, |
| 356 | 510 | confirmButtonColor: '#3085d6', |
| 357 | 511 | cancelButtonColor: '#d33', |
| @@ -358,14 +512,14 @@ | ||
| 358 | 512 | confirmButtonText: 'Yes', |
| 359 | 513 | }).then((result) => { |
| 360 | 514 | if (result.value) { |
| 361 | 515 | $.ajax({ |
| 362 | - url: bbp_core_local_object.ajaxurl, | |
| 516 | + url: forumax_local_object.ajaxurl, | |
| 363 | 517 | type: 'POST', |
| 364 | 518 | data: { |
| 365 | - action: 'bbp_delete_topic', | |
| 366 | - topic_id: topicID, | |
| 367 | - bbpc_nonce: bbp_core_local_object.nonce | |
| 519 | + action: 'forumax_delete_topic', | |
| 520 | + topic_id: topicID, | |
| 521 | + bbpc_nonce: forumax_local_object.nonce | |
| 368 | 522 | }, |
| 369 | 523 | beforeSend: function () { |
| 370 | 524 | Swal.fire({ |
| 371 | 525 | title: 'Deleting Topic...', |
| @@ -377,9 +531,9 @@ | ||
| 377 | 531 | }, |
| 378 | 532 | }); |
| 379 | 533 | }, |
| 380 | 534 | success: function (response) { |
| 381 | - console.log(response); | |
| 535 | + console.log(response); | |
| 382 | 536 | if (response.success) { |
| 383 | 537 | location.reload(); |
| 384 | 538 | } else { |
| 385 | 539 | console.log(response) |
| @@ -405,14 +559,14 @@ | ||
| 405 | 559 | |
| 406 | 560 | delete_topic(); |
| 407 | 561 | |
| 408 | 562 | // Notification pro alert |
| 409 | - $('.easydocs-notification.bbp-core-pro-notification').on( | |
| 563 | + $('.easydocs-notification.forumax-pro-notification').on( | |
| 410 | 564 | 'click', |
| 411 | 565 | function (e) { |
| 412 | 566 | e.preventDefault(); |
| 413 | 567 | let href = $(this).attr('href'); |
| 414 | - let assets = bbp_core_local_object.BBPC_ASSETS; | |
| 568 | + let assets = forumax_local_object.forumax_assets; | |
| 415 | 569 | Swal.fire({ |
| 416 | 570 | title: 'Notification is a Premium feature', |
| 417 | 571 | html: |
| 418 | 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="' + |
| @@ -422,11 +576,11 @@ | ||
| 422 | 576 | buttons: false, |
| 423 | 577 | dangerMode: true, |
| 424 | 578 | showCloseButton: true, |
| 425 | 579 | confirmButtonText: |
| 426 | - '<a href="admin.php?page=bbp-core-pricing">Upgrade to Premium</a>', | |
| 580 | + '<a href="admin.php?page=forumax-pricing">Upgrade to Premium</a>', | |
| 427 | 581 | footer: |
| 428 | - '<a href="https://spider-themes.net/bbp-core/" target="_blank"> Learn More </a>', | |
| 582 | + '<a href="https://forumax.spider-themes.net/" target="_blank"> Learn More </a>', | |
| 429 | 583 | customClass: { |
| 430 | 584 | title: 'upgrade-premium-heading', |
| 431 | 585 | confirmButton: 'upgrade-premium-button', |
| 432 | 586 | footer: 'notification-pro-footer-wrap', |
| @@ -447,11 +601,11 @@ | ||
| 447 | 601 | |
| 448 | 602 | // Sidebar Tabs [COOKIE] |
| 449 | 603 | $(document).on('click', '[cookie-id]', function () { |
| 450 | 604 | 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'); | |
| 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'); | |
| 454 | 608 | $(target).fadeIn('slow').siblings('.easydocs-tab').hide(); |
| 455 | 609 | |
| 456 | 610 | let isActiveTab = $(this).hasClass('is-active'); |
| 457 | 611 | if (isActiveTab === true) { |
| @@ -466,14 +620,67 @@ | ||
| 466 | 620 | function keepLastFilterActive() { |
| 467 | 621 | let bbpcLastActiveFilter = readCookie('bbpc_current_filter'); |
| 468 | 622 | if (bbpcLastActiveFilter) { |
| 469 | 623 | // Tab item |
| 470 | - $('[cookie-id]').removeClass('is-active mixitup-control-active'); | |
| 624 | + $('[cookie-id]').removeClass('is-active mixitup-control-active active'); | |
| 471 | 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(); | |
| 472 | 629 | } |
| 473 | 630 | } |
| 474 | 631 | |
| 475 | 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(); | |
| 476 | 683 | |
| 477 | 684 | }); |
| 478 | 685 | |
| 479 | 686 | })(jQuery); |