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

Function trap_modal_focus

codebase/sources/dhtmlxscheduler.js:10783–10819  ·  view source on GitHub ↗
(scheduler2)

Source from the content-addressed store, hash-verified

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