npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bootstrap-show-modal

v6.0.8

Published

bootstrap plugin to create modals in pure JavaScript, without jQuery

Downloads

1,189

Readme

bootstrap-show-modal

bootstrap plugin to create bootstrap modals in pure JavaScript.

Demo Page

This version is compatible with Bootstrap 5, but we remain a Bootstrap 4 compatible version with the branch bootstrap4-compatible. npm package versions 3.x are Bootstrap 5 compatible, versions 1.x Bootstrap 4 compatible.

With version 5.x of bootstrap-shop-modal we completely removed jQuery 🥳 🚀

Installation

npm install bootstrap-show-modal

Or just download this repository and include src/ShowModal.js.

Usage

Simple Modal

bootstrap.showModal({title: "Hello World!", body: "A very simple modal dialog without buttons."})

Alert Dialog

bootstrap.showAlert({title: "Hi", body: "Please press ok, if you like or dislike cookies."})

Confirm Dialog

bootstrap.showConfirm({
    title: "Please confirm", body: "Do you like cats?", textTrue: "Yes", textFalse: "No",
    onSubmit: function (result) { // callback on confirm
        if (result) {
            bootstrap.showAlert({title: "Result: " + result, body: "You like cats."})
        } else {
            bootstrap.showAlert({title: "Result: " + result, body: "You don't like cats."})
        }
    },
    onDispose: function() {
        console.log("The confirm dialog vanished")
    }
})

Properties

this.props = {
    title: "", // the dialog title html
    body: "", // the dialog body html
    footer: "", // the dialog footer html (mainly used for buttons)
    modalClass: "fade", // Additional css for ".modal", "fade" for fade effect
    modalDialogClass: "", // Additional css for ".modal-dialog", like "modal-lg" or "modal-sm" for sizing
    options: { // The Bootstrap modal options as described here: https://getbootstrap.com/docs/4.0/components/modal/#options
        backdrop: 'static' // disallow closing on click in the background
    },
    draggable: false, // make the dialog draggable 🆕
    // Events:
    onCreate: null, // Callback, called after the modal was created
    onShown: null, // Callback, called after the modal was shown and completely faded in
    onDispose: null, // Callback, called after the modal was disposed
    onSubmit: null // Callback of bootstrap.showConfirm(), called after yes or no was pressed
}

See the Bootstrap 4 Modal documentation for possible values of options, modalClass and modalDialogClass.

Minified version

I don't provide a minified version because I think it should be up to the using programmer to create minified versions, with all the used script sources concatenated to one file.

But, if you want it, it is easy to create your minified version with uglify: https://www.npmjs.com/package/uglify-js

Just install uglify

npm install uglify-js -g

and then in the src-folder

uglifyjs ShowModal.js --compress --mangle > ShowModal.min.js

Browser support

It works in all modern browsers and in the Internet Explorer. Not tested with IE < 11.

You may want to check out my further Bootstrap and HTML extensions