Guest User

Untitled

a guest
May 12th, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.43 KB | None | 0 0
  1. var tdbAutoload = {};
  2. (function (f, h, m) {
  3. var q = f(document), c = f(h);
  4. tdbAutoload = {
  5. original_post_id: null, template_id: null, loaded_posts: [], is_ajax_running: !1, init: function () {
  6. var a = f("#tdb-autoload-article");
  7. if (0 !== a.length) {
  8. var k = a.data("autoload"), b = a.data("autoload-type"), g = a.data("autoload-count"),
  9. l = a.data("autoload-scroll-percent"), d = a.data("autoload-org-post-id"), e = d, n = 0,
  10. p = a.data("autoload-tpl-id");
  11. tdbAutoload.original_post_id = d;
  12. tdbAutoload.template_id = p;
  13. tdbAutoload.loaded_posts.push(d);
  14. tdbAutoload.log("%c tdbAutoload(inf) art. settings", "background: #ffaa00; color: #ffffff; padding:3px 6px");
  15. tdbAutoload.log("tdbAutoload status: " + k);
  16. tdbAutoload.log("tdbAutoload type: " + b);
  17. tdbAutoload.log("tdbAutoload original post id: " + d);
  18. tdbAutoload.log("tdbAutoload count: " + parseInt(g, 10));
  19. tdbAutoload.log("tdbAutoload scroll percent: " + l);
  20. b = m.debounce(function () {
  21. tdbAutoload.log("ajax autoload > scroll");
  22. if (!0 !== tdbAutoload.is_ajax_running) {
  23. var b = 100 * c.scrollTop() / (q.height() - c.height());
  24. (!g || n < parseInt(g, 10)) && b >= l && d === e && (tdbAutoload._ajaxLoadingStart(a), tdbAutoload.is_ajax_running = !0, f.ajax({
  25. timeout: 5E4,
  26. type: "POST",
  27. url: tdbAutoload._getRestEndPoint("td-cloud-library/ajax_autoload", "uid=" + tdbAutoload._getUniqueID()),
  28. data: {
  29. currentPostId: e,
  30. originalPostId: tdbAutoload.original_post_id,
  31. templateId: tdbAutoload.template_id,
  32. loadedPosts: tdbAutoload.loaded_posts
  33. },
  34. success: function (b, k, g) {
  35. 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",
  36. function () {
  37. var b = f(this);
  38. tdbAutoload.is_ajax_running = !1;
  39. tdbAutoload._ajaxLoadingEnd(a);
  40. b.css("opacity", 1);
  41. setTimeout(function () {
  42. var a = b.contents().find("html").outerHeight(!0) + 2;
  43. tdbAutoload.log("initial iframe load height set to: " + a);
  44. b.height(a)
  45. }, 50);
  46. b.contents().find("html").attr("id", b.attr("id"));
  47. b.contents().find(".grecaptcha-badge").css("visibility", "hidden");
  48. var e = h.MutationObserver || h.WebKitMutationObserver || h.MozMutationObserver,
  49. k = document.querySelector("#" + b.attr("id")), d = (k.contentDocument ||
  50. k.contentWindow.document).getElementsByTagName("html"),
  51. n = m.debounce(function () {
  52. var a = d[0].offsetHeight;
  53. tdbAutoload.log("setHeight: height set to: " + a);
  54. b.height(a)
  55. }, 10);
  56. (new e(function (a) {
  57. a.forEach(function (a) {
  58. tdbAutoload.log("mutation occurred!");
  59. tdbAutoload.log(a);
  60. n()
  61. })
  62. })).observe(d[0], {childList: !0, subtree: !0})
  63. })))
  64. },
  65. error: function (a, b, e) {
  66. }
  67. }))
  68. }
  69. }, 100);
  70. p = m.debounce(function () {
  71. tdbAutoload.log("ajax_autoload > resize");
  72. f(".tdb-autoload-wrap").find(".tdb-infinte-post-iframe").each(function () {
  73. var a = f(this);
  74. a.height(a.contents().find("html").outerHeight())
  75. })
  76. }, 100);
  77. var r = m.debounce(function () {
  78. tdbAutoload.log("ajax autoload > scroll location change");
  79. tdbAutoload._locationChange()
  80. }, 100);
  81. "on" === k && (c.scroll(b), c.scroll(r), c.resize(p), c.resize(function () {
  82. }), c.scroll(function () {
  83. }))
  84. }
  85. }, _fixSmartSidebar: function () {
  86. var a = c.scrollTop(), k = a + c.height();
  87. f(".tdb-autoload-wrap").find("iframe").each(function () {
  88. var b = f(this), g = b.offset().top - f("#wpadminbar").outerHeight(), c = b.outerHeight(!0);
  89. b = b.attr("id");
  90. g < a && g + c > k &&
  91. (c = document.getElementById(b).contentWindow, g = a - g, "undefined" !== typeof h.tdSmartSidebar && c.tdSmartSidebar.td_events_scroll(g))
  92. })
  93. }, _locationChange: function () {
  94. var a = c.scrollTop(), k = a + c.height(), b = [];
  95. f(".tdb-autoload-wrap").find("article, iframe").filter(function () {
  96. return f(this).parent().hasClass("tdb-autoload-wrap")
  97. }).each(function () {
  98. var e = f(this), d = f(".td-header-menu-wrap.td-affix");
  99. d = d.length ? d.outerHeight() : 0;
  100. var c = f("#wpadminbar");
  101. c = c.length ? c.outerHeight() : 0;
  102. d = e.offset().top - (d + c);
  103. var h = e.outerHeight(!0);
  104. c = e.data("post-url");
  105. var g = "", l = e.data("post-title");
  106. 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");
  107. e = d + h;
  108. d < a && e > k ? b.push({
  109. top: d,
  110. bottom: e,
  111. post_url: c,
  112. post_edit_url: g,
  113. post_title: l
  114. }) : d > a && d < k ? b.push({
  115. top: d,
  116. bottom: e,
  117. post_url: c,
  118. post_edit_url: g,
  119. post_title: l
  120. }) : e > a && e < k && b.push({top: d, bottom: e, post_url: c, post_edit_url: g, post_title: l})
  121. });
  122. if (0 === b.length) {
  123. var g = h.location.href;
  124. var l = h.tdb_p_autoload_vars.origPostEditUrl;
  125. var d = document.title
  126. } 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);
  127. tdbAutoload._updatePostURL(g, l, d)
  128. }, _updatePostURL: function (a, c, b) {
  129. 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))
  130. }, _ajaxLoadingStart: function (a) {
  131. f(".td-loader-gif").remove();
  132. a.find(".tdc-content-wrap").append('<div class="td-loader-gif td-loader-animation-start tdb-loader-autoload"></div>');
  133. tdLoadingBox.init(tds_theme_color_site_wide);
  134. setTimeout(function () {
  135. f(".td-loader-gif").removeClass("td-loader-animation-start").addClass("td-loader-animation-mid")
  136. }, 50)
  137. }, _ajaxLoadingEnd: function (a) {
  138. a.find(".td-loader-gif").removeClass("td-loader-animation-mid").addClass("td-loader-animation-end");
  139. setTimeout(function () {
  140. a.find(".td-loader-gif").remove();
  141. tdLoadingBox.stop()
  142. }, 400)
  143. }, _getRestEndPoint: function (a, c) {
  144. return m.isEmpty(h.tdb_global_vars.permalinkStructure) ? h.tdb_global_vars.wpRestUrl + a + "&" +
  145. c : h.tdb_global_vars.wpRestUrl + a + "?" + c
  146. }, _getUniqueID: function () {
  147. function a() {
  148. return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
  149. }
  150.  
  151. return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a()
  152. }, log: function (a, c) {
  153. }
  154. };
  155. q.ready(function () {
  156. tdbAutoload.init()
  157. })
  158. })(jQuery, this, _);
  159.  
Advertisement
Add Comment
Please, Sign In to add comment