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

quick-modal

v2.3.6

Published

Generate a custom modal quickly

Downloads

278

Readme

quickModal

Create a custom modal quickly.

Doc

  • Installation

Simply import QuickModal into your HTML.

<link rel="stylesheet" type="text/css" href="https://unpkg.com/[email protected]/quickModal.min.css">
<script src="https://unpkg.com/[email protected]/quickModal.min.js"></script>	
  • How to use

Initialize your modal:

// Without jQuery
const modal = new QuickModal(options);

// Shorthand for a simple title + body
const modal = new QuickModal('Your title', 'Your message');

// With jQuery
$(document).quickModal(options);
  • Options
{
  document: window.document,        // Document in which the QuickModal should be opened into, window.document is used by default
  darkenBackground: true,           // Darken your page background when the modal is active
  isForm: true,                     // Your modal contains a form
  keepHidden: false,                // Hide the modal instead of destroying it on close
  closeText: 'OK',                  // Close button text
  classes: [],                      // Your modal classes (String[])
  attributes: {                     // Your modal additional attributes (attribute name : attribute value)
    'data-modal': 'true'
  },
  form: {                           // If isForm is set to true, this object will define your form properties
    action: 'path/to/your/form',    // Form ACTION attribute
    method: 'POST',                 // Form METHOD attribute
    id: 'formId',                   // Form ID
    classes: [],                    // Form classes (String[])
    submit: 'OK'                    // Form Submit text
  },
  header: '<div>Custom HTML</div>', // Modal header content
  body: [                           // Array containing all your modal lines
    {
      type: 'text',                 // Possible values ["text","form"] If set to 'text', creates a simple HTML node
      text: 'I am Text !',          // Your line text
      tag: 'h3',                    // Your line tag
      id: 'myId',                   // Your line id
      classes: [                    // Your line classes
        'class1',
        'class2'
      ],
      attributes: {                 // Your line additionnal attributes
        'data-modal': 'true'
      },
	  children: [                   // List of children elements
        {
          type: 'text',
          text: 'I am Text !',
          tag: 'h3',
          id: 'myId',
          classes: [
            'class1',
            'class2'
          ],
          attributes: {
            'data-modal': 'true'
          },
	      children: [ ... ]
        }
	  ]
    },
    {
      type: 'form',                 // Possible values ["text","form"] If set to 'form', create a new HTML Node with a label and your tag.
      label: 'I am Input !',        // Your input label
      inputType: 'text',            // If tag == 'input', set this to set your input TYPE attribute
      placeholder: 'Placeholder',   // If tag == 'input' or 'textarea', set this to set your input PLACEHOLDER attribute
      name: 'formText',             // Your input NAME attribute
      value: 'currentValue',        // Your input VALUE attribute
      tag: 'input',                 // Your input tag
      id: 'myInput',                // Your input ID
      classes: [                    // Your input classes
        'class1',
        'class2'
      ]
    },
    {
      type: 'form',
      label: 'I am Select !',
      name: 'formSelect',
      tag: 'select',
      id: 'mySelect',
      classes: [
        'class1',
        'class2'
      ],
      options: [                    // If tag == 'select', contains your select options
        {
          value: 'val', 
          text: 'Option 1', 
          selected: false,
          attributes: {             //Add attributes to your options
            'data-modal': 'true'
          }
        },
        {
          value: 'val2', 
          text: 'Option 2', 
          selected: true
        },
      ]
    }
  ],
  footer: [                          // Contains an array of links displayed at the bottom of your modal
    {
      text: 'I am Link !',           // Your link text
      href: 'path/to/link',          // Your link Href
      id: 'myLink',                  // Your link ID
      classes: [                     // Your link classes
        'class1',
        'class2'
      ]
    }
  ],
  afterOpen: function(modal) {},     // Callback triggered after the modal opens. Parameter is the modal NODE.
  beforeClose: function(modal) {},   // Callback triggered right before the modal closes. Parameter is the modal NODE.
  onSubmit: function(event, form) {} // Callback triggered when the form is submitted. Parameter are the event and the form NODE.
}
  • Methods
modal.open(); 		// Opens the modal (If previously closed)
modal.close(); 		// Closes the modal
modal.destroy(); 	// Destroys the modal
  • Example

See this JSFiddle for a working example

Authors