@qhealth-design-system/core 1.22.1 → 1.23.0
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/.storybook/assets/image-position-demo-portrait.svg +54 -0
- package/.storybook/assets/image-position-demo.svg +55 -0
- package/.storybook/globals.js +10 -1
- package/.storybook/preview.js +8 -1
- package/CHANGELOG.md +4 -0
- package/README.md +0 -6
- package/package.json +13 -33
- package/src/assets/img/svg-icons.svg +154 -154
- package/src/component-loader.js +11 -2
- package/src/components/_global/css/admin/component.scss +1 -0
- package/src/components/_global/css/btn/component.scss +9 -0
- package/src/components/_global/css/img/image-position-utility-classes.scss +30 -0
- package/src/components/_global/css/img/image-ratio-utility-classes.scss +41 -0
- package/src/components/_global/css/img/images.scss +74 -5
- package/src/components/_global/css/modal/component.scss +1 -0
- package/src/components/_global/js/animate/global.js +272 -294
- package/src/components/_global/js/collapsible.js +3 -3
- package/src/components/_global/js/global.js +304 -316
- package/src/components/_global/js/legacyGlobal.js +63 -0
- package/src/components/_global/js/modal/global.js +218 -223
- package/src/components/_global/js/popover/controller.js +4 -4
- package/src/components/_global/js/tabs/global.js +264 -276
- package/src/components/a-z_listing/js/global.js +106 -92
- package/src/components/accordion/css/component.scss +24 -41
- package/src/components/accordion/html/component.hbs +23 -5
- package/src/components/accordion/js/global.js +5 -10
- package/src/components/basic_search/js/global.js +0 -7
- package/src/components/code/js/global.js +6 -12
- package/src/components/file_upload/js/global.js +1 -5
- package/src/components/internal_navigation/css/component.scss +2 -2
- package/src/components/internal_navigation/html/component.hbs +16 -1
- package/src/components/main_navigation/js/global.js +341 -335
- package/src/components/overflow_menu/css/component.scss +1 -0
- package/src/components/search_box/css/component.scss +0 -1
- package/src/components/tab/js/global.js +5 -10
- package/src/components/toggle_tip/js/global.js +0 -6
- package/src/components/tool_tip/js/global.js +0 -6
- package/src/components/video_player/css/component.scss +27 -9
- package/src/components/video_player/html/component.hbs +32 -6
- package/src/components/video_player/js/global.js +8 -1
- package/src/index.js +4 -0
- package/src/stories/Accordion/accordion.stories.js +1 -0
- package/src/stories/Banner/bannerContained.stories.js +123 -0
- package/src/stories/Flexbox/Flexbox.stories.js +316 -0
- package/src/stories/Footer/Footer.stories.js +3 -3
- package/src/stories/Header/Header.js +1 -1
- package/src/stories/Image/Image.stories.js +182 -0
- package/src/stories/PromoPanel/PromoPanel.stories.js +1 -1
- package/src/stories/Templates/ContentPage.stories.js +101 -0
- package/src/stories/Templates/LandingPage.stories.js +193 -0
- package/src/stories/Templates/templateHelpers.js +102 -0
- package/src/stories/VideoPlayer/VideoPlayer.stories.js +16 -0
- package/src/styles/imports/utilities.scss +15 -25
- package/src/styles/imports/variables.scss +26 -0
- package/src/components/_global/html/head.html +0 -22
- package/src/components/_global/html/scripts.html +0 -28
- package/src/components/_global/js/_polyfills/global.js +0 -19
- package/src/components/_template/html/component-page.html +0 -75
- package/src/components/_template/js/global.js +0 -3
- package/src/components/accordion/html/accordion-group.html +0 -163
- package/src/components/accordion/html/default.html +0 -99
- package/src/components/banner_basic/js/global.js +0 -3
- package/src/components/loading_spinner/js/global.js +0 -3
- package/src/components/pagination/html/default.html +0 -39
- package/src/components/search_box/html/component.html +0 -26
- package/src/data/current.json +0 -400
- package/src/data/current_admin.json +0 -305
- package/src/data/model_component.js +0 -14
- package/src/data/site.json +0 -977
- package/src/externals/tinymce_classes.css +0 -62
- package/src/html/component-global-elements.html +0 -2857
- package/src/html/component-horizontal_rule.html +0 -647
- package/src/html/component-internal_navigation.html +0 -583
- package/src/html/component-left_hand_navigation.html +0 -57
- package/src/html/component-main_navigation.html +0 -583
- package/src/html/component-multi_column.html +0 -582
- package/src/html/components.html +0 -354
- package/src/html/home.html +0 -1898
- package/src/html/index.html +0 -129
- package/src/html/inner-with-nav.html +0 -605
- package/src/html/inner.html +0 -618
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module _global/legacyGlobal
|
|
3
|
+
*
|
|
4
|
+
* Single home for the legacy `window.QLD.*` global namespace.
|
|
5
|
+
*
|
|
6
|
+
* Historically each component registered itself onto `window.QLD` as a side
|
|
7
|
+
* effect at module-eval time, scattered across a dozen files. That surface is
|
|
8
|
+
* still part of the public (non-bundled) contract for external callers, so it
|
|
9
|
+
* is preserved here — but centralised, so the individual component modules can
|
|
10
|
+
* stay side-effect-free and independently testable.
|
|
11
|
+
*
|
|
12
|
+
* This module must be imported early (see `component-loader.js`) so the globals
|
|
13
|
+
* exist before any component init runs. Component initialisation itself lives in
|
|
14
|
+
* `component-loader.js`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// `import * as` for the modules whose legacy aggregate is a slice of their named
|
|
18
|
+
// exports; the object is then spelled out member-by-member below so the legacy
|
|
19
|
+
// contract stays explicit and a removed source export surfaces here.
|
|
20
|
+
import utils from "./global.js";
|
|
21
|
+
import * as animate from "./animate/global.js";
|
|
22
|
+
import { tabs } from "./tabs/global.js";
|
|
23
|
+
import { Modal } from "./modal/global.js";
|
|
24
|
+
import { toggleToolTips } from "./popover/controller.js";
|
|
25
|
+
|
|
26
|
+
// Feature components
|
|
27
|
+
import * as accordion from "../../accordion/js/global.js";
|
|
28
|
+
import { fileUploads } from "../../file_upload/js/global.js";
|
|
29
|
+
import initCode from "../../code/js/global.js";
|
|
30
|
+
import initBasicSearch from "../../basic_search/js/global.js";
|
|
31
|
+
import initTab from "../../tab/js/global.js";
|
|
32
|
+
import initToolTip from "../../tool_tip/js/global.js";
|
|
33
|
+
import initToggleTip from "../../toggle_tip/js/global.js";
|
|
34
|
+
|
|
35
|
+
// Expose the legacy `window.QLD.*` namespace for any external (non-bundled) callers.
|
|
36
|
+
// Objects that exist solely for this legacy surface are assembled here rather than
|
|
37
|
+
// in the component modules.
|
|
38
|
+
window.QLD = window.QLD || {};
|
|
39
|
+
window.QLD.utils = utils;
|
|
40
|
+
window.QLD.animate = {
|
|
41
|
+
CalculateAnimationSpecs: animate.CalculateAnimationSpecs,
|
|
42
|
+
GetCSSPropertyBecauseIE: animate.GetCSSPropertyBecauseIE,
|
|
43
|
+
CalculateAuto: animate.CalculateAuto,
|
|
44
|
+
Stop: animate.Stop,
|
|
45
|
+
Run: animate.Run,
|
|
46
|
+
Toggle: animate.Toggle,
|
|
47
|
+
};
|
|
48
|
+
window.QLD.tabs = tabs;
|
|
49
|
+
window.QLD.Modal = Modal;
|
|
50
|
+
window.QLD.toggleToolTips = toggleToolTips;
|
|
51
|
+
window.QLD.accordion = {
|
|
52
|
+
Toggle: accordion.Toggle,
|
|
53
|
+
ToggleAll: accordion.ToggleAll,
|
|
54
|
+
Open: accordion.Open,
|
|
55
|
+
Close: accordion.Close,
|
|
56
|
+
initAccordion: accordion.initAccordion,
|
|
57
|
+
};
|
|
58
|
+
window.QLD.code = { init: initCode };
|
|
59
|
+
window.QLD.basicSearch = { init: initBasicSearch };
|
|
60
|
+
window.QLD.fileUploads = fileUploads;
|
|
61
|
+
window.QLD.tab = { init: () => initTab(document), initTab };
|
|
62
|
+
window.QLD.toolTip = { init: () => initToolTip(document), initToolTip };
|
|
63
|
+
window.QLD.toggleTip = { init: () => initToggleTip(document), initToggleTip };
|
|
@@ -1,253 +1,248 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Modal
|
|
2
|
+
* @module Modal
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const Modal = {
|
|
6
|
+
// Vars
|
|
7
|
+
events: {},
|
|
8
|
+
callbackFns: {},
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Initialise a specific modal
|
|
12
|
+
*
|
|
13
|
+
* @memberof module:Modal
|
|
14
|
+
*
|
|
15
|
+
* @param {Node} modalBtn The modal button element
|
|
7
16
|
*/
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* @param {Node} modalBtn The modal button element
|
|
19
|
-
*/
|
|
20
|
-
init: function (modalBtn) {
|
|
21
|
-
// Init single modal btn
|
|
22
|
-
if (typeof modalBtn !== "undefined") {
|
|
17
|
+
init: function (modalBtn) {
|
|
18
|
+
// Init single modal btn
|
|
19
|
+
if (typeof modalBtn !== "undefined") {
|
|
20
|
+
modalBtn.addEventListener("click", Modal.open);
|
|
21
|
+
|
|
22
|
+
// Else init all modal buttons on the page
|
|
23
|
+
} else {
|
|
24
|
+
var modalBtns = document.querySelectorAll(".qld__open-modal");
|
|
25
|
+
modalBtns.forEach((modalBtn) => {
|
|
23
26
|
modalBtn.addEventListener("click", Modal.open);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
},
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Open the modal
|
|
33
|
+
*
|
|
34
|
+
* @memberof module:Modal
|
|
35
|
+
*
|
|
36
|
+
* @param {Document.event} e
|
|
37
|
+
*/
|
|
38
|
+
open: function (e) {
|
|
39
|
+
let modalOpenBtn = e.currentTarget ? e.currentTarget : null;
|
|
40
|
+
|
|
41
|
+
let modalEl;
|
|
42
|
+
let modalCloseBtns;
|
|
43
|
+
let modalUnderlay;
|
|
44
|
+
|
|
45
|
+
if (modalOpenBtn !== null) {
|
|
46
|
+
var modalTarget = modalOpenBtn.getAttribute("data-modaltarget");
|
|
47
|
+
modalEl = document.querySelector(`#${modalTarget}`);
|
|
48
|
+
modalCloseBtns = modalEl.querySelectorAll('button[data-action="close"]');
|
|
49
|
+
modalUnderlay = modalEl.querySelector(".qld__modal__underlay");
|
|
50
|
+
} else {
|
|
51
|
+
modalEl = e.get(0);
|
|
52
|
+
modalCloseBtns = modalEl.querySelectorAll(
|
|
53
|
+
'button[data-action="close"], button[data-action="deny-location"]',
|
|
54
|
+
);
|
|
55
|
+
modalUnderlay = modalEl.querySelector(".qld__modal__underlay");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// trap focus
|
|
59
|
+
// add all the elements inside modal that are focusable
|
|
60
|
+
let focusableElements =
|
|
61
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
62
|
+
let firstFocusableElement = modalEl.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
|
63
|
+
let focusableContent = modalEl.querySelectorAll(focusableElements);
|
|
64
|
+
let lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
|
65
|
+
|
|
66
|
+
// Add keydown listener
|
|
67
|
+
Modal.events.keydown = Modal.addEvent(document, "keydown", function (e) {
|
|
68
|
+
// ESC
|
|
69
|
+
if (e.keyCode === 27) {
|
|
70
|
+
modalOpenBtn.focus();
|
|
71
|
+
Modal.close(e);
|
|
72
|
+
return;
|
|
57
73
|
}
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
// add all the elements inside modal that are focusable
|
|
61
|
-
let focusableElements =
|
|
62
|
-
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
63
|
-
let firstFocusableElement =
|
|
64
|
-
modalEl.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
|
65
|
-
let focusableContent = modalEl.querySelectorAll(focusableElements);
|
|
66
|
-
let lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
|
67
|
-
|
|
68
|
-
// Add keydown listener
|
|
69
|
-
Modal.events.keydown = Modal.addEvent(document, "keydown", function (e) {
|
|
70
|
-
// ESC
|
|
71
|
-
if (e.keyCode === 27) {
|
|
72
|
-
modalOpenBtn.focus();
|
|
73
|
-
Modal.close(e);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
75
|
+
let isTabPressed = e.key === "Tab" || e.keyCode === 9;
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
if (!isTabPressed) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if (e.shiftKey) {
|
|
82
|
+
// if shift key pressed for shift + tab combination
|
|
83
|
+
if (
|
|
84
|
+
document.activeElement === firstFocusableElement ||
|
|
85
|
+
document.activeElement === modalEl
|
|
86
|
+
) {
|
|
87
|
+
lastFocusableElement.focus(); // add focus for the last focusable element
|
|
88
|
+
e.preventDefault();
|
|
81
89
|
}
|
|
82
|
-
|
|
83
|
-
if
|
|
84
|
-
|
|
85
|
-
if
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
) {
|
|
89
|
-
lastFocusableElement.focus(); // add focus for the last focusable element
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
// if tab key is pressed
|
|
94
|
-
if (document.activeElement === lastFocusableElement) {
|
|
95
|
-
// if focused has reached to last focusable element then focus first focusable element after pressing tab
|
|
96
|
-
firstFocusableElement.focus(); // add focus for the first focusable element
|
|
97
|
-
e.preventDefault();
|
|
98
|
-
}
|
|
90
|
+
} else {
|
|
91
|
+
// if tab key is pressed
|
|
92
|
+
if (document.activeElement === lastFocusableElement) {
|
|
93
|
+
// if focused has reached to last focusable element then focus first focusable element after pressing tab
|
|
94
|
+
firstFocusableElement.focus(); // add focus for the first focusable element
|
|
95
|
+
e.preventDefault();
|
|
99
96
|
}
|
|
100
|
-
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Open modal
|
|
101
|
+
modalEl.classList.add("active");
|
|
102
|
+
modalEl.focus();
|
|
103
|
+
|
|
104
|
+
// Close button click listener
|
|
105
|
+
modalCloseBtns.forEach(function (button, index) {
|
|
106
|
+
Modal.events["close-" + index] = Modal.addEvent(
|
|
107
|
+
button,
|
|
108
|
+
"click",
|
|
109
|
+
function (e) {
|
|
110
|
+
modalOpenBtn !== null ? modalOpenBtn.focus() : null;
|
|
111
|
+
Modal.close(e);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Modal underlay listener
|
|
117
|
+
if (modalUnderlay) {
|
|
118
|
+
Modal.events.underlay = Modal.addEvent(
|
|
119
|
+
modalUnderlay,
|
|
120
|
+
"click",
|
|
121
|
+
Modal.close,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
101
124
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
modalEl.
|
|
125
|
+
// Add callback events
|
|
126
|
+
for (var key in Modal.callbackFns) {
|
|
127
|
+
var button = modalEl.querySelector('button[data-callback="' + key + '"]');
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Modal.events["close-" + index] = Modal.addEvent(
|
|
129
|
+
if (button !== null) {
|
|
130
|
+
Modal.events["callback-" + key] = Modal.addEvent(
|
|
109
131
|
button,
|
|
110
132
|
"click",
|
|
111
133
|
function (e) {
|
|
112
|
-
modalOpenBtn !== null ? modalOpenBtn.focus() : null;
|
|
113
134
|
Modal.close(e);
|
|
135
|
+
var callbackKey = e.target.getAttribute("data-callback");
|
|
136
|
+
Modal.callbackFns[callbackKey](e);
|
|
114
137
|
},
|
|
115
138
|
);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Modal underlay listener
|
|
119
|
-
if (modalUnderlay) {
|
|
120
|
-
Modal.events.underlay = Modal.addEvent(
|
|
121
|
-
modalUnderlay,
|
|
122
|
-
"click",
|
|
123
|
-
Modal.close,
|
|
124
|
-
);
|
|
125
139
|
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Close the modal
|
|
145
|
+
*
|
|
146
|
+
* @memberof module:Modal
|
|
147
|
+
*
|
|
148
|
+
* @param {Document.event} e
|
|
149
|
+
*/
|
|
150
|
+
close: function (e) {
|
|
151
|
+
var modalEl = e.target.closest(".qld__modal");
|
|
152
|
+
modalEl.classList.remove("active");
|
|
132
153
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Modal.close(e);
|
|
139
|
-
var callbackKey = e.target.getAttribute("data-callback");
|
|
140
|
-
Modal.callbackFns[callbackKey](e);
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Close the modal
|
|
149
|
-
*
|
|
150
|
-
* @memberof module:Modal
|
|
151
|
-
*
|
|
152
|
-
* @param {Document.event} e
|
|
153
|
-
*/
|
|
154
|
-
close: function (e) {
|
|
155
|
-
console.log("close");
|
|
156
|
-
var modalEl = e.target.closest(".qld__modal");
|
|
157
|
-
modalEl.classList.remove("active");
|
|
158
|
-
|
|
159
|
-
for (var i in Modal.events) {
|
|
160
|
-
var event = Modal.events[i];
|
|
161
|
-
Modal.removeEvent(event);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Object representing an event listener
|
|
167
|
-
*
|
|
168
|
-
* @typedef {Object} event
|
|
169
|
-
* @property {Node} element Element the event is attached to
|
|
170
|
-
* @property {function} handler Event handler function
|
|
171
|
-
* @property {document#event} event DOM event to listen for
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Add event listener
|
|
176
|
-
*
|
|
177
|
-
* @memberof module:Modal
|
|
178
|
-
* @instance
|
|
179
|
-
* @private
|
|
180
|
-
*
|
|
181
|
-
* @param {Node} element DOM element to add event to
|
|
182
|
-
* @param {document#event} event The event to listen for
|
|
183
|
-
* @param {function} rawHandler The raw handler function
|
|
184
|
-
* @return {event}
|
|
185
|
-
*/
|
|
186
|
-
addEvent: function (element, event, rawHandler) {
|
|
187
|
-
// Using local functions instead of anonymous for event handler
|
|
188
|
-
function listenHandler(event) {
|
|
189
|
-
var handler = rawHandler.apply(this, arguments);
|
|
190
|
-
if (handler === false) {
|
|
191
|
-
event.stopPropagation();
|
|
192
|
-
event.preventDefault();
|
|
193
|
-
}
|
|
194
|
-
return handler;
|
|
195
|
-
}
|
|
154
|
+
for (var i in Modal.events) {
|
|
155
|
+
var event = Modal.events[i];
|
|
156
|
+
Modal.removeEvent(event);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
196
159
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
160
|
+
/**
|
|
161
|
+
* Object representing an event listener
|
|
162
|
+
*
|
|
163
|
+
* @typedef {Object} event
|
|
164
|
+
* @property {Node} element Element the event is attached to
|
|
165
|
+
* @property {function} handler Event handler function
|
|
166
|
+
* @property {document#event} event DOM event to listen for
|
|
167
|
+
*/
|
|
206
168
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Add event listener
|
|
171
|
+
*
|
|
172
|
+
* @memberof module:Modal
|
|
173
|
+
* @instance
|
|
174
|
+
* @private
|
|
175
|
+
*
|
|
176
|
+
* @param {Node} element DOM element to add event to
|
|
177
|
+
* @param {document#event} event The event to listen for
|
|
178
|
+
* @param {function} rawHandler The raw handler function
|
|
179
|
+
* @return {event}
|
|
180
|
+
*/
|
|
181
|
+
addEvent: function (element, event, rawHandler) {
|
|
182
|
+
// Using local functions instead of anonymous for event handler
|
|
183
|
+
function listenHandler(event) {
|
|
184
|
+
var handler = rawHandler.apply(this, arguments);
|
|
185
|
+
if (handler === false) {
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
event.preventDefault();
|
|
222
188
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
* @param {event} token The event to remove
|
|
233
|
-
*/
|
|
234
|
-
removeEvent: function (token) {
|
|
235
|
-
if (token.element.removeEventListener) {
|
|
236
|
-
token.element.removeEventListener(token.event, token.handler);
|
|
237
|
-
} else {
|
|
238
|
-
token.element.detachEvent("on" + token.event, token.handler);
|
|
189
|
+
return handler;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Make sure attachHandler is also going to work
|
|
193
|
+
function attachHandler() {
|
|
194
|
+
var handler = rawHandler.call(element, window.event);
|
|
195
|
+
if (handler === false) {
|
|
196
|
+
window.event.returnValue = false;
|
|
197
|
+
window.event.cancelBubble = true;
|
|
239
198
|
}
|
|
240
|
-
|
|
241
|
-
|
|
199
|
+
return handler;
|
|
200
|
+
}
|
|
242
201
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
202
|
+
// Return the token and add the correct listener
|
|
203
|
+
if (element.addEventListener) {
|
|
204
|
+
element.addEventListener(event, listenHandler, false);
|
|
205
|
+
return {
|
|
206
|
+
element: element,
|
|
207
|
+
handler: listenHandler,
|
|
208
|
+
event: event,
|
|
209
|
+
};
|
|
210
|
+
} else {
|
|
211
|
+
element.attachEvent("on" + event, attachHandler);
|
|
212
|
+
return {
|
|
213
|
+
element: element,
|
|
214
|
+
handler: attachHandler,
|
|
215
|
+
event: event,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
},
|
|
247
219
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Remove event listener
|
|
222
|
+
*
|
|
223
|
+
* @memberof module:Modal
|
|
224
|
+
* @instance
|
|
225
|
+
* @private
|
|
226
|
+
*
|
|
227
|
+
* @param {event} token The event to remove
|
|
228
|
+
*/
|
|
229
|
+
removeEvent: function (token) {
|
|
230
|
+
if (token.element.removeEventListener) {
|
|
231
|
+
token.element.removeEventListener(token.event, token.handler);
|
|
232
|
+
} else {
|
|
233
|
+
token.element.detachEvent("on" + token.event, token.handler);
|
|
251
234
|
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Initialise modal buttons.
|
|
240
|
+
*
|
|
241
|
+
* @param {Node} [modalBtn] - A specific modal button to wire up; omit to wire
|
|
242
|
+
* up every `.qld__open-modal` button on the page.
|
|
243
|
+
*/
|
|
244
|
+
export default function initModal(modalBtn) {
|
|
245
|
+
Modal.init(modalBtn);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { Modal };
|
|
@@ -152,10 +152,10 @@ export function createPopoverController({ componentName, marginFromTrigger }) {
|
|
|
152
152
|
return { init };
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
// Back-compat: the old shared helper was exposed as
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
// Back-compat surface: the old shared helper was exposed as
|
|
156
|
+
// window.QLD.toggleToolTips. Exported here and registered in
|
|
157
|
+
// ../legacyGlobal.js for any external (non-bundled) callers.
|
|
158
|
+
export const toggleToolTips = {
|
|
159
159
|
openToggleToolTip: show,
|
|
160
160
|
closeToggleToolTip: hide,
|
|
161
161
|
closeAllToggleToolTips(componentName, triggers) {
|