jquery-keyboard-focus
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "jquery-keyboard-focus", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "Michelle Bu <michelle@michellebu.com>" |
@@ -28,5 +28,11 @@ (function($) { | ||
$.fn.offKeyboardFocus = function() { | ||
$(document).off('.keyboardFocus'); | ||
this.off('.keyboardFocus'); | ||
}; | ||
// Whether or not global listeners are set up. | ||
var globalListeners = false; | ||
// This needs to be `true` when we start, to catch the first keydown. | ||
var lastKeyPress = true; | ||
function bindKeyboardFocusEvents($el, elementClass, classNames) { | ||
@@ -36,10 +42,14 @@ classNames = classNames.replace(/\./g, ''); | ||
var $target; | ||
// This needs to be `true` when we start, to catch the first tab. | ||
var lastKeyPress = true; | ||
$el.on('keydown.keyboardFocus', elementClass, function(e) { | ||
lastKeyPress = true; | ||
}); | ||
if (!globalListeners) { | ||
$(document).on('keydown.keyboardFocus', function(e) { | ||
lastKeyPress = true; | ||
}); | ||
$(document).on('mousedown.keyboardFocus', function(e) { | ||
lastKeyPress = false; | ||
}); | ||
globalListeners = true; | ||
} | ||
$el.on('mousedown.keyboardFocus', elementClass, function(e) { | ||
lastKeyPress = false; | ||
$(e.target).removeClass(classNames); | ||
@@ -46,0 +56,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(a){function b(b,c,d){d=d.replace(/\./g,"");var e,f=!0;b.on("keydown.keyboardFocus",c,function(a){f=!0}),b.on("mousedown.keyboardFocus",c,function(b){f=!1,a(b.target).removeClass(d)}),b.on("focus.keyboardFocus",c,function(b){f&&(e=a(b.target),e.addClass(d),e.trigger("keyboardFocus"))}),b.on("blur.keyboardFocus",c,function(b){e=a(b.target),e.removeClass(d),f&&e.trigger("keyboardBlur")})}a.keyboardFocus=function(c){if(!c)throw new Error("Please pass a mapping of selectors to focus class names to `keyboardFocus`.");for(var d in c)c.hasOwnProperty(d)&&b(a(document),d,c[d])},a.offKeyboardFocus=function(){a(document).off(".keyboardFocus")},a.fn.keyboardFocus=function(a){if(!a)throw new Error("Please pass your focus class names into `$(...).keyboardFocus(...)`.");return b(this,null,a),this},a.fn.offKeyboardFocus=function(){this.off(".keyboardFocus")}}(jQuery); | ||
!function(a){function b(b,e,f){f=f.replace(/\./g,"");var g;c||(a(document).on("keydown.keyboardFocus",function(a){d=!0}),a(document).on("mousedown.keyboardFocus",function(a){d=!1}),c=!0),b.on("mousedown.keyboardFocus",e,function(b){a(b.target).removeClass(f)}),b.on("focus.keyboardFocus",e,function(b){d&&(g=a(b.target),g.addClass(f),g.trigger("keyboardFocus"))}),b.on("blur.keyboardFocus",e,function(b){g=a(b.target),g.removeClass(f),d&&g.trigger("keyboardBlur")})}a.keyboardFocus=function(c){if(!c)throw new Error("Please pass a mapping of selectors to focus class names to `keyboardFocus`.");for(var d in c)c.hasOwnProperty(d)&&b(a(document),d,c[d])},a.offKeyboardFocus=function(){a(document).off(".keyboardFocus")},a.fn.keyboardFocus=function(a){if(!a)throw new Error("Please pass your focus class names into `$(...).keyboardFocus(...)`.");return b(this,null,a),this},a.fn.offKeyboardFocus=function(){a(document).off(".keyboardFocus"),this.off(".keyboardFocus")};var c=!1,d=!0}(jQuery); |
{ | ||
"name": "jquery-keyboard-focus", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Adds the provided classes to an element when it is focused by keyboard interactions (and not mouse interactions).", | ||
@@ -5,0 +5,0 @@ "main": "jquery.keyboard-focus.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10482
110