GithubHelp home page GithubHelp logo

larsschwarz / remodal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vodkabears/remodal

1.0 2.0 0.0 643 KB

No longer actively maintained.

Home Page: http://vodkabears.github.io/remodal/

License: MIT License

JavaScript 83.53% CSS 11.51% HTML 4.96%

remodal's Introduction

NPM version Bower version Travis Remodal

No longer actively maintained. I am not interested to maintain jQuery plugins anymore. If you have some fixes, feel free to make PR.

Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.

logo

Notes

  • All modern browsers are supported.
  • IE8+. To enable IE8 styles add the lt-ie9 class to the html element, as modernizr does.
  • jQuery, jQuery2, Zepto support.
  • Browserify support.

Start

Download the latest version from GitHub or via package managers:

npm install remodal
bower install remodal

Include the CSS files from the dist folder in the head section:

<link rel="stylesheet" href="../dist/remodal.css">
<link rel="stylesheet" href="../dist/remodal-default-theme.css">

Include the JS file from the dist folder before the </body>:

<script src="../dist/remodal.min.js"></script>

You can define the background container for the modal(for effects like a blur). It can be any simple content wrapper:

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

And now create the modal dialog:

<div class="remodal" data-remodal-id="modal">
  <button data-remodal-action="close" class="remodal-close"></button>
  <h1>Remodal</h1>
  <p>
    Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.
  </p>
  <br>
  <button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
  <button data-remodal-action="confirm" class="remodal-confirm">OK</button>
</div>

Don't use the id attribute, if you want to avoid the anchor jump, use data-remodal-id.

So, now you can call it with the hash:

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

Or:

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

Options

You can pass additional options with the data-remodal-options attribute.

<div class="remodal" data-remodal-id="modal"
  data-remodal-options="hashTracking: false, closeOnOutsideClick: false">

  <button data-remodal-action="close" class="remodal-close"></button>
  <h1>Remodal</h1>
  <p>
    Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.
  </p>
  <br>
  <button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
  <button data-remodal-action="confirm" class="remodal-confirm">OK</button>
</div>

hashTracking

Default: true

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

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

closeOnConfirm

Default: true

If true, closes the modal window after clicking the confirm button.

closeOnCancel

Default: true

If true, closes the modal window after clicking the cancel button.

closeOnEscape

Default: true

If true, closes the modal window after pressing the ESC key.

closeOnOutsideClick

Default: true

If true, closes the modal window by clicking anywhere on the page.

modifier

Default: ''

Modifier CSS classes for the modal that is added to the overlay, modal, background and wrapper (see CSS).

appendTo

Default: document.body

Globals

<script>
window.REMODAL_GLOBALS = {
  NAMESPACE: 'modal',
  DEFAULTS: {
    hashTracking: false
  }
};
</script>
<script src="../dist/remodal.js"></script>

NAMESPACE

Base HTML class for your modals. CSS theme should be updated to reflect this.

DEFAULTS

Extends the default settings.

Initialization with JavaScript

Do not set the 'remodal' class, if you prefer a JS initialization.

<div data-remodal-id="modal">
  <button data-remodal-action="close" class="remodal-close"></button>
  <h1>Remodal</h1>
  <p>
    Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.
  </p>
</div>
<script>
    var options = {...};

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

Methods

Get the instance of the modal and call a method:

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

/**
 * Opens the modal window
 */
inst.open();

/**
 * Closes the modal window
 */
inst.close();

/**
 * Returns a current state of the modal
 * @returns {'closed'|'closing'|'opened'|'opening'}
 */
inst.getState();

/**
 * Destroys the modal window
 */
inst.destroy();

Events

$(document).on('opening', '.remodal', function () {
  console.log('Modal is opening');
});

$(document).on('opened', '.remodal', function () {
  console.log('Modal is opened');
});

$(document).on('closing', '.remodal', function (e) {

  // Reason: 'confirmation', 'cancellation'
  console.log('Modal is closing' + (e.reason ? ', reason: ' + e.reason : ''));
});

$(document).on('closed', '.remodal', function (e) {

  // Reason: 'confirmation', 'cancellation'
  console.log('Modal is closed' + (e.reason ? ', reason: ' + e.reason : ''));
});

$(document).on('confirmation', '.remodal', function () {
  console.log('Confirmation button is clicked');
});

$(document).on('cancellation', '.remodal', function () {
  console.log('Cancel button is clicked');
});

CSS

Classes

.remodal – the default class of modal dialogs.

.remodal-wrapper – the additional wrapper for the .remodal, it is not the overlay and used for the alignment.

.remodal-overlay – the overlay of modal dialogs, it is under the wrapper.

.remodal-bg – the background of modal dialogs, it is under the overlay and usually it is the wrapper of your content. You should add it on your own.

The remodal prefix can be changed in the global settings. See the NAMESPACE option.

States

States are added to the .remodal, .remodal-overlay, .remodal-bg, .remodal-wrapper classes.

List:

.remodal-is-opening
.remodal-is-opened
.remodal-is-closing
.remodal-is-closed

Modifier

A modifier that is specified in the options is added to the .remodal, .remodal-overlay, .remodal-bg, .remodal-wrapper classes.

Using with other javascript libraries

Remodal has wrappers that make it easy to use with other javascript libraries:

Ember

License

The MIT License (MIT)

Copyright (c) 2015 Ilya Makarov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

remodal's People

Contributors

alecrust avatar antstorm avatar brentswisher avatar dancetrain avatar deyceg avatar esbanarango avatar fantarama avatar kris-b avatar madogai avatar marceloavf avatar pesrepus avatar pidgpowell avatar rootedsoftware avatar tigr avatar vodkabears avatar

Stargazers

 avatar

Watchers

 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.