Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquery-keyboard-focus

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-keyboard-focus - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

bower.json
{
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc