Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tdbAutoload = {};
- (function (f, h, m) {
- var q = f(document), c = f(h);
- tdbAutoload = {
- original_post_id: null, template_id: null, loaded_posts: [], is_ajax_running: !1, init: function () {
- var a = f("#tdb-autoload-article");
- if (0 !== a.length) {
- var k = a.data("autoload"), b = a.data("autoload-type"), g = a.data("autoload-count"),
- l = a.data("autoload-scroll-percent"), d = a.data("autoload-org-post-id"), e = d, n = 0,
- p = a.data("autoload-tpl-id");
- tdbAutoload.original_post_id = d;
- tdbAutoload.template_id = p;
- tdbAutoload.loaded_posts.push(d);
- tdbAutoload.log("%c tdbAutoload(inf) art. settings", "background: #ffaa00; color: #ffffff; padding:3px 6px");
- tdbAutoload.log("tdbAutoload status: " + k);
- tdbAutoload.log("tdbAutoload type: " + b);
- tdbAutoload.log("tdbAutoload original post id: " + d);
- tdbAutoload.log("tdbAutoload count: " + parseInt(g, 10));
- tdbAutoload.log("tdbAutoload scroll percent: " + l);
- b = m.debounce(function () {
- tdbAutoload.log("ajax autoload > scroll");
- if (!0 !== tdbAutoload.is_ajax_running) {
- var b = 100 * c.scrollTop() / (q.height() - c.height());
- (!g || n < parseInt(g, 10)) && b >= l && d === e && (tdbAutoload._ajaxLoadingStart(a), tdbAutoload.is_ajax_running = !0, f.ajax({
- timeout: 5E4,
- type: "POST",
- url: tdbAutoload._getRestEndPoint("td-cloud-library/ajax_autoload", "uid=" + tdbAutoload._getUniqueID()),
- data: {
- currentPostId: e,
- originalPostId: tdbAutoload.original_post_id,
- templateId: tdbAutoload.template_id,
- loadedPosts: tdbAutoload.loaded_posts
- },
- success: function (b, k, g) {
- null !== b && void 0 === b.error && (void 0 !== b.noPosts ? tdbAutoload._ajaxLoadingEnd(a) : (n++, k = f(b.article), f(k).appendTo(a.find(".tdc-content-wrap")), e = d = b.id, tdbAutoload.loaded_posts.push(d), k.filter("#tdb-infinte-post-" + e + "-iframe").on("load",
- function () {
- var b = f(this);
- tdbAutoload.is_ajax_running = !1;
- tdbAutoload._ajaxLoadingEnd(a);
- b.css("opacity", 1);
- setTimeout(function () {
- var a = b.contents().find("html").outerHeight(!0) + 2;
- tdbAutoload.log("initial iframe load height set to: " + a);
- b.height(a)
- }, 50);
- b.contents().find("html").attr("id", b.attr("id"));
- b.contents().find(".grecaptcha-badge").css("visibility", "hidden");
- var e = h.MutationObserver || h.WebKitMutationObserver || h.MozMutationObserver,
- k = document.querySelector("#" + b.attr("id")), d = (k.contentDocument ||
- k.contentWindow.document).getElementsByTagName("html"),
- n = m.debounce(function () {
- var a = d[0].offsetHeight;
- tdbAutoload.log("setHeight: height set to: " + a);
- b.height(a)
- }, 10);
- (new e(function (a) {
- a.forEach(function (a) {
- tdbAutoload.log("mutation occurred!");
- tdbAutoload.log(a);
- n()
- })
- })).observe(d[0], {childList: !0, subtree: !0})
- })))
- },
- error: function (a, b, e) {
- }
- }))
- }
- }, 100);
- p = m.debounce(function () {
- tdbAutoload.log("ajax_autoload > resize");
- f(".tdb-autoload-wrap").find(".tdb-infinte-post-iframe").each(function () {
- var a = f(this);
- a.height(a.contents().find("html").outerHeight())
- })
- }, 100);
- var r = m.debounce(function () {
- tdbAutoload.log("ajax autoload > scroll location change");
- tdbAutoload._locationChange()
- }, 100);
- "on" === k && (c.scroll(b), c.scroll(r), c.resize(p), c.resize(function () {
- }), c.scroll(function () {
- }))
- }
- }, _fixSmartSidebar: function () {
- var a = c.scrollTop(), k = a + c.height();
- f(".tdb-autoload-wrap").find("iframe").each(function () {
- var b = f(this), g = b.offset().top - f("#wpadminbar").outerHeight(), c = b.outerHeight(!0);
- b = b.attr("id");
- g < a && g + c > k &&
- (c = document.getElementById(b).contentWindow, g = a - g, "undefined" !== typeof h.tdSmartSidebar && c.tdSmartSidebar.td_events_scroll(g))
- })
- }, _locationChange: function () {
- var a = c.scrollTop(), k = a + c.height(), b = [];
- f(".tdb-autoload-wrap").find("article, iframe").filter(function () {
- return f(this).parent().hasClass("tdb-autoload-wrap")
- }).each(function () {
- var e = f(this), d = f(".td-header-menu-wrap.td-affix");
- d = d.length ? d.outerHeight() : 0;
- var c = f("#wpadminbar");
- c = c.length ? c.outerHeight() : 0;
- d = e.offset().top - (d + c);
- var h = e.outerHeight(!0);
- c = e.data("post-url");
- var g = "", l = e.data("post-title");
- e.is("iframe") ? (e = e.contents().find("#tdb-autoload-article article"), e.length && (g = e.data("post-edit-url"))) : g = e.data("post-edit-url");
- e = d + h;
- d < a && e > k ? b.push({
- top: d,
- bottom: e,
- post_url: c,
- post_edit_url: g,
- post_title: l
- }) : d > a && d < k ? b.push({
- top: d,
- bottom: e,
- post_url: c,
- post_edit_url: g,
- post_title: l
- }) : e > a && e < k && b.push({top: d, bottom: e, post_url: c, post_edit_url: g, post_title: l})
- });
- if (0 === b.length) {
- var g = h.location.href;
- var l = h.tdb_p_autoload_vars.origPostEditUrl;
- var d = document.title
- } else 1 === b.length ? (d = b.pop(), g = d.post_url, l = d.post_edit_url, d = d.post_title) : (g = b[0].post_url, l = b[0].post_edit_url, d = b[0].post_title);
- tdbAutoload._updatePostURL(g, l, d)
- }, _updatePostURL: function (a, c, b) {
- h.location.href === a || "" === a || h.location.href.includes(a) || (h.history.replaceState(null, null, a), document.title = b, h.tdb_p_autoload_vars.isAdminBarShowing && c && f("#wp-admin-bar-edit").find("a").attr("href", c))
- }, _ajaxLoadingStart: function (a) {
- f(".td-loader-gif").remove();
- a.find(".tdc-content-wrap").append('<div class="td-loader-gif td-loader-animation-start tdb-loader-autoload"></div>');
- tdLoadingBox.init(tds_theme_color_site_wide);
- setTimeout(function () {
- f(".td-loader-gif").removeClass("td-loader-animation-start").addClass("td-loader-animation-mid")
- }, 50)
- }, _ajaxLoadingEnd: function (a) {
- a.find(".td-loader-gif").removeClass("td-loader-animation-mid").addClass("td-loader-animation-end");
- setTimeout(function () {
- a.find(".td-loader-gif").remove();
- tdLoadingBox.stop()
- }, 400)
- }, _getRestEndPoint: function (a, c) {
- return m.isEmpty(h.tdb_global_vars.permalinkStructure) ? h.tdb_global_vars.wpRestUrl + a + "&" +
- c : h.tdb_global_vars.wpRestUrl + a + "?" + c
- }, _getUniqueID: function () {
- function a() {
- return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
- }
- return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a()
- }, log: function (a, c) {
- }
- };
- q.ready(function () {
- tdbAutoload.init()
- })
- })(jQuery, this, _);
Advertisement
Add Comment
Please, Sign In to add comment