Script to read more not working after update to 6.0
-
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)
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.