add-to-calendar-button 2.6.12 → 2.6.13

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.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: 3D
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Date
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Flat
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Neumorphism
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Round
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Text
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: Default
7
7
  *
8
- * Version: 2.6.12
8
+ * Version: 2.6.13
9
9
  * Creator: Jens Kuerschner (https://jekuer.com)
10
10
  * Project: https://github.com/add2cal/add-to-calendar-button
11
11
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
974
974
  * Add to Calendar Button
975
975
  * ++++++++++++++++++++++
976
976
  *
977
- * Version: 2.6.12
977
+ * Version: 2.6.13
978
978
  * Creator: Jens Kuerschner (https://jekuer.com)
979
979
  * Project: https://github.com/add2cal/add-to-calendar-button
980
980
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
981
981
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
982
982
  *
983
983
  */
984
- const atcbVersion = '2.6.12';
984
+ const atcbVersion = '2.6.13';
985
985
  const atcbCssTemplate = {};
986
986
  const atcbIsBrowser = () => {
987
987
  if (typeof window === 'undefined') {
@@ -992,7 +992,7 @@ const atcbIsBrowser = () => {
992
992
  };
993
993
  const atcbIsiOS = atcbIsBrowser()
994
994
  ? () => {
995
- if ((/iPad|iPhone|iPod/i.test(navigator.userAgent || window.opera) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) {
995
+ if (/iPad|iPhone|iPod/i.test(navigator.userAgent) && !/MSStream/i.test(navigator.userAgent)) {
996
996
  return true;
997
997
  } else {
998
998
  return false;
@@ -1003,7 +1003,7 @@ const atcbIsiOS = atcbIsBrowser()
1003
1003
  };
1004
1004
  const atcbIsAndroid = atcbIsBrowser()
1005
1005
  ? () => {
1006
- if (/android/i.test(navigator.userAgent || window.opera) && !window.MSStream) {
1006
+ if (/android/i.test(navigator.userAgent) && !/MSStream/i.test(navigator.userAgent)) {
1007
1007
  return true;
1008
1008
  } else {
1009
1009
  return false;
@@ -1054,7 +1054,7 @@ const atcbIsWebView = atcbIsBrowser()
1054
1054
  };
1055
1055
  const atcbIsProblematicWebView = atcbIsBrowser()
1056
1056
  ? () => {
1057
- if (/(Instagram)/i.test(navigator.userAgent || window.opera)) {
1057
+ if (/(Instagram)/i.test(navigator.userAgent)) {
1058
1058
  return true;
1059
1059
  } else {
1060
1060
  return false;
@@ -1350,12 +1350,15 @@ function atcb_decorate_data_options(data) {
1350
1350
  }
1351
1351
  if (
1352
1352
  ((atcbIsiOS() || data.fakeIOS) && atcbIOSInvalidOptions.includes(optionName)) ||
1353
- ((atcbIsAndroid() || data.fakeMobile || data.fakeAndroid) && atcbAndroidInvalidOptions.includes(optionName)) ||
1353
+ ((atcbIsAndroid() || data.fakeAndroid) && atcbAndroidInvalidOptions.includes(optionName)) ||
1354
1354
  (data.recurrence && data.recurrence !== '' && (!atcbValidRecurrOptions.includes(optionName) || (data.recurrence_until && data.recurrence_until !== '' && (optionName === 'apple' || optionName === 'ical')) || ((atcbIsiOS() || data.fakeIOS) && optionName === 'google'))) ||
1355
1355
  (data.subscribe && atcbInvalidSubscribeOptions.includes(optionName))
1356
1356
  ) {
1357
1357
  continue;
1358
1358
  }
1359
+ if ((atcbIsMobile() || data.fakeMobile) && data.subscribe && (optionName === 'ms365' || optionName === 'outlookcom')) {
1360
+ continue;
1361
+ }
1359
1362
  newOptions.push(optionName);
1360
1363
  }
1361
1364
  if (data.subscribe && data.icsFile && data.icsFile.startsWith('https://calendar.google.com/calendar/') && !data.icsFile.endsWith('.ics')) {
@@ -1370,7 +1373,7 @@ function atcb_decorate_data_options(data) {
1370
1373
  if ((atcbIsiOS() || data.fakeIOS) && iCalGiven && !appleGiven) {
1371
1374
  newOptions.push('apple');
1372
1375
  }
1373
- if ((atcbIsAndroid() || data.fakeMobile || data.fakeAndroid) && appleGiven && !iCalGiven) {
1376
+ if ((atcbIsAndroid() || data.fakeAndroid) && appleGiven && !iCalGiven) {
1374
1377
  newOptions.push('ical');
1375
1378
  }
1376
1379
  data.options = newOptions;
@@ -1670,7 +1673,7 @@ function atcb_decorate_data_button_status_handling(data) {
1670
1673
  if (!data.pastDateHandling || (data.pastDateHandling != 'disable' && data.pastDateHandling != 'hide')) {
1671
1674
  data.pastDateHandling = 'none';
1672
1675
  }
1673
- const overdue = (function () {
1676
+ data.allOverdue = (function () {
1674
1677
  for (let i = 0; i < data.dates.length; i++) {
1675
1678
  if (!data.dates[`${i}`].overdue) {
1676
1679
  return false;
@@ -1678,15 +1681,21 @@ function atcb_decorate_data_button_status_handling(data) {
1678
1681
  }
1679
1682
  return true;
1680
1683
  })();
1681
- data.allOverdue = false;
1682
- if (overdue) {
1683
- data.allOverdue = true;
1684
+ if (data.allOverdue) {
1684
1685
  if (data.pastDateHandling == 'disable') {
1685
1686
  data.disabled = true;
1686
1687
  } else if (data.pastDateHandling == 'hide') {
1687
1688
  data.hidden = true;
1688
1689
  }
1689
1690
  }
1691
+ data.allCancelled = (function () {
1692
+ for (let i = 0; i < data.dates.length; i++) {
1693
+ if (!data.dates[`${i}`].status || data.dates[`${i}`].status.toLowerCase() !== 'cancelled') {
1694
+ return false;
1695
+ }
1696
+ }
1697
+ return true;
1698
+ })();
1690
1699
  if (data.disabled || data.hidden) {
1691
1700
  data.blockInteraction = true;
1692
1701
  }
@@ -1855,7 +1864,8 @@ async function atcb_validate_date_blocks(data, msgPrefix) {
1855
1864
  }
1856
1865
  }
1857
1866
  async function atcb_validate_status(data, msgPrefix, i, msgSuffix) {
1858
- if (data.dates[`${i}`].status !== 'TENTATIVE' && data.dates[`${i}`].status !== 'CONFIRMED' && data.dates[`${i}`].status !== 'CANCELLED') {
1867
+ const allowedStatuses = ['tentative', 'confirmed', 'cancelled'];
1868
+ if (!allowedStatuses.includes(data.dates[`${i}`].status.toLowerCase())) {
1859
1869
  throw new Error(msgPrefix + ' failed: event status needs to be TENTATIVE, CONFIRMED, or CANCELLED' + msgSuffix);
1860
1870
  }
1861
1871
  return true;
@@ -2100,7 +2110,7 @@ function atcb_close(host, keyboardTrigger = false) {
2100
2110
  if (allModals.length > 1) {
2101
2111
  existingModalHost.shadowRoot.querySelectorAll('.atcb-modal[data-modal-nr="' + allModals.length + '"]')[0].remove();
2102
2112
  const nextModal = existingModalHost.shadowRoot.querySelectorAll('.atcb-modal[data-modal-nr="' + (allModals.length - 1) + '"]')[0];
2103
- nextModal.style.display = 'block';
2113
+ nextModal.classList.remove('atcb-hidden');
2104
2114
  let focusEl = nextModal;
2105
2115
  const availableButtons = nextModal.getElementsByTagName('button');
2106
2116
  if (availableButtons.length > 0) {
@@ -2366,7 +2376,7 @@ function atcb_generate_button(host, button, data) {
2366
2376
  buttonDropdownAnchor.classList.add('atcb-dropdown-anchor');
2367
2377
  buttonTrigger.append(buttonDropdownAnchor);
2368
2378
  }
2369
- if (!data.hideCheckmark && !data.hideTextLabelButton && !data.buttonsList && !data.disabled) {
2379
+ if (!data.hideCheckmark && !data.hideTextLabelButton && !data.buttonsList && !data.disabled && !data.allCancelled) {
2370
2380
  const btnCheck = document.createElement('div');
2371
2381
  btnCheck.classList.add('atcb-checkmark');
2372
2382
  btnCheck.innerHTML = atcbIcon['checkmark'];
@@ -2676,6 +2686,7 @@ async function atcb_create_modal(mainHost, data, icon = '', headline, content =
2676
2686
  prevModal.classList.add('atcb-hidden');
2677
2687
  }
2678
2688
  atcb_manage_body_scroll(modalHost, modalWrapper);
2689
+ return;
2679
2690
  }
2680
2691
  function atcb_subscribe_yahoo_modal_switch(host, data, keyboardTrigger) {
2681
2692
  atcb_set_fully_successful(host, data);
@@ -2689,11 +2700,11 @@ function atcb_generate_date_button(data, parent, subEvent = 'all', oneOption = f
2689
2700
  }
2690
2701
  const fullTimeInfo = atcb_generate_timestring(data.dates, data.language, subEvent);
2691
2702
  const hoverText = (function () {
2692
- if (subEvent != 'all' && data.dates[`${subEvent}`].status == 'CANCELLED') {
2703
+ if ((subEvent !== 'all' && data.dates[`${subEvent}`].status.toLowerCase() === 'cancelled') || (subEvent === 'all' && data.allCancelled)) {
2693
2704
  return atcb_translate_hook('date.status.cancelled', data) + '<br>' + atcb_translate_hook('date.status.cancelled.cta', data);
2694
2705
  }
2695
2706
  if (data.pastDateHandling != 'none') {
2696
- if ((subEvent == 'all' && data.allOverdue) || (subEvent != 'all' && data.dates[`${subEvent}`].overdue)) {
2707
+ if ((subEvent === 'all' && data.allOverdue) || (subEvent != 'all' && data.dates[`${subEvent}`].overdue)) {
2697
2708
  return atcb_translate_hook('expired', data);
2698
2709
  }
2699
2710
  }
@@ -2703,7 +2714,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all', oneOption = f
2703
2714
  return '+ ' + atcb_translate_hook('label.addtocalendar', data);
2704
2715
  })();
2705
2716
  const cancelledInfo = (function () {
2706
- if (subEvent != 'all' && data.dates[`${subEvent}`].status == 'CANCELLED') {
2717
+ if ((subEvent !== 'all' && data.dates[`${subEvent}`].status.toLowerCase() === 'cancelled') || (subEvent === 'all' && data.allCancelled)) {
2707
2718
  return atcb_translate_hook('date.status.cancelled', data);
2708
2719
  }
2709
2720
  return '';
@@ -2818,7 +2829,7 @@ function atcb_generate_date_button(data, parent, subEvent = 'all', oneOption = f
2818
2829
  btnHover.classList.add('atcb-date-btn-hover');
2819
2830
  btnHover.innerHTML = hoverText;
2820
2831
  btnRight.append(btnHover);
2821
- if (!data.hideCheckmark) {
2832
+ if (!data.hideCheckmark && data.dates[`${subEvent}`].status.toLowerCase() !== 'cancelled') {
2822
2833
  const btnCheck = document.createElement('div');
2823
2834
  btnCheck.classList.add('atcb-checkmark');
2824
2835
  btnCheck.innerHTML = atcbIcon['checkmark'];
@@ -2836,10 +2847,10 @@ function atcb_generate_date_button(data, parent, subEvent = 'all', oneOption = f
2836
2847
  }
2837
2848
  async function atcb_generate_modal_host(host, data, reset = true) {
2838
2849
  const existingModalHost = document.getElementById(data.identifier + '-modal-host');
2839
- if (!reset && existingModalHost) {
2840
- return existingModalHost.shadowRoot;
2841
- }
2842
2850
  if (existingModalHost) {
2851
+ if (!reset) {
2852
+ return existingModalHost.shadowRoot;
2853
+ }
2843
2854
  existingModalHost.remove();
2844
2855
  }
2845
2856
  let newModalHost = document.createElement('div');
@@ -2906,7 +2917,7 @@ function atcb_generate_rich_data(data, parent) {
2906
2917
  if (data.dates.length > 1) {
2907
2918
  schemaContent.push('"@id":"' + id + '-' + (i + 1) + '"');
2908
2919
  }
2909
- if (data.dates[`${i}`].status === 'CANCELLED') {
2920
+ if (data.dates[`${i}`].status.toLowerCase() === 'cancelled') {
2910
2921
  schemaContent.push('"eventStatus":"https://schema.org/EventCancelled"');
2911
2922
  } else {
2912
2923
  schemaContent.push('"eventStatus":"https://schema.org/EventScheduled"');
@@ -3023,7 +3034,7 @@ function atcb_generate_links(host, type, data, subEvent = 'all', keyboardTrigger
3023
3034
  return;
3024
3035
  }
3025
3036
  if (subEvent !== 'all') {
3026
- if (data.dates[`${subEvent}`].status === 'CANCELLED' && linkType !== 'ical') {
3037
+ if (data.dates[`${subEvent}`].status.toLowerCase() === 'cancelled' && linkType !== 'ical') {
3027
3038
  atcb_create_modal(host, data, 'warning', atcb_translate_hook('date.status.cancelled', data), atcb_translate_hook('date.status.cancelled.cta', data), [], [], keyboardTrigger);
3028
3039
  } else {
3029
3040
  if (!skipDoubleLink) {
@@ -3048,20 +3059,20 @@ function atcb_generate_links(host, type, data, subEvent = 'all', keyboardTrigger
3048
3059
  atcb_generate_yahoo(data, data.dates[`${subEvent}`], subEvent);
3049
3060
  break;
3050
3061
  }
3051
- }
3052
- const modalHost = document.getElementById(data.identifier + '-modal-host');
3053
- if (modalHost) {
3054
- const subEventButton = modalHost.shadowRoot.getElementById(data.identifier + '-' + type + '-' + (subEvent + 1));
3055
- if (subEventButton) {
3056
- subEventButton.classList.add('atcb-saved');
3062
+ const modalHost = document.getElementById(data.identifier + '-modal-host');
3063
+ if (modalHost) {
3064
+ const subEventButton = modalHost.shadowRoot.getElementById(data.identifier + '-' + type + '-' + (subEvent + 1));
3065
+ if (subEventButton) {
3066
+ subEventButton.classList.add('atcb-saved');
3067
+ }
3068
+ }
3069
+ if (data.dates[`${subEvent}`].status.toLowerCase() !== 'cancelled') atcbStates[`${data.identifier}`][`${type}`][`${subEvent}`]++;
3070
+ const filteredStates = atcbStates[`${data.identifier}`][`${type}`].filter(function (value) {
3071
+ return value < 1;
3072
+ });
3073
+ if (filteredStates.length == 0) {
3074
+ atcb_set_fully_successful(host, data, multiDateModal);
3057
3075
  }
3058
- }
3059
- atcbStates[`${data.identifier}`][`${type}`][`${subEvent}`]++;
3060
- const filteredStates = atcbStates[`${data.identifier}`][`${type}`].filter(function (value) {
3061
- return value < 1;
3062
- });
3063
- if (filteredStates.length == 0) {
3064
- atcb_set_fully_successful(host, data, multiDateModal);
3065
3076
  }
3066
3077
  return;
3067
3078
  }
@@ -3071,7 +3082,7 @@ function atcb_generate_multidate_links(host, type, linkType, data, keyboardTrigg
3071
3082
  if (
3072
3083
  linkType === 'ical' &&
3073
3084
  data.dates.every(function (theSubEvent) {
3074
- if (theSubEvent.status == 'CANCELLED' || (theSubEvent.organizer != null && theSubEvent.organizer != '')) {
3085
+ if (theSubEvent.status.toLowerCase() == 'cancelled' || (theSubEvent.organizer != null && theSubEvent.organizer != '')) {
3075
3086
  return false;
3076
3087
  }
3077
3088
  return true;
@@ -3096,7 +3107,7 @@ function atcb_generate_subscribe_links(host, linkType, data, keyboardTrigger) {
3096
3107
  const adjustedFileUrl = data.icsFile.replace('https://', 'webcal://');
3097
3108
  switch (linkType) {
3098
3109
  case 'ical': // also for apple (see above)
3099
- if (atcbIsAndroid() || data.fakeMobile || data.fakeAndroid) {
3110
+ if (atcbIsAndroid() || data.fakeAndroid) {
3100
3111
  atcb_subscribe_ical(data, data.icsFile);
3101
3112
  break;
3102
3113
  }
@@ -3182,7 +3193,7 @@ function atcb_subscribe_google(data, fileUrl) {
3182
3193
  }
3183
3194
  return encodeURIComponent(fileUrl);
3184
3195
  })();
3185
- if (atcbIsAndroid() || data.fakeMobile || data.fakeAndroid) {
3196
+ if (atcbIsAndroid() || data.fakeAndroid) {
3186
3197
  atcb_open_cal_url(data, 'google', 'intent://' + baseUrlApp + newFileUrl + '#Intent;scheme=https;package=com.google.android.calendar;end', true);
3187
3198
  return;
3188
3199
  }
@@ -3359,7 +3370,7 @@ function atcb_open_cal_url(data, type, url, subscribe = false, subEvent = null,
3359
3370
  }
3360
3371
  }
3361
3372
  function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = false) {
3362
- if (subEvent != 'all') {
3373
+ if (subEvent !== 'all') {
3363
3374
  subEvent = parseInt(subEvent);
3364
3375
  }
3365
3376
  const filename = atcb_determine_ical_filename(data, subEvent);
@@ -3369,10 +3380,10 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
3369
3380
  if ((data.attendee && data.attendee !== '' && potentialHostAttendee !== '') || (data.customVar && data.customVar !== '' && potentialHostCustomVar !== '')) {
3370
3381
  return '';
3371
3382
  }
3372
- if (subEvent != 'all' && data.dates[`${subEvent}`].icsFile != null && data.dates[`${subEvent}`].icsFile != '') {
3383
+ if (subEvent !== 'all' && data.dates[`${subEvent}`].icsFile && data.dates[`${subEvent}`].icsFile !== '') {
3373
3384
  return data.dates[`${subEvent}`].icsFile;
3374
3385
  }
3375
- if (data.icsFile != null && data.icsFile != '') {
3386
+ if (data.icsFile && data.icsFile !== '') {
3376
3387
  return data.icsFile;
3377
3388
  }
3378
3389
  return '';
@@ -3392,10 +3403,10 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
3392
3403
  if (subEvent == 'all') {
3393
3404
  ics_lines.push('METHOD:PUBLISH');
3394
3405
  } else {
3395
- if (data.dates[`${subEvent}`].status != null && data.dates[`${subEvent}`].status == 'CANCELLED') {
3406
+ if (data.dates[`${subEvent}`].status && data.dates[`${subEvent}`].status.toLowerCase() === 'cancelled') {
3396
3407
  ics_lines.push('METHOD:CANCEL');
3397
3408
  } else {
3398
- if (data.dates[`${subEvent}`].organizer != null && data.dates[`${subEvent}`].organizer != '') {
3409
+ if (data.dates[`${subEvent}`].organizer && data.dates[`${subEvent}`].organizer != '') {
3399
3410
  ics_lines.push('METHOD:REQUEST');
3400
3411
  } else {
3401
3412
  ics_lines.push('METHOD:PUBLISH');
@@ -5551,7 +5562,11 @@ function atcb_setup_state_management(data) {
5551
5562
  for (let i = 0; i < data.options.length; i++) {
5552
5563
  singleDates[data.options[`${i}`]] = [];
5553
5564
  for (let id = 1; id <= data.dates.length; id++) {
5554
- singleDates[data.options[`${i}`]].push(0);
5565
+ if (data.dates[id - 1].status.toLowerCase() === 'cancelled') {
5566
+ singleDates[data.options[`${i}`]].push(1);
5567
+ } else {
5568
+ singleDates[data.options[`${i}`]].push(0);
5569
+ }
5555
5570
  }
5556
5571
  }
5557
5572
  atcbStates[data.identifier] = singleDates;