Code Monkey home page Code Monkey logo

modal's Introduction

modal

An extremely simple modal plugin developed with Vanilla JS

Demo

View demo here

Download

You can download the latest version or checkout all the releases here.

How to use?

Require the package or use the global Modal namespace:

AMD

<script>
require(["path/to/modal.js"], function(Modal) {
    // Code here
});
</script>

commonJS

var Modal = require('modal');

ES6

import Modal from 'modal';

Browser

<script src="path/to/modal.js"></script>

Basic Usage

Open modal with custom content or html:

<script>
    new Modal({
        content: '<div class="my-class">Content of my modal here</div>'
    });
</script>

Open modal indicating an element in the HTML:

<div class="mdl-content" style="display: none">
    <h2>Modal content here</h2>
</div>

<script>
    var mdl = document.querySelector('.mdl-content');

    new Modal({
        content: mdl
    });
</script>

Options

The script expect the following options:

Value Description
content String/DOM node. Required. The content of your modal.
minHeight Integer/String. Optional. The min-height of modal. Default is 250px.
maxWidth Integer/String. Optional. The min-height of modal. Default is 600px.
onOpen Optional. Function to run after modal is open.
onClose Optional. Function to run after modal is closed.

Browser Support

IE Chrome Firefox Opera Safari
IE 10+ ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔

Contributing

Check CONTRIBUTING.md for more information.

History

Check Releases for detailed changelog.

License

MIT

modal's People

Contributors

pinceladasdaweb avatar

Stargazers

WEBBAB avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.