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

extendedbootstrapmodal

v1.0.1

Published

## Overview Extended Bootstrap Modal is a **simple** Javascript plugin enables you to generate a complex bootstrap modal **without any HTML code**.

Downloads

17

Readme

ExtendedBootstrapModal

Overview

Extended Bootstrap Modal is a simple Javascript plugin enables you to generate a complex bootstrap modal without any HTML code.

Requirements

  • Jquery 1.10 or higher.

Installation

<!-- Import Jquery -->
<script
  src="https://code.jquery.com/jquery-1.12.4.min.js"
  integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
  crossorigin="anonymous"></script>

<!-- Import Bootstrap -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Import Extended bootstrap modal plugin -->
<script src="plugin/extendedBootstrapModal.js"></script>

How to use it

Simple modal

You can simply use the plugin without any parameters, it will generate a simple and classic bootstrap modal with the given text, and a close button.

This is an elegant way to replace the old Javascript Alert, and this is as simple as it.

Sample

ExtendedBoostrapModal('Simple modal without any parameters');

MacDown Screenshot

Modal state

You can specify a modal state to change the header color :

  • success
  • warning
  • danger
  • info
  • primary

MacDown Screenshot

Complex modal

The plugin become a powerfull tools when you want to generate complex modal with many HTML components.

  • No HTML code
  • Many modals on the same page without duplicate code
  • Possibility to to add a form with inputs, radio button, checkbox and dropdown list
  • Add Bootstrap row with many columns
  • Easily customizable

Autoload modal with text

ExtendedBoostrapModal({
    autoload: true,
    id: 'my-modal',
    title: 'Sample modal'
});

Modal with simple form

You can add an HTML form by using addForm parameter with id, name, and a list of HTML tags. If you use it, you have to manually define a collection of buttons (at least one for closing).

You can define a callback on each button by using callback parameter, and add parameters with arguments.

ExtendedBoostrapModal({
    autoload: true,
    id: 'my-modal',
    title: 'Sample modal',
    addForm: {
        id: 'form_id',
        name: 'form_name',
        inputs: {
            label: 'textInput',
            list: [
                {
                    id: 'input_id',
                    name: 'input_name',
                    type: 'text',
                    value: '',
                    placeholder: 'my text input'
                }
            ]
        },
        buttons: [
            {
                value: 'Cancel',
                type: 'button'
            },
            {
                name: 'btn_add',
                value: 'Validate',
                type : 'button',
                class: 'btn-success',
                callback: 'my_callback_fct',
                arguments : ['arg1', 'arg2']
            }
        ]
    }
});

function my_callback_fct(arg1, arg2)
{
}

MacDown Screenshot

Modal with complex form

You can add the following components :

  • Input text (with or without pattern)
  • Radio button
  • Checkbox
  • Select

Each component works the same way : you just have to add a node with a name and a tags list.

Input text
inputs: {
    label: 'input1',
    list: [
        {
            id: 'input_id1',
            name: 'input_name1',
            type: 'text',
            value: '',
            placeholder: 'my first text input'
        },
        {
            id: 'input_id2',
            name: 'input_name2',
            type: 'text',
            value: '',
            placeholder: 'my second text input with pattern',
            pattern: '.{5,}' // Pattern example, contain 5 or more characters
        }
    ]
}
Radio button

/!\ You have to use the same name for each radio if you want to linked them

radios : {
	label : 'radios',
	list: [
	    {
	        name: 'radio_name',
	        value: 'choice_1',
	        content: 'Choice 1',
	        checked: true
	    },
	    {
	        name: 'radio_name',
	        value: 'choice_2',
	        content: 'Choice 2'
	    }
	]
}
Checkbox
checkboxs : {
    label : 'checkboxs',
    list: [
        {
            name: 'check1',
            content: 'Choice 1'
        },
        {
            name: 'check2',
            content: 'Choice 2'
        }
    ]
}
Select
selects: {
    label : 'selects',
    list : [
        {
            name:"myList",
            options : [
                {
                    name: 'opt1',
                    value: 'Option 1'
                },
                {
                    name: 'opt2',
                    value: 'Option 2',
                    selected: true
                },
            ],
        }
    ]
}

Complete sample

Here is a complete sample you can use to build your proper modal.

ExtendedBoostrapModal({
    autoload: true,
    id: 'my-modal',
    title: 'Sample modal',
    addForm: {
        id: 'form_id',
        name: 'form_name',
        inputs: {
            label: 'textInput',
            list: [
                {
                    id: 'input_id',
                    name: 'input_name',
                    type: 'text',
                    value: '',
                    placeholder: 'my text input'
                }
            ]
        },
        buttons: [
                {
                    value: 'Cancel',
                    type: 'button'
                },
                {
                    name: 'btn_add',
                    value: 'Validate',
                    type : 'button',
                    class: 'btn-success',
                    callback: 'my_callback_fct',
                    arguments : ['arg1', 'arg2']
                }
        ],
        radios : {
            label : 'radios',
            list: [
                {
                    name: 'radio_name',
                    value: 'choice_1',
                    content: 'Choice 1'
                },
                {
                    name: 'radio_name',
                    value: 'choice_2',
                    content: 'Choice 2'
                }
            ]
        },
        checkboxs : {
            label : 'checkboxs',
            list: [
                {
                    name: 'check1',
                    content: 'Choice 1'
                },
                {
                    name: 'check2',
                    content: 'Choice 2'
                }
            ]
        },
        selects: {
            label : 'selects',
            list : [
                {
                    name:"myList",
                    options : [
                        {
                            name: 'opt1',
                            value: 'Option 1'
                        },
                        {
                            name: 'opt2',
                            value: 'Option 2',
                            selected: true
                        },
                    ],
                }
            ]
        }
    }
});

MacDown Screenshot