CINXE.COM

Apache Kafka

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns:og="http://ogp.me/ns#"> <head> <title>Apache Kafka</title> <link rel='stylesheet' href='/css/styles.css?2' type='text/css'> <link rel="icon" type="image/gif" href="/images/apache_feather.gif"> <meta name="robots" content="index,follow" /> <meta name="language" content="en" /> <meta name="keywords" content="apache kafka messaging queuing distributed stream processing"> <meta name="description" content="Apache Kafka: A Distributed Streaming Platform."> <meta http-equiv='Content-Type' content='text/html;charset=utf-8' /> <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> <meta property="og:title" content="Apache Kafka" /> <meta property="og:image" content="http://apache-kafka.org/images/apache-kafka.png" /> <meta property="og:description" content="Apache Kafka: A Distributed Streaming Platform." /> <meta property="og:site_name" content="Apache Kafka" /> <meta property="og:type" content="website" /> <link href="/css/fonts.css" rel="stylesheet"> <script src="/js/jquery.min.js"></script> <script defer src="/js/fontawesome.js"></script> <link rel="stylesheet" href="/css/prism.min.css" /> <script defer src="/js/prism.min.js"></script> <script> // DO NOT NEED TO UPDATE // Legacy versions of the documentation to not do frontend redirect for // These docs are written as a single super long file so no need to re-route var legacyDocPaths = [ '/07/documentation', '/07/documentation/', '/08/documentation', '/08/documentation/', '/081/documentation', '/081/documentation/', '/082/documentation', '/082/documentation/', '/090/documentation', '/090/documentation/', '/0100/documentation', '/0100/documentation/' ]; // Any direct request for Streams documentation in docs versions prior to 0101 // Redirect these requests to the standalone Streams doc page var currentPath = window.location.pathname; var shouldRedirect = !legacyDocPaths.includes(currentPath); var isDocumenationPage = currentPath.includes('/documentation'); var hasNotSpecifiedFullPath = !currentPath.includes('/documentation/streams') && !currentPath.includes('/documentation/streams/'); // Look for legacy anchors to clue us in on what full path the user needs // Add more as needed var specifiedStreamsAnchor = window.location.hash.includes('#streams_'); if (shouldRedirect && isDocumenationPage && hasNotSpecifiedFullPath) { if (specifiedStreamsAnchor) { window.location.pathname = currentPath + 'streams'; } } </script> <!-- Matomo --> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ /* We explicitly disable cookie tracking to avoid privacy issues */ _paq.push(['disableCookies']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//analytics.apache.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '26']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> </head> <body class="page-home"> <div class="main"> <div class="header" id="header"> <a href="/" class="logo-link"> <span class="visually-hidden">Apache Kafka</span> </a> <button type="button" class="top-nav-toggle burger-toggle" id="top-nav-toggle" aria-haspopup="true" aria-expanded="false"> <span class="visually-hidden">Toggle navigation</span> <span class="burger-line"></span> <span class="burger-line"></span> <span class="burger-line"></span> </button> <div class="top-nav-container" id="top-nav-container"> <nav class="top-nav" role="navigation" aria-label="Main menu"> <ul class="top-nav-list"> <li class="top-nav-item" role="menuitem"> <a href="#" class="top-nav-item-anchor" aria-haspopup="true" aria-expanded="false"> Get Started </a> <ul class="top-nav-menu" aria-hidden="true" role="menu" title="Get Started"> <li class="top-nav-menu-item" role="menuitem"> <a href="/intro" tabindex="-1" class="top-nav-anchor"> Introduction </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a href="/quickstart" tabindex="-1" class="top-nav-anchor"> Quickstart </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a href="/uses" tabindex="-1" class="top-nav-anchor"> Use Cases </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a href="/books-and-papers" tabindex="-1" class="top-nav-anchor"> Books &amp; Papers </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a href="/videos" tabindex="-1" class="top-nav-anchor"> Videos </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a href="/podcasts" tabindex="-1" class="top-nav-anchor"> Podcasts </a> </li> </ul> </li> <li class="top-nav-item" role="menuitem"> <a href="/documentation" class="top-nav-item-anchor" aria-haspopup="true" aria-expanded="false" aria-controls="nav-documentation-menu"> Docs </a> <ul class="top-nav-menu" aria-hidden="true" role="menu" id="nav-documentation-menu" title="Docs"> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#gettingStarted"> Key Concepts </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#api"> APIs </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#configuration"> Configuration </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#design"> Design </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#implementation"> Implementation </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#operations"> Operations </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#security"> Security </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://cwiki.apache.org/confluence/display/KAFKA/Clients" target="_blank"> Clients </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation#connect"> Kafka Connect </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/documentation/streams"> Kafka Streams </a> </li> </ul> </li> <li class="top-nav-item" role="menuitem"> <a class="top-nav-item-anchor" href="/powered-by"> Powered By </a> </li> <li class="top-nav-item" role="menuitem"> <a href="#" class="top-nav-item-anchor" aria-haspopup="true" aria-expanded="false" aria-controls="nav-community-menu"> Community </a> <ul class="top-nav-menu" aria-hidden="true" role="menu" id="nav-community-menu" title="Community"> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/blog" target="_blank"> Blog </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://kafka-summit.org/" target="_blank"> Kafka Summit </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/project"> Project Info </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/trademark"> Trademark </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://cwiki.apache.org/confluence/display/KAFKA/Ecosystem" target="_blank"> Ecosystem </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/events"> Events </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="/contact"> Contact us </a> </li> </ul> </li> <li class="top-nav-item" role="menuitem"> <a href="#" class="top-nav-item-anchor" aria-haspopup="true" aria-expanded="false" aria-controls="nav-community-menu"> Apache </a> <ul class="top-nav-menu" aria-hidden="true" role="menu" id="nav-community-menu" title="Community"> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://www.apache.org/licenses/" target="_blank"> License </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://www.apache.org/foundation/sponsorship.html" target="_blank"> Donate </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://www.apache.org/foundation/thanks.html" target="_blank"> Sponsors </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://www.apache.org/security/" target="_blank"> Security </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank"> Privacy </a> </li> <li class="top-nav-menu-item" role="menuitem"> <a class="top-nav-anchor" tabindex="-1" href="https://www.apache.org/" target="_blank"> Apache.org </a> </li> </ul> </li> <li class="top-nav-item" role="menuitem"> <a href="/downloads" class="top-nav-download" tabindex="-1" id="top-nav-download"> Download Kafka </a> </li> </ul> </nav> </div> </div> <div class="content content-home"> <!-- TODO: should we completely remove this? --> <!-- <nav class="b-sticky-nav"> <div class="nav-scroller"> <div class="nav__inner"> <a class="b-nav__home nav__item" href="/">home</a> <a class="b-nav__intro nav__item" href="/intro">introduction</a> <a class="b-nav__quickstart nav__item" href="/quickstart">quickstart</a> <a class="b-nav__uses nav__item" href="/uses">use cases</a> <div class="nav__item nav__item__with__subs"> <a class="b-nav__docs nav__item nav__sub__anchor" href="/documentation">documentation</a> <a class="nav__item nav__sub__item" href="/documentation#gettingStarted">getting started</a> <a class="nav__item nav__sub__item" href="/documentation#api">APIs</a> <a class="nav__item nav__sub__item" href="/documentation#configuration">configuration</a> <a class="nav__item nav__sub__item" href="/documentation#design">design</a> <a class="nav__item nav__sub__item" href="/documentation#implementation">implementation</a> <a class="nav__item nav__sub__item" href="/documentation#operations">operations</a> <a class="nav__item nav__sub__item" href="/documentation#security">security</a> <a class="nav__item nav__sub__item" href="/documentation#connect">kafka connect</a> <a class="b-nav__streams nav__item nav__sub__item" href="/documentation/streams">kafka streams</a> </div> <a class="b-nav__performance nav__item" href="/performance">performance</a> <a class="b-nav__poweredby nav__item" href="/powered-by">powered by</a> <a class="b-nav__project nav__item" href="/project">project info</a> <a class="b-nav__ecosystem nav__item" href="https://cwiki.apache.org/confluence/display/KAFKA/Ecosystem" target="_blank">ecosystem</a> <a class="b-nav__clients nav__item" href="https://cwiki.apache.org/confluence/display/KAFKA/Clients" target="_blank">clients</a> <a class="b-nav__events nav__item" href="/events">events</a> <a class="b-nav__contact nav__item" href="/contact">contact us</a> <div class="nav__item nav__item__with__subs"> <a class="b-nav__apache nav__item nav__sub__anchor b-nav__sub__anchor" href="#">apache</a> <a class="b-nav__apache nav__item nav__sub__item" href="http://www.apache.org/" target="_blank">foundation</a> <a class="b-nav__apache nav__item nav__sub__item" href="http://www.apache.org/licenses/" target="_blank">license</a> <a class="b-nav__apache nav__item nav__sub__item" href="http://www.apache.org/foundation/sponsorship.html" target="_blank">sponsorship</a> <a class="b-nav__apache nav__item nav__sub__item" href="http://www.apache.org/foundation/thanks.html" target="_blank">thanks</a> <a class="b-nav__apache nav__item nav__sub__item" href="http://www.apache.org/security/" target="_blank">security</a> </div> <a class="btn" href="/downloads">download</a> <div class="social-links"> <a class="twitter" href="https://twitter.com/apachekafka" target="_blank">@apachekafka</a> </div> </div> </div> <div class="navindicator"> <div class="b-nav__home navindicator__item"></div> <div class="b-nav__intro navindicator__item"></div> <div class="b-nav__quickstart navindicator__item"></div> <div class="b-nav__uses navindicator__item"></div> <div class="b-nav__docs navindicator__item"></div> <div class="b-nav__performance navindicator__item"></div> <div class="b-nav__poweredby navindicator__item"></div> <div class="b-nav__project navindicator__item"></div> <div class="b-nav__ecosystem navindicator__item"></div> <div class="b-nav__clients navindicator__item"></div> <div class="b-nav__events navindicator__item"></div> <div class="b-nav__contact navindicator__item"></div> </div> </nav> --> <section class="content-top"> <h2 class="content-top-title"> Apache Kafka </h2> <p class="content-top-subtitle"> More than <strong class="content-top-subtitle-strong"> 80% of all Fortune 100 companies </strong> trust, and use Kafka. </p> <p class="content-top-text"> Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. </p> <hr class="content-top-separator" /> <!-- <p class="content-top-industry"> The Number of Top Ten largest Companies Using Kafka* </p> --> <ul class="content-top-industry-list"> <li class="content-top-industry-item"> <h4 class="content-top-industry-title"> Manufacturing </h4> <p class="content-top-industry-ratio"> 10 <span class="content-top-industry-ratio-stacked"> out of </span> 10 </p> <img class="content-top-industry-image" src="/images/icons/manufacturing.svg" width="50" height="50" /> </li> <li class="content-top-industry-item"> <h4 class="content-top-industry-title"> Banks </h4> <p class="content-top-industry-ratio"> 7 <span class="content-top-industry-ratio-stacked"> out of </span> 10 </p> <img class="content-top-industry-image" src="/images/icons/bank.svg" height="50" /> </li> <li class="content-top-industry-item"> <h4 class="content-top-industry-title"> Insurance </h4> <p class="content-top-industry-ratio"> 10 <span class="content-top-industry-ratio-stacked"> out of </span> 10 </p> <img class="content-top-industry-image" src="/images/icons/shield.svg" height="50" /> </li> <li class="content-top-industry-item"> <h4 class="content-top-industry-title"> Telecom </h4> <p class="content-top-industry-ratio"> 8 <span class="content-top-industry-ratio-stacked"> out of </span> 10 </p> <img class="content-top-industry-image" src="/images/icons/telecom-tower.svg" height="50" /> </li> </ul> <!-- <div class="content-top-industry-full-list"> <a href="/powered-by">See Full List</a> </div> --> <div class="content-top-industry-full-list"> <a href="/powered-by">See Full List</a> <div class="content-top-industry-full-list-tooltip"> <strong>10/10</strong> Largest insurance companies <br /> <strong>10/10</strong> Largest manufacturing companies <br /> <strong>10/10</strong> Largest information technology and services companies <br /> <strong>8/10</strong> Largest telecommunications companies <br /> <strong>8/10</strong> Largest transportation companies <br /> <strong>7/10</strong> Largest retail companies <br /> <strong>7/10</strong> Largest banks and finance companies <br /> <strong>6/10</strong> Largest energy and utilities organizations </div> </div> <p class="content-top-disclaimer"> Above is a snapshot of the number of top-ten largest companies using Kafka, per-industry. </p> </section> <div class="waves" role="presentation"></div> <section class="content-bottom"> <div class="content-section"> <h3 class="content-section-title"> Core Capabilities </h3> <ul class="content-section-list"> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-high-throughput.svg" width="74" height="74" /> <h4 class="content-section-item-title"> High Throughput </h4> <p class="content-section-item-content"> Deliver messages at network limited throughput using a cluster of machines with latencies as low as 2ms. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-scalable.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Scalable </h4> <p class="content-section-item-content"> Scale production clusters up to a thousand brokers, trillions of messages per day, petabytes of data, hundreds of thousands of partitions. Elastically expand and contract storage and processing. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-database.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Permanent storage </h4> <p class="content-section-item-content"> Store streams of data safely in a distributed, durable, fault-tolerant cluster. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-high-availability.svg" width="74" height="74" /> <h4 class="content-section-item-title"> High availability </h4> <p class="content-section-item-content"> Stretch clusters efficiently over availability zones or connect separate clusters across geographic regions. </p> </li> </ul> </div> <hr class="content-section-separator" /> <div class="content-section"> <h3 class="content-section-title"> Ecosystem </h3> <ul class="content-section-list"> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-stream.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Built-in Stream Processing </h4> <p class="content-section-item-content"> Process streams of events with joins, aggregations, filters, transformations, and more, using event-time and exactly-once processing. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-connect.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Connect To Almost Anything </h4> <p class="content-section-item-content"> Kafka鈥檚 out-of-the-box Connect interface integrates with hundreds of event sources and event sinks including Postgres, JMS, Elasticsearch, AWS S3, and more. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-library.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Client Libraries </h4> <p class="content-section-item-content"> Read, write, and process streams of events in a vast array of programming languages. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-code.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Large Ecosystem Open Source Tools </h4> <p class="content-section-item-content"> Large ecosystem of open source tools: Leverage a vast array of community-driven tooling. </p> </li> </ul> </div> <hr class="content-section-separator" /> <div class="content-section"> <h3 class="content-section-title"> Trust &amp; Ease Of Use </h3> <ul class="content-section-list"> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-vital.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Mission Critical </h4> <p class="content-section-item-content"> Support mission-critical use cases with guaranteed ordering, zero message loss, and efficient exactly-once processing. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-trusted.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Trusted By Thousands of Orgs </h4> <p class="content-section-item-content"> Thousands of organizations use Kafka, from internet giants to car manufacturers to stock exchanges. More than 5 million unique lifetime downloads. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-community.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Vast User Community </h4> <p class="content-section-item-content"> Kafka is one of the five most active projects of the Apache Software Foundation, with hundreds of meetups around the world. </p> </li> <li class="content-section-item"> <img class="content-section-item-icon" src="/images/hp-icons/icon-online.svg" width="74" height="74" /> <h4 class="content-section-item-title"> Rich Online Resources </h4> <p class="content-section-item-content"> Rich documentation, online training, guided tutorials, videos, sample projects, Stack Overflow, etc. </p> </li> </ul> </div> </section> </div> </div> </div> </div> <div class="footer"> <div class="footer__inner"> <div class="footer__legal"> <span class="footer__legal__one">The contents of this website are &copy; 2024 <a href="https://www.apache.org/" target="_blank">Apache Software Foundation</a> under the terms of the <a href="https://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache License v2</a>.</span> <span class="footer__legal__two">Apache Kafka, Kafka, and the Kafka logo are either registered trademarks or trademarks of The Apache Software Foundation</span> <span class="footer__legal__three">in the United States and other countries.</span> <div> <a href="https://kafka.apache.org/project-security" target="_blank" rel="noreferrer">Security</a>&nbsp;|&nbsp; <a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noreferrer">Donate</a>&nbsp;|&nbsp; <a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noreferrer">Thanks</a>&nbsp;|&nbsp; <a href="https://apache.org/events/current-event" target="_blank" rel="noreferrer">Events</a>&nbsp;|&nbsp; <a href="https://apache.org/licenses/" target="_blank" rel="noreferrer">License</a>&nbsp;|&nbsp; <a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noreferrer">Privacy</a> </div> </div> <a class="apache-feather" target="_blank" href="https://www.apache.org"> <img width="40" src="/images/feather-small.png" alt="Apache Feather"> </a> </div> </div> <!-- Script tags should be inside the body tag -- not inside the html tag --> <script src="/js/handlebars.js"></script> <script> $(function () { // list of pages that are rendered with Handlebars var templates = [ 'introduction', 'implementation', 'design', 'api', 'configuration', 'ops', 'security', 'connect', 'streams', 'quickstart', 'quickstart-docker', 'toc', 'upgrade', 'content', 'zk2kraft-summary', 'compatibility-summary', 'docker' ]; // loop through all Handlebar templates on the page and render them for(var i = 0; i < templates.length; i++) { var templateScript = $("#" + templates[i] + "-template").html(); if(templateScript) { var template = Handlebars.compile(templateScript); var html = template(context); $(".p-" + templates[i]).html(html); } } }); </script> <script src="/js/jquery.sticky-kit.min.js"></script> <script> let mobileScrolling = false; let mobileTimeout; // Let's start getting rid of jQuery... function checkPageScroll() { if (window.scrollY >= 80 || document.body.scrollTop >= 100) { document.getElementById('header').classList.add('scrolled'); } else { document.getElementById('header').classList.remove('scrolled'); } } function mobilePageScroll() { mobileScrolling = true; mobileTimeout = null; mobileTimeout = setTimeout(checkPageScroll, 200); } function pageScroll(e) { requestAnimationFrame(checkPageScroll); }; function setUpA11yMenus(nav) { const itemsWithMenu = nav.querySelectorAll('[aria-haspopup="true"]'); const topLevelItems = nav.querySelectorAll('.top-nav-item-anchor'); const navAnchors = nav.querySelectorAll('a'); const menus = nav.querySelectorAll('[role="menu"]'); const keyMap = { // directions 'left': 37, 'up': 38, 'right': 39, 'down': 40, // actions 'tab': 9, 'enter': 13, 'esc': 27, 'space': 32, } // TODO: keep synced with the above map const keyCodes = [37, 38, 39, 40, 9, 13, 27, 32]; // allow # links in the nav so they can have focus and we can treat them like links nav.addEventListener('click', (e) => { if (e.target.hasAttribute('href') && e.target.getAttribute('href') === '#') { e.preventDefault(); e.stopPropagation(); } }); for (let i = 0; i < topLevelItems.length; i++) { const item = topLevelItems[i]; const attrNames = { currentFocus: 'data-current-focus', hidden: 'aria-hidden', expanded: 'aria-expanded', }; // get the actual anchor // get the menu which is a sibling to the item const itemMenu = item.parentNode.querySelector('[role="menu"]'); function selectPreviousMenuItem(e, keyPressed) { let selectedIndex = -1; if (!itemMenu) { selectPreviousTopLevelItem(e); } if (itemMenu && itemMenu.hasAttribute(attrNames.currentFocus)) { selectedIndex = parseInt(itemMenu.getAttribute(attrNames.currentFocus), 10); } let nextIndex = selectedIndex - 1; const menuItems = itemMenu.getElementsByTagName('a'); if (nextIndex >= 0) { // select next item menuItems[nextIndex].focus(); itemMenu.setAttribute(attrNames.currentFocus, nextIndex); } else if (nextIndex === -1) { // select top level menu item item.focus(); itemMenu.setAttribute(attrNames.currentFocus, -1); } else if (nextIndex === -2) { if (keyPressed === 'tab') { // go to the previous top level item selectPreviousTopLevelItem(e); } else { // go to the last menu item menuItems[menuItems.length - 1].focus() itemMenu.setAttribute(attrNames.currentFocus, menuItems.length - 1); } } } function selectNextMenuItem(keyPressed) { let selectedIndex = -1; let nextIndex; let menuItems; if (!itemMenu) { selectNextTopLevelItem(); } menuItems = itemMenu.getElementsByTagName('a'); for (let j = 0; j < menuItems.length; j++) { if (menuItems[j] === document.activeElement) { selectedIndex = j; break; } } nextIndex = selectedIndex + 1; // debugger; if (keyPressed === 'tab') { if (nextIndex >= menuItems.length) { selectNextTopLevelItem() } else { menuItems[nextIndex].focus(); } } else { if (nextIndex < menuItems.length) { menuItems[nextIndex].focus(); } else { item.focus(); } } } function selectPreviousTopLevelItem() { let newIndex; for (let j = 0; j < topLevelItems.length; j++) { if (topLevelItems[j] === item) { newIndex = j - 1; break; } } if (itemMenu) { hideMenu(); } if (newIndex < 0) { document.querySelector('.logo-link').focus(); } else { topLevelItems[newIndex].focus(); } } function selectNextTopLevelItem() { let newIndex; for (let j = 0; j < topLevelItems.length; j++) { if (topLevelItems[j] === item) { newIndex = j + 1; break; } } if (itemMenu) { hideMenu(); } if (newIndex > topLevelItems.length - 1) { document.getElementById('top-nav-download').focus(); } else { topLevelItems[newIndex].focus(); } } function isMenuOpen() { return itemMenu && itemMenu.getAttribute(attrNames.hidden) === 'false'; } function showMenu() { item.setAttribute(attrNames.expanded, 'true'); if (itemMenu) { itemMenu.setAttribute(attrNames.hidden, 'false'); } } function hideMenu() { item.setAttribute(attrNames.expanded, 'false'); if (itemMenu) { itemMenu.setAttribute(attrNames.hidden, 'true'); delete itemMenu.dataset.currentFocus; } } item.parentNode.addEventListener('mouseover', showMenu); item.parentNode.addEventListener('mouseout', hideMenu); item.parentNode.addEventListener('blur', hideMenu); item.addEventListener('focus', showMenu); // use keydown for direction keys item.parentNode.addEventListener('keydown', (e) => { // check for an important keycode if (keyCodes.indexOf(e.keyCode) > -1) { e.preventDefault(); e.stopPropagation(); switch(e.keyCode) { case keyMap.left: if (itemMenu) { if (!isMenuOpen()) { selectPreviousTopLevelItem(); } else { hideMenu(); item.focus(); } } else { selectPreviousTopLevelItem(); } break; case keyMap.up: if (itemMenu) { if (isMenuOpen()) { selectPreviousMenuItem(e, 'up'); } } break; case keyMap.right: if (!isMenuOpen() || document.activeElement === item) { selectNextTopLevelItem('right'); } break; case keyMap.down: if (itemMenu) { if (isMenuOpen()) { selectNextMenuItem('down'); } else { showMenu(); } } break; case keyMap.tab: const isShiftActive = e.getModifierState('Shift'); if (itemMenu) { if (isShiftActive) { selectPreviousTopLevelItem(); } else { if (isMenuOpen()) { selectNextMenuItem('tab'); } else { showMenu(); } } } else { if (isShiftActive) { selectPreviousTopLevelItem(); } else { selectNextTopLevelItem('tab'); } } break; case keyMap.esc: if (itemMenu && isMenuOpen()) { hideMenu(); } break; default: // can probably remove the default case (in this case) break; } } }); }; } function is_touch_enabled() { return ( 'ontouchstart' in window ) || ( navigator.maxTouchPoints > 0 ) || ( navigator.msMaxTouchPoints > 0 ); } function setupDocsNav() { var docsContainer = document.querySelector('.documentation--current'); var docsHandle = document.querySelector('.toc-handle'); function toggleDocsWidth() { let isExpanded = docsContainer.classList.toggle('expanded'); // change the arrow direction based on the view state is expanded or not if (isExpanded) { docsHandle.textContent = ">"; } else { docsHandle.textContent = "<"; } } docsHandle.addEventListener('click', toggleDocsWidth); } // jQuery free IIFE (function() { var navToggle = document.getElementById('top-nav-toggle'); var nav = document.getElementById('top-nav-container'); var docsNav = document.querySelector('.docs-nav'); navToggle.addEventListener('click', () => { navToggle.classList.toggle('active'); }); // skip this for touch devices if (is_touch_enabled()) { nav.querySelectorAll('a').forEach(anchor => anchor.removeAttribute('tabindex')); window.addEventListener('touchmove', mobilePageScroll, false); } else { setUpA11yMenus(nav); window.addEventListener('scroll', pageScroll, false); } // jQuery free document ready document.addEventListener("DOMContentLoaded", function() { // anything to do on dom ready here pageScroll(); if (docsNav) { setupDocsNav(); } // document.querySelectorAll('[class^="language-"]').forEach((block) => { // hljs.highlightBlock(block); // }); }); }()); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10