var gym_workout_keyboard_navigation_loop = function (elem) {
  var gym_workout_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
  var gym_workout_firstTabbable = gym_workout_tabbable.first();
  var gym_workout_lastTabbable = gym_workout_tabbable.last();
  gym_workout_firstTabbable.focus();

  gym_workout_lastTabbable.on('keydown', function (e) {
    if ((e.which === 9 && !e.shiftKey)) {
      e.preventDefault();
      gym_workout_firstTabbable.focus();
    }
  });

  gym_workout_firstTabbable.on('keydown', function (e) {
    if ((e.which === 9 && e.shiftKey)) {
      e.preventDefault();
      gym_workout_lastTabbable.focus();
    }
  });

  elem.on('keyup', function (e) {
    if (e.keyCode === 27) {
      elem.hide();
    };
  });
};