wp/wp-includes/js/wp-custom-header.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    48 		};
    48 		};
    49 	}
    49 	}
    50 
    50 
    51 	CustomHeader.prototype = {
    51 	CustomHeader.prototype = {
    52 		/**
    52 		/**
    53 		 * Initalize the custom header.
    53 		 * Initialize the custom header.
    54 		 *
    54 		 *
    55 		 * If the environment supports video, loops through registered handlers
    55 		 * If the environment supports video, loops through registered handlers
    56 		 * until one is found that can handle the video.
    56 		 * until one is found that can handle the video.
    57 		 */
    57 		 */
    58 		initialize: function() {
    58 		initialize: function() {
    77 		 * Themes and plugins can override this method to change the criteria.
    77 		 * Themes and plugins can override this method to change the criteria.
    78 		 *
    78 		 *
    79 		 * @return {boolean}
    79 		 * @return {boolean}
    80 		 */
    80 		 */
    81 		supportsVideo: function() {
    81 		supportsVideo: function() {
    82 			// Don't load video on small screens. @todo: consider bandwidth and other factors.
    82 			// Don't load video on small screens. @todo Consider bandwidth and other factors.
    83 			if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) {
    83 			if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) {
    84 				return false;
    84 				return false;
    85 			}
    85 			}
    86 
    86 
    87 			return true;
    87 			return true;
   106 
   106 
   107 	BaseHandler.prototype = {
   107 	BaseHandler.prototype = {
   108 		/**
   108 		/**
   109 		 * Initialize the video handler.
   109 		 * Initialize the video handler.
   110 		 *
   110 		 *
   111 		 * @param {object} settings Video settings.
   111 		 * @param {Object} settings Video settings.
   112 		 */
   112 		 */
   113 		initialize: function( settings ) {
   113 		initialize: function( settings ) {
   114 			var handler = this,
   114 			var handler = this,
   115 				button = document.createElement( 'button' );
   115 				button = document.createElement( 'button' );
   116 
   116 
   215 
   215 
   216 		/**
   216 		/**
   217 		 * Whether the handler can process a video.
   217 		 * Whether the handler can process a video.
   218 		 *
   218 		 *
   219 		 * @abstract
   219 		 * @abstract
   220 		 * @param {object} settings Video settings.
   220 		 * @param {Object} settings Video settings.
   221 		 * @return {boolean}
   221 		 * @return {boolean}
   222 		 */
   222 		 */
   223 		test: function() {
   223 		test: function() {
   224 			return false;
   224 			return false;
   225 		},
   225 		},
   237 	/**
   237 	/**
   238 	 * Create a custom handler.
   238 	 * Create a custom handler.
   239 	 *
   239 	 *
   240 	 * @memberOf wp
   240 	 * @memberOf wp
   241 	 *
   241 	 *
   242 	 * @param {object} protoProps Properties to apply to the prototype.
   242 	 * @param {Object} protoProps Properties to apply to the prototype.
   243 	 * @return CustomHandler The subclass.
   243 	 * @return CustomHandler The subclass.
   244 	 */
   244 	 */
   245 	BaseHandler.extend = function( protoProps ) {
   245 	BaseHandler.extend = function( protoProps ) {
   246 		var prop;
   246 		var prop;
   247 
   247 
   269 	 */
   269 	 */
   270 	NativeHandler = BaseHandler.extend(/** @lends wp.NativeHandler.prototype */{
   270 	NativeHandler = BaseHandler.extend(/** @lends wp.NativeHandler.prototype */{
   271 		/**
   271 		/**
   272 		 * Whether the native handler supports a video.
   272 		 * Whether the native handler supports a video.
   273 		 *
   273 		 *
   274 		 * @param {object} settings Video settings.
   274 		 * @param {Object} settings Video settings.
   275 		 * @return {boolean}
   275 		 * @return {boolean}
   276 		 */
   276 		 */
   277 		test: function( settings ) {
   277 		test: function( settings ) {
   278 			var video = document.createElement( 'video' );
   278 			var video = document.createElement( 'video' );
   279 			return video.canPlayType( settings.mimeType );
   279 			return video.canPlayType( settings.mimeType );
   343 	 */
   343 	 */
   344 	YouTubeHandler = BaseHandler.extend(/** @lends wp.YouTubeHandler.prototype */{
   344 	YouTubeHandler = BaseHandler.extend(/** @lends wp.YouTubeHandler.prototype */{
   345 		/**
   345 		/**
   346 		 * Whether the handler supports a video.
   346 		 * Whether the handler supports a video.
   347 		 *
   347 		 *
   348 		 * @param {object} settings Video settings.
   348 		 * @param {Object} settings Video settings.
   349 		 * @return {boolean}
   349 		 * @return {boolean}
   350 		 */
   350 		 */
   351 		test: function( settings ) {
   351 		test: function( settings ) {
   352 			return 'video/x-youtube' === settings.mimeType;
   352 			return 'video/x-youtube' === settings.mimeType;
   353 		},
   353 		},