add-to-calendar-button 1.18.2 → 1.18.4

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/DOCS.md CHANGED
@@ -41,6 +41,8 @@ More details about available options and how to configure specific features.
41
41
  - You can use the option `"inline":true` in order to make the button appear with inline-block instead of block style.
42
42
  - Change the relative size of the rendering by using the option `size` with a value between 0 and 10 (default: 6, which equals 16px font-size). You can also define up to 3 values like "8|6|4", where the first one will apply to large, the second to medium, and the third to small screens. If you provide two, it will be for large and medium+small screens.
43
43
  - Use `"background":false` if you want to be the background overlay to be fully transparent.
44
+ - Use the option `icons` if you want to hide the icons and use it text-only. Value "false" would hide it at the button, "false|false" would hide it also at the options list, while "false|false|false" would also hide it at any info modal.
45
+ - The text label at the button as well as at the list items can be omitted via the option `texLabels` and values "false" (button) or "false|false" (button and list).
44
46
  - The default style for the options list, using the regular button, would be a dropdown. You can set the option `listStyle` to "modal" in order to force the modal version (this would also force the click trigger) or `overlay` to show the list right above the button. The default would also show the dropdown upwards, if this better fits the current viewport. You can block this behavior with the option `dropdown-static`.
45
47
  - When you position the button in a way, which makes it move when the user scrolls (e.g. inside a somehow "fixed" container or making a custom button fixed itself), a dropdown or overlay list would run out of the viewport. You can easily fix this by setting the option `"mindScrolling":true`.
46
48
  - If you require line breaks within the description, use `\n` or `<br>`.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Style: 3D
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
@@ -183,6 +183,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
183
183
  z-index: 1;
184
184
  }
185
185
 
186
+ .atcb-button.atcb-no-text {
187
+ min-width: 0;
188
+ }
189
+
186
190
  .atcb-rtl .atcb-button {
187
191
  direction: rtl;
188
192
  text-align: right;
@@ -239,6 +243,11 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
239
243
  margin-left: .8em;
240
244
  }
241
245
 
246
+ .atcb-no-text .atcb-icon {
247
+ margin-right: 0;
248
+ margin-left: 0;
249
+ }
250
+
242
251
  .atcb-icon svg {
243
252
  height: 100%;
244
253
  fill: currentcolor;
@@ -261,13 +270,6 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
261
270
  position: absolute;
262
271
  }
263
272
 
264
- .atcb-pos-wrapper {
265
- position: absolute;
266
- top: 0;
267
- bottom: 0;
268
- width: 100%;
269
- }
270
-
271
273
  .atcb-list-wrapper {
272
274
  box-sizing: border-box;
273
275
  padding: 0 4px;
@@ -439,6 +441,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
439
441
  margin-left: .6em;
440
442
  }
441
443
 
444
+ .atcb-no-text .atcb-list-item .atcb-icon {
445
+ margin: 0 auto;
446
+ }
447
+
442
448
  .atcb-list-item-close {
443
449
  background-color: var(--atcb-close-background);
444
450
  }
@@ -526,6 +532,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
526
532
 
527
533
  .atcb-modal-content {
528
534
  background-color: var(--atcb-modal-background);
535
+ font-size: 1em;
529
536
  padding: .3em 2.5em 2.25em;
530
537
  }
531
538
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Style: Date
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
@@ -374,13 +374,6 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
374
374
  position: absolute;
375
375
  }
376
376
 
377
- .atcb-pos-wrapper {
378
- position: absolute;
379
- top: 0;
380
- bottom: 0;
381
- width: 100%;
382
- }
383
-
384
377
  .atcb-list-wrapper {
385
378
  box-sizing: border-box;
386
379
  padding: 0 4px;
@@ -492,6 +485,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
492
485
  margin-left: .6em;
493
486
  }
494
487
 
488
+ .atcb-no-text .atcb-list-item .atcb-icon {
489
+ margin: 0 auto;
490
+ }
491
+
495
492
  .atcb-list-item-close {
496
493
  background-color: var(--atcb-close-background);
497
494
  }
@@ -579,6 +576,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
579
576
 
580
577
  .atcb-modal-content {
581
578
  background-color: var(--atcb-modal-background);
579
+ font-size: 1em;
582
580
  padding: .3em 2.5em 2.25em;
583
581
  }
584
582
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Style: Flat
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
@@ -168,6 +168,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
168
168
  z-index: 1;
169
169
  }
170
170
 
