Ticket #39239: 39239.diff
File 39239.diff, 3.1 KB (added by , 8 years ago) |
---|
-
src/wp-includes/js/wp-custom-header.js
1 1 /* global YT */ 2 2 (function( window, settings ) { 3 3 4 var NativeHandler, YouTubeHandler; 4 var NativeHandler, YouTubeHandler, 5 storage = {}; 5 6 6 7 window.wp = window.wp || {}; 7 8 … … 49 50 * until one is found that can handle the video. 50 51 */ 51 52 initialize: function() { 53 settings.autoplay = 'no' !== storage['wp-custom-header-video-autoplay']; 54 52 55 if ( this.supportsVideo() ) { 53 56 for ( var id in this.handlers ) { 54 57 var handler = this.handlers[ id ]; … … 130 133 if ( 'a11y' in window.wp ) { 131 134 window.wp.a11y.speak( settings.l10n.playSpeak); 132 135 } 136 storage['wp-custom-header-video-autoplay'] = 'yes'; 133 137 }); 134 138 135 139 this.container.addEventListener( 'pause', function() { … … 138 142 if ( 'a11y' in window.wp ) { 139 143 window.wp.a11y.speak( settings.l10n.pauseSpeak); 140 144 } 145 storage['wp-custom-header-video-autoplay'] = 'no'; 141 146 }); 142 147 143 148 this.ready(); … … 274 279 video = document.createElement( 'video' ); 275 280 276 281 video.id = 'wp-custom-header-video'; 277 video.autoplay = 'autoplay';278 282 video.loop = 'loop'; 279 283 video.muted = 'muted'; 280 284 video.width = this.settings.width; 281 285 video.height = this.settings.height; 282 286 287 if ( this.settings.autoplay ) { 288 video.autoplay = 'autoplay'; 289 } 290 283 291 video.addEventListener( 'play', function() { 284 292 handler.trigger( 'play' ); 285 293 }); … … 327 335 * @class YouTubeHandler 328 336 */ 329 337 YouTubeHandler = BaseHandler.extend({ 338 playerVars: { 339 autoplay: 1, 340 controls: 0, 341 disablekb: 1, 342 fs: 0, 343 iv_load_policy: 3, 344 loop: 1, 345 modestbranding: 1, 346 playsinline: 1, 347 rel: 0, 348 showinfo: 0 349 }, 350 330 351 /** 331 352 * Whether the handler supports a video. 332 353 * … … 370 391 video.id = 'wp-custom-header-video'; 371 392 handler.setVideo( video ); 372 393 394 handler.playerVars.autoplay = this.settings.autoplay; 395 373 396 handler.player = new YT.Player( video, { 374 397 height: this.settings.height, 375 398 width: this.settings.width, … … 389 412 } 390 413 } 391 414 }, 392 playerVars: { 393 autoplay: 1, 394 controls: 0, 395 disablekb: 1, 396 fs: 0, 397 iv_load_policy: 3, 398 loop: 1, 399 modestbranding: 1, 400 playsinline: 1, 401 rel: 0, 402 showinfo: 0 403 } 415 playerVars: handler.playerVars 404 416 }); 405 417 }, 406 418 … … 428 440 } 429 441 }); 430 442 443 /** 444 * Whether local storage is avaialble. 445 * 446 * @return {boolean} 447 */ 448 function checkStorage() { 449 var key = 'wp-custom-header'; 450 try { 451 window.localStorage.setItem( key, key ); 452 window.localStorage.removeItem( key ); 453 return true; 454 } catch( e ) { 455 return false; 456 } 457 } 458 459 if ( checkStorage() ) { 460 storage = window.localStorage; 461 } 462 431 463 // Initialize the custom header when the DOM is ready. 432 464 window.wp.customHeader = new CustomHeader(); 433 465 document.addEventListener( 'DOMContentLoaded', window.wp.customHeader.initialize.bind( window.wp.customHeader ), false );