forked from marklagendijk/jquery.tabbable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.tabbable.min.js
1 lines (1 loc) · 1.15 KB
/
jquery.tabbable.min.js
1
!function(e){"use strict";function t(t){var n=e(t),a=e(":focus"),r=0;if(1===a.length){var i=n.index(a);i+1<n.length&&(r=i+1)}n.eq(r).focus()}function n(t){var n=e(t),a=e(":focus"),r=n.length-1;if(1===a.length){var i=n.index(a);i>0&&(r=i-1)}n.eq(r).focus()}function a(t){function n(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a,r,i,u=t.nodeName.toLowerCase(),o=!isNaN(e.attr(t,"tabindex"));return"area"===u?(a=t.parentNode,r=a.name,t.href&&r&&"map"===a.nodeName.toLowerCase()?(i=e("img[usemap=#"+r+"]")[0],!!i&&n(i)):!1):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||o:o)&&n(t)}e.focusNext=function(){t(":focusable")},e.focusPrev=function(){n(":focusable")},e.tabNext=function(){t(":tabbable")},e.tabPrev=function(){n(":tabbable")},e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,a){return!!e.data(t,a[3])},focusable:function(t){return a(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&a(t,!r)}})}(jQuery);