• joloshop

    (@joloshop)


    Hi I have the following jQuery Script:

    (function (d) {
        var k = "readmore",
            c = {
                speed: 300,
                collapsedHeight: 105,
                heightMargin: 16,
                moreLink: '<a class="showcoupon" href="#"><i class="icon-angle-down"></i> Details</a>',
                lessLink: '<a class="showcoupon" href="#"><i class="icon-angle-up"></i> Details</a>',
                embedCSS: true,
                blockCSS: "display: block; width: 100%;",
                startOpen: false,
                beforeToggle: function () {},
                afterToggle: function () {},
            },
            b = {},
            g = 0;
        function i(m, o, l) {
            var n;
            return function () {
                var s = this,
                    r = arguments;
                var q = function () {
                    n = null;
                    if (!l) {
                        m.apply(s, r);
                    }
                };
                var p = l && !n;
                clearTimeout(n);
                n = setTimeout(q, o);
                if (p) {
                    m.apply(s, r);
                }
            };
        }
        function e(l) {
            var m = ++g;
            return String(l == null ? "rmjs-" : l) + m;
        }
        function h(n) {
            var o = n.clone().css({ height: "auto", width: n.width(), maxHeight: "none", overflow: "hidden" }).insertAfter(n),
                m = o.outerHeight(),
                q = parseInt(
                    o
                        .css({ maxHeight: "" })
                        .css("max-height")
                        .replace(/[^-\d\.]/g, ""),
                    10
                ),
                p = n.data("defaultHeight");
            o.remove();
            var l = q || n.data("collapsedHeight") || p;
            n.data({ expandedHeight: m, maxHeight: q, collapsedHeight: l }).css({ maxHeight: "none" });
        }
        var j = i(function () {
            d("[data-readmore]").each(function () {
                var l = d(this),
                    m = l.attr("aria-expanded") === "true";
                h(l);
                l.css({ height: l.data(m ? "expandedHeight" : "collapsedHeight") });
            });
        }, 100);
        function a(l) {
            if (!b[l.selector]) {
                var m = " ";
                if (l.embedCSS && l.blockCSS !== "") {
                    m += l.selector + " + [data-readmore-toggle], " + l.selector + "[data-readmore]{" + l.blockCSS + "}";
                }
                m += l.selector + "[data-readmore]{transition: height " + l.speed + "ms;overflow: hidden;}";
                (function (p, n) {
                    var o = p.createElement("style");
                    o.type = "text/css";
                    if (o.styleSheet) {
                        o.styleSheet.cssText = n;
                    } else {
                        o.appendChild(p.createTextNode(n));
                    }
                    p.getElementsByTagName("head")[0].appendChild(o);
                })(document, m);
                b[l.selector] = true;
            }
        }
        function f(m, l) {
            var n = this;
            this.element = m;
            this.options = d.extend({}, c, l);
            a(this.options);
            this._defaults = c;
            this._name = k;
            this.init();
            if (window.addEventListener) {
                window.addEventListener("load", j);
                window.addEventListener("resize", j);
            } else {
                window.attachEvent("load", j);
                window.attachEvent("resize", j);
            }
        }
        f.prototype = {
            init: function () {
                var p = this,
                    o = d(this.element);
                o.data({ defaultHeight: this.options.collapsedHeight, heightMargin: this.options.heightMargin });
                h(o);
                var l = o.data("collapsedHeight"),
                    n = o.data("heightMargin");
                if (o.outerHeight(true) <= l + n) {
                    return true;
                } else {
                    var q = o.attr("id") || e(),
                        m = p.options.startOpen ? p.options.lessLink : p.options.moreLink;
                    o.attr({ "data-readmore": "", "aria-expanded": false, id: q });
                    o.after(
                        d(m)
                            .on("click", function (r) {
                                p.toggle(this, o[0], r);
                            })
                            .attr({ "data-readmore-toggle": "", "aria-controls": q })
                    );
                    if (!p.options.startOpen) {
                        o.css({ height: l });
                    }
                }
            },
            toggle: function (n, q, m) {
                if (m) {
                    m.preventDefault();
                }
                if (!n) {
                    n = d('[aria-controls="' + this.element.id + '"]')[0];
                }
                if (!q) {
                    q = this.element;
                }
                var s = this,
                    t = d(q),
                    l = "",
                    o = "",
                    r = false,
                    p = t.data("collapsedHeight");
                if (t.height() <= p) {
                    l = t.data("expandedHeight") + "px";
                    o = "lessLink";
                    r = true;
                } else {
                    l = p;
                    o = "moreLink";
                }
                s.options.beforeToggle(n, q, !r);
                t.css({ height: l });
                t.on("transitionend", function () {
                    s.options.afterToggle(n, q, r);
                    d(this).attr({ "aria-expanded": r }).off("transitionend");
                });
                d(n).replaceWith(
                    d(s.options[o])
                        .on("click", function (u) {
                            s.toggle(this, q, u);
                        })
                        .attr({ "data-readmore-toggle": "", "aria-controls": t.attr("id") })
                );
            },
            destroy: function () {
                d(this.element).each(function () {
                    var l = d(this);
                    l.attr({ "data-readmore": null, "aria-expanded": null }).css({ maxHeight: "", height: "" }).next("[data-readmore-toggle]").remove();
                    l.removeData();
                });
            },
        };
        jQuery.fn.readmore = function (n) {
            var m = arguments,
                l = this.selector;
            n = n || {};
            if (typeof n === "object") {
                return this.each(function () {
                    if (d.data(this, "plugin_" + k)) {
                        var o = d.data(this, "plugin_" + k);
                        o.destroy.apply(o);
                    }
                    n.selector = l;
                    d.data(this, "plugin_" + k, new f(this, n));
                });
            } else {
                if (typeof n === "string" && n[0] !== "_" && n !== "init") {
                    return this.each(function () {
                        var o = d.data(this, "plugin_" + k);
                        if (o instanceof f && typeof o[n] === "function") {
                            o[n].apply(o, Array.prototype.slice.call(m, 1));
                        }
                    });
                }
            }
        };
    })(jQuery);
    jQuery("#info").readmore({
        moreLink: '<a href="#">Usage, examples, and options</a>',
        collapsedHeight: 110,
        afterToggle: function (b, c, a) {
            if (!a) {
                $("html, body").animate({ scrollTop: $(c).offset().top }, { duration: 100 });
            }
        },
    });
    jQuery("article").readmore({ speed: 500 });

    unfortunately it is not working anymore with WordPress 6.0
    You can see it working on my side. However I downgraded because I need the side to run 100%.

    With 6.0 only the darker frame opens and closes (press on Details.) but the text is always fully visible.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • threadi

    (@threadi)

    This is very difficult to understand because on the one hand it obviously concerns the output of a plugin and on the other hand this was also added individually by you. Also currently comes when calling the page an error, but probably not visibly affects. But it is there.

    Have you also deactivated the caching plugin or cleared its cache after the update?

    To better reproduce this, it would be interesting to see the status after the update.

    Thread Starter joloshop

    (@joloshop)

    Hello and thank you, what do you mean there is a error? I don’t see one!
    I am back to 5.4.2 so the script is working. And yes I cleared the cache. I also installed the Enable jQuery Migrate Helper. And it’s working than. But strangely it does not find an error in this script. It is located in the footer of my theme and not inside a plug-in.

    Regards

    threadi

    (@threadi)

    You can see the error only in the JavaScript console. More information: https://wordpress.org/support/article/using-your-browser-to-diagnose-javascript-errors/

    Thread Starter joloshop

    (@joloshop)

    thanks.

    I build a testside to see the problem. http://testshop.joloshop.de/gutscheine/schuhe24-de

    threadi

    (@threadi)

    There are several serious coding errors in the HTML code of your theme. As a result, the browser does not recognize the JavaScript code in it.

    Since you are using a commercial theme with Clipper, I would ask you to contact their support: https://www.appthemes.com/themes/clipper/ – questions about commercial products are not allowed here in the forum.

    Thread Starter joloshop

    (@joloshop)

    You right it was based on clipper. However it was highly customized but the programmer is not available any more and now just need to resolve this problem. I am planning to change to another theme soon. But until than I need a fix.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Script to read more not working after update to 6.0’ is closed to new replies.