From f99396a60e3fc168c5e7f07c05271c256d7571c2 Mon Sep 17 00:00:00 2001 From: AucT Date: Tue, 6 Dec 2022 10:46:19 +0200 Subject: [PATCH 1/6] fix live toast demo --- site/content/docs/5.2/components/toasts.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/site/content/docs/5.2/components/toasts.md b/site/content/docs/5.2/components/toasts.md index b7a84dc6ea2c..684729b2c117 100644 --- a/site/content/docs/5.2/components/toasts.md +++ b/site/content/docs/5.2/components/toasts.md @@ -90,11 +90,10 @@ We use the following JavaScript to trigger our live toast demo: ```js const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') +const toastBootstrap = new bootstrap.Toast(toastLiveExample) if (toastTrigger) { toastTrigger.addEventListener('click', () => { - const toast = new bootstrap.Toast(toastLiveExample) - - toast.show() + toastBootstrap.show() }) } ``` From e4f2abc4e84bd9b5d83edfd695018d40de3e99d9 Mon Sep 17 00:00:00 2001 From: AucT Date: Tue, 6 Dec 2022 11:20:01 +0200 Subject: [PATCH 2/6] Fix live toast demo --- site/assets/js/snippets.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index 43b8a095cfa8..2bcef281d863 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -63,11 +63,10 @@ // Instantiate all toasts in a docs page only const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') + const toastBootstrap = new bootstrap.Toast(toastLiveExample) if (toastTrigger) { toastTrigger.addEventListener('click', () => { - const toast = new bootstrap.Toast(toastLiveExample) - - toast.show() + toastBootstrap.show() }) } From 38255da1b95fc091717ac668c3af2a5ed4df9501 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 26 Dec 2022 21:58:35 +0200 Subject: [PATCH 3/6] Update snippets.js --- site/assets/js/snippets.js | 1 + 1 file changed, 1 insertion(+) diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index 2bcef281d863..e650ae5cc87a 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -64,6 +64,7 @@ const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') const toastBootstrap = new bootstrap.Toast(toastLiveExample) + if (toastTrigger) { toastTrigger.addEventListener('click', () => { toastBootstrap.show() From 433e45458296265e3c262649e482d5473b9efaf5 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 26 Dec 2022 21:58:47 +0200 Subject: [PATCH 4/6] Update toasts.md --- site/content/docs/5.2/components/toasts.md | 1 + 1 file changed, 1 insertion(+) diff --git a/site/content/docs/5.2/components/toasts.md b/site/content/docs/5.2/components/toasts.md index 684729b2c117..e2e9f0e14ed1 100644 --- a/site/content/docs/5.2/components/toasts.md +++ b/site/content/docs/5.2/components/toasts.md @@ -91,6 +91,7 @@ We use the following JavaScript to trigger our live toast demo: const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') const toastBootstrap = new bootstrap.Toast(toastLiveExample) + if (toastTrigger) { toastTrigger.addEventListener('click', () => { toastBootstrap.show() From 3e5297c2f56bc399c73801259ef6989befdca437 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 27 Dec 2022 09:22:30 +0200 Subject: [PATCH 5/6] Update snippets.js --- site/assets/js/snippets.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index e650ae5cc87a..d44d28ed1d63 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -20,7 +20,7 @@ // -------- // Tooltips // -------- - // Instantiate all tooltips in a docs or StackBlitz page + // Instantiate all tooltips in a docs or StackBlitz document.querySelectorAll('[data-bs-toggle="tooltip"]') .forEach(tooltip => { new bootstrap.Tooltip(tooltip) @@ -29,7 +29,7 @@ // -------- // Popovers // -------- - // Instantiate all popovers in a docs or StackBlitz page + // Instantiate all popovers in docs or StackBlitz document.querySelectorAll('[data-bs-toggle="popover"]') .forEach(popover => { new bootstrap.Popover(popover) @@ -50,7 +50,7 @@ }) } - // Instantiate all toasts in a docs page only + // Instantiate all toasts in docs pages only document.querySelectorAll('.bd-example .toast') .forEach(toastNode => { const toast = new bootstrap.Toast(toastNode, { @@ -60,7 +60,7 @@ toast.show() }) - // Instantiate all toasts in a docs page only + // Instantiate all toasts in docs pages only const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') const toastBootstrap = new bootstrap.Toast(toastLiveExample) @@ -99,7 +99,7 @@ // -------- // Carousels // -------- - // Instantiate all non-autoplaying carousels in a docs or StackBlitz page + // Instantiate all non-autoplaying carousels in docs or StackBlitz document.querySelectorAll('.carousel:not([data-bs-ride="carousel"])') .forEach(carousel => { bootstrap.Carousel.getOrCreateInstance(carousel) From 4268e31a065adffa920500d5b96406a72ea9e93f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 2 Jan 2023 20:09:47 -0800 Subject: [PATCH 6/6] Code review comments addressed --- site/assets/js/snippets.js | 2 +- site/content/docs/5.3/components/toasts.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index d44d28ed1d63..4c09e3592fc6 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -63,9 +63,9 @@ // Instantiate all toasts in docs pages only const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') - const toastBootstrap = new bootstrap.Toast(toastLiveExample) if (toastTrigger) { + const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample) toastTrigger.addEventListener('click', () => { toastBootstrap.show() }) diff --git a/site/content/docs/5.3/components/toasts.md b/site/content/docs/5.3/components/toasts.md index e2e9f0e14ed1..d3454633a31c 100644 --- a/site/content/docs/5.3/components/toasts.md +++ b/site/content/docs/5.3/components/toasts.md @@ -90,9 +90,9 @@ We use the following JavaScript to trigger our live toast demo: ```js const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') -const toastBootstrap = new bootstrap.Toast(toastLiveExample) if (toastTrigger) { + const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample) toastTrigger.addEventListener('click', () => { toastBootstrap.show() })