![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
JavaScript Framework agnostic Focus Manager coded in TypeScript
ToleFocus is a small library to manage focus on JavaScript web applications. ToleFocus use ES6 methods, like array.findIndex
, and require some polyfill like core-js in order to work in old browsers, like IE.
ToleFocus is highly inspired on Angular Focus Manager coded by Rob Tylor.
npm install tolefocus --save
To enable the focus manager you have to import focusManager
from tolefocus
module and call enable
method.
import {focusManager} from "tolefocus";
focusManager.enable();
This load the content of body
tag searching for ToleFocus attributes.
You can enable the built in DOM observer witch use MutationObserver in order to detect the DOM changes.
import {focusManager, focusObserver} from "tolefocus";
focusManager.enable();
focusObserver.enable();
ToleFocus handles by default the TAB key in the common focusables controls and sends focus to the next or previous control.
You can set the focus order:
<input /> <!-- first control in focus order -->
<input /> <!-- third control in focus order -->
<input focus-order="1" /> <!-- second control in focus order -->
Focus order is zero based, you can set negative focus order to any element, the negative focus order are pushed to the first positions.
<input id='i1'/> <!-- second order -->
<input id='i2' focus-order='-2' /> <!-- first order -->
<input id='i3' /> <!-- third order -->
<input id='i4' focus-order='2' /> <!-- fourth order -->
<input id='i5' /> <!-- fifth order -->
<input id='i6' /> <!-- seventh order -->
<input id='i7' focus-order='4' /> <!-- sixth order -->
<input id='i8' /> <!-- eighth order -->
You can create focus groups where each element can to have his own focus-order in the group.
<div focus-group>
<input />
<div focus-group focus-order="1">
<input />
<input />
<input />
</div>
<input />
<input focus-order="2" />
</div>
<div focus-group focus-order="1">
<input />
<input />
<input />
</div>
You can control the group loopback, you can set the head and tail behaivor. When behaivor is "stop" the focus doesn't go to the next element, the foucus stops in the last or first element. When behaivor is "loop" the focus go from last to first element in the group or from the first to the end element.
<div focus-group="loop"> <!-- head and tail behaivor to "loop". The focus from first to last or reverse. -->
<input />
<input />
<input />
</div>
<div focus-group="stop"> <!-- head and tail behaivor to "stop". The focus stops in the last or the first element -->
<input />
<input />
<input />
</div>
<div focus-group="stop loop"> <!-- head behaivor set to stop and tail behaivor is "loop". The focus stops in the first element and will go from the last to the first -->
<input />
<input />
<input />
</div>
You can send focus to other controls like div
or spans
, you have to set focus-order
attribute.
<div focus-order>
</di>
<input />
<div focus-order="2">
</di>
You can set an element as autofocus to set focus on it automatically. If you have the focusObserver
enabled the element will focus when it's added to the DOM.
<input />
<input />
<input autofocus /> <!-- gets the focus automatically -->
If you want to hide a element and get focused when it becomes visible you can set observe
value to autofocus
attribute.
<input />
<input />
<input autofocus="observe" style="display: none" /> <!-- gets the focus automatically when become visible -->
<button onclick="showHiddenInput()">Show</button>
To use using SystemJS you have to map tolefocus to the distributed bundle:
System.config({
...
...
map: {
tolefocus: './node_modules/tolefocus/dist/bundles/tolefocus.bundle.umd.js'
...
...
},
...
...
})
Pull request are welcome, to build it:
git clone https://github.com/tolemac/tolefocus.git
cd tolefocus
npm install
npm run build
You can launch test suite using:
npm run test
FAQs
Agnostic Framework Focus Manager
The npm package tolefocus receives a total of 6 weekly downloads. As such, tolefocus popularity was classified as not popular.
We found that tolefocus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.