A Flight utility to manage component focus. Useful when determining which component should responsd to browser events such as keypress, gestures, etc.
bower install --save flight-focus
You need to use both the controller and the mixin. It is not possible to have more than one focus controller per page.
var focusController = require('focus-controller/lib/focus_controller');
focusController.attachTo(document);
var aComponentWithFocus = defineComponent(aComponent, withFocus);
function aComponent() {
this.after('initialize', function () {
// init key event
this.on('keydown', this.handleKeydown);
// request focus
this.focusRequest();
});
this.handleKeydown = function (event) {
if (this.hasFocus) {
// do something
}
};
}
Development of this component requires Bower, and preferably Karma to be globally installed:
npm install -g bower karma
Then install the Node.js and client-side dependencies by running the following commands in the repo's root directory.
npm install
bower install
To continuously run the tests in Chrome and Firefox during development, just run:
karma start
Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.