jquery-focus-exit v1.0.1
jquery-focus-exit
Triggers 'focusExit' event when keyboard focus moves to a non-descendant of widget. This type of behaviour is especially desirable for non-modal overlays.
JavaScript's native 'focusout' event fires when any descendant of a given element loses keyboard focus, even if another descendant immediately gains focus. This type of behaviour is not desirable for non-modal overlays.
// init plugin
$(collection).focusExit();
// handle event
$(collection).on('focusExit', function(e, data) {
console.log(data.lostFocus, data.gainedFocus);
})Install
npm install jquery-focus-exitDevelopment
Run npm start to run the demo page using browser-sync. Run npm run tdd for test driven development. All tests are located in test.js.
Useful NPM scripts:
npm startruns demo page on local server and re-syncs browser on source file changenpm testruns tests & generates reports (see reports section below)npm run tddtest driven development: watches code and re-tests after any changenpm run lintlints code and reports to jshint.txtnpm run buildcleans, lints, tests and minifies (called onnpm prepublishhook)
Execute npm run to view all available CLI scripts.
Reports
Each test run will generate the following reports:
/test_reports/coveragecontains Istanbul code coverage report/test_reports/htmlcontains HTML test report/test_reports/junitcontains JUnit test report
CI Build
https://travis-ci.org/makeup-jquery/jquery-focus-exit
Code Coverage
https://coveralls.io/github/makeup-jquery/jquery-focus-exit?branch=master