Edit File by line
/home/barbar84/www/wp-inclu.../js
File: wp-embed-template.js
/**
[0] Fix | Delete
* @output wp-includes/js/wp-embed-template.js
[1] Fix | Delete
*/
[2] Fix | Delete
(function ( window, document ) {
[3] Fix | Delete
'use strict';
[4] Fix | Delete
[5] Fix | Delete
var supportedBrowser = ( document.querySelector && window.addEventListener ),
[6] Fix | Delete
loaded = false,
[7] Fix | Delete
secret,
[8] Fix | Delete
secretTimeout,
[9] Fix | Delete
resizing;
[10] Fix | Delete
[11] Fix | Delete
function sendEmbedMessage( message, value ) {
[12] Fix | Delete
window.parent.postMessage( {
[13] Fix | Delete
message: message,
[14] Fix | Delete
value: value,
[15] Fix | Delete
secret: secret
[16] Fix | Delete
}, '*' );
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
function onLoad() {
[20] Fix | Delete
if ( loaded ) {
[21] Fix | Delete
return;
[22] Fix | Delete
}
[23] Fix | Delete
loaded = true;
[24] Fix | Delete
[25] Fix | Delete
var share_dialog = document.querySelector( '.wp-embed-share-dialog' ),
[26] Fix | Delete
share_dialog_open = document.querySelector( '.wp-embed-share-dialog-open' ),
[27] Fix | Delete
share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ),
[28] Fix | Delete
share_input = document.querySelectorAll( '.wp-embed-share-input' ),
[29] Fix | Delete
share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ),
[30] Fix | Delete
featured_image = document.querySelector( '.wp-embed-featured-image img' ),
[31] Fix | Delete
i;
[32] Fix | Delete
[33] Fix | Delete
if ( share_input ) {
[34] Fix | Delete
for ( i = 0; i < share_input.length; i++ ) {
[35] Fix | Delete
share_input[ i ].addEventListener( 'click', function ( e ) {
[36] Fix | Delete
e.target.select();
[37] Fix | Delete
} );
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
function openSharingDialog() {
[42] Fix | Delete
share_dialog.className = share_dialog.className.replace( 'hidden', '' );
[43] Fix | Delete
// Initial focus should go on the currently selected tab in the dialog.
[44] Fix | Delete
document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' ).focus();
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
function closeSharingDialog() {
[48] Fix | Delete
share_dialog.className += ' hidden';
[49] Fix | Delete
document.querySelector( '.wp-embed-share-dialog-open' ).focus();
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
if ( share_dialog_open ) {
[53] Fix | Delete
share_dialog_open.addEventListener( 'click', function () {
[54] Fix | Delete
openSharingDialog();
[55] Fix | Delete
} );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
if ( share_dialog_close ) {
[59] Fix | Delete
share_dialog_close.addEventListener( 'click', function () {
[60] Fix | Delete
closeSharingDialog();
[61] Fix | Delete
} );
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
function shareClickHandler( e ) {
[65] Fix | Delete
var currentTab = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );
[66] Fix | Delete
currentTab.setAttribute( 'aria-selected', 'false' );
[67] Fix | Delete
document.querySelector( '#' + currentTab.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'true' );
[68] Fix | Delete
[69] Fix | Delete
e.target.setAttribute( 'aria-selected', 'true' );
[70] Fix | Delete
document.querySelector( '#' + e.target.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'false' );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
function shareKeyHandler( e ) {
[74] Fix | Delete
var target = e.target,
[75] Fix | Delete
previousSibling = target.parentElement.previousElementSibling,
[76] Fix | Delete
nextSibling = target.parentElement.nextElementSibling,
[77] Fix | Delete
newTab, newTabChild;
[78] Fix | Delete
[79] Fix | Delete
if ( 37 === e.keyCode ) {
[80] Fix | Delete
newTab = previousSibling;
[81] Fix | Delete
} else if ( 39 === e.keyCode ) {
[82] Fix | Delete
newTab = nextSibling;
[83] Fix | Delete
} else {
[84] Fix | Delete
return false;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if ( 'rtl' === document.documentElement.getAttribute( 'dir' ) ) {
[88] Fix | Delete
newTab = ( newTab === previousSibling ) ? nextSibling : previousSibling;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
if ( newTab ) {
[92] Fix | Delete
newTabChild = newTab.firstElementChild;
[93] Fix | Delete
[94] Fix | Delete
target.setAttribute( 'tabindex', '-1' );
[95] Fix | Delete
target.setAttribute( 'aria-selected', false );
[96] Fix | Delete
document.querySelector( '#' + target.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'true' );
[97] Fix | Delete
[98] Fix | Delete
newTabChild.setAttribute( 'tabindex', '0' );
[99] Fix | Delete
newTabChild.setAttribute( 'aria-selected', 'true' );
[100] Fix | Delete
newTabChild.focus();
[101] Fix | Delete
document.querySelector( '#' + newTabChild.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'false' );
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
if ( share_dialog_tabs ) {
[106] Fix | Delete
for ( i = 0; i < share_dialog_tabs.length; i++ ) {
[107] Fix | Delete
share_dialog_tabs[ i ].addEventListener( 'click', shareClickHandler );
[108] Fix | Delete
[109] Fix | Delete
share_dialog_tabs[ i ].addEventListener( 'keydown', shareKeyHandler );
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
document.addEventListener( 'keydown', function ( e ) {
[114] Fix | Delete
if ( 27 === e.keyCode && -1 === share_dialog.className.indexOf( 'hidden' ) ) {
[115] Fix | Delete
closeSharingDialog();
[116] Fix | Delete
} else if ( 9 === e.keyCode ) {
[117] Fix | Delete
constrainTabbing( e );
[118] Fix | Delete
}
[119] Fix | Delete
}, false );
[120] Fix | Delete
[121] Fix | Delete
function constrainTabbing( e ) {
[122] Fix | Delete
// Need to re-get the selected tab each time.
[123] Fix | Delete
var firstFocusable = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );
[124] Fix | Delete
[125] Fix | Delete
if ( share_dialog_close === e.target && ! e.shiftKey ) {
[126] Fix | Delete
firstFocusable.focus();
[127] Fix | Delete
e.preventDefault();
[128] Fix | Delete
} else if ( firstFocusable === e.target && e.shiftKey ) {
[129] Fix | Delete
share_dialog_close.focus();
[130] Fix | Delete
e.preventDefault();
[131] Fix | Delete
}
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if ( window.self === window.top ) {
[135] Fix | Delete
return;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
// Send this document's height to the parent (embedding) site.
[139] Fix | Delete
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
[140] Fix | Delete
[141] Fix | Delete
// Send the document's height again after the featured image has been loaded.
[142] Fix | Delete
if ( featured_image ) {
[143] Fix | Delete
featured_image.addEventListener( 'load', function() {
[144] Fix | Delete
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
[145] Fix | Delete
} );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Detect clicks to external (_top) links.
[150] Fix | Delete
*/
[151] Fix | Delete
function linkClickHandler( e ) {
[152] Fix | Delete
var target = e.target,
[153] Fix | Delete
href;
[154] Fix | Delete
if ( target.hasAttribute( 'href' ) ) {
[155] Fix | Delete
href = target.getAttribute( 'href' );
[156] Fix | Delete
} else {
[157] Fix | Delete
href = target.parentElement.getAttribute( 'href' );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
// Only catch clicks from the primary mouse button, without any modifiers.
[161] Fix | Delete
if ( event.altKey || event.ctrlKey || event.metaKey || event.shiftKey ) {
[162] Fix | Delete
return;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
// Send link target to the parent (embedding) site.
[166] Fix | Delete
if ( href ) {
[167] Fix | Delete
sendEmbedMessage( 'link', href );
[168] Fix | Delete
e.preventDefault();
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
document.addEventListener( 'click', linkClickHandler );
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* Iframe resize handler.
[177] Fix | Delete
*/
[178] Fix | Delete
function onResize() {
[179] Fix | Delete
if ( window.self === window.top ) {
[180] Fix | Delete
return;
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
clearTimeout( resizing );
[184] Fix | Delete
[185] Fix | Delete
resizing = setTimeout( function () {
[186] Fix | Delete
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
[187] Fix | Delete
}, 100 );
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Re-get the secret when it was added later on.
[192] Fix | Delete
*/
[193] Fix | Delete
function getSecret() {
[194] Fix | Delete
if ( window.self === window.top || !!secret ) {
[195] Fix | Delete
return;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
secret = window.location.hash.replace( /.*secret=([\d\w]{10}).*/, '$1' );
[199] Fix | Delete
[200] Fix | Delete
clearTimeout( secretTimeout );
[201] Fix | Delete
[202] Fix | Delete
secretTimeout = setTimeout( function () {
[203] Fix | Delete
getSecret();
[204] Fix | Delete
}, 100 );
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
if ( supportedBrowser ) {
[208] Fix | Delete
getSecret();
[209] Fix | Delete
document.documentElement.className = document.documentElement.className.replace( /\bno-js\b/, '' ) + ' js';
[210] Fix | Delete
document.addEventListener( 'DOMContentLoaded', onLoad, false );
[211] Fix | Delete
window.addEventListener( 'load', onLoad, false );
[212] Fix | Delete
window.addEventListener( 'resize', onResize, false );
[213] Fix | Delete
}
[214] Fix | Delete
})( window, document );
[215] Fix | Delete
[216] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function