121 lines
4.1 KiB
Markdown
Raw Normal View History

2015-05-28 20:44:07 +10:00
# Popups
2015-09-26 08:24:16 +10:00
Displays a modal popup, based on the Bootstrap modal implementation.
2015-05-28 20:44:07 +10:00
2015-09-26 08:24:16 +10:00
- [Examples](#examples)
- [Inline popups](#inline-popups)
- [Remote popups](#remote-popups)
2015-09-26 08:29:17 +10:00
- [API documentation](#api-docs)
2015-05-28 20:44:07 +10:00
2015-09-26 08:24:16 +10:00
<a name="examples"></a>
## Examples
2015-05-28 20:44:07 +10:00
2015-09-26 08:24:16 +10:00
<a data-toggle="modal" href="#contentBasic" class="btn btn-primary btn-lg">Launch basic content</a>
<div class="control-popup modal fade" id="contentBasic" tabindex="-1" role="dialog">
2015-05-28 20:44:07 +10:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<p>This is a very basic example of a popup...</p>
</div>
</div>
</div>
</div>
<a data-toggle="modal" href="#content-confirmation" class="btn btn-primary btn-lg">Launch Confirmation dialog</a>
<div class="control-popup modal fade" id="content-confirmation" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Are you sure you wanna do that?</h4>
</div>
<div class="modal-body">
<p>This is your last chance. After this, there is no turning back.</p>
<p>You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill - you stay in Wonderland, and I show you how deep the rabbit hole goes.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Blue Pill</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Red Pill</button>
</div>
</div>
</div>
</div>
2015-09-26 08:24:16 +10:00
<a name="inline-popups"></a>
## Inline popups
An inline popup places the popup content inside the current page, hidden from the view. For example, this container will not be visible on the page.
```html
<div class="control-popup modal fade" id="contentBasic">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<p>This is a very basic example of a popup...</p>
</div>
</div>
</div>
</div>
```
Use the `data-toggle="modal"` HTML attribute to launch this container as a popup.
```html
<a data-toggle="modal" href="#contentBasic" class="btn btn-primary btn-lg">
Launch basic content
</a>
```
<a name="remote-popups"></a>
## Remote popups
Content for the popup can be loaded remotely using an AJAX request. Use the `data-handler` attribute to populate a popup with the contents of an AJAX handler.
```html
<a
data-control="popup"
data-handler="onLoadContent"
href="javascript:;"
class="btn btn-primary btn-lg">
Launch Ajax Form
</a>
```
Using the `data-ajax` attribute you can refer to an external file or URL directly.
```html
<a
data-control="popup"
data-ajax="popup-content.htm"
href="javascript:;"
class="btn btn-primary btn-lg">
Launch Ajax Form
</a>
```
2015-09-26 08:29:17 +10:00
<a name="api-docs"></a>
## API documentation
### Options:
- content: content HTML string or callback
2016-09-30 10:09:15 +10:00
### Data attributes
2015-09-26 08:29:17 +10:00
- data-control="popup" - enables the ajax popup plugin
- data-ajax="popup-content.htm" - ajax content to load
- data-handler="onLoadContent" - October ajax request name
- data-keyboard="false" - Allow popup to be closed with the keyboard
- data-extra-data="file_id: 1" - October ajax request data
- data-size="large" - Popup size, available sizes: giant, huge, large, small, tiny
2016-09-30 10:09:15 +10:00
### JavaScript API
2015-09-26 08:29:17 +10:00
```js
$('a#someLink').popup({ ajax: 'popup-content.htm' })
$('a#someLink').popup({ handler: 'onLoadSomePopup' })
$('a#someLink').popup({ handler: 'onLoadSomePopup', extraData: { id: 3 } })
```