@ons/design-system 48.0.1 → 48.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/modal/_macro.njk +15 -13
- package/components/modal/_modal.scss +17 -0
- package/components/modal/modal.js +15 -2
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/timeout.js +2 -2
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -5,19 +5,21 @@
|
|
|
5
5
|
role="dialog"
|
|
6
6
|
aria-labelledby="ons-modal-title"
|
|
7
7
|
{% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}
|
|
8
|
-
>
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
>
|
|
9
|
+
<div class="ons-modal__content">
|
|
10
|
+
<h1 id="ons-modal-title" class="ons-modal__title">
|
|
11
|
+
{{ params.title }}
|
|
12
|
+
</h1>
|
|
13
|
+
<div class="ons-modal__body">
|
|
14
|
+
{{ (params.body if params else "") | safe }}{{ caller() if caller }}
|
|
15
|
+
</div>
|
|
16
|
+
{% if params.btnText %}
|
|
17
|
+
{% from "components/button/_macro.njk" import onsButton %}
|
|
18
|
+
{{ onsButton({
|
|
19
|
+
"text": params.btnText,
|
|
20
|
+
"classes": "ons-js-modal-btn ons-u-mt-s"
|
|
21
|
+
}) }}
|
|
22
|
+
{% endif %}
|
|
14
23
|
</div>
|
|
15
|
-
{% if params.btnText %}
|
|
16
|
-
{% from "components/button/_macro.njk" import onsButton %}
|
|
17
|
-
{{ onsButton({
|
|
18
|
-
"text": params.btnText,
|
|
19
|
-
"classes": "ons-js-modal-btn ons-u-mt-s"
|
|
20
|
-
}) }}
|
|
21
|
-
{% endif %}
|
|
22
24
|
</dialog>
|
|
23
25
|
{% endmacro %}
|
|
@@ -9,8 +9,20 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
|
|
|
9
9
|
margin-right: 2rem;
|
|
10
10
|
max-width: 500px;
|
|
11
11
|
padding: 2rem;
|
|
12
|
+
position: relative;
|
|
12
13
|
width: auto;
|
|
13
14
|
|
|
15
|
+
&-ie11 & {
|
|
16
|
+
background: $color-white;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
height: 350px;
|
|
19
|
+
left: 0;
|
|
20
|
+
position: fixed;
|
|
21
|
+
right: 0;
|
|
22
|
+
top: 50%;
|
|
23
|
+
transform: translate(0, -50%);
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
@media screen and (min-width: 600px) {
|
|
15
27
|
margin-left: auto;
|
|
16
28
|
margin-right: auto;
|
|
@@ -24,6 +36,11 @@ $backdrop-colour: rgba(0, 0, 0, 0.8);
|
|
|
24
36
|
|
|
25
37
|
& + .backdrop {
|
|
26
38
|
background: $backdrop-colour;
|
|
39
|
+
height: 100%;
|
|
40
|
+
left: 0;
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 0;
|
|
43
|
+
width: 100%;
|
|
27
44
|
}
|
|
28
45
|
}
|
|
29
46
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dialogPolyfill from 'dialog-polyfill';
|
|
2
2
|
|
|
3
3
|
const overLayClass = 'ons-modal-overlay';
|
|
4
|
+
const ie11Class = 'ons-modal-ie11';
|
|
4
5
|
|
|
5
6
|
export default class Modal {
|
|
6
7
|
constructor(component) {
|
|
@@ -8,7 +9,7 @@ export default class Modal {
|
|
|
8
9
|
this.launcher = document.querySelector(`[data-modal-id=${component.id}]`);
|
|
9
10
|
this.closeButton = component.querySelector('.ons-js-modal-btn');
|
|
10
11
|
this.lastFocusedEl = null;
|
|
11
|
-
|
|
12
|
+
this.dialogCSSSupported = true;
|
|
12
13
|
this.initialise();
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -33,6 +34,7 @@ export default class Modal {
|
|
|
33
34
|
} else {
|
|
34
35
|
try {
|
|
35
36
|
dialogPolyfill.registerDialog(this.component);
|
|
37
|
+
this.dialogCSSSupported = false;
|
|
36
38
|
return true;
|
|
37
39
|
} catch (error) {
|
|
38
40
|
/* istanbul ignore next */
|
|
@@ -44,9 +46,15 @@ export default class Modal {
|
|
|
44
46
|
openDialog(event) {
|
|
45
47
|
if (!this.isDialogOpen()) {
|
|
46
48
|
this.component.classList.add('ons-u-db');
|
|
47
|
-
document.querySelector('body').
|
|
49
|
+
document.querySelector('body').classList.add(overLayClass);
|
|
50
|
+
|
|
51
|
+
if (!this.dialogCSSSupported) {
|
|
52
|
+
document.querySelector('body').classList.add(ie11Class);
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
this.makePageContentInert();
|
|
49
56
|
this.saveLastFocusedEl();
|
|
57
|
+
|
|
50
58
|
if (event) {
|
|
51
59
|
const modal = document.getElementById(event.target.getAttribute('data-modal-id'));
|
|
52
60
|
modal.showModal();
|
|
@@ -96,6 +104,11 @@ export default class Modal {
|
|
|
96
104
|
}
|
|
97
105
|
this.component.classList.remove('ons-u-db');
|
|
98
106
|
document.querySelector('body').classList.remove(overLayClass);
|
|
107
|
+
|
|
108
|
+
if (!this.dialogCSSSupported) {
|
|
109
|
+
document.querySelector('body').classList.remove(ie11Class);
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
this.component.close();
|
|
100
113
|
this.setFocusOnLastFocusedEl(this.lastFocusedEl);
|
|
101
114
|
this.removeInertFromPageContent();
|