All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.emulatetab.joelpurra.index.min.js Maven / Gradle / Ivy

The newest version!
var JoelPurra=JoelPurra||{};(function(document,$,namespace,pluginName){"use strict";var eventNamespace="."+pluginName,focusable=":input, a[href]",lastFocusedElement=null,internal={escapeSelectorName:function(str){return str.replace(/(!"#$%&'\(\)\*\+,\.\/:;<=>\?@\[\]^`\{\|\}~)/g,"\\\\$1")},findNextFocusable:function($from,offset){var $focusable=$(focusable).not(":disabled").not(":hidden").not("a[href]:empty");if($from[0].tagName==="INPUT"&&$from[0].type==="radio"&&$from[0].name!==""){var name=internal.escapeSelectorName($from[0].name);$focusable=$focusable.not("input[type=radio][name="+name+"]").add($from)}var currentIndex=$focusable.index($from);var nextIndex=(currentIndex+offset)%$focusable.length;if(nextIndex<=-1){nextIndex=$focusable.length+nextIndex}var $next=$focusable.eq(nextIndex);return $next},focusInElement:function(event){lastFocusedElement=event.target},tryGetElementAsNonEmptyJQueryObject:function(selector){try{var $element=$(selector);if(!!$element&&$element.size()!==0){return $element}}catch(e){}return null},getFocusedElement:function(){var $focused=internal.tryGetElementAsNonEmptyJQueryObject(":focus")||internal.tryGetElementAsNonEmptyJQueryObject(document.activeElement)||internal.tryGetElementAsNonEmptyJQueryObject(lastFocusedElement)||$();return $focused},emulateTabbing:function($from,offset){var $next=internal.findNextFocusable($from,offset);$next.focus()},initializeAtLoad:function(){$(document).on("focusin"+eventNamespace,internal.focusInElement)}},plugin={tab:function($from,offset){if($.isNumeric($from)){offset=$from;$from=undefined}$from=$from||plugin.getFocused();offset=offset||+1;internal.emulateTabbing($from,offset)},forwardTab:function($from){return plugin.tab($from,+1)},reverseTab:function($from){return plugin.tab($from,-1)},getFocused:function(){return internal.getFocusedElement()}},installJQueryExtensions=function(){$.extend({emulateTab:function($from,offset){return plugin.tab($from,offset)}});$.fn.extend({emulateTab:function(offset){return plugin.tab(this,offset)}})},init=function(){namespace[pluginName]=plugin;installJQueryExtensions();$(internal.initializeAtLoad)};init()})(document,jQuery,JoelPurra,"EmulateTab");




© 2015 - 2024 Weber Informatics LLC | Privacy Policy