1(function ($, window, document, _undefined) { 2 "use strict"; 3 4 window.iFrameResizer = { 5 onReady: function () { 6 // console.log('framed onReady'); 7 8 var postPositions = []; 9 $(".js-post:visible").map(function (i, el) { 10 let link = $(el).find(".message-attribution a:visible").first(); 11 let result = null; 12 if (link.length) { 13 result = link.attr("href").match(/post=(\d+)/); 14 } else { 15 link = $(el).find('[data-xf-click="inserter"]').first(); 16 if (link.length) { 17 result = link.attr("href").match(/posts\/(\d+)/); 18 } 19 } 20 if (result && result[1]) { 21 let offset = $(el).offset(); 22 if (offset.top) { 23 postPositions.push({ 24 post: result[1], 25 position: offset.top, 26 }); 27 } 28 29 return; 30 } 31 }); 32 parentIFrame.sendMessage({ postPositions: postPositions.reverse() }); 33 34 let urlParams = new URLSearchParams(window.location.search); 35 36 if (urlParams.get("add-reply")) { 37 // console.log('framed addReply'); 38 if ($(".js-quickReply").length) { 39 setTimeout(function () { 40 parentIFrame.sendMessage({ 41 addReply: { 42 offset: $(".js-quickReply").offset().top, 43 height: $(".js-quickReply").height(), 44 }, 45 }); 46 }, 50); 47 } 48 49 return; 50 } 51 52 let page = window.location.href.match(/page-(\d+)/); 53 if (page) { 54 parentIFrame.sendMessage({ page: page[1] }); 55 } else { 56 parentIFrame.sendMessage({ page: 1 }); 57 } 58 59 if (window.location.hash) { 60 let result = window.location.hash.match(/^#post-(\d+)$/); 61 if (result && result[1]) { 62 let postElement = $('[data-content="post-' + result[1] + '"]'); 63 let offset = postElement.offset(); 64 parentIFrame.sendMessage({ offset: offset.top }); 65 if ( 66 postElement.find( 67 '[data-replace="[data-content=post-' + result[1] + ']"]' 68 ).length 69 ) { 70 setTimeout(function () { 71 postElement 72 .find('[data-replace="[data-content=post-' + result[1] + ']"]') 73 .click(); 74 }, 500); 75 } 76 77 return; 78 } 79 } 80 81 $("body").css("position", "static"); 82 }, 83 onMessage: function (data) { 84 // console.log('framed onMessage'); 85 // console.log(data); 86 87 if (data.getPostPosition) { 88 let offset = $("#js-post-" + data.getPostPosition).offset(); 89 parentIFrame.sendMessage({ offset: offset.top }); 90 } 91 }, 92 }; 93 94 XF.WpConnectFeature = XF.extend(XF.SwitchClick, { 95 applyResponseActions: function (data) { 96 this.applyActionsTo(this.$target, data); 97 }, 98 99 applyActionsTo: function ($target, data) { 100 XF.handleSwitchResponse($target, data, false); 101 102 var $message = $target.closest(".message"); 103 104 if (data.switchKey == "marked") { 105 $message.addClass("message--wp-connect-featured"); 106 } else if (data.switchKey == "removed") { 107 $message.removeClass("message--wp-connect-featured"); 108 } 109 }, 110 }); 111 XF.Event.register("click", "wpconnect-feature", "XF.WpConnectFeature"); 112 113 if (!$("html").hasClass("in-iframe")) { 114 return; 115 } 116 117 XF.config.speed.normal = 0; 118 119 var spamPostId = null; 120 121 XF.addFixedMessage = function (el, extraAttrs) { 122 if (el == XF.phrase("active_user_changed_reload_page")) { 123 let urlParams, wpData, wpPostRedirectUrl, wpPostRedirectQuery; 124 125 urlParams = new URLSearchParams(window.location.search); 126 wpData = JSON.parse(atob(urlParams.get("wp_data"))); 127 128 wpPostRedirectQuery = []; 129 130 if (wpData.open_comments) { 131 wpPostRedirectQuery.push(wpData.open_comments); 132 } 133 134 let page = window.location.href.match(/page-(\d+)/); 135 if (page) { 136 wpPostRedirectQuery.push("comments-page=" + page[1]); 137 } 138 139 wpPostRedirectQuery.push("add-reply=1"); 140 141 wpPostRedirectQuery = wpPostRedirectQuery.join("&"); 142 143 wpPostRedirectUrl = 144 wpData.url + 145 (wpData.url.indexOf("?") === -1 ? "?" : "&") + 146 wpPostRedirectQuery; 147 148 parentIFrame.sendMessage({ navigate: wpPostRedirectUrl }); 149 150 return; 151 } 152 }; 153 154 if ("Lightbox" in XF) { 155 XF.WpConnectLightbox = XF.extend(XF.Lightbox, { 156 init: function () { 157 return; 158 }, 159 }); 160 XF.Element.register("lightbox", "XF.WpConnectLightbox"); 161 } 162 163 $("body").on("overlay:showing", ".overlay-container", function (overlay) {
164 var $overlay = $(overlay.target).find("> .overlay"); 165 166 var postId = $overlay.find(".wpconnect_post_id").val(); 167 var requestUrl = $overlay.find(".wpconnect_url").val(); 168 var formAction = $overlay.find("form").attr("action"); 169 170 var postPositionOffset = 300; 171 172 if (requestUrl) { 173 let regexResult = null; 174 175 if (requestUrl.match(/\/add-reply$/)) { 176 return repositionToQuickReply($overlay); 177 } 178 179 if (requestUrl.match(/editor\/dialog/)) { 180 if (requestUrl.match(/dialog=code/)) { 181 setTimeout(function () { 182 let quickReplyPosition = 183 $(".js-quickReply").offset().top - 184 ($overlay.height() - $(".js-quickReply").height()) - 185 200; 186 return repositionOverlay($overlay, quickReplyPosition); 187 }, 50); 188 } 189 return repositionToQuickReply($overlay); 190 } 191 192 if ((regexResult = requestUrl.match(/posts\/(\d+)\/edit$/))) { 193 postId = regexResult[1]; 194 } 195 196 if ((regexResult = requestUrl.match(/posts\/(\d+)\/report$/))) { 197 let reportPosition = 198 $overlay.parent().prev().find("> .overlay").offset().top - 150; 199 return repositionOverlay($overlay, reportPosition); 200 } 201 202 if ((regexResult = requestUrl.match(/posts\/(\d+)\/add-comment$/))) { 203 let postPosition = 204 $(".js-commentsTarget-" + regexResult[1]).offset().top - 200; 205 return repositionOverlay($overlay, postPosition); 206 } 207 } else if (formAction) { 208 if (formAction.match(/login\/login/)) { 209 $( 210 ".block-container > .js-replyNewMessageContainer:has(article)" 211 ).addClass("wp-connect-expanded"); 212 213 let xfRedirect = $($overlay).find('input[name="_xfRedirect"]'); 214 215 let urlParams, wpData, wpPostRedirectUrl, wpPostRedirectQuery; 216 217 urlParams = new URLSearchParams(window.location.search); 218 wpData = JSON.parse(atob(urlParams.get("wp_data"))); 219 220 wpPostRedirectQuery = []; 221 222 if (wpData.open_comments) { 223 wpPostRedirectQuery.push(wpData.open_comments); 224 } 225 226 let page = window.location.href.match(/page-(\d+)/); 227 if (page) { 228 wpPostRedirectQuery.push("comments-page=" + page[1]); 229 } 230 231 wpPostRedirectQuery.push("add-reply=1"); 232 233 wpPostRedirectQuery = wpPostRedirectQuery.join("&"); 234 235 wpPostRedirectUrl = 236 wpData.url + 237 (wpData.url.indexOf("?") === -1 ? "?" : "&") + 238 wpPostRedirectQuery; 239 240 xfRedirect.val(wpPostRedirectUrl); 241 242 return repositionToBottom($overlay); 243 } 244 245 if (formAction.match(/inline-mod/)) { 246 return repositionToBottom($overlay); 247 } 248 249 if (formAction.match(/spam-cleaner/)) { 250 postId = spamPostId; 251 postPositionOffset = 300; 252 } 253 } 254 255 if (!postId) { 256 return; 257 } 258 259 let postPosition = $("#js-post-" + postId).offset().top; 260 let postHeight = $("#js-post-" + postId) 261 .find(".message-cell--main") 262 .height(); 263 return repositionOverlay( 264 $overlay, 265 postPosition + postHeight - postPositionOffset 266 ); 267 }); 268 269 $("body").on("overlay:hiding", ".overlay-container", function (overlay) {
270 var $overlay = $(overlay.target).find("> .overlay"); 271 272 var formAction = $overlay.find("form").attr("action"); 273 274 if (formAction) { 275 if (formAction.match(/login\/login/)) { 276 $( 277 ".block-container > .js-replyNewMessageContainer:has(article)" 278 ).removeClass("wp-connect-expanded"); 279 } 280 } 281 }); 282 283 function repositionOverlay($overlay, position) { 284 $overlay.css({ 285 position: "relative", 286 top: position + "px", 287 marginTop: "40px", 288 }); 289 } 290 291 function repositionToQuickReply($overlay) { 292 let quickReplyPosition = $(".js-quickReply").offset().top - 100; 293 return repositionOverlay($overlay, quickReplyPosition); 294 } 295 296 function repositionToBottom($overlay) { 297 let overlayPosition = $("body").height() - $overlay.height() - 100; 298 return repositionOverlay($overlay, overlayPosition); 299 } 300 301 $("body").on("click", ".actionBar-action--reply", function (e) { 302 let offset = $(".js-quickReply").offset(); 303 parentIFrame.sendMessage({ offset: offset.top }); 304 }); 305 306 $("body").on("click", ".actionBar-action--spam", function (e) { 307 // hack to reposition the spam cleaner modal based on ID as it's not exposed anywhere in the modal itself 308 spamPostId = $(e.target) 309 .parents(".js-post") 310 .attr("id") 311 .match(/js-post-(\d+)/)[1]; 312 }); 313 314 $("body").on( 315 "click", 316 '.message-attribution a:not([data-xf-click="quote"]):not(.wp-connect-feature)', 317 function (e) { 318 // let urlParams, wpData; 319 // urlParams = new URLSearchParams(window.location.search); 320 // wpData = JSON.parse(atob(urlParams.get('wp_data'))); 321 322 // console.log('framed navigate'); 323 parentIFrame.sendMessage({ navigate: $(this).attr("href") }); 324 325 return false; 326 } 327 ); 328 329 $(".pageNav a[href]").each((i, el) => { 330 enableIframeNavigation(el); 331 }); 332 $('.tabs-tab[href*="order="]') 333 .parent() 334 .find("a") 335 .each((i, el) => { 336 enableIframeNavigation(el); 337 }); 338 $(".bbCodeBlock-sourceJump").each((i, el) => { 339 $(el).data("content-selector", ""); 340 enableIframeNavigation(el); 341 }); 342 $('a[href^="javascript"]').each((i, el) => { 343 $(el).attr("target", "_self"); 344 }); 345 346 function enableIframeNavigation(el) { 347 $(el).click(function (e) { 348 if (!e.altKey && !e.metaKey && !e.shiftKey) { 349 $(this).attr("target", "_self"); 350 $(this).attr("href", appendIframeQueryString($(this).attr("href"))); 351 } 352 }); 353 } 354 355 function appendIframeQueryString(url) { 356 let sep = url.indexOf("?") === -1 ? "?" : "&"; 357 let wpData = ""; 358 try { 359 const urlParams = new URLSearchParams(window.location.search); 360 wpData = urlParams.get("wp_data"); 361 } catch (e) { 362 // console.log(e); 363 } 364 365 let urlParts = url.split("#"); 366 367 return ( 368 urlParts[0] + 369 sep + 370 "in_iframe=1&wp_data=" + 371 wpData + 372 (urlParts[1] ? "#" + urlParts[1] : "") 373 ); 374 } 375})(jQuery, window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.