SAMYANG/m/asset/js/sy.m.plugin.js
/**
         * Makes sure the tab key will only focus elements within the current section/slide
         * preventing this way from breaking the page.
         * Based on "Modals and keyboard traps"
         * from https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex
         */
Makes sure the tab key will only focus elements within the current section/slide
preventing this way from breaking the page.
Makes sure the tab key will only focus elements within the current section / slide preventing this way from breaking the page .
function onTab(e) {
            var isShiftPressed = e.shiftKey;
            var activeElement = $(':focus');
            var activeSection = $(SECTION_ACTIVE_SEL);
            var activeSlide = activeSection.find(SLIDE_ACTIVE_SEL);
            var focusableWrapper = activeSlide.length ? activeSlide : activeSection;
            var focusableElements = focusableWrapper.find(focusableElementsString).not('[tabindex="-1"]');
            function preventAndFocusFirst(e) {
                e.preventDefault();
                return focusableElements.first().focus();
            }
            if (activeElement.length) {
                if (!activeElement.closest(SECTION_ACTIVE_SEL, SLIDE_ACTIVE_SEL).length) {
                    activeElement = preventAndFocusFirst(e);
                }
            }
            else {
                preventAndFocusFirst(e);
            }
            if (!isShiftPressed && activeElement.is(focusableElements.last()) ||
                isShiftPressed && activeElement.is(focusableElements.first())
            ) {
                e.preventDefault();
            }
        }
function onTab ( e ) { var isShiftPressed = e . shiftKey ; var activeElement = $ ( ':focus' ) ; var activeSection = $ ( SECTION_ACTIVE_SEL ) ; var activeSlide = activeSection . find ( SLIDE_ACTIVE_SEL ) ; var focusableWrapper = activeSlide . length ? activeSlide : activeSection ; var focusableElements = focusableWrapper . find ( focusableElementsString ) . not ( '[tabindex="-1"]' ) ; function preventAndFocusFirst ( e ) { e . preventDefault ( ) ; return focusableElements . first ( ) . focus ( ) ; } if ( activeElement . length ) { if ( ! activeElement . closest ( SECTION_ACTIVE_SEL , SLIDE_ACTIVE_SEL ) . length ) { activeElement = preventAndFocusFirst ( e ) ; } } else { preventAndFocusFirst ( e ) ; } if ( ! isShiftPressed && activeElement . is ( focusableElements . last ( ) ) || isShiftPressed && activeElement . is ( focusableElements . first ( ) ) ) { e . preventDefault ( ) ; } }
Makes sure the tab key will only focus elements within the current section/slide
 preventing this way from breaking the page.
Makes sure the tab key will only focus elements within the current section / slide preventing this way from breaking the page .
//is there an element with focus? //no element if focused? Let's focus the first one of the section/slide //when reached the first or last focusable element of the section/slide //we prevent the tab action to keep it in the last focusable element