Skip to content

Commit 36d425e

Browse files
committed
Docs: Document functions within embed-template.js.
See #65860. git-svn-id: https://develop.svn.wordpress.org/trunk@63403 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1e78133 commit 36d425e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎src/js/_enqueues/lib/embed-template.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
/**
22
* @output wp-includes/js/wp-embed-template.js
33
*/
4+
5+
/**
6+
* IIFE setup function.
7+
*
8+
* @param {Window} window Global window object.
9+
* @param {Document} document Global document object.
10+
*/
411
(function ( window, document ) {
512
'use strict';
613

@@ -25,6 +32,12 @@
2532
sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
2633
}
2734

35+
/**
36+
* Runs on DomContentLoaded and load event.
37+
*
38+
* Exits early on the load event if the earlier event has
39+
* successfully fired.
40+
*/
2841
function onLoad() {
2942
if ( loaded ) {
3043
return;
@@ -47,12 +60,18 @@
4760
}
4861
}
4962

63+
/**
64+
* Open share dialog within embed iframe.
65+
*/
5066
function openSharingDialog() {
5167
share_dialog.className = share_dialog.className.replace( 'hidden', '' );
5268
// Initial focus should go on the currently selected tab in the dialog.
5369
document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' ).focus();
5470
}
5571

72+
/**
73+
* Close share dialog within embed iframe.
74+
*/
5675
function closeSharingDialog() {
5776
share_dialog.className += ' hidden';
5877
document.querySelector( '.wp-embed-share-dialog-open' ).focus();
@@ -70,6 +89,11 @@
7089
} );
7190
}
7291

92+
/**
93+
* Click event handler for share button.
94+
*
95+
* @param {MouseEvent} event Event handler.
96+
*/
7397
function shareClickHandler( event ) {
7498
var currentTab = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );
7599
currentTab.setAttribute( 'aria-selected', 'false' );
@@ -79,6 +103,12 @@
79103
document.querySelector( '#' + event.target.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'false' );
80104
}
81105

106+
/**
107+
* Keyboard event handler for share button.
108+
*
109+
* @param {KeyboardEvent} event Event handler.
110+
* @return {boolean|void} Returns false if default action is to be prevented.
111+
*/
82112
function shareKeyHandler( event ) {
83113
var target = event.target,
84114
previousSibling = target.parentElement.previousElementSibling,
@@ -127,6 +157,11 @@
127157
}
128158
}, false );
129159

160+
/**
161+
* Constrain tabbing to share dialog when open.
162+
*
163+
* @param {KeyboardEvent} event Event object.
164+
*/
130165
function constrainTabbing( event ) {
131166
// Need to re-get the selected tab each time.
132167
var firstFocusable = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );

0 commit comments

Comments
 (0)