| @@ -1,5 +1,4 @@ | ||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?> | |
| 2 | 1 | <script> |
| 3 | 2 | jQuery(document).ready(function($) { |
| 4 | 3 | let listSidebarCatTitles = $( |
| 5 | 4 | ".betterdocs-sidebar-content .betterdocs-sidebar-list-wrapper .betterdocs-sidebar-list .betterdocs-category-header" |
| @@ -15,40 +14,8 @@ | ||
| 15 | 14 | ); |
| 16 | 15 | |
| 17 | 16 | let nestedCategoriesToggle = $(".betterdocs-nested-category-title"); |
| 18 | 17 | |
| 19 | - // When "Lazy Load Sidebar Docs & Subcategories" is on, non-active | |
| 20 | - // categories render an empty body (data-bd-lazy="1") and the docs are | |
| 21 | - // fetched on click. That fetch normally lives in category-toggler.js, | |
| 22 | - // which binds on window.load and does NOT run inside the Elementor editor | |
| 23 | - // preview — so replicate it here. The AJAX returns the category's full | |
| 24 | - // doc list, so all docs display (no cap). No-ops for non-lazy bodies. | |
| 25 | - function loadLazyBody($body) { | |
| 26 | - if (!$body.length || $body.attr("data-bd-lazy") !== "1") return; | |
| 27 | - if ($body.attr("data-bd-loaded") === "1" || $body.attr("data-bd-loading") === "1") return; | |
| 28 | - var cfg = window.betterdocsCategoryGridConfig || {}; | |
| 29 | - // The config object is not reliably printed into the Elementor editor | |
| 30 | - // preview, so fall back to the PHP-injected admin-ajax URL. Without this | |
| 31 | - // the editor fetch bailed on `!cfg.ajax_url` and no docs loaded, even | |
| 32 | - // though the front end (where the config IS present) worked fine. | |
| 33 | - var ajaxUrl = cfg.ajax_url || <?php echo wp_json_encode( esc_url_raw( admin_url( 'admin-ajax.php' ) ) ); ?>; | |
| 34 | - var lazyAction = cfg.lazy_load_action || "betterdocs_lazy_category_body"; | |
| 35 | - if (!ajaxUrl) return; | |
| 36 | - var category_icon = $body.closest(".betterdocs-sidebar-layout-7").length ? "folder" : ""; | |
| 37 | - $body.attr("data-bd-loading", "1"); | |
| 38 | - $.post(ajaxUrl, { | |
| 39 | - action: lazyAction, | |
| 40 | - term_id: $body.attr("data-bd-term-id"), | |
| 41 | - category_icon: category_icon | |
| 42 | - }).done(function (resp) { | |
| 43 | - if (resp && resp.success && resp.data && typeof resp.data.html === "string") { | |
| 44 | - $body.html(resp.data.html).attr("data-bd-loaded", "1").removeAttr("data-bd-lazy"); | |
| 45 | - } | |
| 46 | - }).always(function () { | |
| 47 | - $body.removeAttr("data-bd-loading"); | |
| 48 | - }); | |
| 49 | - } | |
| 50 | - | |
| 51 | 18 | function categoryAccordion() { |
| 52 | 19 | let $parentThis = this; |
| 53 | 20 | currentActiveCat |
| 54 | 21 | .addClass("show") |
| @@ -62,16 +29,9 @@ | ||
| 62 | 29 | e.preventDefault(); |
| 63 | 30 | let $parentCat = jQuery(e.target).closest( |
| 64 | 31 | ".betterdocs-single-category-wrapper" |
| 65 | 32 | ); |
| 66 | - let $body = $parentCat | |
| 67 | - .children(".betterdocs-single-category-inner") | |
| 68 | - .children(".betterdocs-body"); | |
| 69 | - if (!$body.length) { | |
| 70 | - $body = $parentCat.find(".betterdocs-body").first(); | |
| 71 | - } | |
| 72 | - loadLazyBody($body); | |
| 73 | - $body.slideToggle(); | |
| 33 | + $parentCat.find(".betterdocs-body").slideToggle(); | |
| 74 | 34 | $parentCat |
| 75 | 35 | .addClass("active") |
| 76 | 36 | .toggleClass("show") |
| 77 | 37 | .siblings() |