Skip to content

Commit 54a8a3e

Browse files
authored
Merge pull request #40 from jekuer/v1.7_fixes
V1.7 fixes
2 parents 81cd4d5 + ac44f1c commit 54a8a3e

12 files changed

+40
-43
lines changed

Gruntfile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const npmDelimiter = /\/\/ START INIT[\s\S]*?\/\/ END INIT/gm
22

33
function process(content, exportPhrase) {
4-
content = content.replace('atcb_addToCalendar', 'addToCalendar');
5-
return content.replace(npmDelimiter, `${exportPhrase} { addToCalendar, atcb_init };`);
4+
return content.replace(npmDelimiter, `${exportPhrase} { atcb_action, atcb_init };`);
65
}
76
module.exports = function(grunt) {
87

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
7070

7171
1. Requires Node, npm, and a project, which builds on it (e.g. React or Angular).
7272
2. Run **`npm install add-to-calendar-button`**.
73-
3. Import the module into your project/component. For example with Angular/React: `import { addToCalendar, atcb_init } from 'add-to-calendar-button';`.
74-
4. Either use `addToCalendar` with your own buttons/forms/etc, or run `atcb_init` after the DOM has been loaded. To determine the right moment and execute, ...
73+
3. Import the module into your project/component. For example with Angular/React: `import { atcb_action, atcb_init } from 'add-to-calendar-button';`.
74+
4. Either use `atcb_action` with your own buttons/forms/etc, or run `atcb_init` after the DOM has been loaded. To determine the right moment and execute, ...
7575
1. with Angular, you would use `ngAfterViewInit()` with `atcb_init();` (mind that, depending on your app, other hooks might be better);
7676
2. with React, you might want to include an event listener like `document.addEventListener('DOMContentLoaded', atcb_init, false);` or using hooks in a functional component like `useEffect(() => atcb_init());`
7777
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'`;
@@ -173,22 +173,22 @@ You can use startTime and endTime in the event block, but it is recommended to r
173173
</div>
174174
```
175175

176-
### `addToCalendar` example with React
176+
### `atcb_action` example with React
177177

178-
If you can't or don't want to use `atcb_init`, you can use the `addToCalendar` import with your own buttons or other elements/components. If you omit the second argument, the dropdown list will display as a modal in the middle of the viewport - in this case, add the "atcb_customTrigger" class to the submitting element for better keyboard support.
178+
If you can't or don't want to use `atcb_init`, you can use the `atcb_action` import with your own buttons or other elements/components. If you omit the second argument, the dropdown list will display as a modal in the middle of the viewport - in this case, add the "atcb_customTrigger" class to the submitting element for better keyboard support.
179179

180180
This may work better with React and other frontend frameworks.
181181

182182
```js
183183
import React from 'react'
184-
import { addToCalendar } from 'add-to-calendar-button'
184+
import { atcb_action } from 'add-to-calendar-button'
185185

186-
const AddToCalendar = () => {
186+
const atcb_action = () => {
187187
const [name, setName] = React.useState('Some event')
188188
return (
189189
<form onSubmit={e => {
190190
e.preventDefault()
191-
addToCalendar({
191+
atcb_action({
192192
name,
193193
startDate: "2022-01-14",
194194
endDate: "2022-01-18",
@@ -210,7 +210,7 @@ Alternatively, you could use `atcb_init` with a `useEffect` hook:
210210
import React from 'react'
211211
import { atcb_init } from 'add-to-calendar-button'
212212

213-
const AddToCalendar = () => {
213+
const atcb_action = () => {
214214
React.useEffect(atcb_init, [])
215215
return (
216216
<div className='atcb' style={{display: 'none'}}>

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.7.0
6+
* Version: 1.7.1
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0

assets/js/atcb.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.7.0';
6+
const atcbVersion = '1.7.1';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0
@@ -265,7 +265,7 @@ function atcb_generate(button, buttonId, data) {
265265
buttonTrigger.addEventListener('mousedown', () => atcb_toggle(data, buttonTrigger, true, false));
266266
} else {
267267
buttonTrigger.addEventListener('touchstart', () => atcb_toggle(data, buttonTrigger, true, false), {passive: true});
268-
buttonTrigger.addEventListener('mouseenter', () => atcb_addToCalendar(data, buttonTrigger, true, false));
268+
buttonTrigger.addEventListener('mouseenter', () => atcb_action(data, buttonTrigger, true, false));
269269
}
270270
buttonTrigger.addEventListener('keydown', function(event) { // trigger click on enter as well
271271
if (event.key == 'Enter') {
@@ -401,12 +401,12 @@ function atcb_toggle(data, button, buttonGenerated, keyboardTrigger = true) {
401401
if (button.classList.contains('atcb_active')) {
402402
atcb_close();
403403
} else {
404-
atcb_addToCalendar(data, button, buttonGenerated, keyboardTrigger);
404+
atcb_action(data, button, buttonGenerated, keyboardTrigger);
405405
}
406406
}
407407

408408
// show the dropdown list + background overlay
409-
function atcb_addToCalendar(data, button, buttonGenerated = false, keyboardTrigger = true) {
409+
function atcb_action(data, button, buttonGenerated = false, keyboardTrigger = true) {
410410
// abort early if an add-to-calendar dropdown already opened
411411
if (document.querySelector('.atcb_list')) return
412412

@@ -708,5 +708,4 @@ document.addEventListener('keydown', evt => {
708708

709709
// START INIT
710710
document.addEventListener('DOMContentLoaded', atcb_init, false); // init the magic as soon as the DOM has been loaded
711-
//export { addToCalendar, atcb_init }; // export statement - requires explicit init somewhere else. Remove the line above, if you want to use this one here
712711
// END INIT

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: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare module 'add-to-calendar-button' {
22
export type ISO8601Date = string;
33
export type ISO8601Time = string;
44
export function atcb_init(): any;
5-
export function addToCalendar (
5+
export function atcb_action (
66
config: {
77
name?: string;
88
description?: string;

index.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@
124124
</style>
125125

126126
<!-- load the general button css -->
127-
<link rel="stylesheet" href="./assets/css/atcb.min.css?v=1.7.0">
127+
<link rel="stylesheet" href="./assets/css/atcb.min.css?v=1.7.1">
128128

129129
</head>
130130
<body>
131131
<div class="container">
132132

133-
<h1>Add-to-Calendar Button <span id="tinyVersion">v1.7.0</span></h1>
133+
<h1>Add-to-Calendar Button <span id="tinyVersion">v1.7.1</span></h1>
134134
<h2>A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.</h2>
135135
<p class="github">
136136
<a target="_blank" href="https://github.com/jekuer/add-to-calendar-button" class="clean">
@@ -525,8 +525,7 @@ <h3>Example 7: Schema.org Event Markup</h3>
525525

526526
<h3>Example 8: Bring-Your-Own Button</h3>
527527
<p class="description">
528-
If you can't or don't want to use "atcb_init", you can use the "atcb_addToCalendar" function and apply it to your own button.<br>
529-
<em>In the NPM package, this is exported simply as "addToCalendar"!</em><br>
528+
If you can't or don't want to use "atcb_init", you can use the "atcb_action" function and apply it to your own button.<br>
530529
For a good look, the element should be at least 160px wide; or remove the second argument to go for a modal dropdown.
531530
</p>
532531
<div class="example">
@@ -547,7 +546,7 @@ <h3>Example 8: Bring-Your-Own Button</h3>
547546
iCalFileName: "Reminder-Event",
548547
}
549548
const button = document.querySelector('#default-button')
550-
button.addEventListener('click', () => atcb_addToCalendar(config, button))
549+
button.addEventListener('click', () => atcb_action(config, button))
551550
</script>
552551
<!-- end of button code -->
553552

@@ -565,7 +564,7 @@ <h3>Example 8: Bring-Your-Own Button</h3>
565564
iCalFileName: "Reminder-Event",
566565
}
567566
const button = document.querySelector('#default-button')
568-
button.addEventListener('click', () => atcb_addToCalendar(config, button))
567+
button.addEventListener('click', () => atcb_action(config, button))
569568
&lt;/script&gt;</code>
570569
</div>
571570
</div>
@@ -574,7 +573,7 @@ <h3>Example 8: Bring-Your-Own Button</h3>
574573

575574
<h3>Example 9: Bring-Your-Own Anything</h3>
576575
<p class="description">
577-
When using "atcb_addToCalendar" (again, if importing from the NPM package, just import "addToCalendar"), you don't need to use a button. A form, a link, an image — whatever element you want to trigger the dropdown, you can use it (though not all of them are good for accessibility).<br>
576+
When using "atcb_action", you don't need to use a button. A form, a link, an image — whatever element you want to trigger the dropdown, you can use it (though not all of them are good for accessibility).<br>
578577
If you don't provide a second argument, the dropdown list will appear as a modal in the middle of the viewport.<br>
579578
Use of the 'click' trigger is highly recommended here.
580579
</p>
@@ -593,7 +592,7 @@ <h3>Example 9: Bring-Your-Own Anything</h3>
593592
document.querySelector('#event-form')
594593
.addEventListener('submit', (e) => {
595594
e.preventDefault();
596-
atcb_addToCalendar({
595+
atcb_action({
597596
name: e.currentTarget.elements.name.value,
598597
startDate: "2022-01-14",
599598
endDate: "2022-01-18",
@@ -618,7 +617,7 @@ <h3>Example 9: Bring-Your-Own Anything</h3>
618617
document.querySelector('#event-form')
619618
.addEventListener('submit', (e) =&gt; {
620619
e.preventDefault();
621-
atcb_addToCalendar({
620+
atcb_action({
622621
name: e.currentTarget.elements.name.value,
623622
startDate: "2022-01-14",
624623
endDate: "2022-01-18",
@@ -651,7 +650,7 @@ <h3>Example 9: Bring-Your-Own Anything</h3>
651650

652651

653652
<!-- load the button js -->
654-
<script type="application/javascript" src="./assets/js/atcb.min.js?v=1.7.0" defer></script>
653+
<script type="application/javascript" src="./assets/js/atcb.min.js?v=1.7.1" defer></script>
655654

656655
</body>
657656
</html>

npm_dist/cjs/index.js

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

npm_dist/mjs/index.js

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

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "add-to-calendar-button",
3-
"version": "1.7.0",
3+
"version": "1.7.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/cjs/index.js",
66
"module": "npm_dist/mjs/index.js",
@@ -14,7 +14,7 @@
1414
"style": "assets/css/atcb.css",
1515
"repository": {
1616
"type": "git",
17-
"url": "git+https://github.com/jekuer/add-to-calendar-button.git"
17+
"url": "https://github.com/jekuer/add-to-calendar-button.git"
1818
},
1919
"keywords": [
2020
"button",

0 commit comments

Comments
 (0)