A Flight component for UI Modals
bower install --save flight-modalFor a demo visit https://giuseppeg.github.io/flight-modal
define(function (require) {
'use strict';
var modal = require('component/modal');
return initialize;
function initialize() {
modal.attachTo('#modal');
modal.attachTo('#modal2', {
autoOpen: true,
closeEnabled: false
});
}
});What you need is a container (eg .modal) and a content container (eg .modal-content).
<div class="modal" id="modal" data-size="l" data-effect="scale">
<div class="modal-content">
<div class="modal-header">
<h2>Flight Modal</h2>
</div>
<div class="modal-body">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="modal-footer">
<p>© Giuseppe Gurgone</p>
</div>
<nav aria-hidden="true">
<a href="#modal" class="modal-close">close</a>
<a href="#modal" class="modal-fullscreen-btn">toggle fullscreen</a>
</nav>
</div>
</div>Flight modal takes care of the modal dialog only and it reacts to events.
Therefore it doesn't provide logic for an open button.
Flight Modal doesn't ship with CSS.
However I wrote some CSS for the demo.
Feel free to use it.
-
dialogSelector: '.modal-content'the modal dialog -
activeClass: 'modal-is-active'added to both the modal* and thehtmlelement -
inactiveClass: 'modal-is-inactive'added when the modal* is hidden -
aboveClass: 'modal-is-above'added to the last activated modal -
toggleUsingCSS: falseit turns off the javascript hide/show logic and let you hiding/showing the modal with CSS (so that you can add fancy CSS3 effects for instance) -
autoOpen: falseauto opens the modal after initialization
Close button
-
closeEnabled: trueif false disable the close functionality -
closeBtnSelector: '.modal-close'the close button
Fullscreen mode
-
fullScreenEnabled: trueif true allows you to togglefullScreenClass -
fullScreenClass: 'modal-fullscreen'added to the modal* on toggle -
fullScreenBtnSelector: '.modal-fullscreen-btn'the toggle fullscreen button
* the outer container
-
uiModalShownfired when a modal is shown. TheeventDataobject contains the modal id. -
uiModalHiddenfired when a modal is hidden. TheeventDataobject contains the modal id. -
uiModalFullScreenEnabledfired when a modal goes in fullscreen mode. TheeventDataobject contains the modal id. -
uiModalFullScreenDisabledfired when a modal exits the fullscreen mode. TheeventDataobject contains the modal id. -
uiModalRequestedwhen fired opens all the modal dialogs in the page. Pass an id with theeventDataobject to open a specific modal eg.this.trigger(document, 'uiModalRequested', { id: 'myModal'} ) -
uiModalCloseRequestedwhen fired hides all the modal dialogs in the page. Pass an id with theeventDataobject to hide a specific modal eg.this.trigger(document, 'uiModalCloseRequested', { id: 'myModal'} ) -
uiModalToggleFullScreenwhen fired with an id toggles thefullScreenClassclass -
uiModalTeardownAllwhen fired it teardowns all the modal dialogs -
uiModalTeardownwhen fired with an id it teardowns the corrispondent modal
Development of this component requires Bower, and preferably Karma to be globally installed:
npm install -g bower karmaThen install the Node.js and client-side dependencies by running the following commands in the repo's root directory.
npm install
bower installTo continuously run the tests in Chrome and Firefox during development, just run:
karma startAnyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.
