JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 243
  • Score
    100M100P100Q78560F
  • License MIT

A simple JavaScript popup alert manager.

Package Exports

  • js-alert

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-alert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

js-alert

A simple JavaScript alert manager.

Use from the browser

The simplest way to use from the browser is to include the minified script:

<script src="https://npmcdn.com/js-alert@1.0.0/dist/jsalert.min.js"></script>

Use from Node

To use this library in your node web app, first install the dependency:

npm install --save js-alert

Then you can use it in your project:

var JSAlert = require("js-alert");

Usage examples

See all tests here.

// Show a plain alert
JSAlert.alert("This is an alert.");
// Show an alert with a title and custom dismiss button
JSAlert.alert("Your files have been saved successfully.", "Files Saved", "Got it");
// Show multiple alerts (alerts are automatically queued)
JSAlert.alert("This is the first alert.");
JSAlert.alert("This is the second alert.");
JSAlert.alert("This is the third and final alert.");
// Automatically dismiss alert
JSAlert.alert("This will only last 10 seconds").dismissIn(1000 * 10);
// Event when dismissed
JSAlert.alert("This one has an event listener!").then(function() {
    console.log("Alert dismissed!");
});
// Show a confirm alert
JSAlert.confirm("Are you sure you want to delete this file?").then(function(result) {

    // Check if pressed yes
    if (!result)
        return;
    
    // User pressed yes!
    JSAlert.alert("File deleted!");

});
// Create an alert with custom buttons
var alert = new JSAlert("My text", "My title");
alert.addButton("Yes").then(function() {
    console.log("Alert button Yes pressed");
});
alert.addButton("No").then(function() {
    console.log("Alert button No pressed");
});
alert.show();

Building the library

To create a minified build of this library, run this:

npm run build

A built version of the library will be saved to the dist folder.