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

glory-modal

v2.3.2

Published

Modal dialog plugin, written in pure JavaScript.

Downloads

167

Readme

Glory-modal

Demo

Demo

Installation

NPM

npm i glory-modal

or CDN (do not forget to replace {version} with the current version)

https://unpkg.com/glory-modal@latest/dist/gmodal.css
https://unpkg.com/glory-modal@latest/dist/gmodal.js

or basic download

Use

Include the plugin styles

<link rel="stylesheet" href="gmodal.css">

Or If you use SASS, you can import a sass source

@import './node_modules/glory-modal/src/scss/gmodal.scss';

We will need a modal window markup

<div class="gmodal" id="exampleModal" role="dialog" aria-labelledby="Modal">
  <div class="gmodal__container">
    <div class="gmodal__dialog">
      <div class="gmodal__header">
        <div class="gmodal__title">Modal</div>
        <button type="button" class="gmodal__close" data-gmodal="dismiss">
            <svg width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6.34 6.34l11.32 11.32m-11.32 0L17.66 6.34"/>
          </svg>
        </button>
      </div>
      <div class="gmodal__body">
        Some content
      </div>
      <div class="gmodal__footer">
        <button data-gmodal="dismiss">Close</button>
      </div>
    </div>
  </div>
</div>

Add the plugin to the page

<script src="gmodal.js"></script>

or if you are using a module bundler

import Gmodal from 'glory-modal';

Init plugin

var modal = new Gmodal('#exampleModal');

Options

But we can also use advanced plugin options. Available options and their default values.

new Gmodal(elem, {
  stickySelectors: [],
  animation: true,
  backdrop: true,
  closeBackdrop: true,
  keyboard: true
});

elem (string | HTMLElement) selector or element

stickySelectors (array of strings) array with selectors (fixed elements will also be margin-right)

animation (bool) modal animation

backdrop (bool) add backdrop

closeBackdrop (bool) close by clicking on the backdrop, only if the backdrop: true

keyboard (bool) Keyboard events

Public methods

Public methods for working with the plugin

.open()

This method open modal dialog

.close()

This method close modal dialog.

.destroy()

This method stops the plugin. To reinitialize, you need to call the constructor again.

Static properties and methods

Gmodal.closeAll()

Method will be useful when several modals are open and you need to close all at once

Gmodal.modals

Array with data about open modals

Events

Plugin provides an event for open|close modal

var elem = document.querySelector('#modal');
var modal = new Gmodal(elem);

elem.addEventListener('gmodal:beforeopen', function(evt) {
  console.log(evt)
})
elem.addEventListener('gmodal:open', function(evt) {
  console.log(evt)
})
elem.addEventListener('gmodal:beforeclose', function(evt) {
  console.log(evt)
})
elem.addEventListener('gmodal:close', function(evt) {
  console.log(evt)
})