2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-includes/js/wp-custom-header.js
|
|
|
|
*/
|
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/* global YT */
|
2016-11-17 04:04:31 -05:00
|
|
|
(function( window, settings ) {
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
var NativeHandler, YouTubeHandler;
|
|
|
|
|
2017-09-08 14:42:49 -04:00
|
|
|
/** @namespace wp */
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
window.wp = window.wp || {};
|
|
|
|
|
|
|
|
// Fail gracefully in unsupported browsers.
|
2016-10-31 02:17:29 -04:00
|
|
|
if ( ! ( 'addEventListener' in window ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Trigger an event.
|
|
|
|
*
|
|
|
|
* @param {Element} target HTML element to dispatch the event on.
|
|
|
|
* @param {string} name Event name.
|
|
|
|
*/
|
|
|
|
function trigger( target, name ) {
|
|
|
|
var evt;
|
|
|
|
|
|
|
|
if ( 'function' === typeof window.Event ) {
|
|
|
|
evt = new Event( name );
|
|
|
|
} else {
|
|
|
|
evt = document.createEvent( 'Event' );
|
|
|
|
evt.initEvent( name, true, true );
|
|
|
|
}
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
target.dispatchEvent( evt );
|
|
|
|
}
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Create a custom header instance.
|
|
|
|
*
|
2017-09-08 14:42:49 -04:00
|
|
|
* @memberOf wp
|
|
|
|
*
|
|
|
|
* @class
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
*/
|
|
|
|
function CustomHeader() {
|
|
|
|
this.handlers = {
|
|
|
|
nativeVideo: new NativeHandler(),
|
|
|
|
youtube: new YouTubeHandler()
|
|
|
|
};
|
|
|
|
}
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
CustomHeader.prototype = {
|
|
|
|
/**
|
|
|
|
* Initalize the custom header.
|
|
|
|
*
|
|
|
|
* If the environment supports video, loops through registered handlers
|
|
|
|
* until one is found that can handle the video.
|
|
|
|
*/
|
|
|
|
initialize: function() {
|
|
|
|
if ( this.supportsVideo() ) {
|
|
|
|
for ( var id in this.handlers ) {
|
|
|
|
var handler = this.handlers[ id ];
|
2016-11-02 21:21:28 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
if ( 'test' in handler && handler.test( settings ) ) {
|
|
|
|
this.activeHandler = handler.initialize.call( handler, settings );
|
2016-11-02 21:21:28 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
// Dispatch custom event when the video is loaded.
|
|
|
|
trigger( document, 'wp-custom-header-video-loaded' );
|
2016-10-27 17:51:31 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
},
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Determines if the current environment supports video.
|
|
|
|
*
|
|
|
|
* Themes and plugins can override this method to change the criteria.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
supportsVideo: function() {
|
2016-10-27 17:51:31 -04:00
|
|
|
// Don't load video on small screens. @todo: consider bandwidth and other factors.
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) {
|
2016-10-27 17:51:31 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base handler for custom handlers to extend.
|
|
|
|
*
|
|
|
|
* @type {BaseHandler}
|
|
|
|
*/
|
|
|
|
BaseVideoHandler: BaseHandler
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a video handler instance.
|
|
|
|
*
|
2017-09-08 14:42:49 -04:00
|
|
|
* @memberOf wp
|
|
|
|
*
|
|
|
|
* @class
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
*/
|
|
|
|
function BaseHandler() {}
|
|
|
|
|
|
|
|
BaseHandler.prototype = {
|
|
|
|
/**
|
|
|
|
* Initialize the video handler.
|
|
|
|
*
|
|
|
|
* @param {object} settings Video settings.
|
|
|
|
*/
|
|
|
|
initialize: function( settings ) {
|
|
|
|
var handler = this,
|
|
|
|
button = document.createElement( 'button' );
|
|
|
|
|
|
|
|
this.settings = settings;
|
2016-11-17 04:04:31 -05:00
|
|
|
this.container = document.getElementById( 'wp-custom-header' );
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
this.button = button;
|
|
|
|
|
|
|
|
button.setAttribute( 'type', 'button' );
|
|
|
|
button.setAttribute( 'id', 'wp-custom-header-video-button' );
|
|
|
|
button.setAttribute( 'class', 'wp-custom-header-video-button wp-custom-header-video-play' );
|
|
|
|
button.innerHTML = settings.l10n.play;
|
|
|
|
|
|
|
|
// Toggle video playback when the button is clicked.
|
|
|
|
button.addEventListener( 'click', function() {
|
|
|
|
if ( handler.isPaused() ) {
|
|
|
|
handler.play();
|
|
|
|
} else {
|
|
|
|
handler.pause();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update the button class and text when the video state changes.
|
|
|
|
this.container.addEventListener( 'play', function() {
|
|
|
|
button.className = 'wp-custom-header-video-button wp-custom-header-video-play';
|
|
|
|
button.innerHTML = settings.l10n.pause;
|
|
|
|
if ( 'a11y' in window.wp ) {
|
|
|
|
window.wp.a11y.speak( settings.l10n.playSpeak);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.container.addEventListener( 'pause', function() {
|
|
|
|
button.className = 'wp-custom-header-video-button wp-custom-header-video-pause';
|
|
|
|
button.innerHTML = settings.l10n.play;
|
|
|
|
if ( 'a11y' in window.wp ) {
|
|
|
|
window.wp.a11y.speak( settings.l10n.pauseSpeak);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.ready();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ready method called after a handler is initialized.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
ready: function() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the video is paused.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isPaused: function() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause the video.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
pause: function() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the video.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
play: function() {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append a video node to the header container.
|
|
|
|
*
|
|
|
|
* @param {Element} node HTML element.
|
|
|
|
*/
|
|
|
|
setVideo: function( node ) {
|
|
|
|
var editShortcutNode,
|
|
|
|
editShortcut = this.container.getElementsByClassName( 'customize-partial-edit-shortcut' );
|
|
|
|
|
|
|
|
if ( editShortcut.length ) {
|
|
|
|
editShortcutNode = this.container.removeChild( editShortcut[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
this.container.innerHTML = '';
|
|
|
|
this.container.appendChild( node );
|
|
|
|
|
|
|
|
if ( editShortcutNode ) {
|
|
|
|
this.container.appendChild( editShortcutNode );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the video controls.
|
|
|
|
*
|
|
|
|
* Appends a play/pause button to header container.
|
|
|
|
*/
|
|
|
|
showControls: function() {
|
|
|
|
if ( ! this.container.contains( this.button ) ) {
|
|
|
|
this.container.appendChild( this.button );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the handler can process a video.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @param {object} settings Video settings.
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
test: function() {
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trigger an event on the header container.
|
|
|
|
*
|
|
|
|
* @param {string} name Event name.
|
|
|
|
*/
|
|
|
|
trigger: function( name ) {
|
|
|
|
trigger( this.container, name );
|
2016-10-27 17:51:31 -04:00
|
|
|
}
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
};
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Create a custom handler.
|
|
|
|
*
|
2017-09-08 14:42:49 -04:00
|
|
|
* @memberOf wp
|
|
|
|
*
|
2016-11-17 04:04:31 -05:00
|
|
|
* @param {object} protoProps Properties to apply to the prototype.
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
* @return CustomHandler The subclass.
|
|
|
|
*/
|
|
|
|
BaseHandler.extend = function( protoProps ) {
|
|
|
|
var prop;
|
|
|
|
|
|
|
|
function CustomHandler() {
|
|
|
|
var result = BaseHandler.apply( this, arguments );
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomHandler.prototype = Object.create( BaseHandler.prototype );
|
|
|
|
CustomHandler.prototype.constructor = CustomHandler;
|
|
|
|
|
|
|
|
for ( prop in protoProps ) {
|
|
|
|
CustomHandler.prototype[ prop ] = protoProps[ prop ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return CustomHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Native video handler.
|
|
|
|
*
|
2017-09-08 14:42:49 -04:00
|
|
|
* @memberOf wp
|
|
|
|
*
|
|
|
|
* @class
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
*/
|
2017-09-08 14:42:49 -04:00
|
|
|
NativeHandler = BaseHandler.extend(/** @lends wp.NativeHandler.prototype */{
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Whether the native handler supports a video.
|
|
|
|
*
|
|
|
|
* @param {object} settings Video settings.
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
test: function( settings ) {
|
|
|
|
var video = document.createElement( 'video' );
|
|
|
|
return video.canPlayType( settings.mimeType );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up a native video element.
|
|
|
|
*/
|
|
|
|
ready: function() {
|
|
|
|
var handler = this,
|
|
|
|
video = document.createElement( 'video' );
|
|
|
|
|
|
|
|
video.id = 'wp-custom-header-video';
|
|
|
|
video.autoplay = 'autoplay';
|
|
|
|
video.loop = 'loop';
|
|
|
|
video.muted = 'muted';
|
|
|
|
video.width = this.settings.width;
|
|
|
|
video.height = this.settings.height;
|
|
|
|
|
|
|
|
video.addEventListener( 'play', function() {
|
|
|
|
handler.trigger( 'play' );
|
|
|
|
});
|
|
|
|
|
|
|
|
video.addEventListener( 'pause', function() {
|
|
|
|
handler.trigger( 'pause' );
|
|
|
|
});
|
|
|
|
|
|
|
|
video.addEventListener( 'canplay', function() {
|
|
|
|
handler.showControls();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.video = video;
|
|
|
|
handler.setVideo( video );
|
|
|
|
video.src = this.settings.videoUrl;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the video is paused.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isPaused: function() {
|
|
|
|
return this.video.paused;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause the video.
|
|
|
|
*/
|
|
|
|
pause: function() {
|
|
|
|
this.video.pause();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the video.
|
|
|
|
*/
|
|
|
|
play: function() {
|
|
|
|
this.video.play();
|
|
|
|
}
|
|
|
|
});
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* YouTube video handler.
|
|
|
|
*
|
2017-09-08 14:42:49 -04:00
|
|
|
* @memberOf wp
|
|
|
|
*
|
|
|
|
* @class wp.YouTubeHandler
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
*/
|
2017-09-08 14:42:49 -04:00
|
|
|
YouTubeHandler = BaseHandler.extend(/** @lends wp.YouTubeHandler.prototype */{
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Whether the handler supports a video.
|
|
|
|
*
|
|
|
|
* @param {object} settings Video settings.
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
test: function( settings ) {
|
|
|
|
return 'video/x-youtube' === settings.mimeType;
|
|
|
|
},
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Set up a YouTube iframe.
|
|
|
|
*
|
|
|
|
* Loads the YouTube IFrame API if the 'YT' global doesn't exist.
|
|
|
|
*/
|
|
|
|
ready: function() {
|
|
|
|
var handler = this;
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
if ( 'YT' in window ) {
|
|
|
|
YT.ready( handler.loadVideo.bind( handler ) );
|
2016-10-27 17:51:31 -04:00
|
|
|
} else {
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
var tag = document.createElement( 'script' );
|
|
|
|
tag.src = 'https://www.youtube.com/iframe_api';
|
|
|
|
tag.onload = function () {
|
|
|
|
YT.ready( handler.loadVideo.bind( handler ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementsByTagName( 'head' )[0].appendChild( tag );
|
2016-10-27 17:51:31 -04:00
|
|
|
}
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
},
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Load a YouTube video.
|
|
|
|
*/
|
|
|
|
loadVideo: function() {
|
|
|
|
var handler = this,
|
|
|
|
video = document.createElement( 'div' ),
|
|
|
|
// @link http://stackoverflow.com/a/27728417
|
|
|
|
VIDEO_ID_REGEX = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/;
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
video.id = 'wp-custom-header-video';
|
|
|
|
handler.setVideo( video );
|
|
|
|
|
|
|
|
handler.player = new YT.Player( video, {
|
|
|
|
height: this.settings.height,
|
|
|
|
width: this.settings.width,
|
|
|
|
videoId: this.settings.videoUrl.match( VIDEO_ID_REGEX )[1],
|
|
|
|
events: {
|
|
|
|
onReady: function( e ) {
|
|
|
|
e.target.mute();
|
|
|
|
handler.showControls();
|
2016-10-27 17:51:31 -04:00
|
|
|
},
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
onStateChange: function( e ) {
|
|
|
|
if ( YT.PlayerState.PLAYING === e.data ) {
|
|
|
|
handler.trigger( 'play' );
|
|
|
|
} else if ( YT.PlayerState.PAUSED === e.data ) {
|
|
|
|
handler.trigger( 'pause' );
|
|
|
|
} else if ( YT.PlayerState.ENDED === e.data ) {
|
|
|
|
e.target.playVideo();
|
|
|
|
}
|
2016-10-27 17:51:31 -04:00
|
|
|
}
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
},
|
|
|
|
playerVars: {
|
|
|
|
autoplay: 1,
|
|
|
|
controls: 0,
|
|
|
|
disablekb: 1,
|
|
|
|
fs: 0,
|
|
|
|
iv_load_policy: 3,
|
|
|
|
loop: 1,
|
|
|
|
modestbranding: 1,
|
|
|
|
playsinline: 1,
|
|
|
|
rel: 0,
|
|
|
|
showinfo: 0
|
|
|
|
}
|
2016-10-27 17:51:31 -04:00
|
|
|
});
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
},
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
/**
|
|
|
|
* Whether the video is paused.
|
|
|
|
*
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isPaused: function() {
|
|
|
|
return YT.PlayerState.PAUSED === this.player.getPlayerState();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause the video.
|
|
|
|
*/
|
|
|
|
pause: function() {
|
|
|
|
this.player.pauseVideo();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the video.
|
|
|
|
*/
|
|
|
|
play: function() {
|
|
|
|
this.player.playVideo();
|
2016-10-27 17:51:31 -04:00
|
|
|
}
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
});
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
// Initialize the custom header when the DOM is ready.
|
|
|
|
window.wp.customHeader = new CustomHeader();
|
|
|
|
document.addEventListener( 'DOMContentLoaded', window.wp.customHeader.initialize.bind( window.wp.customHeader ), false );
|
2016-10-27 17:51:31 -04:00
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
// Selective refresh support in the Customizer.
|
2016-10-27 17:51:31 -04:00
|
|
|
if ( 'customize' in window.wp ) {
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
window.wp.customize.selectiveRefresh.bind( 'render-partials-response', function( response ) {
|
2016-10-27 17:51:31 -04:00
|
|
|
if ( 'custom_header_settings' in response ) {
|
|
|
|
settings = response.custom_header_settings;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.
This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.
Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272
git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:26:31 -05:00
|
|
|
window.wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) {
|
2016-10-27 17:51:31 -04:00
|
|
|
if ( 'custom_header' === placement.partial.id ) {
|
|
|
|
window.wp.customHeader.initialize();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-02 21:21:28 -04:00
|
|
|
})( window, window._wpCustomHeaderSettings || {} );
|