add-to-calendar-button 2.13.0 → 2.13.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Version 2
4
4
 
5
+ - v2.13 : Hebrew language
5
6
  - v2.12 : ⚠️ Breaking: Date buttons now show the next possible date in multi-date and recurrence cases. Recurrence UNTIL support. Mitigating edge cases where ics files with unsupported time zones loaded into Google calendar. Always block background scroll on modals open
6
7
  - v2.11 : ⚠️ Breaking: When setting the dates objects and respective attributes on the root level, root values always override the dates object (except for name in the multi-date case)
7
8
  - v2.10 : Hungarian language, no more X cursor, no different button icons for oneOption cases, create 1 ics file if organizer is the same, subtle style updates, allow to override automatic option-cleanup on mobile via mobile Options
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Style: 3D
7
7
  *
8
- * Version: 2.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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: Simple
7
7
  *
8
- * Version: 2.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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.13.0
8
+ * Version: 2.13.2
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)
@@ -223,14 +223,14 @@ function tzlib_get_timezones(jsonType = false) {
223
223
  * Add to Calendar Button
224
224
  * ++++++++++++++++++++++
225
225
  *
226
- * Version: 2.13.0
226
+ * Version: 2.13.2
227
227
  * Creator: Jens Kuerschner (https://jekuer.com)
228
228
  * Project: https://github.com/add2cal/add-to-calendar-button
229
229
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
230
230
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
231
231
  *
232
232
  */
233
- const atcbVersion = '2.13.0';
233
+ const atcbVersion = '2.13.2';
234
234
  const atcbCssTemplate = {};
235
235
  const atcbIsBrowser = () => {
236
236
  if (typeof window === 'undefined') {
@@ -1617,7 +1617,7 @@ function atcb_generate_label(host, data, parent, type, icon = false, text = '',
1617
1617
  if (!data.blockInteraction) {
1618
1618
  parent.addEventListener(
1619
1619
  'click',
1620
- atcb_debounce_leading(() => {
1620
+ atcb_debounce_leading(async () => {
1621
1621
  if (oneOption) {
1622
1622
  host.querySelector('#' + parent.id)?.blur();
1623
1623
  atcb_log_event('openSingletonLink', parent.id, data.identifier);
@@ -1625,10 +1625,10 @@ function atcb_generate_label(host, data, parent, type, icon = false, text = '',
1625
1625
  atcb_toggle(host, 'close');
1626
1626
  atcb_log_event('openCalendarLink', parent.id, data.identifier);
1627
1627
  }
1628
- atcb_generate_links(host, type, data);
1628
+ await atcb_generate_links(host, type, data);
1629
1629
  }),
1630
1630
  );
1631
- parent.addEventListener('keyup', function (event) {
1631
+ parent.addEventListener('keyup', async function (event) {
1632
1632
  if (event.key === 'Enter') {
1633
1633
  event.preventDefault();
1634
1634
  if (oneOption) {
@@ -1638,7 +1638,7 @@ function atcb_generate_label(host, data, parent, type, icon = false, text = '',
1638
1638
  atcb_toggle(host, 'close');
1639
1639
  atcb_log_event('openCalendarLink', parent.id, data.identifier);
1640
1640
  }
1641
- atcb_generate_links(host, type, data, 'all', true);
1641
+ await atcb_generate_links(host, type, data, 'all', true);
1642
1642
  }
1643
1643
  });
1644
1644
  }
@@ -1986,10 +1986,10 @@ async function atcb_create_modal(mainHost, data, icon = '', headline, content =
1986
1986
  }
1987
1987
  modalSubEventButton.addEventListener(
1988
1988
  'click',
1989
- atcb_debounce(() => {
1989
+ atcb_debounce(async () => {
1990
1990
  atcb_log_event('openSubEventLink', modalSubEventButton.id, data.identifier);
1991
1991
  modalSubEventButton.blur();
1992
- atcb_generate_links(mainHost, subEvents[0], data, subEvents[`${i}`], keyboardTrigger, true);
1992
+ await atcb_generate_links(mainHost, subEvents[0], data, subEvents[`${i}`], keyboardTrigger, true);
1993
1993
  }),
1994
1994
  );
1995
1995
  } else {
@@ -2052,30 +2052,30 @@ async function atcb_create_modal(mainHost, data, icon = '', headline, content =
2052
2052
  case 'yahoo2nd': // for yahoo subscribe modal, where we guide the user through the process
2053
2053
  modalButton.addEventListener(
2054
2054
  'click',
2055
- atcb_debounce(() => {
2055
+ atcb_debounce(async () => {
2056
2056
  atcb_close(mainHost);
2057
- atcb_subscribe_yahoo_modal_switch(mainHost, data);
2057
+ await atcb_subscribe_yahoo_modal_switch(mainHost, data);
2058
2058
  }),
2059
2059
  );
2060
- modalButton.addEventListener('keyup', function (event) {
2060
+ modalButton.addEventListener('keyup', async function (event) {
2061
2061
  if (event.key === 'Enter' || event.code == 'Space' || (event.key === 'Alt' && event.key === 'Control' && event.code === 'Space')) {
2062
2062
  atcb_toggle(mainHost, 'close', '', '', true);
2063
- atcb_subscribe_yahoo_modal_switch(mainHost, data, keyboardTrigger);
2063
+ await atcb_subscribe_yahoo_modal_switch(mainHost, data, keyboardTrigger);
2064
2064
  }
2065
2065
  });
2066
2066
  break;
2067
2067
  case '2timeslink': // for the note that the user shall click the button twice
2068
2068
  modalButton.addEventListener(
2069
2069
  'click',
2070
- atcb_debounce(() => {
2070
+ atcb_debounce(async () => {
2071
2071
  atcb_close(mainHost);
2072
- atcb_generate_links(mainHost, goto.type, data, goto.id, keyboardTrigger, false, true);
2072
+ await atcb_generate_links(mainHost, goto.type, data, goto.id, keyboardTrigger, false, true);
2073
2073
  }),
2074
2074
  );
2075
- modalButton.addEventListener('keyup', function (event) {
2075
+ modalButton.addEventListener('keyup', async function (event) {
2076
2076
  if (event.key === 'Enter' || event.code == 'Space' || (event.key === 'Alt' && event.key === 'Control' && event.code === 'Space')) {
2077
2077
  atcb_toggle(mainHost, 'close', '', '', true);
2078
- atcb_generate_links(mainHost, goto.type, data, goto.id, keyboardTrigger, false, true);
2078
+ await atcb_generate_links(mainHost, goto.type, data, goto.id, keyboardTrigger, false, true);
2079
2079
  }
2080
2080
  });
2081
2081
  break;
@@ -2090,9 +2090,9 @@ async function atcb_create_modal(mainHost, data, icon = '', headline, content =
2090
2090
  atcb_manage_body_scroll(modalHost, modalWrapper);
2091
2091
  return;
2092
2092
  }
2093
- function atcb_subscribe_yahoo_modal_switch(host, data, keyboardTrigger) {
2093
+ async function atcb_subscribe_yahoo_modal_switch(host, data, keyboardTrigger) {
2094
2094
  atcb_set_fully_successful(host, data);
2095
- atcb_generate_links(host, 'yahoo2nd', data, 'all', keyboardTrigger);
2095
+ await atcb_generate_links(host, 'yahoo2nd', data, 'all', keyboardTrigger);
2096
2096
  }
2097
2097
  function atcb_generate_date_button(data, parent, subEvent = 'all', oneOption = false, forceFullDate = false) {
2098
2098
  if (subEvent !== 'all') {
@@ -2433,7 +2433,7 @@ function atcb_generate_rich_data_recurrence(data, formattedDate) {
2433
2433
  }
2434
2434
 
2435
2435
 
2436
- function atcb_generate_links(host, type, data, subEvent = 'all', keyboardTrigger = false, multiDateModal = false, skipDoubleLink = false) {
2436
+ async function atcb_generate_links(host, type, data, subEvent = 'all', keyboardTrigger = false, multiDateModal = false, skipDoubleLink = false) {
2437
2437
  let linkType = type;
2438
2438
  if (type === 'apple') {
2439
2439
  linkType = 'ical';
@@ -2444,7 +2444,7 @@ function atcb_generate_links(host, type, data, subEvent = 'all', keyboardTrigger
2444
2444
  subEvent = 0;
2445
2445
  }
2446
2446
  if (data.subscribe) {
2447
- atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigger);
2447
+ await atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigger);
2448
2448
  return;
2449
2449
  }
2450
2450
  if (subEvent !== 'all') {
@@ -2509,8 +2509,9 @@ function atcb_generate_multidate_links(host, type, linkType, data, keyboardTrigg
2509
2509
  atcb_create_modal(host, data, type, atcb_translate_hook('modal.multidate.h', data), atcb_translate_hook('modal.multidate.text', data), [], individualButtons, keyboardTrigger);
2510
2510
  }
2511
2511
  }
2512
- function atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigger) {
2512
+ async function atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigger) {
2513
2513
  const adjustedFileUrl = data.icsFile.replace('https://', 'webcal://');
2514
+ let copied = false;
2514
2515
  switch (linkType) {
2515
2516
  case 'ical': // also for apple (see above)
2516
2517
  if (atcbIsAndroid() || data.fakeAndroid) {
@@ -2533,7 +2534,13 @@ function atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigg
2533
2534
  atcb_open_cal_url(data, 'yahoo', '', true);
2534
2535
  return;
2535
2536
  }
2536
- atcb_copy_to_clipboard(data.icsFile);
2537
+ try {
2538
+ await atcb_copy_to_clipboard(data.icsFile);
2539
+ copied = true;
2540
+ } catch (e) {
2541
+ console.warn(e);
2542
+ copied = false;
2543
+ }
2537
2544
  atcb_create_modal(
2538
2545
  host,
2539
2546
  data,
@@ -2554,7 +2561,13 @@ function atcb_generate_subscribe_links(host, type, linkType, data, keyboardTrigg
2554
2561
  );
2555
2562
  return;
2556
2563
  case 'yahoo2nd':
2557
- atcb_copy_to_clipboard(data.icsFile);
2564
+ try {
2565
+ await atcb_copy_to_clipboard(data.icsFile);
2566
+ copied = true;
2567
+ } catch (e) {
2568
+ console.warn(e);
2569
+ copied = false;
2570
+ }
2558
2571
  atcb_create_modal(
2559
2572
  host,
2560
2573
  data,
@@ -2960,8 +2973,15 @@ function atcb_determine_ical_filename(data, subEvent) {
2960
2973
  }
2961
2974
  return 'event' + filenameSuffix;
2962
2975
  }
2963
- function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
2964
- atcb_copy_to_clipboard(dataUrl);
2976
+ async function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
2977
+ let copied = false;
2978
+ try {
2979
+ await atcb_copy_to_clipboard(dataUrl);
2980
+ copied = true;
2981
+ } catch (e) {
2982
+ console.warn(e);
2983
+ copied = false;
2984
+ }
2965
2985
  if (atcbIsiOS() && !atcbIsSafari()) {
2966
2986
  atcb_create_modal(
2967
2987
  host,
@@ -3852,28 +3872,73 @@ function atcb_map_special_time_zones(timeZone) {
3852
3872
  };
3853
3873
  return mapping[`${timeZone.toUpperCase()}`] || 'GMT';
3854
3874
  }
3855
- function atcb_copy_to_clipboard(dataString) {
3856
- const tmpInput = document.createElement('input');
3857
- document.body.append(tmpInput);
3858
- const editable = tmpInput.contentEditable;
3859
- const readOnly = tmpInput.readOnly;
3860
- tmpInput.contentEditable = true;
3861
- tmpInput.readOnly = false;
3862
- tmpInput.value = dataString;
3863
- if (atcbIsiOS()) {
3864
- var range = document.createRange();
3865
- range.selectNodeContents(tmpInput);
3866
- var selection = window.getSelection();
3867
- selection.removeAllRanges();
3868
- selection.addRange(range);
3869
- tmpInput.setSelectionRange(0, 999999);
3870
- } else {
3871
- tmpInput.select();
3875
+ async function atcb_copy_to_clipboard(dataString) {
3876
+ const v = (dataString ?? '').toString().trim();
3877
+ if (!v) throw new Error('No value to copy!');
3878
+ const legacyCopy = () => {
3879
+ if (typeof window === 'undefined' || typeof document === 'undefined') return false;
3880
+ if (!document.queryCommandSupported || !document.queryCommandSupported('copy')) return false;
3881
+ const ta = document.createElement('textarea');
3882
+ const prevFocus = document.activeElement;
3883
+ ta.value = v;
3884
+ ta.setAttribute('readonly', '');
3885
+ ta.style.contain = 'strict';
3886
+ ta.style.position = 'fixed';
3887
+ ta.style.top = '-9999px';
3888
+ ta.style.left = '-9999px';
3889
+ ta.style.opacity = '0';
3890
+ ta.style.outline = 'none';
3891
+ ta.style.pointerEvents = 'none';
3892
+ ta.style.fontSize = '12pt';
3893
+ document.body.appendChild(ta);
3894
+ try {
3895
+ ta.focus();
3896
+ ta.select();
3897
+ if (atcbIsiOS()) {
3898
+ ta.selectionStart = 0;
3899
+ ta.selectionEnd = v.length;
3900
+ }
3901
+ const ok = document.execCommand('copy');
3902
+ document.body.removeChild(ta);
3903
+ if (prevFocus && typeof prevFocus.focus === 'function') prevFocus.focus();
3904
+ return ok;
3905
+ } catch {
3906
+ document.body.removeChild(ta);
3907
+ if (prevFocus && typeof prevFocus.focus === 'function') prevFocus.focus();
3908
+ return false;
3909
+ }
3910
+ };
3911
+ const secure = (() => {
3912
+ try {
3913
+ if (typeof window !== 'undefined' && 'isSecureContext' in window && window.isSecureContext) return true;
3914
+ if (typeof window !== 'undefined' && window.location && window.location.protocol === 'https:') return true;
3915
+ if (typeof window !== 'undefined' && window.location && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) return true;
3916
+ return false;
3917
+ } catch {
3918
+ return false;
3919
+ }
3920
+ })();
3921
+ if (secure && typeof navigator !== 'undefined' && navigator.clipboard) {
3922
+ try {
3923
+ if (typeof navigator.clipboard.writeText === 'function') {
3924
+ await navigator.clipboard.writeText(v);
3925
+ return 'Copied!';
3926
+ }
3927
+ } catch {
3928
+ }
3929
+ try {
3930
+ if (typeof window !== 'undefined' && typeof window.ClipboardItem !== 'undefined' && typeof navigator.clipboard.write === 'function') {
3931
+ const type = 'text/plain';
3932
+ const blob = new Blob([v], { type });
3933
+ const data = [new ClipboardItem({ [type]: blob })];
3934
+ await navigator.clipboard.write(data);
3935
+ return 'Copied!';
3936
+ }
3937
+ } catch {
3938
+ }
3872
3939
  }
3873
- tmpInput.contentEditable = editable;
3874
- tmpInput.readOnly = readOnly;
3875
- document.execCommand('copy');
3876
- tmpInput.remove();
3940
+ if (legacyCopy()) return 'Copied!';
3941
+ throw new Error('Clipboard copy not supported in this environment');
3877
3942
  }
3878
3943
  function atcb_debounce(func, timeout = 200) {
3879
3944
  let timer;
@@ -5468,7 +5533,7 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
5468
5533
  atcb_generate_rsvp_form(host.shadowRoot, data, triggerElement, keyboardTrigger);
5469
5534
  } else {
5470
5535
  if (oneOption) {
5471
- atcb_generate_links(host.shadowRoot, data.options[0], data, 'all', keyboardTrigger);
5536
+ await atcb_generate_links(host.shadowRoot, data.options[0], data, 'all', keyboardTrigger);
5472
5537
  atcb_log_event('openSingletonLink', data.identifier, data.identifier);
5473
5538
  } else {
5474
5539
  atcb_toggle(host.shadowRoot, 'open', data, triggerElement, keyboardTrigger);