Skip to content

Commit 3826ecb

Browse files
committed
Fix to prevent multiple inits
1 parent 0110e8c commit 3826ecb

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
6363
2. Run **`npm install add-to-calendar-button`**.
6464
3. Import the module into your project/component. For example with Angular/React: `import { atcb_init } from 'add-to-calendar-button';`.
6565
4. Init the js after the DOM has been loaded. To determine the right moment and execute, ...
66-
1. with Angular, you would use `ngAfterViewInit()` with `atcb_init();`;
66+
1. with Angular, you would use `ngAfterViewInit()` with `atcb_init();` (mind that, depending on your app, other hooks might be better);
6767
2. with React, you might want to include an event listener like `document.addEventListener('DOMContentLoaded', atcb_init, false);`.
6868
5. Include the css. For example with Angular or React, add the following to the global style.css: `@import 'add-to-calendar-button/assets/css/atcb.min'`;
6969
6. Create your button as can be seen in the "Configuration" section below.

assets/css/atcb.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*
6-
* Version: 1.2.0
6+
* Version: 1.2.1
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)

assets/js/atcb.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.2.0';
6+
const atcbVersion = '1.2.1';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)
@@ -259,6 +259,9 @@ function atcb_generate(button, buttonId, data) {
259259
bgOverlay.addEventListener('click', atcb_close_all, {passive: true});
260260
bgOverlay.addEventListener('touchstart', atcb_close_all, {passive: true});
261261
bgOverlay.addEventListener('mouseenter', atcb_close_all, false);
262+
// update the placeholder class to prevent multiple initializations
263+
button.classList.remove('atcb');
264+
button.classList.add('atcb_initialized');
262265
// show the placeholder div
263266
if (data['inline']) {
264267
button.style.display = 'inline-block';

assets/js/atcb.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/atcb.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<body>
122122
<div class="container">
123123

124-
<h1>Add-to-Calendar Button <span id="tinyVersion">v1.2.0</span></h1>
124+
<h1>Add-to-Calendar Button <span id="tinyVersion">v1.2.1</span></h1>
125125
<h2>A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.</h2>
126126
<p class="github">
127127
<a target="_blank" href="https://github.com/jekuer/add-to-calendar-button">
@@ -143,7 +143,7 @@ <h3>Example 1: The usual One</h3>
143143
<div class="atcb" style="display:none;">
144144
{
145145
"title":"Reminder to check the add-to-calendar-button repo",
146-
"description":"Check<br> out<br /> the<br/> maybe\neasiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
146+
"description":"Check out the maybe easiest way to include add-to-calendar-buttons to your website at: https://github.com/jekuer/add-to-calendar-button",
147147
"dateStart":"01-14-2022",
148148
"dateEnd":"01-18-2022",
149149
"timeStart":"10:15",
@@ -444,7 +444,7 @@ <h3>Example 6: Timezone Offset</h3>
444444

445445

446446
<!-- load the button js -->
447-
<script src="./assets/js/atcb.min.js?v=1.2.0" defer></script>
447+
<script src="./assets/js/atcb.min.js?v=1.2.1" defer></script>
448448

449449

450450
</body>

npm_dist/atcb_npm.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.2.0';
6+
const atcbVersion = '1.2.1';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)
@@ -259,6 +259,9 @@ function atcb_generate(button, buttonId, data) {
259259
bgOverlay.addEventListener('click', atcb_close_all, {passive: true});
260260
bgOverlay.addEventListener('touchstart', atcb_close_all, {passive: true});
261261
bgOverlay.addEventListener('mouseenter', atcb_close_all, false);
262+
// update the placeholder class to prevent multiple initializations
263+
button.classList.remove('atcb');
264+
button.classList.add('atcb_initialized');
262265
// show the placeholder div
263266
if (data['inline']) {
264267
button.style.display = 'inline-block';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "add-to-calendar-button",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.",
55
"main": "npm_dist/atcb_npm.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)