Repository URL to install this package:
|
Version:
1.1.9 ▾
|
| config |
| css |
| js |
| src |
| templates |
| tests |
| README.md |
| composer.json |
| melt_modal.info.yml |
| melt_modal.libraries.yml |
| melt_modal.links.menu.yml |
| melt_modal.module |
| melt_modal.routing.yml |
This module leverages iziModal to add the ablility for buttons and links to trigger modals.
NOTE: You can technically leverage any of iziModal options as data attributes. Read their docs for more information.
composer require drupal/melt_modal
For basic modal functionality, just add the data-izimodal-open="TARGET" attribute to any button or link. Replace TARGET with a CSS selector that targets the modal the link/button is suppose to open. We recommend using an id if possible.
Underneath the hood, we initialize the modals based on the target value of the data-izimodal-open attribute. This allows us to just leverage the data attributes of the iziModal libary.
<!-- Modal Trigger --> <a href="#" data-izimodal-open="#cool-modal"> Open </a> <!-- Modal --> <div id="cool-modal"> <!-- ADD CONTENT --> <button type="button" data-izimodal-close="true">Close</button> </div>
It's common for sites we build to have a modal popup that alerts the user that they've clicked on a url that'll take them to another website. So we've extended iziModal to handle modals for 3rd party links. There's only 2 requirement:
<a> and include a valid url in the href.data-externallink-continue="TARGET" attribute. This targets the "continue" link in the modal.A settings page has been created at admin/config/melt_modal/modal that allows you to:
<!-- External Link Modal Trigger --> <a href="https://www.meltmedia.com" data-izimodal-open="#external-link-modal" data-externallink-continue=".external-link--continue">Go to external link</a> <!-- External Link Modal --> <div id="external-link-modal"> <!-- ADD CONTENT --> <a href="#" class="external-link--continue">OK</a> <button type="button" data-izimodal-close="true">Close</button> </div>
There has been a special data-izimodal-video attribute that takes a string of JSON based on some of the options provided. Currently autoplay is the only option available. Each <video> should be a mediaelement instance. If using DX8's video element, then it automatically uses MediaElement.js.
<!-- External Link Modal Trigger --> <a href="https://www.meltmedia.com" data-izimodal-open="#external-link-modal" data-izimodal-video='{ "autoplay": true}'>Open Modal</a> <!-- External Link Modal --> <div id="external-link-modal"> <video src="myvideo.mp4" width="320" height="240" class="mejs__player" data-mejsoptions='{"pluginPath": "/path/to/shims/", "alwaysShowControls": "true"}'></video> <button type="button" data-izimodal-close="true">Close</button> </div>