Skip to content

Commit c0ed72a

Browse files
committed
Toggle Button + Toggle Button Input
1 parent a2999c4 commit c0ed72a

8 files changed

Lines changed: 296 additions & 1064 deletions

File tree

assets/js/odyssey.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
const Hooks = {
2-
OdysseyActivityPicker: {
1+
// Function to add global event listeners
2+
function addOdysseyGlobalEvents(windowObj) {
3+
// Global event listener for triggering input events on form fields, this is
4+
// needed for input fields that maintain a hidden input field behind the scenes
5+
// and need to tell the parent form when a change has been made.
6+
windowObj.addEventListener("phx:trigger-input", (event) => {
7+
const { field_id } = event.detail
8+
const input = windowObj.document.getElementById(field_id)
9+
if (input) {
10+
input.dispatchEvent(new Event('input', { bubbles: true }))
11+
}
12+
})
13+
}
14+
15+
const OdysseyHooks = {
16+
OdysseyActivityPicker: {
317
mounted () {
418
const picker = this.el.querySelector('odyssey-product-picker')
519

@@ -24,4 +38,5 @@ const Hooks = {
2438
}
2539
}
2640

27-
export default Hooks
41+
export { OdysseyHooks, addOdysseyGlobalEvents }
42+
export default OdysseyHooks

coveralls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"test/*",
55
"lib/peek_app_sdk/application.ex",
66
"lib/peek_app_sdk/ui/core_components.ex",
7-
"lib/peek_app_sdk/ui/get_text.ex"
7+
"lib/peek_app_sdk/ui/get_text.ex",
8+
"demo/**"
89
],
910
"print_summary": true
1011
}

0 commit comments

Comments
 (0)