OI Modals

This is a demonstration and test of the many ways to trigger and determine the content for modals within Opportunity International's front-end framework. The library has jQuery and Weavr as dependencies.


Basic Modal

To create a basic modal, you simply

  1. Add the markup to your document.
  2. Add a data-modal attribute to the element that should trigger the modal.
  3. Initialize the trigger with some Javascript.

Basic modal

Example:



Basic modal






Dynamic content

You can also create modals with dynamic content by declaring them with a bit of Javascript.

Dynamic content

Example:


Dynamic content



iFrame Content

If the data-modal attribute is a URL, the URL will be loaded in an iframe in the modal. If the URL is a Vimeo or YouTube embed URL, it will be displayed in a 16:9 widescreen format. Otherwise it defaults to a 4:3 format.

iframe modal Video modal

Example:


iframe modal

Video modal

Fullscreen Modals

Modals can be displayed "fullscreen" (i.e. full viewport), making them more like an overlay.

Fullscreen modal


Modal Sizes

By default, modals are 400px wide. Other sizes can be set by adding one of Weavr's container classes, such as .contained-12, .contained-9,.contained-6, etc.

Because modals are sized with classes, you have the freedom to define additional sizes by creating your own classes in your stylesheets.

Normal Modal Medium Modal Large Modal X-large Modal


Callback functions

You can declare callback functions to execute before and after a modal closes or opens. You can prevent a modal from opening or closing by returning false from the beforeOpen() and beforeClose() callbacks, respectively.

Try me


Open via Javascript

Modals can also be opened via Javascript instead of being attached to click event handlers.


Lightbox Galleries

Create lightbox-style galleries with OI Lightbox (built on top of OI Modals). Put the image URL in the href attribute, and use the rel attribute to group images into galleries.

Photo 1 | Photo 2 | Photo 3 | Photo 4