Giter VIP home page Giter VIP logo

remodal's Introduction

Remodal

Flat, responsive, lightweight, fast, easy customizable modal window plugin with declarative state notation and hash tracking.

Minified version size: ~4kb

Notes

  • All modern browsers are supported.
  • Only webkit browsers has a blur effect in the default css theme. If you want a blur for another kind of browsers use: https://github.com/Schepp/CSS-Filters-Polyfill, but it's not fast like a native css3 blur.
  • IE9+
  • Zepto support.

Start

That's very simple too start using Remodal.

Add this in the head section:

<link rel="stylesheet" href="path/to/your/jquery.remodal.css">

Add this before the </body>(or in the head):

<script src="path/to/your/jquery.remodal.min.js"></script>

Define the background container for the modal(for effects like a blur). It could be any simple content wrapper:

<div class="remodal-bg">
...All your content...
</div>

And now create a modal dialog:

<div class="remodal" data-remodal-id="modal">
    <h1>Remodal</h1>
    <p>
      Flat, responsive, lightweight, fast, easy customizable modal window plugin
      with declarative state notation and hash tracking.
    </p>
    <br>
    <a class="remodal-cancel" href="#">Cancel</a>
    <a class="remodal-confirm" href="#">OK</a>
</div>

So, now you can call it with a hash:

<a href="#modal">Call the modal with data-remodal-id="modal"</a>

Options

You can pass additional options by the data-remodal-options attribute. Data must be valid JSON.

<div class="remodal" data-remodal-id="modal"
    data-remodal-options='{ "hashTracking": false }'>
    <h1>Remodal</h1>
    <p>
      Flat, responsive, lightweight, fast, easy customizable modal window plugin
      with declarative state notation and hash tracking.
    </p>
    <br>
    <a class="remodal-cancel" href="#">Cancel</a>
    <a class="remodal-confirm" href="#">OK</a>
</div>

hashTracking

Default: true

To open a modal without a hash, use data-remodal-target attribute.

<a data-remodal-target="modal" href="#modal">Call the modal with data-remodal-id="modal"</a>

Events

$(document).on('open', '.remodal', function () {
    var modal = $(this);
});

$(document).on('opened', '.remodal', function () {
    var modal = $(this);
});

$(document).on('close', '.remodal', function () {
    var modal = $(this);
});

$(document).on('closed', '.remodal', function () {
    var modal = $(this);
});

$(document).on('confirm', '.remodal', function () {
    var modal = $(this);
});

$(document).on('cancel', '.remodal', function () {
    var modal = $(this);
});

Cool bro! But i don't like declarative style!

Ok, don't set class attribute and write something like this:

<script>
    var options = {...};
    $('[data-remodal-id=modal]').remodal(options).open();
</script>

Don't use id attribute, if you don't want browser scrolling to the anchor point.

Methods

Get an instance of modal and call a method:

var inst = $.remodal.lookup[$('[data-remodal-id=modal]').data('remodal')];

// open a modal
inst.open();

// close a modal
inst.close();

remodal's People

Contributors

vodkabears avatar

Stargazers

Yashi Lanka avatar

Watchers

Yashi Lanka 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.