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.
- All modern browsers are supported.
- IE8+. To enable IE8 styles add the
lt-ie9class to thehtmlelement, as modernizr does. - jQuery, jQuery2, Zepto support.
- Browserify support.
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:
<linkrel="stylesheet" href="../dist/remodal.css"><linkrel="stylesheet" href="../dist/remodal-default-theme.css">Include the JS file from the dist folder before the </body>:
<scriptsrc="../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:
<divclass="remodal-bg"> ...Page content... </div>And now create the modal dialog:
<divclass="remodal" data-remodal-id="modal"><buttondata-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><buttondata-remodal-action="cancel" class="remodal-cancel">Cancel</button><buttondata-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:
<ahref="#modal">Call the modal with data-remodal-id="modal"</a>Or:
<adata-remodal-target="modal">Call the modal with data-remodal-id="modal"</a>You can pass additional options with the data-remodal-options attribute.
<divclass="remodal" data-remodal-id="modal" data-remodal-options="hashTracking: false, closeOnOutsideClick: false"><buttondata-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><buttondata-remodal-action="cancel" class="remodal-cancel">Cancel</button><buttondata-remodal-action="confirm" class="remodal-confirm">OK</button></div>Default: true
To open the modal without the hash, use the data-remodal-target attribute.
<adata-remodal-target="modal" href="#">Call the modal with data-remodal-id="modal"</a>Default: true
If true, closes the modal window after clicking the confirm button.
Default: true
If true, closes the modal window after clicking the cancel button.
Default: true
If true, closes the modal window after pressing the ESC key.
Default: true
If true, closes the modal window by clicking anywhere on the page.
Default: ''
Modifier CSS classes for the modal that is added to the overlay, modal, background and wrapper (see CSS).
Default: document.body
<script>window.REMODAL_GLOBALS={NAMESPACE: 'modal',DEFAULTS: {hashTracking: false}};</script><scriptsrc="../dist/remodal.js"></script>Base HTML class for your modals. CSS theme should be updated to reflect this.
Extends the default settings.
Do not set the 'remodal' class, if you prefer a JS initialization.
<divdata-remodal-id="modal"><buttondata-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>varoptions={...};$('[data-remodal-id=modal]').remodal(options);</script>Get the instance of the modal and call a method:
varinst=$('[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();$(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');});.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 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 A modifier that is specified in the options is added to the .remodal, .remodal-overlay, .remodal-bg, .remodal-wrapper classes.
Remodal has wrappers that make it easy to use with other javascript libraries:
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. 