rocketbelt/components/dialogs/rocketbelt.dialogs.js
function trapTabKey(node, event) {
    var focusableChildren = getFocusableChildren(node);
    var focusedItemIndex = focusableChildren.index($(document.activeElement));

    if (event.shiftKey && focusedItemIndex === 0) {
      focusableChildren[focusableChildren.length - 1].focus();
      event.preventDefault();
    } else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {
      focusableChildren[0].focus();
      event.preventDefault();
    }
  }
function trapTabKey(node, event) {
    var focusableChildren = getFocusableChildren(node);
    var focusedItemIndex = focusableChildren.index($(document.activeElement));

    if (event.shiftKey && focusedItemIndex === 0) {
      focusableChildren[focusableChildren.length - 1].focus();
      event.preventDefault();
    } else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {
      focusableChildren[0].focus();
      event.preventDefault();
    }
  }
function trapTabKey ( node , event ) { var focusableChildren = getFocusableChildren ( node ) ; var focusedItemIndex = focusableChildren . index ( $ ( document . activeElement ) ) ; if ( event . shiftKey && focusedItemIndex === 0 ) { focusableChildren [ focusableChildren . length - 1 ] . focus ( ) ; event . preventDefault ( ) ; } else if ( ! event . shiftKey && focusedItemIndex === focusableChildren . length - 1 ) { focusableChildren [ 0 ] . focus ( ) ; event . preventDefault ( ) ; } }
Helper function trapping the tab key inside a node
Helper function trapping the tab key inside a node