
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Superlight vanilla javascript plugin improving forms look and functionality
Give a modern look to your applications and take advantage of javascript events and public functions.
Vanilla javascript. No dependencies. Everything in a single 7KB file, all inclusive!
Tested on all mordern browsers (don't ask for old IE support please)
For live demos check: https://lcweb.it/lc-switch-javascript-plugin
include lc_switch.min.js
initialize plugin targeting one/multiple fields.
NB: first parameter may be a textual selector or a DOM object (yes, also jQuery objects)
<script type="text/javascript">
lc_switch('input[type=checkbox], input[type=radio]');
</script>
Available options with default values
<script type="text/javascript>
lc_switch('input[type=checkbox], input[type=radio]', {
// (string) "checked" status label text
on_txt : 'ON',
// (string) "not checked" status label text
off_txt : 'OFF',
// (string) custom "on" color. Supports also gradients
on_color : false,
// (bool) whether to enable compact mode
compact_mode: false
});
</script>
Available public functions to be called on initialized inputs
<script type="text/javascript">
const inputs = document.querySelectorAll('input[type=checkbox], input[type=radio]');
lc_switch(inputs):
// checks the field
lcs_on(inputs);
// unchecks the field
lcs_off(inputs);
// toggles targeted field
lcs_toggle(inputs);
// disables the field
lcs_disable(inputs);
// enables the field
lcs_enable(inputs);
// refreshes plugin interface retrieving input attributes (useful while changing HTML attributes directly)
lcs_update(inputs);
// destroys plugin initialization showing HTML fields again
lcs_destroy(inputs);
</script>
<script type="text/javascript">
document.querySelectorAll('input[type=checkbox], input[type=radio]').forEach(function(el) {
// triggered each time input status changes (checked and disabled)
el.addEventListener('lcs-statuschange', ...);
// triggered each time input is checked
el.addEventListener('lcs-on', ...);
// triggered each time input is uncheked
el.addEventListener('lcs-off', ...);
// triggered each time input is enabled
el.addEventListener('lcs-enabled', ...);
// triggered each time input is disabled
el.addEventListener('lcs-disabled', ...);
});
</script>
Copyright © Luca Montanari - LCweb
FAQs
Superlight vanilla javascript plugin improving forms look and functionality
The npm package lc-switch receives a total of 0 weekly downloads. As such, lc-switch popularity was classified as not popular.
We found that lc-switch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.