Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit a0e5503

Browse files
authored
Merge branch 'master' into prompt-widget-documentation-adjustments
2 parents 07591d7 + 922ca0c commit a0e5503

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
9.56 KB
Loading

guides/v2.1/javascript-dev-guide/widgets/widget_alert.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The alert widget has the following options:
5656
- [content]
5757
- [focus]
5858
- [title]
59+
- [modalClass]
5960

6061
### `actions` {#alert_actions}
6162
Widget callbacks.
@@ -105,14 +106,83 @@ The title of the alert window.
105106

106107
**Default value**: `''`
107108

109+
### `modalClass` {#alert_modalClass}
110+
The CSS class of the alert window.
111+
112+
**Type**: String.
113+
114+
**Default value**: `'confirm'`
115+
108116
## Events {#alert_events}
109117

110118
The alert widget implements a single event: the `always` callback.
119+
The `always` callback is invoked when a modal window is closed.
111120

112121
## Keyboard navigation {#alert_key_navigation}
113122

114123
The keyboard navigation for the alert windows is similar to the [navigation of the modal widget].
115124

125+
## Code Sample
126+
127+
### Code sample of standalone initialization
128+
129+
```html
130+
<div class="alert-modal-content">
131+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci amet aut consequuntur culpa cum, distinctio earum harum, iste magnam nobis numquam pariatur tempora ullam vero vitae. Hic ipsam itaque velit.</p>
132+
</div>
133+
134+
<script>
135+
require([
136+
'jquery',
137+
'Magento_Ui/js/modal/alert'
138+
], function ($, alert) {
139+
'use strict';
140+
141+
alert({
142+
title: 'Alert Title',
143+
content: $('.alert-modal-content'),
144+
modalClass: 'alert',
145+
actions: {
146+
always: function() {
147+
// do something when the modal is closed
148+
}
149+
}
150+
});
151+
});
152+
</script>
153+
```
154+
155+
### Code sample of initialization on an element
156+
157+
```html
158+
<div class="alert-modal-content">
159+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci amet aut consequuntur culpa cum, distinctio earum harum, iste magnam nobis numquam pariatur tempora ullam vero vitae. Hic ipsam itaque velit.</p>
160+
</div>
161+
162+
<script>
163+
require([
164+
'jquery',
165+
'Magento_Ui/js/modal/alert'
166+
], function ($) {
167+
'use strict';
168+
169+
$('.alert-modal-content').alert({
170+
title: 'Alert Title',
171+
modalClass: 'alert',
172+
actions: {
173+
always: function() {
174+
// do something when the modal is closed
175+
}
176+
}
177+
});
178+
});
179+
</script>
180+
```
181+
182+
## Result
183+
184+
![Alert Widget]({{ site.baseurl }}/common/images/widget/alert-widget-result.png)
185+
116186
[Magento modal widget]: {{ page.baseurl }}/javascript-dev-guide/widgets/widget_modal.html
117187
[`<Magento_Ui_module_dir>/view/base/web/js/modal/alert.js`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Ui/view/base/web/js/modal/alert.js
118188
[Magento Admin Pattern Library, the Slide-out Panels, Modal Windows, and Overlays topic.]: {{ page.baseurl }}/pattern-library/containers/slideouts-modals-overlays/slideouts-modals-overalys.html#modals
@@ -123,4 +193,5 @@ The keyboard navigation for the alert windows is similar to the [navigation of t
123193
[content]: #alert_content
124194
[focus]: #alert_focus
125195
[title]: #alert_title
196+
[modalClass]: #alert_modalClass
126197
[navigation of the modal widget]: {{ page.baseurl }}/javascript-dev-guide/widgets/widget_modal.html#key_navigation

0 commit comments

Comments
 (0)