1/** 2 * Advanced iframe functions v2026.3 3 */ 4/* jslint devel: true, unused: false */ 5/* globals ai_show_id_only:false, aiChangeUrl: false, aiResizeIframeHeightId: false, aiShowIframeId: false, findAndReplaceDOMText: false, aiShowDebug: false */ 6 7var aiEnableCookie = (typeof x === 'undefined') ? false : aiEnableCookie; 8var aiId = ''; 9var aiExtraSpace = (typeof aiExtraSpace === 'undefined') ? 0 : aiExtraSpace; 10var aiAccTime = 0; 11var aiRealFullscreen = (typeof aiRealFullscreen === 'undefined') ? false : aiRealFullscreen; 12var aiInFullscreen = false; 13var aiOnloadEventsCounter = 0; 14var aiOverflowHtml = jQuery('html').css('overflow') ?? 'visible'; 15var aiOverflowBody = jQuery('body').css('overflow') ?? 'visible'; 16 17var aiCallbackExists = typeof aiReadyCallbacks !== 'undefined' && aiReadyCallbacks instanceof Array; 18var aiReadyCallbacks = aiCallbackExists ? aiReadyCallbacks : []; 19 20/** 21 * The debug messages are enabled if you enable the debug console. 22 */ 23function aiDebugExtended(message) { 24 if (typeof aiShowDebug !== 'undefined' && aiShowDebug) { 25 if (console && console.log) { 26 console.log("Advanced iframe: " + message); 27 } 28 } 29} 30 31/** 32 * This function resizes the iframe after loading to the height 33 * of then content of the iframe. 34 * 35 * The extra space is not stored in the cookie! The height would 36 * be added every time otherwise and the iframe would grow, 37 */ 38function aiResizeIframe(obj, resizeWidth, resizeMinHeight) { 39 aiDebugExtended("aiResizeIframe"); 40 try { 41 if (obj.contentWindow.location.href === 'about:blank') { 42 return; 43 } 44 if (obj.contentWindow.document.body != null) { 45 var oldScrollPosition = jQuery(window).scrollTop(); 46 obj.style.marginTop = '0'; 47 obj.style.marginBottom = '0'; 48 obj.height = Number(resizeMinHeight); // set to 1 because otherwise the iframe does never get smaller. 49 obj.style.height = Number(resizeMinHeight) + 'px'; 50 var newHeight = aiGetIframeHeight(obj); 51 aiDebugExtended("aiResizeIframe - newHeight: " + newHeight); 52 obj.height = newHeight; 53 obj.style.height = newHeight + 'px'; 54 55 // set the height of the zoom div 56 const zoomDivjQuery = jQuery('#ai-zoom-div-' + obj.id); 57 if (zoomDivjQuery.length !== 0) { 58 var zoom = window['zoom_' + obj.id]; 59 zoomDivjQuery.css('height', newHeight * zoom); 60 } 61 62 if (aiEnableCookie && aiExtraSpace === 0) { 63 aiWriteCookie(newHeight); 64 } 65 var hash = aiGetIframeHash(obj.contentWindow.location.href); 66 if (hash !== '-1') { 67 var iframeId = '#' + obj.id; 68 try { 69 var hashPosition = jQuery(iframeId).contents().find('#' + hash); 70 if (hashPosition.length !== 0) { 71 var hashPositionTop = hashPosition.offset().top; 72 oldScrollPosition = Math.round(jQuery(iframeId).offset().top + hashPositionTop); 73 } 74 } catch (e) { 75 // in case of an invalid hash it is ignored. 76 } 77 } 78 setTimeout(function () { 79 jQuery("html,body").scrollTop(oldScrollPosition); 80 }, 50); 81 82 if (resizeWidth === 'true') { 83 var newWidth = aiGetIframeWidth(obj); 84 obj.width = newWidth; 85 obj.style.width = newWidth + 'px'; 86 } 87 var fCallback = window['resizeCallback' + obj.id]; 88 fCallback(); 89 // fires the onload event again if iframes are wrapped 90 if (window.frameElement != null) { 91 parent.jQuery('iframe').trigger('onload'); 92 } 93 aiHandleAnchorLinkScrolling(obj.id); 94 } else { 95 // body is not loaded yet - we wait 100 ms. 96 setTimeout(function () { 97 aiResizeIframe(obj, resizeWidth); 98 }, 100); 99 } 100 } catch (e) { 101 if (console && console.error) { 102 console.error( 103 'Advanced iframe configuration error: You have enabled the resize of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); 104 console.log(e); 105 } 106 } 107} 108 109function aiHandleAnchorLinkScrolling(iframeId) { 110 var iframejQuery = jQuery('#' + iframeId); 111 var posIframeTop = iframejQuery.offset().top; 112 113 iframejQuery.contents().find('body').on('click', "a[href^='#']", function () { 114 var anchorId = jQuery(this).attr('href'); 115 var anchorElem = jQuery('#' + iframeId).contents().find(anchorId); 116 117 if (anchorElem.length !== 0) { 118 var anchorPositionTop = anchorElem.offset().top; 119 var totalPosition = Math.round(posIframeTop + anchorPositionTop + 2); 120 jQuery("html,body").scrollTop(totalPosition); 121 } 122 }); 123} 124 125/** 126 * returns the position of a #hash in the iframe or -1 if none was found. 127 */ 128 129function aiGetIframeHash(url) { 130 var hash = url.split('#')[1]; 131 return (hash) ? hash : '-1'; 132} 133 134/** 135 * Get the iframe height 136 */ 137function aiGetIframeHeight(obj) { 138 var bodyHeight = Math.max(obj.contentWindow.document.body.scrollHeight, 139 obj.contentWindow.document.body.offsetHeight, 140 obj.contentWindow.document.documentElement.scrollHeight, 141 obj.contentWindow.document.documentElement.offsetHeight); 142 return bodyHeight + aiExtraSpace; 143} 144 145/** 146 * Get the iframe width 147 */ 148function aiGetIframeWidth(obj) { 149 var oldWidth = obj.width; 150 obj.width = 1; // set to 1 because otherwise I don't get the minimum width 151 obj.style.width = '1px'; 152 var bodyWidth = Math.max(obj.contentWindow.document.body.scrollWidth, 153 obj.contentWindow.document.body.offsetWidth, 154 obj.contentWindow.document.documentElement.scrollWidth, 155 obj.contentWindow.document.documentElement.offsetWidth);
156 if (bodyWidth !== 1) { // avoid that fully responsive sites do not get displayed at all. 157 obj.width = bodyWidth; 158 obj.style.width = bodyWidth + 'px'; 159 } else { 160 obj.width = oldWidth; 161 obj.style.width = oldWidth + 'px'; 162 } 163 return bodyWidth; 164} 165 166/** 167 * Get the current width of the iframe inside the parent. 168 */ 169function aiGetParentIframeWidth(obj) { 170 if (obj != null) { 171 const iframejQuery = jQuery('#' + obj.id); 172 if (iframejQuery.length !== 0) { 173 return iframejQuery.width(); 174 } 175 return -1; 176 } 177} 178 179/** 180 * Resizes an iframe to a given height. 181 * this is used for xss enabled iframes. 182 * Please read the documentation! 183 */ 184function aiResizeIframeHeightById(id, nHeight) { 185 aiDebugExtended("aiResizeIframeHeightById - id: " + id + ", nHeight: " + nHeight); 186 try { 187 var fCallback = window['resizeCallback' + id]; 188 fCallback(); 189 var height = parseInt(nHeight, 10) + aiExtraSpace; 190 var iframe = document.getElementById(id); 191 if (iframe === null) { 192 if (console && console.error) { 193 console.error('Advanced iframe configuration error: The iframe to resize could not be found. The id of the iframe and the one defined for ai_external.js (' + id 194 + ') are most likely different! Check your settings.'); 195 return; 196 } 197 } 198 var oldScrollposition = jQuery(document).scrollTop(); 199 iframe.height = height; 200 iframe.style.height = height + 'px'; 201 jQuery("html,body").scrollTop(oldScrollposition); 202 if (aiEnableCookie && aiExtraSpace === 0) { 203 aiWriteCookie(height); 204 } 205 // send the new height to the parent if it is a wrapped call 206 var parentResizeCall = window['aiExecuteWorkaround_' + id]; 207 if (parentResizeCall != null) { 208 parentResizeCall(); 209 } 210 } catch (e) { 211 if (console && console.error) { 212 console.error('Advanced iframe configuration error: The id of the parent and the external workaround are different! Check your settings.'); 213 console.log(e); 214 } 215 } 216} 217 218/** 219 * Scrolls the parent window to the top. 220 * This is e.g. wanted when you have a link in the iframe and you want that the 221 * page starts at the top and not that only the iframe changes. 222 * 223 * Sometimes are 2 onload events after another. To prevent that this causes 224 * a jump to the top a delay of 1 sec is used for the increase of the counter. 225 */ 226function aiScrollToTop(id, position) { 227 aiDebugExtended("aiScrollToTop - id: " + id + ", position: " + position); 228 229 if (aiOnloadEventsCounter > 0) { 230 var posTop = 0; 231 if (position === 'iframe') { 232 posTop = jQuery('#' + id).offset().top; 233 } 234 setTimeout(function () { 235 aiDebugExtended("aiScrollToTop - posTop: " + posTop); 236 window.scrollTo(0, posTop); 237 }, 100); 238 } 239 setTimeout(function () { 240 aiOnloadEventsCounter++; 241 }, 1000); 242} 243 244/** 245 * Writes the last height to the cookie. 246 */ 247function aiWriteCookie(height) { 248 var cookieName = 'ai-last-height'; 249 if (aiId !== '') { 250 cookieName = cookieName + '-' + aiId; 251 } 252 document.cookie = cookieName + '=' + height; 253} 254 255/** 256 * Reads the cookie and preset the height of the iframe 257 */ 258function aiUseCookie() { 259 var cookieName = 'ai-last-height'; 260 if (aiId !== '') { 261 cookieName = cookieName + '-' + aiId; 262 } 263 var allcookies = document.cookie; 264 // Get all the cookies pairs in an array 265 var cookiearray = allcookies.split(';'); 266 // Now take key value pair out of this array 267 for (var i = 0; i < cookiearray.length; i++) { 268 var name = cookiearray[i].split('=')[0]; 269 var value = cookiearray[i].split('=')[1]; 270 // cookie does exist and has a numeric value 271 if (name === cookieName && value !== null && aiIsNumeric(value)) { 272 var iframe = document.getElementById(aiId); 273 iframe.height = parseInt(value, 10); 274 iframe.style.height = value + 'px'; 275 } 276 } 277} 278 279/** 280 * check if we have a numeric input 281 */ 282function aiIsNumeric(input) { 283 return !isNaN(input); 284} 285 286/** 287 * Disable the additional_height input field 288 */ 289function aiDisableHeight() { 290 jQuery('#additional_height').attr('readonly', 'readonly') 291 .val('0'); 292} 293 294/** 295 * Enable the additional_height input field 296 */ 297function aiEnableHeight() { 298 jQuery('#additional_height').removeAttr('readonly'); 299} 300 301/** 302 * Removes all elements from an iframe except the given one 303 * 304 * @param iframeId id of the iframe 305 * @param showElement the id, class (jQuery syntax) of the element that should be displayed. 306 */ 307function aiShowElementOnly(iframeId, showElement) { 308 aiDebugExtended("aiShowElementOnly"); 309 try { 310 var iframe = jQuery(iframeId).contents().find('body'); 311 var selectedBox = iframe.find(showElement).clone(true, true); 312 iframe.find('*').not(jQuery('script')).remove();
313 iframe.prepend(selectedBox); 314 } catch (e) { 315 if (console && console.error) { 316 console.error( 317 'Advanced iframe configuration error: You have enabled to show only one element of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); 318 console.log(e); 319 } 320 } 321} 322 323function aiCheckIfValidTarget(evt, elements) { 324 var targ; 325 if (!evt) { 326 evt = window.event; 327 } 328 if (evt.target) { 329 targ = evt.target; 330 } else if (evt.srcElement) { 331 targ = evt.srcElement; 332 } 333 if (targ.nodeType === 3) { 334 targ = targ.parentNode; 335 } 336 337 var parts = elements.split(','); 338 // check each part if we have a match... 339 for (var i = 0; i < parts.length; ++i) { 340 var selectorArray = parts[i].split(':'); 341 if (selectorArray[0].toLowerCase() === targ.nodeName.toLowerCase()) { 342 if (selectorArray.length > 1) { 343 if (targ.id.toLowerCase().indexOf(selectorArray[1].toLowerCase()) !== -1) { 344 return true; 345 } 346 } else { 347 return true; 348 } 349 } 350 } 351 return false; 352} 353 354function aiOpenSelectorWindow(url) { 355 aiDebugExtended("aiOpenSelectorWindow"); 356 var localWidth = jQuery('#width').val(); 357 var localHeight = jQuery('#ai-height-0').val(); 358 359 if (localWidth.indexOf('%') >= 0 || Number(localWidth) < 900) { 360 localWidth = 900; 361 } 362 localWidth = Number(localWidth) + 40; 363 if (localWidth > (screen.width)) { 364 localWidth = screen.width; 365 } 366 if (localHeight.indexOf('%') >= 0) { 367 localHeight = screen.height; 368 } else { 369 localHeight = Number(localHeight) + 480; 370 } 371 if (localHeight > (screen.height - 50)) { 372 localHeight = screen.height - 50; 373 } 374 var options = 'width=' + localWidth + ',height=' + localHeight + ',left=0,top=0,resizable=1,scrollbars=1'; 375 var popup_window = window.open(url, '', options); 376 popup_window.focus(); 377} 378 379function aiDisableAiResizeOptions(value) { 380 jQuery('#onload_resize_delay').prop('readonly', value); 381 jQuery('input[id=store_height_in_cookie1]:radio, input[id=store_height_in_cookie2]:radio').attr('disabled', value); 382 jQuery('#additional_height').prop('readonly', value); 383 jQuery('input[id=onload_resize_width1]:radio, input[id=onload_resize_width2]:radio').attr('disabled', value); 384 jQuery('#resize_on_click').prop('readonly', value); 385 jQuery('#resize_on_click_elements').prop('readonly', value); 386 jQuery('#resize_on_ajax').prop('readonly', value); 387 jQuery('input[id=resize_on_ajax_jquery1]:radio, input[id=resize_on_ajax_jquery2]:radio').attr('disabled', value); 388 389 var selector = '#onload_resize_delay, #store_height_in_cookie1, #additional_height, #onload_resize_width1, '; 390 selector += '#resize_on_click, #resize_on_click_elements, #resize_on_ajax, #resize_on_ajax_jquery1'; 391 aiDisableTextSection(value, selector); 392} 393 394function aiDisablePartOfIframeOptions(value) { 395 jQuery('#show_part_of_iframe_x').prop('readonly', value); 396 jQuery('#show_part_of_iframe_y').prop('readonly', value); 397 jQuery('#show_part_of_iframe_height').prop('readonly', value); 398 jQuery('#show_part_of_iframe_width').prop('readonly', value); 399 jQuery('input[id=show_part_of_iframe_allow_scrollbar_horizontal1]:radio, input[id=show_part_of_iframe_allow_scrollbar_horizontal2]:radio').attr('disabled', value); 400 jQuery('input[id=show_part_of_iframe_allow_scrollbar_vertical1]:radio, input[id=show_part_of_iframe_allow_scrollbar_vertical2]:radio').attr('disabled', value); 401 jQuery('#show_part_of_iframe_next_viewports').prop('readonly', value); 402 jQuery('input[id=show_part_of_iframe_next_viewports_loop1]:radio, input[id=show_part_of_iframe_next_viewports_loop2]:radio').attr('disabled', value); 403 jQuery('#show_part_of_iframe_new_window').prop('readonly', value); 404 jQuery('#show_part_of_iframe_new_url').prop('readonly', value); 405 jQuery('input[id=show_part_of_iframe_next_viewports_hide1]:radio, input[id=show_part_of_iframe_next_viewports_hide2]:radio').attr('disabled', value); 406 jQuery('#show_part_of_iframe_style').prop('readonly', value); 407 jQuery('input[id=show_part_of_iframe_zoom1]:radio, input[id=show_part_of_iframe_zoom2]:radio, input[id=show_part_of_iframe_zoom3]:radio').attr('disabled', value); 408 jQuery('.media-query-input').prop('readonly', value); 409 410 var selector = '#show_part_of_iframe_x, #show_part_of_iframe_y, #show_part_of_iframe_height, #show_part_of_iframe_width, '; 411 selector += '#show_part_of_iframe_allow_scrollbar_horizontal1, #show_part_of_iframe_next_viewports, #show_part_of_iframe_next_viewports_loop1, '; 412 selector += '#show_part_of_iframe_new_window, #show_part_of_iframe_new_url, #show_part_of_iframe_next_viewports_hide1, #show_part_of_iframe_style, '; 413 selector += '#show_part_of_iframe_zoom1, #show_part_of_iframe_allow_scrollbar_vertical1, #add-media-query-show_part_of_iframe_media_query'; 414 aiDisableTextSection(value, selector); 415 416 if (value) { 417 jQuery('#add-media-query-show_part_of_iframe_media_query').hide(); 418 jQuery('.ai-delete').hide(); 419 } else { 420 jQuery('#add-media-query-show_part_of_iframe_media_query').show(); 421 jQuery('.ai-delete').show(); 422 } 423 424} 425 426function aiDisableLazyLoadOptions(value) { 427 jQuery('#enable_lazy_load_threshold').prop('readonly', value); 428 jQuery('#enable_lazy_load_fadetime').prop('readonly', value); 429 jQuery('input[id=enable_lazy_load_reserve_space1]:radio, input[id=enable_lazy_load_reserve_space2]:radio').attr('disabled', value); 430 jQuery('input[id=enable_lazy_load_manual1]:radio, input[id=enable_lazy_load_manual2]:radio, input[id=enable_lazy_load_manual3]:radio').attr('disabled', value); 431 432 var selector = '#enable_lazy_load_threshold, #enable_lazy_load_fadetime, #enable_lazy_load_reserve_space1, #enable_lazy_load_manual1'; 433 aiDisableTextSection(value, selector); 434} 435 436function aiDisableIframeAsLayerOptions(value) { 437 jQuery('input[id=show_iframe_as_layer_full]:radio').attr('disabled', value); 438 jQuery('#show_iframe_as_layer_header_file').prop('readonly', value); 439 jQuery('#show_iframe_as_layer_header_height').prop('readonly', value); 440 jQuery('#show_iframe_as_layer_autoclick_delay').prop('readonly', value); 441 jQuery('#show_iframe_as_layer_autoclick_hide_time').prop('readonly', value); 442 jQuery('input[id=show_iframe_as_layer_header_position1]:radio, input[id=show_iframe_as_layer_header_position2]:radio').attr('disabled', value); 443 jQuery('input[id=show_iframe_as_layer_full1]:radio, input[id=show_iframe_as_layer_full2]:radio, input[id=show_iframe_as_layer_full3]:radio').attr('disabled', value); 444 jQuery('input[id=show_iframe_as_layer_keep_content1]:radio, input[id=show_iframe_as_layer_keep_content2]:radio').attr('disabled', value); 445 446 var selector = '#show_iframe_as_layer_full, #show_iframe_as_layer_header_file, #show_iframe_as_layer_header_height, '; 447 selector += '#show_iframe_as_layer_header_position1, #show_iframe_as_layer_full1, #show_iframe_as_layer_keep_content1, '; 448 selector += '#show_iframe_as_layer_autoclick_delay, #show_iframe_as_layer_autoclick_hide_time'; 449 450 aiDisableTextSection(value, selector); 451 452} 453 454function aiDisableAddParamOptions(value) { 455 jQuery('input[id=add_iframe_url_as_param_direct1]:radio, input[id=add_iframe_url_as_param_direct2]:radio').attr('disabled', value); 456 jQuery('#add_iframe_url_as_param_prefix').prop('readonly', value); 457 var selector = '#add_iframe_url_as_param_prefix, #add_iframe_url_as_param_direct1'; 458 aiDisableTextSection(value, selector); 459} 460 461function aiDisableTextSection(value, selector) { 462 if (value) { 463 jQuery(selector).closest('tr').addClass('disabled'); 464 } else { 465 jQuery(selector).closest('tr').removeClass('disabled'); 466 } 467} 468 469var aiInstance; 470 471/** 472 * This function initializes all checks that are done by Javascript 473 * on the admin page like enabling disabling fields... 474 */ 475function aiInitAdminConfiguration(isPro, acc_type) { 476 // enable checkbox of onload_resize_delay and if resize is set to true external workaround is set to false 477 if (jQuery('input[type=radio][name=onload_resize]:checked').val() === 'false') { 478 aiDisableAiResizeOptions(true); 479 } 480 jQuery('input[type=radio][name=onload_resize]').click(function () { 481 if (jQuery(this).val() === 'true') {
482 jQuery('input:radio[name=enable_external_height_workaround]')[1].checked = true; // set to external! 483 aiDisableAiResizeOptions(false); 484 } else { 485 jQuery('#onload_resize_delay').val(''); 486 aiDisableAiResizeOptions(true); 487 488 } 489 }); 490 491 // if external workaround is set to to true resize on load is set to false and the 492 // onload_resize_delay is made readonly 493 jQuery('input[type=radio][name=enable_external_height_workaround]').click(function () { 494 if (jQuery(this).val() === 'true') { 495 jQuery('input:radio[name=onload_resize]')[1].checked = true; 496 jQuery('#onload_resize_delay').val(''); 497 aiDisableAiResizeOptions(true); 498 } 499 }); 500 501 // Show only a part of the iframe enable/disable 502 if (jQuery('input[type=radio][name=show_part_of_iframe]:checked').val() === 'false') { 503 aiDisablePartOfIframeOptions(true); 504 } 505 jQuery('input[type=radio][name=show_part_of_iframe]').click(function () { 506 if (jQuery(this).val() === 'false') { 507 aiDisablePartOfIframeOptions(true); 508 } else { 509 aiDisablePartOfIframeOptions(false); 510 } 511 }); 512 513 // show_iframe_as_layer enable/disable 514 if (jQuery('input[type=radio][name=show_iframe_as_layer]:checked').val() === 'false') { 515 aiDisableIframeAsLayerOptions(true); 516 } 517 jQuery('input[type=radio][name=show_iframe_as_layer]').click(function () { 518 if (jQuery(this).val() === 'false') { 519 aiDisableIframeAsLayerOptions(true); 520 } else { 521 aiDisableIframeAsLayerOptions(false); 522 } 523 }); 524 525 // if expert mode 526 if (jQuery('input[type=radio][name=expert_mode]:checked').val() === 'true') { 527 jQuery('.description').css('display', 'none'); 528 jQuery('table.form-table th').css('cursor', 'pointer') 529 .css('padding-top', '8px') 530 .css('padding-bottom', '2px') 531 .click(function () { 532 jQuery('.description').css('display', 'none'); 533 jQuery('.description', jQuery(this).parent()).css('display', 'block'); 534 }); 535 jQuery('table.form-table td').css('padding-top', '5px').css('padding-bottom', '5px'); 536 } 537 jQuery('input[type=radio][name=expert_mode]').click(function () { 538 if (jQuery(this).val() === 'false') { 539 jQuery('.description').css('display', 'block'); 540 jQuery('table.form-table th').css('cursor', 'auto') 541 .css('padding-top', '20px') 542 .css('padding-bottom', '20px') 543 .off('click'); 544 jQuery('table.form-table td').css('padding-top', '15px').css('padding-bottom', '15px'); 545 } else { 546 jQuery('.description').css('display', 'none'); 547 jQuery('table.form-table th').css('cursor', 'pointer') 548 .css('padding-top', '8px') 549 .css('padding-bottom', '2px') 550 .click(function () { 551 jQuery('.description').css('display', 'none'); 552 jQuery('.description', jQuery(this).parent()).css('display', 'block'); 553 }); 554 jQuery('table.form-table td').css('padding-top', '5px').css('padding-bottom', '5px'); 555 } 556 }); 557 558 const accordionjQuery = jQuery('#accordion'); 559 accordionjQuery.find('h1').click(function () { 560 jQuery(this).next().slideToggle(aiAccTime); 561 }).next().hide(); 562 563 accordionjQuery.find('a').click(function () { 564 var hash = jQuery(this).prop('hash'); 565 var hash_only = '#h1-' + hash.substring(1); 566 jQuery(hash_only).next().show(); 567 location.hash = hash_only; 568 }); 569 570 // lazy load 571 if (jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val() === 'false') { 572 jQuery('#enable_lazy_load_manual_element').prop('readonly', true); 573 } 574 575 jQuery('input[type=radio][name=enable_lazy_load_manual]').click(function () { 576 if (jQuery(this).val() === 'false' || jQuery(this).val() === 'auto') { 577 jQuery('#enable_lazy_load_manual_element').prop('readonly', true); 578 } else { 579 jQuery('#enable_lazy_load_manual_element').prop('readonly', false); 580 } 581 }); 582 583 // add_iframe_url_as_param 584 if (jQuery('input[type=radio][name=add_iframe_url_as_param]:checked').val() === 'false') { 585 aiDisableAddParamOptions(true); 586 } 587 jQuery('input[type=radio][name=add_iframe_url_as_param]').click(function () { 588 aiDisableAddParamOptions(jQuery(this).val() === 'false'); 589 }); 590 591 if (jQuery('input[type=radio][name=enable_lazy_load]:checked').val() === 'false') { 592 aiDisableLazyLoadOptions(true); 593 jQuery('#enable_lazy_load_manual_element').prop('readonly', true); 594 } 595 596 jQuery('input[type=radio][name=enable_lazy_load]').click(function () { 597 if (jQuery(this).val() === 'false') { 598 aiDisableLazyLoadOptions(true); 599 jQuery('#enable_lazy_load_manual_element').prop('readonly', true); 600 } else { 601 aiDisableLazyLoadOptions(false); 602 const valueLazyLoad = jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val(); 603 if (valueLazyLoad === 'false' || valueLazyLoad === 'auto') { 604 jQuery('#enable_lazy_load_manual_element').prop('readonly', true); 605 } else { 606 jQuery('#enable_lazy_load_manual_element').prop('readonly', false); 607 } 608 } 609 }); 610 611 jQuery('.confirmation').on('click', function () { 612 return confirm('Are you sure? Selecting OK will set all settings to the default.'); 613 }); 614 615 jQuery('.confirmation-file').on('click', function () { 616 return confirm('Do you really want to delete the file?'); 617 }); 618 619 jQuery('.confirmation-hash').on('click', function () { 620 return confirm('Do you really want to delete the hash/URL cache?'); 621 }); 622 623 jQuery('a.post').click(function (e) { 624 e.stopPropagation(); 625 e.preventDefault(); 626 var href = this.href; 627 var parts = href.split('?'); 628 var url = parts[0]; 629 var params = parts[1].split('&'); 630 var pp, inputs = ''; 631 url += '?' + params[0]; 632 for (var i = 1, n = params.length; i < n; i++) {
633 pp = params[i].split('='); 634 inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />'; 635 } 636 // Add twg-options nonce 637 var nonceValue = jQuery('#twg-options').val(); 638 inputs += '<input type="hidden" name="twg-options" value="' + nonceValue + '" />'; 639 640 jQuery('body').append('<form action="' + url + '" method="post" id="poster">' + inputs + '</form>'); 641 jQuery('#poster').submit(); 642 }); 643 644 jQuery('.ai-input-search').keyup(function () { 645 var searchTerm = jQuery('input.ai-input-search').val().toLowerCase(); 646 aiSettingsSearch(searchTerm, acc_type); 647 }) 648 .on('click', function () { 649 setTimeout(function () { 650 var searchTerm = jQuery('input.ai-input-search').val().toLowerCase(); 651 aiSettingsSearch(searchTerm, acc_type); 652 }, 100); 653 }); 654 655 jQuery(document).on('click', '.nav-tab-wrapper a', function () { 656 var current_tab = jQuery(this).attr('id'); 657 jQuery('section').hide(); 658 jQuery('section.' + current_tab).show(); 659 jQuery('#current_tab').val(current_tab.substr(4, 1)); 660 localStorage.setItem('ai_current_tab', current_tab.substr(4, 1)); 661 jQuery('.nav-tab').removeClass('nav-tab-active'); 662 jQuery(this).addClass('nav-tab-active'); 663 jQuery(this).blur(); 664 665 return false; 666 }); 667 668 // set the links between tabs and open the right one at the right section. 669 jQuery(document).on('click', 'a#external-workaround-link', function () { 670 jQuery('.external-workaround').click(); 671 location.hash = 'tab_3'; 672 // no flash 673 aiShowHeader('tab_3'); 674 return false; 675 }); 676 jQuery(document).on('click', 'a#resize-same-link', function () { 677 jQuery('.advanced-settings-tab').click(); 678 jQuery('#id-advanced-resize').removeClass('closed'); 679 location.hash = 'id-advanced-resize'; 680 // no flash 681 aiShowHeader('id-advanced-resize'); 682 return false; 683 }); 684 jQuery(document).on('click', 'a.jquery-help-link', function () { 685 jQuery('.help-tab').click(); 686 jQuery('#id-help-jquery').removeClass('closed'); 687 jQuery('#jquery-help').show(); 688 location.hash = 'id-help-jquery'; 689 // no flash 690 aiShowHeader('id-help-jquery'); 691 return false; 692 }); 693 jQuery(document).on('click', 'a#browser-detection-link', function () { 694 jQuery('.help-tab').click(); 695 jQuery('#id-help-browser').removeClass('closed'); 696 jQuery('#browser-help').show(); 697 location.hash = 'id-help-browser'; 698 // no flash 699 aiShowHeader('id-help-browser'); 700 return false; 701 }); 702 jQuery(document).on('click', 'a.howto-id-link', function () { 703 jQuery('.help-tab').click(); 704 jQuery('#id-help-id').removeClass('closed'); 705 location.hash = 'id-help-id'; 706 // no flash 707 aiShowHeader('id-help-id'); 708 return false; 709 }); 710 jQuery(document).on('click', '.modifycontent-link', function () { 711 jQuery('.advanced-settings-tab').click(); 712 jQuery('#id-advanced-modify-iframe').removeClass('closed'); 713 location.hash = 'id-advanced-modify-iframe'; 714 aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); 715 return false; 716 }); 717 718 jQuery(document).on('click', '.id-modify-css-iframe-link', function () { 719 jQuery('.advanced-settings-tab').click(); 720 jQuery('#id-advanced-modify-iframe').removeClass('closed'); 721 location.hash = 'id-modify-css-iframe'; 722 aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); 723 return false; 724 }); 725 726 jQuery(document).on('click', '.modify-target', function () { 727 jQuery('.advanced-settings-tab').click(); 728 jQuery('#id-advanced-modify-iframe').removeClass('closed'); 729 location.hash = 'id-modify-target'; 730 aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); 731 return false; 732 }); 733 734 jQuery(document).on('click', 'a.link-external-domain', function () { 735 jQuery('#id-external-different').removeClass('closed'); 736 location.hash = '#id-external-different'; 737 // no flash - 'id-external-different' 738 aiShowHeader('id-external-different'); 739 return false; 740 }); 741 jQuery(document).on('click', 'a.link-id-external-ai-config-post', function () { 742 jQuery('#id-external-ai-config-post').removeClass('closed'); 743 location.hash = '#id-external-ai-config-post'; 744 aiShowHeader('id-external-ai-config-post', 'tr-use_post_message'); 745 return false; 746 }); 747 jQuery(document).on('click', 'a.link-id-external-ai-overview', function () { 748 jQuery('#id-external-ai-overview').removeClass('closed'); 749 location.hash = '#id-external-ai-overview'; 750 aiShowHeader('id-external-ai-overview', 'id-external-ai-overview'); 751 return false; 752 }); 753 jQuery(document).on('click', 'a.post-message-help-link', function () { 754 jQuery('.help-tab').click(); 755 jQuery('#id-help-communication').removeClass('closed'); 756 location.hash = '#id-help-communication'; 757 aiShowHeader('id-help-communication', 'id-help-communication'); 758 return false; 759 }); 760 761 jQuery(document).on('click', 'a.enable-admin', function () { 762 jQuery('.options-tab').click(); 763 jQuery('#id-options-display').removeClass('closed'); 764 location.hash = '#id-options-display'; 765 aiShowHeader('id-options-display', 'tr-demo'); 766 return false; 767 }); 768 769 jQuery(document).on('click', 'a.enter-registration', function () { 770 jQuery('.options-tab').click(); 771 jQuery('#id-options-registration').removeClass('closed'); 772 location.hash = '#id-options-registration'; 773 aiShowHeader('id-options-registration', 'tr-demo'); 774 return false; 775 }); 776 777 jQuery(document).on('click', 'a.enter-pro', function () { 778 jQuery('.options-tab').click(); 779 jQuery('#id-options-pro').removeClass('closed'); 780 location.hash = '#id-options-pro'; 781 aiShowHeader('id-options-pro', 'first'); 782 return false; 783 }); 784 785 jQuery(document).on('click', 'a#user-help-link', function () { 786 jQuery('#user-help').css('display', 'block'); 787 return false; 788 }); 789 jQuery(document).on('click', 'a#user-meta-link', function () { 790 jQuery('#meta-help').css('display', 'block'); 791 return false; 792 }); 793 794 jQuery(document).on('click', '#ai-selector-help-link', function () { 795 jQuery('#ai-selector-help').slideDown(1000); 796 return false; 797 }); 798 799 jQuery(document).on('click', '.ai-selector-help-link-move', function () { 800 jQuery('#ai-selector-help').show('slow'); 801 location.hash = '#ai-selector-help-link'; 802 // no flash 803 aiShowHeader('ai-selector-help-link'); 804 return false; 805 }); 806 807 jQuery('#ai_form').submit(function () { 808 aiSetScrollposition(); 809 }); 810 811 // Close postboxes that should be closed. 812 jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 813 // Postboxes setup. 814 if (typeof postboxes !== 'undefined') { 815 postboxes.add_postbox_toggles('toplevel_page_advanced-iframe'); 816 } 817 818 jQuery('.ai-spinner').css('display', 'none'); 819 jQuery("#" + acc_type).next().show(); 820 821 jQuery(document).on('click', '#test-pro-admin.is-permanent-closable button', function () { 822 closeInfoPermanent('test-pro-admin'); 823 }); 824 825 jQuery(document).on('click', '#show-registration-message.is-permanent-closable button', function () { 826 closeInfoPermanent('show-registration-message'); 827 }); 828 829 jQuery(document).on('click', '#show-version-message.is-permanent-closable button', function () { 830 closeInfoPermanent('show-version-message'); 831 }); 832 833 jQuery(document).on('click', '#show-ai-assistant-message.is-permanent-closable button', function () { 834 closeInfoPermanent('show-ai-assistant-message'); 835 }); 836 837 jQuery(document).on('click', '.mq-breakpoint-height a', function (evt) { 838 jQuery(this).parent().remove(); 839 aiUpdateHeightHiddenField('height'); 840 evt.preventDefault(); 841 return false; 842 }); 843 844 jQuery(document).on('click', 'a#add-media-query-height', function (evt) { 845 // count existing elements 846 var nextNr = jQuery(".mq-breakpoint-height").length + 1; 847 jQuery(this).parent().append('<div id="breakpoint-row-height-' + nextNr + '" class="mq-breakpoint-height">' + 848 '<input type="text" id="ai-height-' + nextNr 849 + '" style="width:150px;margin-top:5px;" onblur="aiCheckHeightNumber(this, \'height\');" placeholder="Insert height"/>
849Breakpoint: ' 850 + 851 '<input type="text" id="ai-breakpoint-height-' + nextNr 852 + '" style="width:130px;" onblur="aiCheckHeightNumber(this, \'height\');" placeholder="Insert breakpoint"/>' + 853 '<a id="delete-media-query-' + nextNr + '" href="#" class="delete ai-delete">Delete</a>'); 854 evt.preventDefault(); 855 return false; 856 }); 857 858 jQuery(document).on('click', '.mq-breakpoint-show_part_of_iframe_media_query a', function (evt) { 859 jQuery(this).parent().remove(); 860 aiUpdateHeightHiddenFieldMediaQuery('show_part_of_iframe_media_query'); 861 evt.preventDefault(); 862 return false; 863 }); 864 865 jQuery(document).on('click', 'a#add-media-query-show_part_of_iframe_media_query', function (evt) { 866 // count existing elements 867 var nextNr = jQuery(".mq-breakpoint-show_part_of_iframe_media_query").length + 1; 868 jQuery(this).parent().append('<div id="breakpoint-row-show_part_of_iframe_media_query-' + nextNr 869 + '" class="mq-breakpoint-show_part_of_iframe_media_query">' + 870 'x: <input type="text" id="ai-x-show_part_of_iframe_media_query-' + nextNr + '" class="media-query-input" ' + 871 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="x"/>' + 872 ' y: <input type="text" id="ai-y-show_part_of_iframe_media_query-' + nextNr + '" class="media-query-input" ' 873 + 874 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="y"/>' + 875 ' w: <input type="text" id="ai-w-show_part_of_iframe_media_query-' + nextNr + '" class="media-query-input" ' 876 + 877 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="width"/>' + 878 ' h: <input type="text" id="ai-h-show_part_of_iframe_media_query-' + nextNr + '" class="media-query-input" ' 879 + 880 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="height"/>' + 881 ' iframe width: <input type="text" id="ai-i-show_part_of_iframe_media_query-' + nextNr 882 + '" class="media-query-input" style="width:100px;" ' + 883 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="iframe width"/>' 884 + 885 ' Breakpoint: <input type="text" id="ai-breakpoint-show_part_of_iframe_media_query-' + nextNr 886 + '" class="media-query-input" style="width:130px;" ' + 887 ' onblur="aiCheckHeightNumberMediaQuery(this, \'show_part_of_iframe_media_query\');" placeholder="Insert breakpoint"/>' 888 + 889 '<a id="delete-media-query-show_part_of_iframe_media_query-' + nextNr 890 + '" href="#" class="delete ai-delete">Delete</a>'); 891 evt.preventDefault(); 892 return false; 893 }); 894} 895 896function aiCheckHeightNumber(element, id) { 897 aiCheckInputNumber(element); 898 aiUpdateHeightHiddenField(id); 899} 900 901function aiCheckHeightNumberMediaQuery(element, id) { 902 aiCheckInputNumber(element); 903 aiUpdateHeightHiddenFieldMediaQuery(id); 904} 905 906function aiUpdateHeightHiddenField(id) { 907 var heightDefault = jQuery('#ai-' + id + '-0').val(); 908 var breakpoints = []; 909 jQuery('.mq-breakpoint-' + id).each(function () { 910 911 var heightChild = jQuery(this).children().eq(0).val(); 912 var breakpointChild = jQuery(this).children().eq(1).val(); 913 914 if (heightChild !== '' && breakpointChild !== '') { 915 breakpoints.push({ 916 heightChild: heightChild, 917 breakpointChild: breakpointChild 918 }); 919 } 920 }); 921 922 // we sort to have higher breakpoints first. Because of css cascading styles order is important 923 breakpoints.sort(function (a, b) { 924 return b.breakpointChild - a.breakpointChild; 925 }); 926 927 let output = heightDefault; 928 breakpoints.forEach(function (element) { 929 output += ',' + element.heightChild + '|' + element.breakpointChild; 930 }); 931 jQuery('#' + id).val(output); 932 const descriptionjQuery = jQuery('#description-' + id); 933 const newVal = descriptionjQuery.html().split('Shortcode attribute: ')[0]; 934 descriptionjQuery.html(newVal + 'Shortcode attribute: ' + id + '="' + output + '"'); 935} 936 937function aiUpdateHeightHiddenFieldMediaQuery(id) { 938 var breakpoints = []; 939 jQuery('.mq-breakpoint-' + id).each(function () { 940 941 var mediaX = jQuery(this).children().eq(0).val(); 942 var mediaY = jQuery(this).children().eq(1).val(); 943 var mediaW = jQuery(this).children().eq(2).val(); 944 var mediaH = jQuery(this).children().eq(3).val(); 945 var mediaIW = jQuery(this).children().eq(4).val(); 946 var breakpointChild = jQuery(this).children().eq(5).val(); 947 948 if ((mediaX !== '' || mediaY !== '' || mediaW !== '' || mediaH !== '' || mediaIW !== '') && 949 breakpointChild !== '') { 950 breakpoints.push({ 951 mediaX: mediaX, 952 mediaY: mediaY, 953 mediaW: mediaW, 954 mediaH: mediaH, 955 mediaIW: mediaIW, 956 breakpointChild: breakpointChild 957 }); 958 } 959 }); 960 961 // we sort to have higher breakpoints first. Because of css cascading styles order is important 962 breakpoints.sort(function (a, b) { 963 return b.breakpointChild - a.breakpointChild; 964 }); 965 966 let output = '';
967 breakpoints.forEach(function (element) { 968 output += ',' + element.mediaX + '|' + element.mediaY + '|' + 969 element.mediaW + '|' + element.mediaH + '|' + element.mediaIW + '|' + element.breakpointChild 970 }); 971 output = output.replace(/(^,)|(,$)/g, ""); 972 jQuery('#' + id).val(output); 973 // update description 974 const descriptionjQuery = jQuery('#description-' + id); 975 const newVal = descriptionjQuery.html().split('Shortcode attribute: ')[0]; 976 descriptionjQuery.html(newVal + 'Shortcode attribute: ' + id + '="' + output + '"'); 977} 978 979function aiSettingsSearch(searchTerm, accType) { 980 var found = 0; 981 982 if (searchTerm !== '') { 983 jQuery('#ai p').not('.form-table p').hide(); 984 jQuery('#ai ul').not('.form-table ul').hide(); 985 jQuery('#ai ol').not('.form-table ol').hide(); 986 if (accType !== 'false') { 987 jQuery('#ai h1').not('.show-always').hide(); 988 jQuery('#ai #accordion').attr('id', 'acc'); 989 jQuery('#ai #acc > div').show(); 990 jQuery('#ai #spacer-div').show(); 991 } 992 jQuery('#ai h2,#ai .icon_ai,#ai h3,#ai h4').not('.show-always').hide(); 993 jQuery('#ai .form-table').addClass('ai-remove-margin'); 994 jQuery('#ai hr, .signup_account_container, .config-file-block').hide(); 995 jQuery('#ai .hide-always').hide(); 996 jQuery('#ai .hide-search').hide(); 997 jQuery('#ai .postbox-container').not('.show-always').hide(); 998 jQuery('#ai .show-always p').show(); 999 jQuery('#ai .show-always ul').show(); 1000 jQuery('#ai .show-always ol').show(); 1001 jQuery('#ai .show-always h2,#ai .show-always .icon_ai,#ai .show-always h3,#ai .show-always h4').show(); 1002 } else { 1003 jQuery('#ai p').not('.form-table p').show(); 1004 jQuery('#ai section .ai-anchor').show(); 1005 jQuery('#ai ul').not('.form-table ul').show(); 1006 jQuery('#ai ol').not('.form-table ol').show(); 1007 if (accType !== 'false') { 1008 jQuery('#ai h1').not('.show-always').show(); 1009 jQuery('#ai #acc').attr('id', 'accordion'); 1010 jQuery('#ai #accordion > div').hide(); 1011 jQuery('#ai #spacer-div').hide(); 1012 } 1013 jQuery('#ai h2,#ai .icon_ai,#ai h3,#ai h4').not('.show-always').show(); 1014 jQuery('#ai .form-table').removeClass('ai-remove-margin'); 1015 jQuery('#ai hr, .signup_account_container, .config-file-block').show(); 1016 jQuery('#ai .sub-domain-container').show(); 1017 jQuery('#ai .hide-search').show(); 1018 jQuery('#ai .hide-always').hide(); 1019 jQuery('#ai .postbox-container').show(); 1020 1021 setTimeout(function () { 1022 jQuery('#ai .postbox-container .closed .inside').css('display', ''); 1023 }, 5); 1024 1025 } 1026 1027 const markTabHeaderjQuery = jQuery('#ai .mark-tab-header'); 1028 markTabHeaderjQuery.removeClass('mark-tab-header'); 1029 1030 var firstHit = ''; 1031 1032 // check the search. 1033 jQuery('#ai tr').each(function () { 1034 var $this = jQuery(this); 1035 var valueLabel = $this.find('th').text(); 1036 var valueDescription = $this.find('p.description').text(); 1037 1038 valueLabel = (valueLabel !== undefined) ? valueLabel.toLowerCase() : 'XXXXXXX'; 1039 valueDescription = (valueDescription !== undefined) ? valueDescription.toLowerCase() : 'XXXXXXX'; 1040 1041 if (valueLabel.indexOf(searchTerm) === -1 && valueDescription.indexOf(searchTerm) === -1) { 1042 if ($this.parents('.show-always').length === 0) { 1043 $this.addClass('hide-setting'); 1044 } 1045 } else { 1046 $this.closest('table').prevAll('h2:first').show(); 1047 $this.closest('.postbox-container').show(); 1048 $this.closest('.postbox-container').find('h2, .inside').show(); 1049 $this.closest('table').prevAll('#ai .icon_ai:first').show(); 1050 $this.closest('table').nextAll('p.button-submit:first').show(); 1051 $this.removeClass('hide-setting'); 1052 $this.closest('.hide-search').show(); 1053 1054 if (searchTerm.length > 2) { 1055 var headerId = $this.closest('section').attr('class'); 1056 if (headerId !== undefined) { 1057 jQuery('#' + headerId).addClass('mark-tab-header'); 1058 if (firstHit === '') { 1059 firstHit = headerId; 1060 } 1061 } 1062 } 1063 found++; 1064 } 1065 }); 1066 if (found === 0) { 1067 jQuery('#ai-input-search-result').show(); 1068 markTabHeaderjQuery.removeClass('mark-tab-header'); 1069 } else { 1070 jQuery('#ai-input-search-result').hide(); 1071 // https://github.com/padolsey/findAndReplaceDOMText 1072 aiInstance && aiInstance.revert(); 1073 if (searchTerm !== '' && searchTerm.length > 2) { 1074 var regex = RegExp(searchTerm, 'gi');
1075 aiInstance = findAndReplaceDOMText(document.getElementById('tab_wrapper'), { 1076 find: regex, 1077 wrap: 'em' 1078 }); 1079 } 1080 jQuery('#' + firstHit).click(); 1081 1082 } 1083} 1084 1085/** 1086 * Resizes the iframe with a certain ratio. 1087 * Width is read and the height is than calculated. 1088 */ 1089function aiResizeIframeRatio(obj, ratio) { 1090 aiDebugExtended("aiResizeIframeRatio"); 1091 var width = jQuery('#' + obj.id).width(); 1092 var valueRatio = parseFloat(ratio.replace(',', '.')); 1093 var newHeight = Math.ceil(width * valueRatio); 1094 obj.height = newHeight; 1095 obj.style.height = newHeight + 'px'; 1096} 1097 1098/** 1099 * Generate a shortcode string from the current settings. 1100 */ 1101function aiGenerateShortcode(isPro) { 1102 var output = '[advanced_iframe '; 1103 1104 // default section 1105 const securityKey = jQuery('#securitykey').val(); 1106 if (securityKey !== '') { 1107 output += 'securitykey="' + securityKey + '" '; 1108 } 1109 output += 'use_shortcode_attributes_only="true" '; 1110 1111 var include_html_val = jQuery('#include_html').val(); 1112 var include_url_val = jQuery('#include_url').val(); 1113 var document_domain_add = jQuery('#document_domain_add').val(); 1114 1115 if (include_html_val === undefined || (include_html_val === '' && include_url_val === '')) { 1116 var src = jQuery('#src').val(); 1117 if (src === '') { 1118 alert('Required url is missing.'); 1119 } else { 1120 output += 'src="' + src + '" '; 1121 } 1122 1123 output += aiGenerateTextShortcode('src_hide'); 1124 output += aiGenerateTextShortcode('width'); 1125 output += aiGenerateTextShortcode('height'); 1126 output += aiGenerateRadioShortcode('scrolling', 'none'); 1127 output += aiGenerateRadioShortcode('add_surrounding_p', 'false'); 1128 output += aiGenerateRadioShortcode('enable_ios_mobile_scolling', 'false'); 1129 output += aiGenerateTextShortcode('marginwidth'); 1130 output += aiGenerateTextShortcode('marginheight'); 1131 output += aiGenerateTextShortcode('frameborder'); 1132 output += aiGenerateRadioShortcode('transparency', 'true'); 1133 output += aiGenerateTextShortcode('class'); 1134 output += aiGenerateTextShortcode('style'); 1135 output += aiGenerateTextShortcodeWithDefault('id', 'advanced_iframe'); 1136 output += aiGenerateTextShortcode('name'); 1137 output += aiGenerateRadioShortcode('allowfullscreen', 'false'); 1138 output += aiGenerateTextShortcode('safari_fix_url'); 1139 output += aiGenerateTextShortcode('sandbox'); 1140 output += aiGenerateTextShortcode('title'); 1141 output += aiGenerateTextShortcode('allow'); 1142 output += aiGenerateRadioShortcode('loading', 'lazy'); 1143 output += aiGenerateTextShortcode('referrerpolicy'); 1144 output += aiGenerateTextShortcode('custom'); 1145 1146 // advanced settings 1147 output += aiGenerateTextShortcode('url_forward_parameter'); 1148 output += aiGenerateTextShortcode('map_parameter_to_url'); 1149 output += aiGenerateRadioShortcode('add_iframe_url_as_param', 'false'); 1150 output += aiGenerateTextShortcode('add_iframe_url_as_param_prefix'); 1151 output += aiGenerateRadioShortcode('add_iframe_url_as_param_direct', 'false'); 1152 output += aiGenerateRadioShortcode('use_iframe_title_for_parent', 'false'); 1153 output += aiGenerateRadioShortcode('onload_scroll_top', 'false'); 1154 output += aiGenerateRadioShortcode('hide_page_until_loaded', 'false'); 1155 output += aiGenerateRadioShortcode('show_iframe_loader', 'false'); 1156 output += aiGenerateTextShortcode('hide_content_until_iframe_color'); 1157 output += aiGenerateTextShortcode('iframe_zoom'); 1158 output += aiGenerateRadioShortcode('use_zoom_absolute_fix', 'false'); 1159 output += aiGenerateRadioShortcode('auto_zoom', 'false'); 1160 output += aiGenerateTextShortcode('auto_zoom_by_ratio'); 1161 1162 output += aiGenerateRadioShortcode('enable_responsive_iframe', 'false'); 1163 output += aiGenerateTextShortcode('iframe_height_ratio'); 1164 1165 output += aiGenerateRadioShortcode('enable_lazy_load', 'false'); 1166 output += aiGenerateTextShortcodeWithDefault('enable_lazy_load_threshold', '3000'); 1167 output += aiGenerateRadioShortcode('enable_lazy_load_reserve_space', 'true'); 1168 1169 output += aiGenerateTextShortcode('enable_lazy_load_fadetime'); 1170 output += aiGenerateRadioShortcode('enable_lazy_load_manual', 'false'); 1171 output += aiGenerateRadioShortcode('enable_lazy_load_manual_element', 'false'); 1172 output += aiGenerateTextShortcode('reload_interval'); 1173 1174 // modify the parent page 1175 output += aiGenerateTextShortcode('hide_elements'); 1176 output += aiGenerateTextShortcode('content_id'); 1177 output += aiGenerateTextShortcode('content_styles'); 1178 output += aiGenerateTextShortcode('parent_content_css'); 1179 output += aiGenerateRadioShortcode('add_css_class_parent', 'false'); 1180 1181 output += aiGenerateTextShortcode('change_parent_links_target'); 1182 output += aiGenerateRadioShortcode('show_iframe_as_layer', 'false'); 1183 output += aiGenerateRadioShortcode('show_iframe_as_layer_full', 'false'); 1184 1185 output += aiGenerateTextShortcode('show_iframe_as_layer_autoclick_delay'); 1186 output += aiGenerateTextShortcode('show_iframe_as_layer_autoclick_hide_time'); 1187 output += aiGenerateTextShortcode('show_iframe_as_layer_header_file'); 1188 output += aiGenerateTextShortcodeWithDefault('show_iframe_as_layer_header_height', '100'); 1189 output += aiGenerateRadioShortcode('show_iframe_as_layer_header_position', 'top'); 1190 output += aiGenerateRadioShortcode('show_iframe_as_layer_keep_content', 'true'); 1191 1192 // show only a part of the iframe 1193 var showPartOfIframe = aiGenerateRadioShortcode('show_part_of_iframe', 'false'); 1194 output += showPartOfIframe; 1195 1196 if (showPartOfIframe !== '') { 1197 output += aiGenerateTextShortcodeWithDefault('show_part_of_iframe_x', -1); 1198 output += aiGenerateTextShortcodeWithDefault('show_part_of_iframe_y', -1); 1199 output += aiGenerateTextShortcode('show_part_of_iframe_width'); 1200 output += aiGenerateTextShortcode('show_part_of_iframe_height'); 1201 output += aiGenerateTextShortcode('show_part_of_iframe_media_query'); 1202 output += aiGenerateRadioShortcode('show_part_of_iframe_allow_scrollbar_horizontal', 'false'); 1203 output += aiGenerateRadioShortcode('show_part_of_iframe_allow_scrollbar_vertical', 'false'); 1204 output += aiGenerateTextShortcode('show_part_of_iframe_style'); 1205 output += aiGenerateRadioShortcode('show_part_of_iframe_zoom', 'false'); 1206 1207 output += aiGenerateTextShortcode('show_part_of_iframe_next_viewports'); 1208 output += aiGenerateRadioShortcode('show_part_of_iframe_next_viewports_loop', 'false'); 1209 output += aiGenerateTextShortcode('show_part_of_iframe_new_window'); 1210 output += aiGenerateTextShortcode('show_part_of_iframe_new_url'); 1211 output += aiGenerateRadioShortcode('show_part_of_iframe_next_viewports_hide', 'false'); 1212 } 1213 1214 // hide cover parts on an iframe 1215 output += aiGenerateTextShortcode('hide_part_of_iframe'); 1216 output += aiGenerateRadioShortcode('fullscreen_button', 'false'); 1217 output += aiGenerateTextShortcode('fullscreen_button_hide_elements'); 1218 output += aiGenerateRadioShortcode('fullscreen_button_full', 'false'); 1219 output += aiGenerateRadioShortcode('fullscreen_button_style', 'black'); 1220 1221 // same domain 1222 output += aiGenerateRadioShortcode('add_css_class_iframe', 'false'); 1223 output += aiGenerateTextShortcode('iframe_hide_elements'); 1224 output += aiGenerateTextShortcode('onload_show_element_only'); 1225 output += aiGenerateTextShortcode('iframe_content_id'); 1226 output += aiGenerateTextShortcode('iframe_content_styles'); 1227 output += aiGenerateTextShortcode('iframe_content_css'); 1228 output += aiGenerateTextShortcode('change_iframe_links'); 1229 output += aiGenerateTextShortcode('change_iframe_links_target'); 1230 output += aiGenerateTextShortcode('change_iframe_links_href'); 1231 1232 // resize content height 1233 output += aiGenerateTextShortcode('onload'); 1234 output += aiGenerateRadioShortcode('onload_resize', 'false'); 1235 output += aiGenerateTextShortcode('onload_resize_delay'); 1236 output += aiGenerateRadioShortcode('store_height_in_cookie', 'false'); 1237 output += aiGenerateTextShortcode('additional_height'); 1238 output += aiGenerateRadioShortcode('onload_resize_width', 'false'); 1239 output += aiGenerateTextShortcode('resize_on_ajax'); 1240 output += aiGenerateRadioShortcode('resize_on_ajax_jquery', 'true'); 1241 output += aiGenerateTextShortcode('resize_on_click'); 1242 output += aiGenerateTextShortcodeWithDefault('resize_on_click_elements', 'a'); 1243 1244 output += aiGenerateTextShortcode('resize_on_element_resize'); 1245 output += aiGenerateTextShortcodeWithDefault('resize_on_element_resize_delay', '250'); 1246 1247 // tabs 1248 output += aiGenerateTextShortcode('tab_hidden'); 1249 output += aiGenerateTextShortcode('tab_visible'); 1250 // cross domain .... 1251 output += aiGenerateRadioShortcode('add_document_domain', 'false'); 1252 // 1253 if (document_domain_add === 'true') { 1254 output += aiGenerateTextShortcode('document_domain'); 1255 } 1256 output += aiGenerateRadioShortcode('enable_external_height_workaround', 'external'); 1257 output += aiGenerateRadioShortcode('hide_page_until_loaded_external', 'false'); 1258 output += aiGenerateTextShortcode('pass_id_by_url'); 1259 output += aiGenerateRadioShortcode('multi_domain_enabled', 'true'); 1260 if (isPro === 'true') { 1261 output += aiGenerateRadioShortcode('use_post_message', 'true'); 1262 } else { 1263 output += aiGenerateRadioShortcode('use_post_message', 'false'); 1264 } 1265 // additional files 1266 output += aiGenerateTextShortcode('additional_css'); 1267 output += aiGenerateTextShortcode('additional_js'); 1268 output += aiGenerateTextShortcode('additional_js_file_iframe'); 1269 output += aiGenerateTextShortcode('additional_css_file_iframe'); 1270 } else { // include content directly 1271 if (include_html_val === '') { 1272 output += aiGenerateTextShortcode('include_url'); 1273 output += aiGenerateTextShortcode('include_content'); 1274 output += aiGenerateTextShortcode('include_height'); 1275 output += aiGenerateTextShortcode('include_fade'); 1276 output += aiGenerateRadioShortcode('include_hide_page_until_loaded', 'false'); 1277 } else { 1278 output += aiGenerateTextShortcode('include_html'); 1279 } 1280 } 1281 // options 1282 output += aiGenerateRadioShortcode('debug_js', 'false'); 1283 output = output.slice(0, -1); 1284 output += ']'; 1285 jQuery('#gen-shortcode').html(output); 1286} 1287 1288/** 1289 * Generate a text shortcode with default 1290 */ 1291function aiGenerateTextShortcodeWithDefault(field, defaultValue) { 1292 var output = ''; 1293 var value = jQuery('#' + field); 1294 var val = value.val(); 1295 if (value.length > 0 && val !== '' && val !== defaultValue) { 1296 output = field + '="' + val + '" '; 1297 } 1298 return output; 1299} 1300 1301/** 1302 * Generate a text shortcode if the value is not empty or != 0 1303 */ 1304function aiGenerateTextShortcode(field) { 1305 var output = ''; 1306 var value = jQuery('#' + field); 1307 var val = value.val(); 1308 if (value.length > 0 && val !== '' && val !== '0') { 1309 output = field + '="' + val + '" '; 1310 } 1311 return output; 1312} 1313 1314/** 1315 * Generate a radio shortcode with default 1316 */ 1317function aiGenerateRadioShortcode(field, defaultValue) { 1318 var output = '';
1319 var value = jQuery('input:radio[name=' + field + ']:checked'); 1320 var val = value.val(); 1321 1322 if (field === 'enable_ios_mobile_scolling') { 1323 field = 'enable_ios_mobile_scrolling'; 1324 } 1325 1326 if (value.length > 0 && val !== defaultValue) { 1327 output += field + '="' + val + '" '; 1328 } 1329 return output; 1330} 1331 1332/** 1333 * Add a css class to the parents to enable that the iframe parents 1334 * can be identified very easy. Is an is ist set ai-class-<id> is used. 1335 * Otherwise a-class-<number> with an increasing number is used. 1336 */ 1337function aiAddCssClassAllParents(element) { 1338 var parents = jQuery(element).parentsUntil('html'); 1339 var ai_class = 'ai-class-'; 1340 for (var i = 0; i < parents.length; i++) { 1341 var id = jQuery(parents[i]).attr('id'); 1342 if (typeof id !== 'undefined') { 1343 if (id.indexOf('ai-') !== 0) { 1344 jQuery(parents[i]).addClass(ai_class + id); 1345 } 1346 } else { 1347 jQuery(parents[i]).addClass(ai_class + i); 1348 } 1349 } 1350} 1351 1352function aiAutoZoomExternalHeight(id, width, height, responsive) { 1353 aiDebugExtended("aiAutoZoomExternalHeight"); 1354 var parentWidth = aiAutoZoomExternal(id, width, responsive); 1355 var zoomRatio = window['zoom_' + id]; 1356 var oldScrollposition = jQuery(document).scrollTop(); 1357 var newHeight = Math.ceil(height * zoomRatio); 1358 jQuery('#ai-zoom-div-' + id).css('height', newHeight); 1359 jQuery("html,body").scrollTop(oldScrollposition); 1360 return parentWidth; 1361} 1362 1363function aiAutoZoomExternal(id, width, responsive) { 1364 aiDebugExtended("aiAutoZoomExternal"); 1365 var obj = document.getElementById(id); 1366 var objAround = document.getElementById('ai-zoom-div-' + id); 1367 var jObj = jQuery('#' + id); 1368 1369 if (responsive === 'true') { 1370 jObj.css('max-width', '100%'); 1371 } 1372 var iframeWidth = width; 1373 var parentWidth = aiGetParentIframeWidth(obj); 1374 if (parentWidth === iframeWidth) { 1375 // we check again the surrounding div as some browser do return the zoomes value! 1376 parentWidth = aiGetParentIframeWidth(objAround); 1377 } 1378 var zoomRatio = parentWidth / iframeWidth; 1379 var zoomRatioRounded = Math.floor(zoomRatio * 100) / 100; 1380 if (zoomRatioRounded > 1) { 1381 zoomRatioRounded = 1; 1382 } 1383 1384 aiSetZoom(id, zoomRatioRounded); 1385 window['zoom_' + id] = zoomRatioRounded; 1386 jObj.width(iframeWidth).css('max-width', 'none'); 1387 return parentWidth; 1388} 1389 1390function aiAutoZoom(id, responsive, ratio) { 1391 aiDebugExtended("aiAutoZoom"); 1392 var parts = ratio.split('|'); 1393 ratio = parts[0]; 1394 var width = -1; 1395 if (parts.length !== 1) { 1396 width = parts[1]; 1397 } 1398 1399 var obj = document.getElementById(id); 1400 var iframeWidth; 1401 if (width === -1) { 1402 obj.width = 1; // set to 1 because otherwise the iframe does never get smaller. 1403 obj.style.width = '1px'; 1404 iframeWidth = aiGetIframeWidth(obj); 1405 obj.width = iframeWidth; 1406 obj.style.width = iframeWidth + 'px'; 1407 } else { 1408 iframeWidth = width; 1409 } 1410 1411 var parentWidth = aiAutoZoomExternal(id, iframeWidth, responsive); 1412 if (ratio === '') { 1413 aiResizeIframe(obj, false); 1414 } else { 1415 var newheight = Math.ceil(iframeWidth * ratio); 1416 obj.height = newheight; 1417 obj.style.height = newheight + 'px'; 1418 // set the height of the zoom div 1419 const zoomDivjQuery = jQuery('#ai-zoom-div-' + obj.id); 1420 if (zoomDivjQuery.length !== 0) { 1421 var zoom = window['zoom_' + obj.id]; 1422 zoomDivjQuery.css('height', Math.ceil(newheight * zoom));
1423 } 1424 } 1425 return parentWidth; 1426} 1427 1428/** 1429 * Set the zoom div settings dynamically. 1430 */ 1431function aiSetZoom(id, zoom) { 1432 1433 var obj = jQuery('#' + id); 1434 1435 obj.css({ 1436 '-ms-transform': 'scale(' + zoom + ')', 1437 '-moz-transform': 'scale(' + zoom + ')', 1438 '-o-transform': 'scale(' + zoom + ')', 1439 '-webkit-transform': 'scale(' + zoom + ')', 1440 'transform': 'scale(' + zoom + ')' 1441 }); 1442} 1443 1444function aiAutoZoomViewport(id, full) { 1445 1446 var viewportDiv = jQuery(id); 1447 var outerDiv = viewportDiv.parent(); 1448 var counter = 0; 1449 1450 // We only go up and look for divs which are not from ai or p elements which are rendered by mistake. 1451 while (outerDiv.is('p') || (outerDiv.attr('id') !== undefined && outerDiv.attr('id').indexOf('ai-') === 0)) { 1452 outerDiv = outerDiv.parent(); 1453 if (counter++ > 10) { 1454 alert('Unexpected div structure. Please disable the zoom.'); 1455 break; 1456 } 1457 } 1458 1459 var viewportDivWidth = viewportDiv.width(); 1460 var outer_div_width = outerDiv.width(); 1461 var viewportDivHeight = viewportDiv.height(); 1462 var zoom = outer_div_width / viewportDivWidth; 1463 1464 if (full === 'true' && zoom > 1) { 1465 zoom = 1; 1466 } 1467 1468 aiSetZoom(viewportDiv.attr('id'), zoom); 1469 // set the margin because otherwise it is normally "centered" in the old area 1470 var marginLeft = -Math.round((viewportDivWidth - viewportDivWidth * zoom) / 2); 1471 var marginTop = -Math.round((viewportDivHeight - viewportDivHeight * zoom) / 2); 1472 viewportDiv.css({ 1473 'margin-left': marginLeft + 'px', 1474 'margin-right': marginLeft + 'px', 1475 'margin-top': marginTop + 'px', 1476 'margin-bottom': marginTop + 'px' 1477 }); 1478 1479} 1480 1481function aiResetAiSettings() { 1482 jQuery('#action').val('reset'); 1483} 1484 1485function aiCheckInputNumber(inputField) { 1486 inputField.value = inputField.value.split(' ').join(''); 1487 var f = inputField.value; 1488 if (inputField.value === '') { 1489 return; 1490 } 1491 var match = f.match( 1492 /^(-)?([\d.])+(px|%|em|pt|vh|vw|rem|ch)?([-+])?([\d.]){0,7}(px|%|em|pt|vh|vw|rem|ch)?$/); 1493 1494 if (!match) { 1495 alert( 1496 'Please check the value you have entered. Only numbers with a dot or with an optional px, %, em or pt are allowed.'); 1497 setTimeout(function () { 1498 inputField.focus(); 1499 }, 10); 1500 } 1501} 1502 1503function aiCheckInputPurchaseCode(inputField) { 1504 inputField.value = inputField.value.split(' ').join(''); 1505 var f = inputField.value; 1506 if (inputField.value === '') { 1507 return; 1508 } 1509 1510 if (!f.match(/^([a-f0-9]{8})-(([a-f0-9]{4})-){3}([a-f0-9]{12})$/i)) { 1511 alert('Please check the value you have entered. Your input seems not to be a valid purchase code.'); 1512 inputField.value = ''; 1513 setTimeout(function () { 1514 inputField.focus(); 1515 }, 10); 1516 } 1517} 1518 1519function aiCheckInputNumberOnly(inputField) { 1520 inputField.value = inputField.value.split(' ').join(''); 1521 var f = inputField.value; 1522 if (inputField.value === '') { 1523 inputField.value = '0'; 1524 return; 1525 } 1526 var match = f.match(/^(-)?([\d.])+$/); 1527 1528 if (!match) { 1529 alert( 1530 'Please check the value you have entered. Only numbers without a dot or optional px, %, em or pt are allowed.'); 1531 setTimeout(function () { 1532 inputField.focus(); 1533 }, 10); 1534 } 1535} 1536 1537// https://codepen.io/anon/pen/baaLYB/ 1538function aiShowHeader(id, element) { 1539 var y = jQuery(window).scrollTop(); 1540 jQuery(window).scrollTop(y - 40); 1541 if (element !== undefined) { 1542 aiFlashElement(element); 1543 } 1544} 1545 1546function aiFlashElement(element) { 1547 setTimeout(function () { 1548 jQuery('#' + element).css('background-color', '#eee'); 1549 }, 500); 1550 setTimeout(function () { 1551 jQuery('#' + element).css('background-color', '#fff'); 1552 }, 900); 1553 setTimeout(function () { 1554 jQuery('#' + element).css('background-color', '#eee'); 1555 }, 1300); 1556 setTimeout(function () { 1557 jQuery('#' + element).css('background-color', '#fff'); 1558 }, 1700); 1559} 1560 1561function aiSetScrollposition() { 1562 var scrollposition = jQuery(document).scrollTop(); 1563 jQuery('#scrollposition').val(scrollposition); // +32 1564} 1565 1566function aiResetShowPartOfAnIframe(id) { 1567 jQuery('#' + id).css('top', '0px').css('left', '0px').css('position', 'static'); 1568 jQuery('#ai-div-' + id).css('width', 'auto').css('height', 'auto').css('overflow', 'auto').css('position', 'static'); 1569} 1570 1571function aiShowLayerIframe(event, id, path, showLoadingIcon, keep, reload) { 1572 aiDebugExtended("aiShowLayerIframe"); 1573 keep = (keep === undefined) ? false : keep; 1574 reload = (reload === undefined) ? true : reload; 1575 1576 var layerId = '#' + id; 1577 jQuery('#ai-zoom-div-' + id).show() 1578 .css('visibility', 'visible'); 1579 jQuery(layerId).show(); 1580 jQuery(layerId).css('visibility', 'visible'); 1581 1582 if (jQuery('#ai-layer-div-' + id).length) { 1583 layerId = '#ai-layer-div-' + id; 1584 jQuery(layerId).show() 1585 .css('visibility', 'visible'); 1586 } 1587 1588 jQuery('html').css('overflow-y', 'visible'); 1589 jQuery('body').css('overflow', 'hidden') 1590 .append('<img alt="" id="ai_backlink" src="' + path + 'close.png" style="z-index:100005;position:fixed;top:0;right:0;cursor:pointer" />'); 1591 1592 var icon = '<!-- -->'; 1593 if (reload && showLoadingIcon === 'true') { 1594 icon = '<div id="ai-div-loader-global" style="position: fixed;z-index:100004;margin-left:-33px;left: 50%;top:50%;margin-top:-33px"><img src="' + path 1595 + 'loader.gif" width="66" height="66" title="Loading" alt="Loading"></div>'; 1596 } 1597 1598 if (jQuery('#ai_backlayer').length === 0) { // we do not have a layer yet... 1599 jQuery(layerId).parent().append( 1600 '<div id="ai_backlayer" style="z-index:100001;position:fixed;top:0;left:0;width:100%;height:100%;background-color: rgba(50,50,50,0.5);overflow:hidden;cursor:pointer"><!-- --></div>' + icon); 1601 } 1602 1603 jQuery('#ai_backlink, #ai_backlayer').click(function () { 1604 aiHideLayerIframe(id, keep);
1605 }); 1606 if (!reload) { 1607 event.preventDefault(); 1608 event.stopPropagation(); 1609 } 1610} 1611 1612function aiHideLayerIframe(id, keep) { 1613 aiDebugExtended("aiHideLayerIframe"); 1614 const idjQuery = jQuery('#' + id); 1615 idjQuery.css('visibility', 'hidden'); 1616 if (!keep) { 1617 idjQuery.attr('src', 'about:blank'); 1618 aiLayerIframeHrefs[id] = 'about:blank'; 1619 } 1620 jQuery('#ai-zoom-div-' + id).css('visibility', 'hidden'); 1621 jQuery('#ai-layer-div-' + id).css('visibility', 'hidden'); 1622 jQuery('#ai_backlink').remove(); 1623 jQuery('#ai_backlayer').remove(); 1624 jQuery('#ai-div-loader-global').remove(); 1625 jQuery('body').css('overflow', 'auto'); 1626 jQuery('html').css('overflow-y', 'scroll'); 1627} 1628 1629/** 1630 * As the src of an iframe cannot be read from a remote domain we remember 1631 * the urls from the links here for each opened iframe. 1632 */ 1633var aiLayerIframeHrefs = []; 1634 1635/** 1636 * Check if the location of the iframe is already the one of the link. 1637 * The iframe is only loaded if it is was not loaded already. 1638 * 1639 * true - if src and url of the iframe is different and need to be loaded 1640 * false - if it is already the same; 1641 */ 1642function aiCheckReload(link, id) { 1643 var iframeSrc; 1644 if (typeof aiLayerIframeHrefs[id] === 'undefined') { 1645 iframeSrc = jQuery('#' + id).attr('src'); 1646 } else { 1647 iframeSrc = aiLayerIframeHrefs[id]; 1648 } 1649 var linkHref = jQuery(link).attr('href'); 1650 // alert(linkHref + ": iframe:" + iframeSrc); 1651 aiLayerIframeHrefs[id] = linkHref; 1652 return (iframeSrc !== linkHref); 1653} 1654 1655function aiChangeTitle(id) { 1656 aiDebugExtended("aiChangeTitle"); 1657 try { 1658 var title = document.getElementById(id).contentDocument.title; 1659 if (title !== null && title !== 'undefined' && title !== '') { 1660 document.title = title; 1661 } 1662 } catch (e) { 1663 if (console && console.error) { 1664 console.error( 1665 'Advanced iframe configuration error: You have enabled to add the title if the iframe to the parent on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); 1666 console.log(e); 1667 } 1668 } 1669} 1670 1671/** 1672 * This changes the current url and adds or updates the 1673 * existing parameter with the given url 1674 */ 1675function aiChangeUrlParam(loc, param, orig, prefix, isDirect) { 1676 aiDebugExtended("aiChangeUrlParam"); 1677 var newUrl; 1678 var keepSlash = false; 1679 1680 // add protocol if // is used in the shortcode 1681 if (orig.lastIndexOf("//", 0) !== -1) { 1682 orig = location.protocol + orig; 1683 } 1684 1685 if (loc !== encodeURIComponent(orig)) { 1686 newUrl = aiSetGetParameter(param, loc); 1687 var removeProtocol = true; 1688 if (prefix.startsWith('hash')) { 1689 return aiGetUrlMapping(loc, param, prefix); 1690 } else if (prefix) { 1691 var repUrl = newUrl.replace(prefix, ''); 1692 if (repUrl === newUrl) { 1693 removeProtocol = false; 1694 } 1695 newUrl = repUrl; 1696 } 1697 1698 // remove protocol 1699 if (removeProtocol) { 1700 newUrl = newUrl.replace('http%3A%2F%2F', ''); 1701 if (window.location.href.toLowerCase().lastIndexOf("http:", 0) !== -1) { 1702 newUrl = newUrl.replace('https%3A%2F%2F', 's|'); 1703 } else { 1704 newUrl = newUrl.replace('https%3A%2F%2F', ''); 1705 } 1706 } 1707 1708 if (isDirect) { 1709 newUrl = aiRemoveQueryString(window.location.href); 1710 var locDecoded = decodeURIComponent(loc); 1711 var queryStart = locDecoded.indexOf('?'); 1712 var hashStart = locDecoded.indexOf('#'); 1713 if (queryStart !== -1) { 1714 var queryPart = locDecoded.slice(queryStart + 1); 1715 newUrl += '?' + queryPart; 1716 keepSlash = true; 1717 } else if (hashStart !== -1) { 1718 var hashPart = locDecoded.slice(hashStart + 1); 1719 newUrl += '?hash=' + hashPart; 1720 keepSlash = true; 1721 } 1722 } 1723 if (aiEndsWidth(newUrl, param + "=")) { 1724 newUrl = aiRemoveURLParameter(newUrl, param); 1725 } 1726 } else { 1727 var fullUrl = window.location.href; 1728 // remove param/* first 1729 fullUrl = fullUrl.split("/" + param + "/", 1)[0]; 1730 newUrl = aiRemoveURLParameter(fullUrl, param); 1731 } 1732 var seperator = (newUrl.indexOf('?') >= 0) ? '&' : '?'; 1733 newUrl = newUrl.replace("#", seperator + "hash="); 1734 aiSetBrowserUrl(newUrl, keepSlash); 1735} 1736 1737function aiGetUrlMappingUrl(param, prefix, id) { 1738 var fullUrl = window.location.href; 1739 1740 param = param.replace(":short", ""); 1741 var newUrl = aiRemoveURLParameter(fullUrl, param); 1742 if (prefix.startsWith('hashrewrite')) { 1743 // remove param/* first 1744 var queryString = ""; 1745 if (newUrl.indexOf('?') >= 0) { 1746 var newUrlArray = newUrl.split('?'); 1747 newUrl = newUrlArray[0]; 1748 queryString = '?' + newUrlArray[1]; 1749 } 1750 var baseUrl = newUrl.split("/" + param + "/", 1)[0]; 1751 // add the path before the query string 1752 if (!aiEndsWidth(baseUrl, "/")) { 1753 baseUrl += '/'; 1754 } 1755 var path = param + "/"; 1756 newUrl = baseUrl + path + id + queryString; 1757 } else { 1758 var seperator = (newUrl.indexOf('?') >= 0) ? '&' : '?'; 1759 newUrl += seperator + param + "=" + id; 1760 } 1761 return newUrl; 1762} 1763 1764function aiSetBrowserUrl(newUrl, keepSlash) { 1765 if (aiSupportsHistoryApi()) { 1766 if (!keepSlash) { 1767 newUrl = newUrl.replace(/%2F/g, '/'); 1768 } 1769 window.history.pushState({}, '', newUrl); 1770 // I asume the back button is clicked. 1771 window.onpopstate = function (event) { 1772 if (event && event.state) { 1773 window.history.back(); 1774 } 1775 }; 1776 } 1777} 1778 1779function aiRemoveQueryString(loc) { 1780 if (loc.indexOf('%3F') >= 0) { 1781 return loc.split('%3F')[0]; 1782 } else if (loc.indexOf('?') >= 0) { 1783 return loc.split('?')[0]; 1784 } else { 1785 return loc; 1786 } 1787} 1788 1789function aiGetUrlMapping(url, param, prefix) { 1790 var data = { 1791 action: 'aip_map_url_action', 1792 security: MyAjax.security, 1793 url: url 1794 }; 1795 1796 // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 1797 jQuery.post(MyAjax.ajaxurl, data, function (id) { 1798 var newUrl = aiGetUrlMappingUrl(param, prefix, id); 1799 aiSetBrowserUrl(newUrl, false); 1800 }); 1801} 1802 1803function closeInfoPermanent(id) { 1804 var data = { 1805 action: 'aip_close_message_permanent', 1806 security: MyAjax.security, 1807 id: id 1808 }; 1809 // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 1810 var message = 'The message before will only appear again when you reset the advanced iframe settings.'; 1811 if (id === 'show-discount-message') { 1812 message = 'The message of advanced iframe shown before will only appear again when you reset the advanced iframe settings or a new discount is available.'; 1813 } else if (id === 'show-registration-message') { 1814 message = 'The message will appear again after a page reload.'; 1815 } 1816 1817 jQuery.post(MyAjax.ajaxurl, data, function () { 1818 jQuery('h1').after('<div class="message-notice notice notice-success"><p>' + message + '</p></div>'); 1819 }); 1820 setTimeout(function () { 1821 jQuery(".message-notice").fadeOut() 1822 }, 4000); 1823} 1824 1825function aiSupportsHistoryApi() { 1826 return !!(window.history && history.pushState); 1827} 1828 1829function aigetIframeLocation(id) { 1830 try { 1831 var location = document.getElementById(id).contentWindow.location; 1832 return encodeURIComponent(location); 1833 } catch (e) { 1834 if (console && console.error) { 1835 console.error( 1836 'Advanced iframe configuration error: You have enabled to add the url to the url on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described
1836in the settings. Also check the next log. There the browser message for this error is displayed.'); 1837 console.log(e); 1838 } 1839 } 1840} 1841 1842/** 1843 * Replaces a url parameter with a given value. 1844 */ 1845function aiSetGetParameter(paramName, paramValue) { 1846 var url = window.location.href; 1847 var splitAtAnchor = url.split('#'); 1848 url = splitAtAnchor[0]; 1849 var anchor = typeof splitAtAnchor[1] === 'undefined' ? '' : '#' + splitAtAnchor[1]; 1850 if (url.indexOf(paramName + '=') >= 0) { 1851 var prefix = url.substring(0, url.indexOf(paramName + '=')); 1852 var suffix = url.substring(url.indexOf(paramName + '=')); 1853 suffix = suffix.substring(suffix.indexOf('=') + 1); 1854 suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : ''; 1855 url = prefix + paramName + '=' + paramValue + suffix; 1856 } else { 1857 if (url.indexOf('?') < 0) { 1858 url += '?' + paramName + '=' + paramValue; 1859 } else { 1860 url += '&' + paramName + '=' + paramValue; 1861 } 1862 } 1863 return url + anchor; 1864} 1865 1866/** 1867 * Remove a given parameter from the url 1868 */ 1869function aiRemoveURLParameter(url, parameter) { 1870 //prefer to use l.search if you have a location/link object 1871 var urlparts = url.split('?'); 1872 if (urlparts.length >= 2) { 1873 1874 var prefix = encodeURIComponent(parameter) + '='; 1875 var pars = urlparts[1].split(/[&;]/g); 1876 1877 //reverse iteration as may be destructive 1878 for (var i = pars.length; i-- > 0;) { 1879 //idiom for string.startsWith 1880 if (pars[i].lastIndexOf(prefix, 0) !== -1) { 1881 pars.splice(i, 1); 1882 } 1883 } 1884 if (pars.length !== 0) { 1885 url = urlparts[0] + '?' + pars.join('&'); 1886 } else { 1887 url = urlparts[0]; 1888 } 1889 return url; 1890 } else { 1891 return url; 1892 } 1893} 1894 1895function aiEndsWidth(string, target) { 1896 return string.substr(-target.length) === target; 1897} 1898 1899/** 1900 * Adds css to the end of the body to make sure that styles are 1901 * not overwritten by inline css of any kind. 1902 */ 1903function aiAddCss(id, css) { 1904 css = decodeURIComponent(css.replace(/\+/g, '%20')); 1905 1906 var body = jQuery(id).contents().find('body'); 1907 var s = document.createElement('style'); 1908 s.setAttribute('type', 'text/css'); 1909 if (s.styleSheet) { // IE 1910 s.styleSheet.cssText = css; 1911 } else { // the world 1912 s.appendChild(document.createTextNode(css)); 1913 } 1914 body.append(s); 1915} 1916 1917/** 1918 * add a css file to the end of the body to make sure that styles 1919 * are not overwritten by inline css of any kind. 1920 */ 1921function aiAddCssFile(id, filename) { 1922 var body = jQuery(id).contents().find('body'); 1923 var link = document.createElement('link'); 1924 link.rel = 'stylesheet'; 1925 link.type = 'text/css'; 1926 link.href = filename; 1927 body.append(link); 1928} 1929 1930/** 1931 * Add a Javascript file to the end of the body 1932 */ 1933function aiAddJsFile(id, filename) { 1934 jQuery.ajaxSetup({cache: true}); 1935 1936 var body = jQuery(id).contents().find('body'); 1937 var script = document.createElement('script'); 1938 script.type = 'text/javascript'; 1939 script.src = filename; 1940 body.append(script); 1941} 1942 1943function aiPresetFullscreen() { 1944 jQuery('#style').val('position:fixed;z-index:9000;top:0px;left:0px;margin:0px'); 1945 jQuery('#width').val('100%'); 1946 jQuery('#ai-height-0').val('100%'); 1947 jQuery('#content_id').val('html,body'); 1948 jQuery('#content_styles').val('overflow:hidden'); 1949 jQuery('#hide_content_until_iframe_color').val('#ffffff'); 1950} 1951 1952/** 1953 * main ready function that calls all generated callbacks. 1954 * Add dynamically created functions that should be loaded 1955 * when the page is read to aiReadyCallbacks 1956 */ 1957jQuery(document).ready(function () { 1958 aiDebugExtended("document.ready called"); 1959 1960 // wordpress adds often p elements that have margins we remove here. 1961 jQuery('iframe').parent('p').css('margin', '0'); 1962 1963 aiWindowWidth = jQuery(window).width(); 1964 jQuery.each(aiReadyCallbacks, function (index, callback) { 1965 callback(); 1966 }); 1967 1968 jQuery('.ai-fullscreen-open').on('click', function () { 1969 jQuery(this).closest('.ai-wrapper-div').addClass("ai-fullscreen-wrapper"); 1970 jQuery(this).closest('.ai-wrapper-div').find('iframe').addClass("ai-fullscreen"); 1971 jQuery('.ai-fullscreen-open').hide(); 1972 jQuery('.ai-fullscreen-hide').addClass("ai-fullscreen-display-none") 1973 .hide(); 1974 jQuery('html,body').css('overflow', 'hidden'); 1975 1976 var id = jQuery(this).data("id"); 1977 // show/render the close button 1978 jQuery('.ai-fullscreen-close-' + id).show(); 1979 jQuery(document).on('keydown', function (evt) { 1980 if (evt.key === "Escape") { 1981 jQuery('.ai-fullscreen-close').trigger("click"); 1982 } 1983 });
1984 aiOpenFullscreen(); 1985 aiInFullscreen = true; 1986 }); 1987 1988 jQuery('.ai-fullscreen-close').on('click', function () { 1989 // remove css for fullscreen-open 1990 jQuery('div.ai-wrapper-div').removeClass("ai-fullscreen-wrapper") 1991 jQuery('iframe.ai-fullscreen').removeClass("ai-fullscreen"); 1992 jQuery('html').css('overflow', aiOverflowHtml); 1993 jQuery('body').css('overflow', aiOverflowBody); 1994 1995 // hide/remove the close button 1996 jQuery('.ai-fullscreen-close').hide(); 1997 // show the fullscreen icon again 1998 jQuery('.ai-fullscreen-open').show(); 1999 jQuery('.ai-fullscreen-display-none').removeClass("ai-fullscreen-display-none"); 2000 jQuery('.ai-fullscreen-hide').show(); 2001 2002 jQuery(document).off("keydown"); 2003 if (aiInFullscreen) { 2004 aiCloseFullscreen(); 2005 } 2006 2007 }); 2008 2009 setTimeout(function () { 2010 jQuery("#ai #ai-updated-text").css("visibility", "hidden") 2011 }, 4000); 2012 2013 jQuery('#ai #checkIframes').on('click', function () { 2014 jQuery('.ai-spinner').css('display', 'inline-table'); 2015 jQuery(this).addClass('disabled'); 2016 setTimeout(aiDisableCheckIframes, 200); 2017 }); 2018 2019 var moved = false; 2020 jQuery('#aiDebugDivTotal').mousedown(function () { 2021 moved = false; 2022 }).mousemove(function () { 2023 moved = true; 2024 }).mouseup(function () { 2025 if (!moved) { 2026 var elem = jQuery('#aiDebugDiv'); 2027 if (Math.floor(elem.height()) > '300') { 2028 elem.height('0px'); 2029 } else { 2030 elem.height('400px'); 2031 } 2032 } 2033 }); 2034 2035 if (typeof ai_show_id_only !== 'undefined') { 2036 const showIdOnlyjQuery = jQuery('#' + ai_show_id_only); 2037 if (showIdOnlyjQuery.length === 0) { 2038 alert('The element with the id "' + ai_show_id_only + '" cannot be found. Please check your configuration.'); 2039 } else { 2040 showIdOnlyjQuery.siblings().hide(); 2041 var parents = showIdOnlyjQuery.parents(); 2042 parents.siblings().hide(); 2043 parents.css('padding', '0px').css('margin', '0px').css('overflow', 'hidden'); 2044 2045 // we send the size of the element as post message if we are in an iframe 2046 if (parent === top) { 2047 var elementRaw = showIdOnlyjQuery[0]; 2048 elementRaw.style.marginTop = elementRaw.style.marginBottom = '0'; 2049 elementRaw.style.overflow = "hidden"; 2050 var newHeightRaw = Math.max(elementRaw.scrollHeight, elementRaw.offsetHeight) + ''; 2051 var newHeight = parseInt(newHeightRaw, 10); 2052 var data = {'aitype': 'height', 'height': newHeight, 'id': ai_show_id_only}; 2053 var json_data = JSON.stringify(data); 2054 window.parent.postMessage(json_data, '*'); 2055 } 2056 } 2057 } 2058}); 2059 2060function aiDisableCheckIframes() { 2061 var input = jQuery("<input>").attr("type", "hidden").attr("name", "checkIframes").val("true"); 2062 jQuery("#ai_form").append(input) 2063 .submit(); 2064 jQuery('#checkIframes').prop('disabled', 'disabled'); 2065} 2066 2067 2068function aiProcessMessage(event, id, debug, dataPostMessage, addIframeUrlAsParam, useIframeTitleForParent) { 2069 var jsObject; 2070 try { 2071 jsObject = JSON.parse(event.data); 2072 } catch (e) { 2073 // Result is not expected so we try if data is an object already 2074 // because a converter was not implemented properly. 2075 if (debug === 'debug' && console && console.log) { 2076 console.log( 2077 'Advanced iframe: The received message cannot be parsed and seems not to belong to advanced iframe pro. Please disable the postMessage debug mode if this o.k. and that this message is not shown anymore.'); 2078 console.log("Advanced iframe: Unknown event: ", event); 2079 } 2080 jsObject = event.data; 2081 } 2082 try { 2083 // we only process objects from advanced iframe 2084 if (jsObject.hasOwnProperty('aitype')) { 2085 // we only process the ones for the same id here. 2086 if (id === jsObject.id) { 2087 var type = jsObject.aitype; 2088 if (type === 'debug') { 2089 aiProcessDebug(jsObject); 2090 } else if (type === 'scrollToTop') { 2091 aiProcessScrollToTop(jsObject); 2092 } else if (type === 'anchor') { 2093 aiProcessAnchor(jsObject); 2094 } else { 2095 // check if the data is of the expected 2096 if (type === 'height') { 2097 aiProcessHeight(jsObject, addIframeUrlAsParam, useIframeTitleForParent); 2098 } else if (type === 'show') { 2099 aiProcessShow(jsObject); 2100 } 2101 2102 //only configured keys! 2103 for (var key in jsObject.data) { 2104 if (jsObject.data.hasOwnProperty(key) && aiIsValidKey(key, dataPostMessage)) { 2105 jQuery(key).html(aiRemoveScriptTags(jsObject.data[key])); 2106 } 2107 } 2108 } 2109 } 2110 } 2111 } catch (e) { 2112 if (debug === 'debug' && console && console.log) { 2113 console.log('Advanced iframe: The received message do not belong to advanced iframe pro. Please disable the postMessage debug mode if this o.k. and that this message is not shown anymore.'); 2114 console.log(e); 2115 } 2116 } 2117} 2118 2119/** 2120 * Checks if the key we get from the post message is in dataPostMessage saved 2121 */ 2122function aiIsValidKey(key, dataPostMessage) { 2123 if (!dataPostMessage) return false; 2124 2125 var parts = dataPostMessage.split(','); 2126 2127 for (var i = 0; i < parts.length; i++) {
2128 var validKey = parts[i].split('|')[0].trim(); 2129 if (validKey === key) { 2130 return true; 2131 } 2132 } 2133 2134 return false; 2135} 2136 2137function aiRemoveScriptTags(htmlString) { 2138 const temp = jQuery('<div>').html(htmlString); 2139 temp.find('script').remove(); 2140 return temp.html(); 2141} 2142 2143function aiProcessDebug(jsObject) { 2144 var debugData = jsObject.data; 2145 const debugDivjQuery = jQuery('#aiDebugDiv'); 2146 if (debugDivjQuery.length !== 0) { 2147 debugData = debugData.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); 2148 debugData = debugData.replace('\"', '"').replace(/\\/g, ""); 2149 debugDivjQuery.append('<p class="ai-debug-remote"> r: ' + debugData + '</p>'); 2150 } 2151} 2152 2153function aiProcessScrollToTop(jsObject) { 2154 var id = jsObject.id; 2155 aiScrollToTop(id, aiOnloadScrollTop); 2156} 2157 2158function aiProcessAnchor(jsObject) { 2159 var id = jsObject.id; 2160 var position = parseInt(jsObject.position, 10); 2161 var iframeTop = jQuery("#" + id).offset().top; 2162 setTimeout(function () { 2163 jQuery("html,body").scrollTop(Math.round(iframeTop + position)); 2164 }, 100); 2165} 2166 2167function aiProcessHeight(jsObject, addIframeUrlAsParam, useIframeTitleForParent) { 2168 var nHeight = jsObject.height; 2169 var nWidth = jsObject.width; 2170 var iAnchor = parseInt(jsObject.anchor, 10); 2171 var id = jsObject.id; 2172 2173 if (nHeight != null) { 2174 try { 2175 if (addIframeUrlAsParam == "remote") { 2176 var loc = jsObject.loc; 2177 if (loc != null && !loc.includes("send_console_log")) { 2178 if (typeof aiChangeUrl === "function") { 2179 aiChangeUrl(loc); 2180 } 2181 } 2182 } 2183 if (useIframeTitleForParent == "remote") { 2184 var title = jsObject.title; 2185 if (title != null && title !== "undefined" && title !== "") { 2186 document.title = decodeURIComponent(title); 2187 } 2188 } 2189 if (id != null) { 2190 var iHeight = parseInt(nHeight, 10); 2191 var iWidth = parseInt(nWidth, 10); 2192 aiResizeIframeHeightId(iHeight, iWidth, id); 2193 if (!isNaN(iAnchor) && iAnchor > -1) { 2194 // 2195 var iframeTop = jQuery("#" + id).offset().top; 2196 setTimeout(function () { 2197 jQuery("html,body").scrollTop(Math.round(iframeTop + iAnchor)); 2198 aiShowIframeId(id); 2199 }, 100); 2200 } else { 2201 aiShowIframeId(id); 2202 } 2203 } else { 2204 alert('Please update the ai_external.js to the current version.'); 2205 } 2206 } catch (e) { 2207 if (console && console.log) { 2208 console.log(e); 2209 } 2210 } 2211 } 2212} 2213 2214function aiProcessShow(jsObject) { 2215 var id = jsObject.id; 2216 2217 try { 2218 aiShowIframeId(id); 2219 } catch (e) { 2220 if (console && console.log) { 2221 console.log(e); 2222 } 2223 } 2224} 2225 2226function aiDisableRightClick(id) { 2227 try { 2228 window.frames[id].document.oncontextmenu = function () { 2229 return false; 2230 }; 2231 } catch (e) { 2232 // we ignore the error as it only works on the same domain. 2233 } 2234} 2235 2236function aiRemoveElementsFromHeight(id, height, removeElements) { 2237 const iframejQuery = jQuery('#' + id); 2238 var elementArray = removeElements.split(','); 2239 var totalHeight = 0; 2240 for (var i = 0; i < elementArray.length; i++) { 2241 try { 2242 var el = elementArray[i]; 2243 if (el.includes("|")) { 2244 var rangeArray = el.split('|'); 2245 var bottomElement = jQuery(rangeArray[0]); 2246 var beforeBottom = Math.round(bottomElement.offset().top + bottomElement.outerHeight(true)); 2247 var nextTop = Math.round(jQuery(rangeArray[1]).offset().top); 2248 totalHeight += nextTop - beforeBottom; 2249 } else if (el === 'top') { 2250 totalHeight += Math.round(iframejQuery.offset().top); 2251 } else if (isNaN(el)) { 2252 totalHeight += jQuery(el).outerHeight(true); 2253 } else { 2254 totalHeight += parseInt(el); 2255 } 2256 } catch (e) { 2257 if (console && console.error) { 2258 console.error('Advanced iframe configuration error: The configuration of remove_elements_from_height "' + removeElements 2259 + '" is invalid. Please check if the elements you defined do exist and ids/classes are defined properly.'); 2260 console.log(e); 2261 } 2262 } 2263 } 2264 var calc = 'calc(' + height + ' - ' + totalHeight + 'px)'; 2265 iframejQuery.css('height', calc); 2266} 2267 2268function aiTriggerAutoOpen(id, selector, autoclickDelay, hideTime) { 2269 aiDebugExtended("aiTriggerAutoOpen"); 2270 2271 if (autoclickDelay === 0) { 2272 aiOpenIframeOnClick(id, selector); 2273 } else { 2274 setTimeout(function () { 2275 aiOpenIframeOnClick(id, selector); 2276 }, autoclickDelay); 2277 } 2278 2279 var now = new Date(); 2280 var time = now.getTime(); 2281 var expireTime = time + (hideTime * 86400000); 2282 now.setTime(expireTime); 2283 var trimmedSelector = selector.replace(/[^A-Za-z0-9\-]/g, ''); 2284 document.cookie = 'ai_disable_autoclick_iframe_' + trimmedSelector + '=Auto open is disabled until this cookie expires;expires=' + now.toUTCString() + ';path=/'; 2285} 2286 2287function aiCheckAutoOpenHash(id, autoclickDelay, hideTime) { 2288 if (window.location.hash) { 2289 var hash = window.location.hash; 2290 var trimmedHash = hash.replace(/[^A-Za-z0-9\-]/g, ''); 2291 trimmedHash = "#" + trimmedHash; 2292 if (jQuery(trimmedHash).length !== 0) { // id does exist 2293 if (jQuery(trimmedHash).first().attr('target') === id) { // target is
2293iframe 2294 aiTriggerAutoOpen(id, trimmedHash, autoclickDelay, hideTime); 2295 } 2296 } 2297 } 2298} 2299 2300function aiOpenIframeOnClick(id, selector) { 2301 var myelement = jQuery(selector).first().attr("href"); 2302 jQuery("#" + id).attr("src", myelement); 2303 jQuery(selector).first().click(); 2304} 2305 2306// IE11 does not support includes 2307if (!String.prototype.includes) { 2308 String.prototype.includes = function (search, start) { 2309 if (typeof start !== 'number') { 2310 start = 0; 2311 } 2312 if (start + search.length > this.length) { 2313 return false; 2314 } else { 2315 return this.indexOf(search, start) !== -1; 2316 } 2317 }; 2318} 2319 2320if (!String.prototype.startsWith) { 2321 String.prototype.startsWith = function (searchString, position) { 2322 position = position || 0; 2323 return this.indexOf(searchString, position) === position; 2324 }; 2325} 2326 2327// aiRealFullscreen 2328/* Get the documentElement (<html>) to display the page in fullscreen */ 2329var elem = document.documentElement; 2330 2331/* View in fullscreen */ 2332function aiOpenFullscreen() { 2333 if (aiRealFullscreen) { 2334 if (elem.requestFullscreen) { 2335 elem.requestFullscreen(); 2336 } else if (elem.webkitRequestFullscreen) { /* Safari */ 2337 elem.webkitRequestFullscreen(); 2338 } else if (elem.msRequestFullscreen) { /* IE11 */ 2339 elem.msRequestFullscreen(); 2340 } 2341 } 2342} 2343 2344/* Close fullscreen */ 2345function aiCloseFullscreen() { 2346 if (aiRealFullscreen) { 2347 if (document.exitFullscreen) { 2348 document.exitFullscreen(); 2349 } else if (document.webkitExitFullscreen) { /* Safari */ 2350 document.webkitExitFullscreen(); 2351 } else if (document.msExitFullscreen) { /* IE11 */ 2352 document.msExitFullscreen(); 2353 } 2354 } 2355} 2356 2357document.addEventListener('fullscreenchange', aiExitHandler); 2358document.addEventListener('webkitfullscreenchange', aiExitHandler); 2359document.addEventListener('mozfullscreenchange', aiExitHandler); 2360document.addEventListener('MSFullscreenChange', aiExitHandler); 2361 2362function aiExitHandler() { 2363 if (!document.fullscreenElement && !document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement) { 2364 aiInFullscreen = false; 2365 jQuery('.ai-fullscreen-close').trigger("click"); 2366 } 2367} 2368 2369 2370 2371
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.