171
+ .atcb-button.atcb-no-text {
172
+ min-width: 0;
173
+ }
174
+
171
175
  .atcb-button.atcb-click {
172
176
  top: -3px;
173
177
  left: -3px;
@@ -211,7 +215,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
211
215
 
212
216
  .atcb-icon {
213
217
  height: 1em;
214
- padding-right: 1em;
218
+ margin-right: 1em;
215
219
  line-height: 1em;
216
220
  flex-grow: 0;
217
221
  flex-shrink: 0;
@@ -219,7 +223,12 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
219
223
 
220
224
  .atcb-rtl .atcb-icon {
221
225
  margin-right: 0;
222
- padding-left: 1em;
226
+ margin-left: 1em;
227
+ }
228
+
229
+ .atcb-no-text .atcb-icon {
230
+ margin-right: 0;
231
+ margin-left: 0;
223
232
  }
224
233
 
225
234
  .atcb-icon svg {
@@ -253,13 +262,6 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
253
262
  position: absolute;
254
263
  }
255
264
 
256
- .atcb-pos-wrapper {
257
- position: absolute;
258
- top: 0;
259
- bottom: 0;
260
- width: 100%;
261
- }
262
-
263
265
  .atcb-list-wrapper {
264
266
  box-sizing: border-box;
265
267
  padding: 0 2px 0 6px;
@@ -348,6 +350,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
348
350
  padding-left: 0.6em;
349
351
  }
350
352
 
353
+ .atcb-no-text .atcb-list-item .atcb-icon {
354
+ margin: 0 auto;
355
+ }
356
+
351
357
  .atcb-list-item-close {
352
358
  background-color: var(--atcb-close-background);
353
359
  }
@@ -435,6 +441,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
435
441
 
436
442
  .atcb-modal-content {
437
443
  padding: .3em 2.5em 2.25em;
444
+ font-size: 1em;
438
445
  }
439
446
 
440
447
  @media (max-width: 575px) {
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Style: Text
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
@@ -186,6 +186,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
186
186
  z-index: 1;
187
187
  }
188
188
 
189
+ .atcb-button.atcb-no-text {
190
+ min-width: 0;
191
+ }
192
+
189
193
  .atcb-rtl .atcb-button {
190
194
  direction: rtl;
191
195
  text-align: right;
@@ -253,7 +257,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
253
257
 
254
258
  .atcb-icon {
255
259
  height: 1em;
256
- padding-right: 1em;
260
+ margin-right: 1em;
257
261
  line-height: 1em;
258
262
  flex-grow: 0;
259
263
  flex-shrink: 0;
@@ -261,7 +265,12 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
261
265
 
262
266
  .atcb-rtl .atcb-icon {
263
267
  margin-right: 0;
264
- padding-left: 1em;
268
+ margin-left: 1em;
269
+ }
270
+
271
+ .atcb-no-text .atcb-icon {
272
+ margin-right: 0;
273
+ margin-left: 0;
265
274
  }
266
275
 
267
276
  .atcb-icon svg {
@@ -295,13 +304,6 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
295
304
  position: absolute;
296
305
  }
297
306
 
298
- .atcb-pos-wrapper {
299
- position: absolute;
300
- top: 0;
301
- bottom: 0;
302
- width: 100%;
303
- }
304
-
305
307
  .atcb-list-wrapper {
306
308
  box-sizing: border-box;
307
309
  position: absolute;
@@ -437,6 +439,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
437
439
  padding-left: 0.7em;
438
440
  }
439
441
 
442
+ .atcb-no-text .atcb-list-item .atcb-icon {
443
+ margin: 0 auto;
444
+ }
445
+
440
446
  .atcb-list-item-close {
441
447
  background-color: var(--atcb-close-background);
442
448
  }
@@ -524,6 +530,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
524
530
 
525
531
  .atcb-modal-content {
526
532
  background-color: var(--atcb-modal-background);
533
+ font-size: 1em;
527
534
  padding: .3em 2.5em 2.25em;
528
535
  }
529
536
 
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Style: Default
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
@@ -180,6 +180,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
180
180
  z-index: 1;
181
181
  }
182
182
 
183
+ .atcb-button.atcb-no-text {
184
+ min-width: 0;
185
+ }
186
+
183
187
  .atcb-rtl .atcb-button {
184
188
  direction: rtl;
185
189
  text-align: right;
@@ -226,6 +230,11 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
226
230
  margin-left: .8em;
227
231
  }
228
232
 
233
+ .atcb-no-text .atcb-icon {
234
+ margin-right: 0;
235
+ margin-left: 0;
236
+ }
237
+
229
238
  .atcb-icon svg {
230
239
  height: 100%;
231
240
  fill: currentcolor;
@@ -248,13 +257,6 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
248
257
  position: absolute;
249
258
  }
250
259
 
251
- .atcb-pos-wrapper {
252
- position: absolute;
253
- top: 0;
254
- bottom: 0;
255
- width: 100%;
256
- }
257
-
258
260
  .atcb-list-wrapper {
259
261
  box-sizing: border-box;
260
262
  padding: 0 4px;
@@ -366,6 +368,10 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
366
368
  margin-left: .6em;
367
369
  }
368
370
 
371
+ .atcb-no-text .atcb-list-item .atcb-icon {
372
+ margin: 0 auto;
373
+ }
374
+
369
375
  .atcb-list-item-close {
370
376
  background-color: var(--atcb-close-background);
371
377
  }
@@ -453,6 +459,7 @@ body.atcb-dark #atcb-bgoverlay.atcb-bodyScheme {
453
459
 
454
460
  .atcb-modal-content {
455
461
  background-color: var(--atcb-modal-background);
462
+ font-size: 1em;
456
463
  padding: .3em 2.5em 2.25em;
457
464
  }
458
465
 
package/dist/atcb.js CHANGED
@@ -217,14 +217,14 @@ function tzlib_get_timezones(jsonType = false) {
217
217
  * Add to Calendar Button
218
218
  * ++++++++++++++++++++++
219
219
  *
220
- * Version: 1.18.2
220
+ * Version: 1.18.4
221
221
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
222
222
  * Project: https://github.com/add2cal/add-to-calendar-button
223
223
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
224
224
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
225
225
  *
226
226
  */
227
- const atcbVersion = '1.18.2';
227
+ const atcbVersion = '1.18.4';
228
228
  const isBrowser = () => {
229
229
  if (typeof window === 'undefined') {
230
230
  return false;
@@ -364,6 +364,7 @@ function atcb_decorate_data(data) {
364
364
  data = atcb_decorate_data_options(data);
365
365
  data.richData = atcb_decorate_data_rich_data(data);
366
366
  data.checkmark = atcb_decorate_data_checkmark(data);
367
+ data.background = atcb_decorate_data_background(data);
367
368
  data.mindScrolling = atcb_decorate_data_mind_scrolling(data);
368
369
  data.branding = atcb_decorate_data_branding(data);
369
370
  data = atcb_decorate_data_style(data);
@@ -502,6 +503,12 @@ function atcb_decorate_data_checkmark(data) {
502
503
  }
503
504
  return true;
504
505
  }
506
+ function atcb_decorate_data_background(data) {
507
+ if (data.background != null && data.background == false) {
508
+ return false;
509
+ }
510
+ return true;
511
+ }
505
512
  function atcb_decorate_data_branding(data) {
506
513
  if (data.branding != null && data.branding == false) {
507
514
  return false;
@@ -574,6 +581,38 @@ function atcb_decorate_data_style(data) {
574
581
  break;
575
582
  }
576
583
  }
584
+ data.iconButton = true;
585
+ data.iconList = true;
586
+ data.iconModal = true;
587
+ if (data.icons != null) {
588
+ data.icons = String(data.icons);
589
+ if (data.icons != '') {
590
+ const iconsConfig = data.icons.split('|');
591
+ if (iconsConfig[0] == 'false') {
592
+ data.iconButton = false;
593
+ }
594
+ if (iconsConfig[1] != null && iconsConfig[1] == 'false') {
595
+ data.iconList = false;
596
+ }
597
+ if (iconsConfig[2] != null && iconsConfig[2] == 'false') {
598
+ data.iconModal = false;
599
+ }
600
+ }
601
+ }
602
+ data.textLabelButton = true;
603
+ data.textLabelList = true;
604
+ if (data.textLabels != null) {
605
+ data.textLabels = String(data.textLabels);
606
+ if (data.textLabels != '') {
607
+ const textLabelsConfig = data.textLabels.split('|');
608
+ if (textLabelsConfig[0] == 'false') {
609
+ data.textLabelButton = false;
610
+ }
611
+ if (textLabelsConfig[1] != null && textLabelsConfig[1] == 'false') {
612
+ data.textLabelList = false;
613
+ }
614
+ }
615
+ }
577
616
  return data;
578
617
  }
579
618
  function atcb_decorate_data_i18n(data) {
@@ -1147,6 +1186,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
1147
1186
  const list = atcb_generate_dropdown_list(data);
1148
1187
  const listWrapper = document.createElement('div');
1149
1188
  listWrapper.classList.add('atcb-list-wrapper');
1189
+ if (data.textLabelList == false) {
1190
+ listWrapper.classList.add('atcb-no-text');
1191
+ }
1150
1192
  if (button) {
1151
1193
  button.classList.add('atcb-active');
1152
1194
  if (data.listStyle === 'modal') {
@@ -1180,6 +1222,10 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
1180
1222
  } else {
1181
1223
  const positionWrapper = document.createElement('div');
1182
1224
  positionWrapper.id = 'atcb-pos-wrapper';
1225
+ positionWrapper.style.position = 'absolute';
1226
+ positionWrapper.style.top = '0';
1227
+ positionWrapper.style.bottom = '0';
1228
+ positionWrapper.style.width = '100%';
1183
1229
  document.body.appendChild(positionWrapper);
1184
1230
  positionWrapper.appendChild(listWrapper);
1185
1231
  listWrapper.appendChild(list);
@@ -1191,7 +1237,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
1191
1237
  }
1192
1238
  document.body.appendChild(bgOverlay);
1193
1239
  atcb_set_sizes(list, data.sizes);
1240
+ listWrapper.style.display = 'none';
1194
1241
  setTimeout(function () {
1242
+ listWrapper.style.display = 'block';
1195
1243
  if (data.listStyle === 'dropdown-static') {
1196
1244
  atcb_position_list(button, listWrapper, true);
1197
1245
  } else {
@@ -1322,9 +1370,9 @@ function atcb_generate_label(data, parent, type, icon = false, text = '', oneOpt
1322
1370
  if (oneOption) {
1323
1371
  parent.id = data.identifier;
1324
1372
  }
1325
- atcb_generate_label_text(data, parent, type, icon, text, oneOption);
1373
+ atcb_generate_label_content(data, parent, type, icon, text, oneOption);
1326
1374
  }
1327
- function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1375
+ function atcb_generate_label_content(data, parent, type, icon, text, oneOption) {
1328
1376
  const defaultTriggerText = atcb_translate_hook('Add to Calendar', data);
1329
1377
  if (oneOption && text == '') {
1330
1378
  text = defaultTriggerText;
@@ -1368,10 +1416,15 @@ function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1368
1416
  iconEl.innerHTML = atcbIcon[`${type}`];
1369
1417
  parent.appendChild(iconEl);
1370
1418
  }
1371
- const textEl = document.createElement('span');
1372
- textEl.classList.add('atcb-text');
1373
- textEl.textContent = text;
1374
- parent.appendChild(textEl);
1419
+ if (
1420
+ (type == 'trigger' && data.textLabelButton == true) ||
1421
+ (type != 'trigger' && data.textLabelList == true)
1422
+ ) {
1423
+ const textEl = document.createElement('span');
1424
+ textEl.classList.add('atcb-text');
1425
+ textEl.textContent = text;
1426
+ parent.appendChild(textEl);
1427
+ }
1375
1428
  }
1376
1429
  function atcb_generate_button(button, data) {
1377
1430
  button.textContent = '';
@@ -1388,6 +1441,9 @@ function atcb_generate_button(button, data) {
1388
1441
  atcb_set_sizes(buttonTriggerWrapper, data.sizes);
1389
1442
  const buttonTrigger = document.createElement('button');
1390
1443
  buttonTrigger.classList.add('atcb-button');
1444
+ if (data.textLabelButton == false) {
1445
+ buttonTrigger.classList.add('atcb-no-text');
1446
+ }
1391
1447
  if (data.trigger === 'click') {
1392
1448
  buttonTrigger.classList.add('atcb-click');
1393
1449
  }
@@ -1401,9 +1457,9 @@ function atcb_generate_button(button, data) {
1401
1457
  }
1402
1458
  if (data.options.length === 1) {
1403
1459
  buttonTrigger.classList.add('atcb-single');
1404
- atcb_generate_label(data, buttonTrigger, data.options[0], true, data.label, true);
1460
+ atcb_generate_label(data, buttonTrigger, data.options[0], data.iconButton, data.label, true);
1405
1461
  } else {
1406
- atcb_generate_label(data, buttonTrigger, 'trigger', true, data.label);
1462
+ atcb_generate_label(data, buttonTrigger, 'trigger', data.iconButton, data.label);
1407
1463
  const buttonDropdownAnchor = document.createElement('div');
1408
1464
  buttonDropdownAnchor.classList.add('atcb-dropdown-anchor');
1409
1465
  buttonTrigger.appendChild(buttonDropdownAnchor);
@@ -1577,14 +1633,14 @@ function atcb_generate_dropdown_list(data) {
1577
1633
  listCount++;
1578
1634
  optionItem.dataset.optionNumber = listCount;
1579
1635
  optionsList.appendChild(optionItem);
1580
- atcb_generate_label(data, optionItem, option, true, data.optionLabels[listCount - 1]);
1636
+ atcb_generate_label(data, optionItem, option, data.iconList, data.optionLabels[listCount - 1]);
1581
1637
  });
1582
1638
  if (data.listStyle === 'modal') {
1583
1639
  const optionItem = document.createElement('div');
1584
1640
  optionItem.classList.add('atcb-list-item', 'atcb-list-item-close');
1585
1641
  optionItem.tabIndex = 0;
1586
1642
  optionsList.appendChild(optionItem);
1587
- atcb_generate_label(data, optionItem, 'close', true);
1643
+ atcb_generate_label(data, optionItem, 'close', data.iconList);
1588
1644
  }
1589
1645
  return optionsList;
1590
1646
  }
@@ -1710,7 +1766,7 @@ function atcb_create_modal(
1710
1766
  modalWrapper.appendChild(modal);
1711
1767
  atcb_set_sizes(modal, data.sizes);
1712
1768
  atcb_set_fullsize(bgOverlay);
1713
- if (icon != '') {
1769
+ if (icon != '' && data.iconModal == true) {
1714
1770
  const modalIcon = document.createElement('div');
1715
1771
  modalIcon.classList.add('atcb-modal-icon');
1716
1772
  modalIcon.innerHTML = atcbIcon[`${icon}`];
@@ -1943,7 +1999,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all') {
1943
1999
  btnHeadline.classList.add('atcb-date-btn-headline');
1944
2000
  btnHeadline.textContent = data.dates[`${subEvent}`].name;
1945
2001
  btnDetails.appendChild(btnHeadline);
1946
- if ((data.location != null && data.location != '') || cancelledInfo == '') {
2002
+ if ((data.location != null && data.location != '') || cancelledInfo != '') {
1947
2003
  const btnLocation = document.createElement('div');
1948
2004
  btnLocation.classList.add('atcb-date-btn-content');
1949
2005
  btnDetails.appendChild(btnLocation);
@@ -2185,7 +2241,7 @@ function atcb_generate_google(data) {
2185
2241
  urlParts.push(
2186
2242
  'dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end)
2187
2243
  );
2188
- if (data.timeZone != null && data.timeZone != '' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone)) {
2244
+ if (data.timeZone != null && data.timeZone != '' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(data.timeZone)) {
2189
2245
  urlParts.push('ctz=' + data.timeZone);
2190
2246
  }
2191
2247
  if (data.name != null && data.name != '') {
@@ -2505,15 +2561,9 @@ function atcb_save_file(file, filename) {
2505
2561
  }
2506
2562
  }
2507
2563
  function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', addTimeZoneOffset = false) {
2508
- const startDate = data.startDate.split('-');
2509
- const endDate = data.endDate.split('-');
2510
2564
  if (data.startTime != null && data.startTime != '' && data.endTime != null && data.endTime != '') {
2511
- const newStartDate = new Date(
2512
- startDate[0] + '-' + startDate[1] + '-' + startDate[2] + 'T' + data.startTime + ':00.000+00:00'
2513
- );
2514
- const newEndDate = new Date(
2515
- endDate[0] + '-' + endDate[1] + '-' + endDate[2] + 'T' + data.endTime + ':00.000+00:00'
2516
- );
2565
+ const newStartDate = new Date(data.startDate + 'T' + data.startTime + ':00.000+00:00');
2566
+ const newEndDate = new Date(data.endDate + 'T' + data.endTime + ':00.000+00:00');
2517
2567
  const durationMS = newEndDate - newStartDate;
2518
2568
  const durationHours = Math.floor(durationMS / 1000 / 60 / 60);
2519
2569
  const durationMinutes = Math.floor(((durationMS - durationHours * 60 * 60 * 1000) / 1000 / 60) % 60);
@@ -2532,7 +2582,13 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2532
2582
  };
2533
2583
  }
2534
2584
  if (data.timeZone != null && data.timeZone != '') {
2535
- if (targetCal == 'ical' || (targetCal == 'google' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone))) {
2585
+ if (
2586
+ targetCal == 'ical' ||
2587
+ (targetCal == 'google' &&
2588
+ !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(
2589
+ data.timeZone
2590
+ ))
2591
+ ) {
2536
2592
  return {
2537
2593
  start: atcb_format_datetime(newStartDate, 'clean', true, true),
2538
2594
  end: atcb_format_datetime(newEndDate, 'clean', true, true),
@@ -2570,8 +2626,8 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2570
2626
  allday: false,
2571
2627
  };
2572
2628
  } else {
2573
- const newStartDate = new Date(Date.UTC(startDate[0], startDate[1] - 1, startDate[2]));
2574
- const newEndDate = new Date(Date.UTC(endDate[0], endDate[1] - 1, endDate[2]));
2629
+ const newStartDate = new Date(data.startDate + 'T00:00:00.000Z');
2630
+ const newEndDate = new Date(data.endDate + 'T00:00:00.000Z');
2575
2631
  if (targetCal == 'google' || targetCal == 'microsoft' || targetCal == 'ical') {
2576
2632
  newEndDate.setDate(newEndDate.getDate() + 1);
2577
2633
  }
@@ -2666,15 +2722,16 @@ function atcb_position_list(trigger, list, blockUpwards = false, resize = false)
2666
2722
  let triggerDim = trigger.getBoundingClientRect();
2667
2723
  let listDim = list.getBoundingClientRect();
2668
2724
  const btnDim = originalTrigger.getBoundingClientRect();
2725
+ const viewportHeight = document.documentElement.clientHeight;
2726
+ const posWrapper = document.getElementById('atcb-pos-wrapper');
2727
+ if (posWrapper !== null) {
2728
+ posWrapper.style.height = viewportHeight + 'px';
2729
+ }
2669
2730
  if (anchorSet === true && !list.classList.contains('atcb-dropoverlay')) {
2670
- const viewportHeight = document.documentElement.clientHeight;
2671
- const posWrapper = document.getElementById('atcb-pos-wrapper');
2672
- if (posWrapper !== null) {
2673
- posWrapper.style.height = viewportHeight + 'px';
2674
- }
2675
2731
  if (
2676
2732
  (list.classList.contains('atcb-dropup') && resize) ||
2677
2733
  (!blockUpwards &&
2734
+ !resize &&
2678
2735
  triggerDim.top + listDim.height > viewportHeight - 20 &&
2679
2736
  2 * btnDim.top + btnDim.height - triggerDim.top - listDim.height > 20)
2680
2737
  ) {
package/index.d.ts CHANGED
@@ -49,6 +49,8 @@ declare module 'add-to-calendar-button' {
49
49
  listStyle?: 'dropdown' | 'dropdown-static' | 'overlay' | 'modal';
50
50
  buttonStyle?: 'default' | '3d' | 'flat' | 'round' | 'neumorphism' | 'text' | 'date' | 'custom' | 'none';
51
51
  trigger?: 'hover' | 'click';
52
+ icons?: string;
53
+ textLabels?: string;
52
54
  background?: boolean;
53
55
  checkmark?: boolean;
54
56
  mindScrolling?: boolean;
@@ -8,14 +8,14 @@ const tzlibActions = require('timezones-ical-library');
8
8
  * Add to Calendar Button
9
9
  * ++++++++++++++++++++++
10
10
  *
11
- * Version: 1.18.2
11
+ * Version: 1.18.4
12
12
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
13
13
  * Project: https://github.com/add2cal/add-to-calendar-button
14
14
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
15
15
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
16
16
  *
17
17
  */
18
- const atcbVersion = '1.18.2';
18
+ const atcbVersion = '1.18.4';
19
19
  const isBrowser = () => {
20
20
  if (typeof window === 'undefined') {
21
21
  return false;
@@ -155,6 +155,7 @@ function atcb_decorate_data(data) {
155
155
  data = atcb_decorate_data_options(data);
156
156
  data.richData = atcb_decorate_data_rich_data(data);
157
157
  data.checkmark = atcb_decorate_data_checkmark(data);
158
+ data.background = atcb_decorate_data_background(data);
158
159
  data.mindScrolling = atcb_decorate_data_mind_scrolling(data);
159
160
  data.branding = atcb_decorate_data_branding(data);
160
161
  data = atcb_decorate_data_style(data);
@@ -293,6 +294,12 @@ function atcb_decorate_data_checkmark(data) {
293
294
  }
294
295
  return true;
295
296
  }
297
+ function atcb_decorate_data_background(data) {
298
+ if (data.background != null && data.background == false) {
299
+ return false;
300
+ }
301
+ return true;
302
+ }
296
303
  function atcb_decorate_data_branding(data) {
297
304
  if (data.branding != null && data.branding == false) {
298
305
  return false;
@@ -365,6 +372,38 @@ function atcb_decorate_data_style(data) {
365
372
  break;
366
373
  }
367
374
  }
375
+ data.iconButton = true;
376
+ data.iconList = true;
377
+ data.iconModal = true;
378
+ if (data.icons != null) {
379
+ data.icons = String(data.icons);
380
+ if (data.icons != '') {
381
+ const iconsConfig = data.icons.split('|');
382
+ if (iconsConfig[0] == 'false') {
383
+ data.iconButton = false;
384
+ }
385
+ if (iconsConfig[1] != null && iconsConfig[1] == 'false') {
386
+ data.iconList = false;
387
+ }
388
+ if (iconsConfig[2] != null && iconsConfig[2] == 'false') {
389
+ data.iconModal = false;
390
+ }
391
+ }
392
+ }
393
+ data.textLabelButton = true;
394
+ data.textLabelList = true;
395
+ if (data.textLabels != null) {
396
+ data.textLabels = String(data.textLabels);
397
+ if (data.textLabels != '') {
398
+ const textLabelsConfig = data.textLabels.split('|');
399
+ if (textLabelsConfig[0] == 'false') {
400
+ data.textLabelButton = false;
401
+ }
402
+ if (textLabelsConfig[1] != null && textLabelsConfig[1] == 'false') {
403
+ data.textLabelList = false;
404
+ }
405
+ }
406
+ }
368
407
  return data;
369
408
  }
370
409
  function atcb_decorate_data_i18n(data) {
@@ -938,6 +977,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
938
977
  const list = atcb_generate_dropdown_list(data);
939
978
  const listWrapper = document.createElement('div');
940
979
  listWrapper.classList.add('atcb-list-wrapper');
980
+ if (data.textLabelList == false) {
981
+ listWrapper.classList.add('atcb-no-text');
982
+ }
941
983
  if (button) {
942
984
  button.classList.add('atcb-active');
943
985
  if (data.listStyle === 'modal') {
@@ -971,6 +1013,10 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
971
1013
  } else {
972
1014
  const positionWrapper = document.createElement('div');
973
1015
  positionWrapper.id = 'atcb-pos-wrapper';
1016
+ positionWrapper.style.position = 'absolute';
1017
+ positionWrapper.style.top = '0';
1018
+ positionWrapper.style.bottom = '0';
1019
+ positionWrapper.style.width = '100%';
974
1020
  document.body.appendChild(positionWrapper);
975
1021
  positionWrapper.appendChild(listWrapper);
976
1022
  listWrapper.appendChild(list);
@@ -982,7 +1028,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
982
1028
  }
983
1029
  document.body.appendChild(bgOverlay);
984
1030
  atcb_set_sizes(list, data.sizes);
1031
+ listWrapper.style.display = 'none';
985
1032
  setTimeout(function () {
1033
+ listWrapper.style.display = 'block';
986
1034
  if (data.listStyle === 'dropdown-static') {
987
1035
  atcb_position_list(button, listWrapper, true);
988
1036
  } else {
@@ -1113,9 +1161,9 @@ function atcb_generate_label(data, parent, type, icon = false, text = '', oneOpt
1113
1161
  if (oneOption) {
1114
1162
  parent.id = data.identifier;
1115
1163
  }
1116
- atcb_generate_label_text(data, parent, type, icon, text, oneOption);
1164
+ atcb_generate_label_content(data, parent, type, icon, text, oneOption);
1117
1165
  }
1118
- function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1166
+ function atcb_generate_label_content(data, parent, type, icon, text, oneOption) {
1119
1167
  const defaultTriggerText = atcb_translate_hook('Add to Calendar', data);
1120
1168
  if (oneOption && text == '') {
1121
1169
  text = defaultTriggerText;
@@ -1159,10 +1207,15 @@ function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1159
1207
  iconEl.innerHTML = atcbIcon[`${type}`];
1160
1208
  parent.appendChild(iconEl);
1161
1209
  }
1162
- const textEl = document.createElement('span');
1163
- textEl.classList.add('atcb-text');
1164
- textEl.textContent = text;
1165
- parent.appendChild(textEl);
1210
+ if (
1211
+ (type == 'trigger' && data.textLabelButton == true) ||
1212
+ (type != 'trigger' && data.textLabelList == true)
1213
+ ) {
1214
+ const textEl = document.createElement('span');
1215
+ textEl.classList.add('atcb-text');
1216
+ textEl.textContent = text;
1217
+ parent.appendChild(textEl);
1218
+ }
1166
1219
  }
1167
1220
  function atcb_generate_button(button, data) {
1168
1221
  button.textContent = '';
@@ -1179,6 +1232,9 @@ function atcb_generate_button(button, data) {
1179
1232
  atcb_set_sizes(buttonTriggerWrapper, data.sizes);
1180
1233
  const buttonTrigger = document.createElement('button');
1181
1234
  buttonTrigger.classList.add('atcb-button');
1235
+ if (data.textLabelButton == false) {
1236
+ buttonTrigger.classList.add('atcb-no-text');
1237
+ }
1182
1238
  if (data.trigger === 'click') {
1183
1239
  buttonTrigger.classList.add('atcb-click');
1184
1240
  }
@@ -1192,9 +1248,9 @@ function atcb_generate_button(button, data) {
1192
1248
  }
1193
1249
  if (data.options.length === 1) {
1194
1250
  buttonTrigger.classList.add('atcb-single');
1195
- atcb_generate_label(data, buttonTrigger, data.options[0], true, data.label, true);
1251
+ atcb_generate_label(data, buttonTrigger, data.options[0], data.iconButton, data.label, true);
1196
1252
  } else {
1197
- atcb_generate_label(data, buttonTrigger, 'trigger', true, data.label);
1253
+ atcb_generate_label(data, buttonTrigger, 'trigger', data.iconButton, data.label);
1198
1254
  const buttonDropdownAnchor = document.createElement('div');
1199
1255
  buttonDropdownAnchor.classList.add('atcb-dropdown-anchor');
1200
1256
  buttonTrigger.appendChild(buttonDropdownAnchor);
@@ -1368,14 +1424,14 @@ function atcb_generate_dropdown_list(data) {
1368
1424
  listCount++;
1369
1425
  optionItem.dataset.optionNumber = listCount;
1370
1426
  optionsList.appendChild(optionItem);
1371
- atcb_generate_label(data, optionItem, option, true, data.optionLabels[listCount - 1]);
1427
+ atcb_generate_label(data, optionItem, option, data.iconList, data.optionLabels[listCount - 1]);
1372
1428
  });
1373
1429
  if (data.listStyle === 'modal') {
1374
1430
  const optionItem = document.createElement('div');
1375
1431
  optionItem.classList.add('atcb-list-item', 'atcb-list-item-close');
1376
1432
  optionItem.tabIndex = 0;
1377
1433
  optionsList.appendChild(optionItem);
1378
- atcb_generate_label(data, optionItem, 'close', true);
1434
+ atcb_generate_label(data, optionItem, 'close', data.iconList);
1379
1435
  }
1380
1436
  return optionsList;
1381
1437
  }
@@ -1501,7 +1557,7 @@ function atcb_create_modal(
1501
1557
  modalWrapper.appendChild(modal);
1502
1558
  atcb_set_sizes(modal, data.sizes);
1503
1559
  atcb_set_fullsize(bgOverlay);
1504
- if (icon != '') {
1560
+ if (icon != '' && data.iconModal == true) {
1505
1561
  const modalIcon = document.createElement('div');
1506
1562
  modalIcon.classList.add('atcb-modal-icon');
1507
1563
  modalIcon.innerHTML = atcbIcon[`${icon}`];
@@ -1734,7 +1790,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all') {
1734
1790
  btnHeadline.classList.add('atcb-date-btn-headline');
1735
1791
  btnHeadline.textContent = data.dates[`${subEvent}`].name;
1736
1792
  btnDetails.appendChild(btnHeadline);
1737
- if ((data.location != null && data.location != '') || cancelledInfo == '') {
1793
+ if ((data.location != null && data.location != '') || cancelledInfo != '') {
1738
1794
  const btnLocation = document.createElement('div');
1739
1795
  btnLocation.classList.add('atcb-date-btn-content');
1740
1796
  btnDetails.appendChild(btnLocation);
@@ -1976,7 +2032,7 @@ function atcb_generate_google(data) {
1976
2032
  urlParts.push(
1977
2033
  'dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end)
1978
2034
  );
1979
- if (data.timeZone != null && data.timeZone != '' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone)) {
2035
+ if (data.timeZone != null && data.timeZone != '' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(data.timeZone)) {
1980
2036
  urlParts.push('ctz=' + data.timeZone);
1981
2037
  }
1982
2038
  if (data.name != null && data.name != '') {
@@ -2296,15 +2352,9 @@ function atcb_save_file(file, filename) {
2296
2352
  }
2297
2353
  }
2298
2354
  function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', addTimeZoneOffset = false) {
2299
- const startDate = data.startDate.split('-');
2300
- const endDate = data.endDate.split('-');
2301
2355
  if (data.startTime != null && data.startTime != '' && data.endTime != null && data.endTime != '') {
2302
- const newStartDate = new Date(
2303
- startDate[0] + '-' + startDate[1] + '-' + startDate[2] + 'T' + data.startTime + ':00.000+00:00'
2304
- );
2305
- const newEndDate = new Date(
2306
- endDate[0] + '-' + endDate[1] + '-' + endDate[2] + 'T' + data.endTime + ':00.000+00:00'
2307
- );
2356
+ const newStartDate = new Date(data.startDate + 'T' + data.startTime + ':00.000+00:00');
2357
+ const newEndDate = new Date(data.endDate + 'T' + data.endTime + ':00.000+00:00');
2308
2358
  const durationMS = newEndDate - newStartDate;
2309
2359
  const durationHours = Math.floor(durationMS / 1000 / 60 / 60);
2310
2360
  const durationMinutes = Math.floor(((durationMS - durationHours * 60 * 60 * 1000) / 1000 / 60) % 60);
@@ -2323,7 +2373,13 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2323
2373
  };
2324
2374
  }
2325
2375
  if (data.timeZone != null && data.timeZone != '') {
2326
- if (targetCal == 'ical' || (targetCal == 'google' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone))) {
2376
+ if (
2377
+ targetCal == 'ical' ||
2378
+ (targetCal == 'google' &&
2379
+ !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(
2380
+ data.timeZone
2381
+ ))
2382
+ ) {
2327
2383
  return {
2328
2384
  start: atcb_format_datetime(newStartDate, 'clean', true, true),
2329
2385
  end: atcb_format_datetime(newEndDate, 'clean', true, true),
@@ -2361,8 +2417,8 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2361
2417
  allday: false,
2362
2418
  };
2363
2419
  } else {
2364
- const newStartDate = new Date(Date.UTC(startDate[0], startDate[1] - 1, startDate[2]));
2365
- const newEndDate = new Date(Date.UTC(endDate[0], endDate[1] - 1, endDate[2]));
2420
+ const newStartDate = new Date(data.startDate + 'T00:00:00.000Z');
2421
+ const newEndDate = new Date(data.endDate + 'T00:00:00.000Z');
2366
2422
  if (targetCal == 'google' || targetCal == 'microsoft' || targetCal == 'ical') {
2367
2423
  newEndDate.setDate(newEndDate.getDate() + 1);
2368
2424
  }
@@ -2457,15 +2513,16 @@ function atcb_position_list(trigger, list, blockUpwards = false, resize = false)
2457
2513
  let triggerDim = trigger.getBoundingClientRect();
2458
2514
  let listDim = list.getBoundingClientRect();
2459
2515
  const btnDim = originalTrigger.getBoundingClientRect();
2516
+ const viewportHeight = document.documentElement.clientHeight;
2517
+ const posWrapper = document.getElementById('atcb-pos-wrapper');
2518
+ if (posWrapper !== null) {
2519
+ posWrapper.style.height = viewportHeight + 'px';
2520
+ }
2460
2521
  if (anchorSet === true && !list.classList.contains('atcb-dropoverlay')) {
2461
- const viewportHeight = document.documentElement.clientHeight;
2462
- const posWrapper = document.getElementById('atcb-pos-wrapper');
2463
- if (posWrapper !== null) {
2464
- posWrapper.style.height = viewportHeight + 'px';
2465
- }
2466
2522
  if (
2467
2523
  (list.classList.contains('atcb-dropup') && resize) ||
2468
2524
  (!blockUpwards &&
2525
+ !resize &&
2469
2526
  triggerDim.top + listDim.height > viewportHeight - 20 &&
2470
2527
  2 * btnDim.top + btnDim.height - triggerDim.top - listDim.height > 20)
2471
2528
  ) {
@@ -7,14 +7,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
7
7
  * Add to Calendar Button
8
8
  * ++++++++++++++++++++++
9
9
  *
10
- * Version: 1.18.2
10
+ * Version: 1.18.4
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Apache-2.0 with “Commons Clause” License Condition v1.0
14
14
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
15
15
  *
16
16
  */
17
- const atcbVersion = '1.18.2';
17
+ const atcbVersion = '1.18.4';
18
18
  const isBrowser = () => {
19
19
  if (typeof window === 'undefined') {
20
20
  return false;
@@ -154,6 +154,7 @@ function atcb_decorate_data(data) {
154
154
  data = atcb_decorate_data_options(data);
155
155
  data.richData = atcb_decorate_data_rich_data(data);
156
156
  data.checkmark = atcb_decorate_data_checkmark(data);
157
+ data.background = atcb_decorate_data_background(data);
157
158
  data.mindScrolling = atcb_decorate_data_mind_scrolling(data);
158
159
  data.branding = atcb_decorate_data_branding(data);
159
160
  data = atcb_decorate_data_style(data);
@@ -292,6 +293,12 @@ function atcb_decorate_data_checkmark(data) {
292
293
  }
293
294
  return true;
294
295
  }
296
+ function atcb_decorate_data_background(data) {
297
+ if (data.background != null && data.background == false) {
298
+ return false;
299
+ }
300
+ return true;
301
+ }
295
302
  function atcb_decorate_data_branding(data) {
296
303
  if (data.branding != null && data.branding == false) {
297
304
  return false;
@@ -364,6 +371,38 @@ function atcb_decorate_data_style(data) {
364
371
  break;
365
372
  }
366
373
  }
374
+ data.iconButton = true;
375
+ data.iconList = true;
376
+ data.iconModal = true;
377
+ if (data.icons != null) {
378
+ data.icons = String(data.icons);
379
+ if (data.icons != '') {
380
+ const iconsConfig = data.icons.split('|');
381
+ if (iconsConfig[0] == 'false') {
382
+ data.iconButton = false;
383
+ }
384
+ if (iconsConfig[1] != null && iconsConfig[1] == 'false') {
385
+ data.iconList = false;
386
+ }
387
+ if (iconsConfig[2] != null && iconsConfig[2] == 'false') {
388
+ data.iconModal = false;
389
+ }
390
+ }
391
+ }
392
+ data.textLabelButton = true;
393
+ data.textLabelList = true;
394
+ if (data.textLabels != null) {
395
+ data.textLabels = String(data.textLabels);
396
+ if (data.textLabels != '') {
397
+ const textLabelsConfig = data.textLabels.split('|');
398
+ if (textLabelsConfig[0] == 'false') {
399
+ data.textLabelButton = false;
400
+ }
401
+ if (textLabelsConfig[1] != null && textLabelsConfig[1] == 'false') {
402
+ data.textLabelList = false;
403
+ }
404
+ }
405
+ }
367
406
  return data;
368
407
  }
369
408
  function atcb_decorate_data_i18n(data) {
@@ -937,6 +976,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
937
976
  const list = atcb_generate_dropdown_list(data);
938
977
  const listWrapper = document.createElement('div');
939
978
  listWrapper.classList.add('atcb-list-wrapper');
979
+ if (data.textLabelList == false) {
980
+ listWrapper.classList.add('atcb-no-text');
981
+ }
940
982
  if (button) {
941
983
  button.classList.add('atcb-active');
942
984
  if (data.listStyle === 'modal') {
@@ -970,6 +1012,10 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
970
1012
  } else {
971
1013
  const positionWrapper = document.createElement('div');
972
1014
  positionWrapper.id = 'atcb-pos-wrapper';
1015
+ positionWrapper.style.position = 'absolute';
1016
+ positionWrapper.style.top = '0';
1017
+ positionWrapper.style.bottom = '0';
1018
+ positionWrapper.style.width = '100%';
973
1019
  document.body.appendChild(positionWrapper);
974
1020
  positionWrapper.appendChild(listWrapper);
975
1021
  listWrapper.appendChild(list);
@@ -981,7 +1027,9 @@ function atcb_open(data, button, keyboardTrigger = false, generatedButton = fals
981
1027
  }
982
1028
  document.body.appendChild(bgOverlay);
983
1029
  atcb_set_sizes(list, data.sizes);
1030
+ listWrapper.style.display = 'none';
984
1031
  setTimeout(function () {
1032
+ listWrapper.style.display = 'block';
985
1033
  if (data.listStyle === 'dropdown-static') {
986
1034
  atcb_position_list(button, listWrapper, true);
987
1035
  } else {
@@ -1112,9 +1160,9 @@ function atcb_generate_label(data, parent, type, icon = false, text = '', oneOpt
1112
1160
  if (oneOption) {
1113
1161
  parent.id = data.identifier;
1114
1162
  }
1115
- atcb_generate_label_text(data, parent, type, icon, text, oneOption);
1163
+ atcb_generate_label_content(data, parent, type, icon, text, oneOption);
1116
1164
  }
1117
- function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1165
+ function atcb_generate_label_content(data, parent, type, icon, text, oneOption) {
1118
1166
  const defaultTriggerText = atcb_translate_hook('Add to Calendar', data);
1119
1167
  if (oneOption && text == '') {
1120
1168
  text = defaultTriggerText;
@@ -1158,10 +1206,15 @@ function atcb_generate_label_text(data, parent, type, icon, text, oneOption) {
1158
1206
  iconEl.innerHTML = atcbIcon[`${type}`];
1159
1207
  parent.appendChild(iconEl);
1160
1208
  }
1161
- const textEl = document.createElement('span');
1162
- textEl.classList.add('atcb-text');
1163
- textEl.textContent = text;
1164
- parent.appendChild(textEl);
1209
+ if (
1210
+ (type == 'trigger' && data.textLabelButton == true) ||
1211
+ (type != 'trigger' && data.textLabelList == true)
1212
+ ) {
1213
+ const textEl = document.createElement('span');
1214
+ textEl.classList.add('atcb-text');
1215
+ textEl.textContent = text;
1216
+ parent.appendChild(textEl);
1217
+ }
1165
1218
  }
1166
1219
  function atcb_generate_button(button, data) {
1167
1220
  button.textContent = '';
@@ -1178,6 +1231,9 @@ function atcb_generate_button(button, data) {
1178
1231
  atcb_set_sizes(buttonTriggerWrapper, data.sizes);
1179
1232
  const buttonTrigger = document.createElement('button');
1180
1233
  buttonTrigger.classList.add('atcb-button');
1234
+ if (data.textLabelButton == false) {
1235
+ buttonTrigger.classList.add('atcb-no-text');
1236
+ }
1181
1237
  if (data.trigger === 'click') {
1182
1238
  buttonTrigger.classList.add('atcb-click');
1183
1239
  }
@@ -1191,9 +1247,9 @@ function atcb_generate_button(button, data) {
1191
1247
  }
1192
1248
  if (data.options.length === 1) {
1193
1249
  buttonTrigger.classList.add('atcb-single');
1194
- atcb_generate_label(data, buttonTrigger, data.options[0], true, data.label, true);
1250
+ atcb_generate_label(data, buttonTrigger, data.options[0], data.iconButton, data.label, true);
1195
1251
  } else {
1196
- atcb_generate_label(data, buttonTrigger, 'trigger', true, data.label);
1252
+ atcb_generate_label(data, buttonTrigger, 'trigger', data.iconButton, data.label);
1197
1253
  const buttonDropdownAnchor = document.createElement('div');
1198
1254
  buttonDropdownAnchor.classList.add('atcb-dropdown-anchor');
1199
1255
  buttonTrigger.appendChild(buttonDropdownAnchor);
@@ -1367,14 +1423,14 @@ function atcb_generate_dropdown_list(data) {
1367
1423
  listCount++;
1368
1424
  optionItem.dataset.optionNumber = listCount;
1369
1425
  optionsList.appendChild(optionItem);
1370
- atcb_generate_label(data, optionItem, option, true, data.optionLabels[listCount - 1]);
1426
+ atcb_generate_label(data, optionItem, option, data.iconList, data.optionLabels[listCount - 1]);
1371
1427
  });
1372
1428
  if (data.listStyle === 'modal') {
1373
1429
  const optionItem = document.createElement('div');
1374
1430
  optionItem.classList.add('atcb-list-item', 'atcb-list-item-close');
1375
1431
  optionItem.tabIndex = 0;
1376
1432
  optionsList.appendChild(optionItem);
1377
- atcb_generate_label(data, optionItem, 'close', true);
1433
+ atcb_generate_label(data, optionItem, 'close', data.iconList);
1378
1434
  }
1379
1435
  return optionsList;
1380
1436
  }
@@ -1500,7 +1556,7 @@ function atcb_create_modal(
1500
1556
  modalWrapper.appendChild(modal);
1501
1557
  atcb_set_sizes(modal, data.sizes);
1502
1558
  atcb_set_fullsize(bgOverlay);
1503
- if (icon != '') {
1559
+ if (icon != '' && data.iconModal == true) {
1504
1560
  const modalIcon = document.createElement('div');
1505
1561
  modalIcon.classList.add('atcb-modal-icon');
1506
1562
  modalIcon.innerHTML = atcbIcon[`${icon}`];
@@ -1733,7 +1789,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all') {
1733
1789
  btnHeadline.classList.add('atcb-date-btn-headline');
1734
1790
  btnHeadline.textContent = data.dates[`${subEvent}`].name;
1735
1791
  btnDetails.appendChild(btnHeadline);
1736
- if ((data.location != null && data.location != '') || cancelledInfo == '') {
1792
+ if ((data.location != null && data.location != '') || cancelledInfo != '') {
1737
1793
  const btnLocation = document.createElement('div');
1738
1794
  btnLocation.classList.add('atcb-date-btn-content');
1739
1795
  btnDetails.appendChild(btnLocation);
@@ -1975,7 +2031,7 @@ function atcb_generate_google(data) {
1975
2031
  urlParts.push(
1976
2032
  'dates=' + encodeURIComponent(formattedDate.start) + '%2F' + encodeURIComponent(formattedDate.end)
1977
2033
  );
1978
- if (data.timeZone != null && data.timeZone != '' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone)) {
2034
+ if (data.timeZone != null && data.timeZone != '' && !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(data.timeZone)) {
1979
2035
  urlParts.push('ctz=' + data.timeZone);
1980
2036
  }
1981
2037
  if (data.name != null && data.name != '') {
@@ -2295,15 +2351,9 @@ function atcb_save_file(file, filename) {
2295
2351
  }
2296
2352
  }
2297
2353
  function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', addTimeZoneOffset = false) {
2298
- const startDate = data.startDate.split('-');
2299
- const endDate = data.endDate.split('-');
2300
2354
  if (data.startTime != null && data.startTime != '' && data.endTime != null && data.endTime != '') {
2301
- const newStartDate = new Date(
2302
- startDate[0] + '-' + startDate[1] + '-' + startDate[2] + 'T' + data.startTime + ':00.000+00:00'
2303
- );
2304
- const newEndDate = new Date(
2305
- endDate[0] + '-' + endDate[1] + '-' + endDate[2] + 'T' + data.endTime + ':00.000+00:00'
2306
- );
2355
+ const newStartDate = new Date(data.startDate + 'T' + data.startTime + ':00.000+00:00');
2356
+ const newEndDate = new Date(data.endDate + 'T' + data.endTime + ':00.000+00:00');
2307
2357
  const durationMS = newEndDate - newStartDate;
2308
2358
  const durationHours = Math.floor(durationMS / 1000 / 60 / 60);
2309
2359
  const durationMinutes = Math.floor(((durationMS - durationHours * 60 * 60 * 1000) / 1000 / 60) % 60);
@@ -2322,7 +2372,13 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2322
2372
  };
2323
2373
  }
2324
2374
  if (data.timeZone != null && data.timeZone != '') {
2325
- if (targetCal == 'ical' || (targetCal == 'google' && !/GMT[+|-]\d{1,2}/i.test(data.timeZone))) {
2375
+ if (
2376
+ targetCal == 'ical' ||
2377
+ (targetCal == 'google' &&
2378
+ !/(GMT[+|-]\d{1,2}|Etc\/U|Etc\/Zulu|CET|CST6CDT|EET|EST|EST5EDT|MET|MST|MST7MDT|PST8PDT|WET)/i.test(
2379
+ data.timeZone
2380
+ ))
2381
+ ) {
2326
2382
  return {
2327
2383
  start: atcb_format_datetime(newStartDate, 'clean', true, true),
2328
2384
  end: atcb_format_datetime(newEndDate, 'clean', true, true),
@@ -2360,8 +2416,8 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general', a
2360
2416
  allday: false,
2361
2417
  };
2362
2418
  } else {
2363
- const newStartDate = new Date(Date.UTC(startDate[0], startDate[1] - 1, startDate[2]));
2364
- const newEndDate = new Date(Date.UTC(endDate[0], endDate[1] - 1, endDate[2]));
2419
+ const newStartDate = new Date(data.startDate + 'T00:00:00.000Z');
2420
+ const newEndDate = new Date(data.endDate + 'T00:00:00.000Z');
2365
2421
  if (targetCal == 'google' || targetCal == 'microsoft' || targetCal == 'ical') {
2366
2422
  newEndDate.setDate(newEndDate.getDate() + 1);
2367
2423
  }
@@ -2456,15 +2512,16 @@ function atcb_position_list(trigger, list, blockUpwards = false, resize = false)
2456
2512
  let triggerDim = trigger.getBoundingClientRect();
2457
2513
  let listDim = list.getBoundingClientRect();
2458
2514
  const btnDim = originalTrigger.getBoundingClientRect();
2515
+ const viewportHeight = document.documentElement.clientHeight;
2516
+ const posWrapper = document.getElementById('atcb-pos-wrapper');
2517
+ if (posWrapper !== null) {
2518
+ posWrapper.style.height = viewportHeight + 'px';
2519
+ }
2459
2520
  if (anchorSet === true && !list.classList.contains('atcb-dropoverlay')) {
2460
- const viewportHeight = document.documentElement.clientHeight;
2461
- const posWrapper = document.getElementById('atcb-pos-wrapper');
2462
- if (posWrapper !== null) {
2463
- posWrapper.style.height = viewportHeight + 'px';
2464
- }
2465
2521
  if (
2466
2522
  (list.classList.contains('atcb-dropup') && resize) ||
2467
2523
  (!blockUpwards &&
2524
+ !resize &&
2468
2525
  triggerDim.top + listDim.height > viewportHeight - 20 &&
2469
2526
  2 * btnDim.top + btnDim.height - triggerDim.top - listDim.height > 20)
2470
2527
  ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "1.18.2",
3
+ "version": "1.18.4",
4
4
  "engines": {
5
5
  "node": ">=14.20.0"
6
6
  },
@@ -69,9 +69,9 @@
69
69
  "timezones-ical-library": "^1.4.2"
70
70
  },
71
71
  "devDependencies": {
72
- "@typescript-eslint/eslint-plugin": "^5.40.1",
73
- "@typescript-eslint/parser": "^5.40.1",
74
- "eslint": "^8.25.0",
72
+ "@typescript-eslint/eslint-plugin": "^5.41.0",
73
+ "@typescript-eslint/parser": "^5.41.0",
74
+ "eslint": "^8.26.0",
75
75
  "eslint-config-prettier": "^8.5.0",
76
76
  "eslint-plugin-commonjs": "^1.0.2",
77
77
  "eslint-plugin-security": "^1.5.0",