Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@claviska/jquery-alertable
Advanced tools
Developed by Cory LaViska for A Beautiful Site, LLC
Licensed under the MIT license: http://opensource.org/licenses/MIT
This plugin provides a minimal, lightweight, and customizable alternative to window.alert()
and window.confirm()
. It's flexible enough to mold to your application's existing stylesheet and markup.
Features:
$.alertable.alert('Howdy!')
$.alertable.confirm('You sure?').then(function() { ... })
$.alertable.prompt('How many?').then(function(data) { ... })
A quick demo can be found on CodePen: http://codepen.io/claviska/pen/mPNWxy
A local demo can be found in example.html
.
Include the minified version of this plugin in your project or install via NPM:
npm install --save @claviska/jquery-alertable
Example alerts:
// Basic example
$.alertable.alert('Howdy!');
// Example with action when the modal is dismissed
$.alertable.alert('Howdy!').always(function() {
// Modal was dismissed
});
Example confirmations:
// Basic example
$.alertable.confirm('You sure?').then(function() {
// OK was selected
});
// Example with then/always
$.alertable.confirm('You sure?').then(function() {
// OK was selected
}, function() {
// Cancel was selected
}).always(function() {
// Modal was dismissed
});
Example prompts:
// Basic example
$.alertable.prompt('How many?').then(function(data) {
// Prompt was submitted
});
// Example with then/always
$.alertable.prompt('How many?').then(function(data) {
// Prompt was submitted
}, function() {
// Prompt was canceled
}).always(function() {
// Modal was dismissed
});
Important: Unlike window.alert()
, window.confirm()
, and window.prompt()
, using this plugin will not cause execution of the script to stop while the modal is open. This behavior is not possible to emulate with a plugin nor is it desirable in modern web applications.
Pass options as the second argument of any method:
$.alertable.alert('Howdy!', {
optionName: optionValue,
...
});
$.alertable.confirm('You sure?', {
optionName: optionValue,
...
});
$.alertable.prompt('How many?', {
optionName: optionValue,
...
});
Available options:
container
: The container to append the modal to. Defaults to 'body'.
html
: Whether or not your message contains HTML. Defaults to false
.
cancelButton
: HTML to use for the reject button. Default value:
<button class="alertable-cancel" type="button">Cancel</button>
okButton
: HTML to use for the resolve button. Default value:<button class="alertable-ok" type="button">OK</button>
overlay
: HTML to use for the overlay. Default value:<div class="alertable-overlay"></div>
prompt
: HTML to use for the prompt body. All inputs contained in this HTML will be serialized and returned when the prompt is submitted. Default value:<input class="alertable-input" type="text" name="value">
modal
: HTML to use for the modal. Default value:<div class="alertable">
<div class="alertable-message"></div>
<div class="alertable-buttons"></div>
</div>
hide
: Function for hiding the modal and overlay. Use this.modal
and this.overlay
to reference the modal and overlay elements. Default value:$(this.modal).add(this.overlay).fadeOut(100);
show
: Function for showing the modal and overlay. Use this.modal
and this.overlay
to reference the modal and overlay elements. Default value:$(this.modal).add(this.overlay).fadeIn(100);
You may also update the default options before calling either method:
$.alertable.defaults.optionName = yourValue;
Both alert
and confirm
return a promise-compatible (jQuery-deferred) object. As a result, you can use any of the supported chainable methods. However, the examples above demonstrate the most appropriate ones to use.
FAQs
Minimal alert and confirmation alternatives.
The npm package @claviska/jquery-alertable receives a total of 22 weekly downloads. As such, @claviska/jquery-alertable popularity was classified as not popular.
We found that @claviska/jquery-alertable 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.