MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / trap_modal_focus

Function trap_modal_focus

codebase/sources/dhtmlxscheduler.es.js:10779–10815  ·  view source on GitHub ↗
(scheduler2)

Source from the content-addressed store, hash-verified

10777 } };
10778}
10779function trap_modal_focus(scheduler2) {
10780 (function() {
10781 scheduler2.$keyboardNavigation.getFocusableNodes = scheduler2._getFocusableNodes;
10782 scheduler2.$keyboardNavigation.trapFocus = function trapFocus(root, e) {
10783 if (e.keyCode != 9)
10784 return false;
10785 var focusable = scheduler2.$keyboardNavigation.getFocusableNodes(root);
10786 var currentFocus = document.activeElement;
10787 var currentIndex = -1;
10788 for (var i = 0; i < focusable.length; i++) {
10789 if (focusable[i] == currentFocus) {
10790 currentIndex = i;
10791 break;
10792 }
10793 }
10794 var nextIndex, nextItem;
10795 if (e.shiftKey) {
10796 nextIndex = currentIndex <= 0 ? focusable.length - 1 : currentIndex - 1;
10797 nextItem = focusable[nextIndex];
10798 if (nextItem) {
10799 nextItem.focus();
10800 e.preventDefault();
10801 return true;
10802 }
10803 } else {
10804 nextIndex = currentIndex >= focusable.length - 1 ? 0 : currentIndex + 1;
10805 nextItem = focusable[nextIndex];
10806 if (nextItem) {
10807 nextItem.focus();
10808 e.preventDefault();
10809 return true;
10810 }
10811 }
10812 return false;
10813 };
10814 })();
10815}
10816function marker(scheduler2) {
10817 scheduler2.$keyboardNavigation.marker = { clear: function() {
10818 var divs = scheduler2.$container.querySelectorAll(".dhx_focus_slot");

Callers 1

key_navFunction · 0.70

Calls 1

focusMethod · 0.65

Tested by

no test coverage detected