CoreFiles by mySites.guru
focus-manager.js44 lines, 959 bytes, from wordpress-4.2-beta4.zip
Raw History Compare with 4.2-beta3
md5
3dbe8894068fd828d723d1e61b78ea65
sha1
242dc9c39cfb494af1a79791e05d5b84a64a5ff0
sha256
24c4527cbbfca8065cfd5fb6c64cdb638c559aeb463a30d5862956410e187f7f
/**
 * wp.media.view.FocusManager
 *
 * @class
 * @augments wp.media.View
 * @augments wp.Backbone.View
 * @augments Backbone.View
 */
var FocusManager = wp.media.View.extend({

	events: {
		'keydown': 'constrainTabbing'
	},

	focus: function() { // Reset focus on first left menu item
		this.$('.media-menu-item').first().focus();
	},
	/**
	 * @param {Object} event
	 */
	constrainTabbing: function( event ) {
		var tabbables;

		// Look for the tab key.
		if ( 9 !== event.keyCode ) {
			return;
		}

		// Skip the file input added by Plupload.
		tabbables = this.$( ':tabbable' ).not( '.moxie-shim input[type="file"]' );

		// Keep tab focus within media modal while it's open
		if ( tabbables.last()[0] === event.target && ! event.shiftKey ) {
			tabbables.first().focus();
			return false;
		} else if ( tabbables.first()[0] === event.target && event.shiftKey ) {
			tabbables.last().focus();
			return false;
		}
	}

});

module.exports = FocusManager;

No other release has this exact content. See every version of this file.