
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@knighttower/block-ui
Advanced tools
BlockUI.js is a lightweight JavaScript library designed for blocking user interactions with a specific element or the entire page. This library can be used with jQuery or Cash.js (the latter is preferred due to its smaller size). It is heavily inspired/based on the jQuery BlockUI plugin but fully refactored and modified, although it retains most of its functionality API.
To use BlockUI.js, include the library and either jQuery or Cash.js in your project. Cash.js is recommended for its smaller footprint and performance benefits.
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/8.1.1/cash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/knighttower@latest/packages/block-ui/dist/browser/blockui.js"></script>
npm i @knighttower/block-ui
there are also EMS and CJS via jsdelivr https://www.jsdelivr.com/package/npm/@knighttower/block-ui
or from the monorepo
npm i knighttower
onBlock
, onUnblock
, and onOverlayClick
callbacks.z-index
adjustments for compatibility.// Basic usage
$.blockui.on('Please wait...');
// With configuration
$.blockui.on({
content: '<h4>Loading...</h4>',
loader: '<div class="custom-loader"></div>',
css: {
color: '#fff',
backgroundColor: '#444',
},
overlayCSS: {
opacity: 0.8,
},
});
$.blockui.off();
// Block an element
$(element).block();
// Custom block message for an element
$(element).block({
content: 'Loading...',
css: {
color: '#888',
},
});
$(element).unblock();
Extend the default configuration to apply custom styles globally.
$.extend(true, $.blockui.defaults, {
content: '<h4>Please wait...</h4>',
loader: '<div class="spinner"></div>',
css: {
color: '#555',
},
overlayCSS: {
opacity: 0.7,
},
});
Option | Type | Default Value | Description |
---|---|---|---|
content | string | <h4>Please wait...</h4> | The message displayed in the block UI. |
loader | string | Custom HTML for loader. | The loading animation content. |
tag | string | 'div' | The tag for the message container. |
css | object | Styling for the block content. | Styles for the blocking element. |
overlayCSS | object | Styling for the overlay. | Styles for the overlay background. |
fadeIn | number | 200 | Fade-in duration in milliseconds. |
fadeOut | number | 400 | Fade-out duration in milliseconds. |
timeout | number | 0 | Auto unblock after timeout milliseconds. |
zindex | string or number | 'auto' | Determines the z-index value. |
onBlock | function | null | Callback when blocking starts. |
onUnblock | function | null | Callback when unblocking completes. |
onOverlayClick | function | null | Callback for overlay clicks. |
$.blockui.on({
content: '<h3>Loading...</h3>',
loader: '<div class="my-loader"></div>',
overlayCSS: {
backgroundColor: '#333',
opacity: 0.9,
},
});
$(element).block({
content: 'Please wait...',
timeout: 3000, // Unblock after 3 seconds
});
$.blockui.on({
content: '<h4>Processing...</h4>',
zindex: 9999,
onBlock: function () {
console.log('BlockUI activated');
},
onUnblock: function () {
console.log('BlockUI deactivated');
},
});
By default, the library provides a minimal loader:
<style>
.x-ldr, .x-ldr div {
box-sizing: border-box;
}
.x-ldr {
display: inline-block;
position: relative;
width: 80px;
height: 30px;
}
.x-ldr div {
position: absolute;
width: 12px;
height: 12px;
border-radius: 50%;
background: #a6a8b5;
animation: x-ldr2 0.6s infinite;
}
</style>
Override it by providing custom loader
HTML or CSS.
Event | Description |
---|---|
onBlock | Invoked when blocking begins. |
onUnblock | Invoked after unblocking is completed. |
onOverlayClick | Triggered when the overlay is clicked. |
Example:
$.blockui.on({
onBlock: function () {
console.log('Blocking started');
},
onUnblock: function () {
console.log('Blocking ended');
},
onOverlayClick: function () {
alert('Overlay clicked!');
},
});
z-index
for seamless overlays.tab
key constraint during blocking.$.extend
.Enjoy using BlockUI.js to create seamless UI interactions! 🎉
FAQs
A simple block ui plugin for Jquery or CashJs
The npm package @knighttower/block-ui receives a total of 2 weekly downloads. As such, @knighttower/block-ui popularity was classified as not popular.
We found that @knighttower/block-ui 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.