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