add-to-calendar-button 2.6.8 → 2.6.9
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/assets/css/atcb-3d.css +1 -1
- package/assets/css/atcb-date.css +1 -1
- package/assets/css/atcb-flat.css +1 -1
- package/assets/css/atcb-neumorphism.css +1 -1
- package/assets/css/atcb-round.css +1 -1
- package/assets/css/atcb-text.css +1 -1
- package/assets/css/atcb.css +1 -1
- package/dist/atcb-no-pro-unstyle.js +17 -6
- package/dist/atcb-no-pro.js +17 -6
- package/dist/atcb-unstyle.js +29 -6
- package/dist/atcb.js +29 -6
- package/dist/commonjs/index.js +29 -6
- package/dist/commonjs/no-pro/index.js +17 -6
- package/dist/commonjs/no-pro-unstyle/index.js +17 -6
- package/dist/commonjs/unstyle/index.js +29 -6
- package/dist/module/index.js +29 -6
- package/dist/module/no-pro/index.js +17 -6
- package/dist/module/no-pro-unstyle/index.js +17 -6
- package/dist/module/unstyle/index.js +29 -6
- package/package.json +3 -3
package/assets/css/atcb-3d.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Style: 3D
|
|
7
7
|
*
|
|
8
|
-
* Version: 2.6.
|
|
8
|
+
* Version: 2.6.9
|
|
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)
|
package/assets/css/atcb-date.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Style: Date
|
|
7
7
|
*
|
|
8
|
-
* Version: 2.6.
|
|
8
|
+
* Version: 2.6.9
|
|
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)
|
package/assets/css/atcb-flat.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Style: Flat
|
|
7
7
|
*
|
|
8
|
-
* Version: 2.6.
|
|
8
|
+
* Version: 2.6.9
|
|
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.
|
|
8
|
+
* Version: 2.6.9
|
|
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.
|
|
8
|
+
* Version: 2.6.9
|
|
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)
|
package/assets/css/atcb-text.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Style: Text
|
|
7
7
|
*
|
|
8
|
-
* Version: 2.6.
|
|
8
|
+
* Version: 2.6.9
|
|
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)
|
package/assets/css/atcb.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Style: Default
|
|
7
7
|
*
|
|
8
|
-
* Version: 2.6.
|
|
8
|
+
* Version: 2.6.9
|
|
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.
|
|
977
|
+
* Version: 2.6.9
|
|
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.
|
|
984
|
+
const atcbVersion = '2.6.9';
|
|
985
985
|
const atcbCssTemplate = {};
|
|
986
986
|
const atcbIsBrowser = () => {
|
|
987
987
|
if (typeof window === 'undefined') {
|
|
@@ -1707,6 +1707,9 @@ async function atcb_check_required(data) {
|
|
|
1707
1707
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
1708
1708
|
}
|
|
1709
1709
|
if (data.dates != null && data.dates.length > 0) {
|
|
1710
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
1711
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
1712
|
+
}
|
|
1710
1713
|
const requiredMultiField = ['name', 'startDate'];
|
|
1711
1714
|
const requiredMultiFieldFlex = ['name'];
|
|
1712
1715
|
return requiredMultiField.every(function (field) {
|
|
@@ -1715,7 +1718,11 @@ async function atcb_check_required(data) {
|
|
|
1715
1718
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
1716
1719
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
1717
1720
|
) {
|
|
1718
|
-
|
|
1721
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1722
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
1723
|
+
} else {
|
|
1724
|
+
data.dates[`${i}`].startDate = 'today';
|
|
1725
|
+
}
|
|
1719
1726
|
}
|
|
1720
1727
|
}
|
|
1721
1728
|
return true;
|
|
@@ -1724,7 +1731,11 @@ async function atcb_check_required(data) {
|
|
|
1724
1731
|
const requiredSingleField = ['startDate'];
|
|
1725
1732
|
return requiredSingleField.every(function (field) {
|
|
1726
1733
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
1727
|
-
|
|
1734
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1735
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
1736
|
+
} else {
|
|
1737
|
+
data.startDate = 'today';
|
|
1738
|
+
}
|
|
1728
1739
|
}
|
|
1729
1740
|
return true;
|
|
1730
1741
|
});
|
|
@@ -2273,6 +2284,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2273
2284
|
text = atcb_translate_hook(type, data);
|
|
2274
2285
|
}
|
|
2275
2286
|
}
|
|
2287
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2276
2288
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2277
2289
|
return;
|
|
2278
2290
|
}
|
|
@@ -2291,7 +2303,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2291
2303
|
textEl.textContent = text;
|
|
2292
2304
|
parent.append(textEl);
|
|
2293
2305
|
}
|
|
2294
|
-
parent.setAttribute('aria-label', text);
|
|
2295
2306
|
}
|
|
2296
2307
|
function atcb_generate_button(host, button, data) {
|
|
2297
2308
|
const oneOption = (function () {
|
|
@@ -5228,7 +5239,7 @@ async function atcb_build_button(host, data) {
|
|
|
5228
5239
|
} else {
|
|
5229
5240
|
atcb_generate_button(host, rootObj, data);
|
|
5230
5241
|
}
|
|
5231
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5242
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5232
5243
|
atcb_generate_rich_data(data, host.host);
|
|
5233
5244
|
}
|
|
5234
5245
|
}
|
package/dist/atcb-no-pro.js
CHANGED
|
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
|
|
|
974
974
|
* Add to Calendar Button
|
|
975
975
|
* ++++++++++++++++++++++
|
|
976
976
|
*
|
|
977
|
-
* Version: 2.6.
|
|
977
|
+
* Version: 2.6.9
|
|
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.
|
|
984
|
+
const atcbVersion = '2.6.9';
|
|
985
985
|
const atcbCssTemplate = {
|
|
986
986
|
if (typeof window === 'undefined') {
|
|
987
987
|
return false;
|
|
@@ -1706,6 +1706,9 @@ async function atcb_check_required(data) {
|
|
|
1706
1706
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
1707
1707
|
}
|
|
1708
1708
|
if (data.dates != null && data.dates.length > 0) {
|
|
1709
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
1710
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
1711
|
+
}
|
|
1709
1712
|
const requiredMultiField = ['name', 'startDate'];
|
|
1710
1713
|
const requiredMultiFieldFlex = ['name'];
|
|
1711
1714
|
return requiredMultiField.every(function (field) {
|
|
@@ -1714,7 +1717,11 @@ async function atcb_check_required(data) {
|
|
|
1714
1717
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
1715
1718
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
1716
1719
|
) {
|
|
1717
|
-
|
|
1720
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1721
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
1722
|
+
} else {
|
|
1723
|
+
data.dates[`${i}`].startDate = 'today';
|
|
1724
|
+
}
|
|
1718
1725
|
}
|
|
1719
1726
|
}
|
|
1720
1727
|
return true;
|
|
@@ -1723,7 +1730,11 @@ async function atcb_check_required(data) {
|
|
|
1723
1730
|
const requiredSingleField = ['startDate'];
|
|
1724
1731
|
return requiredSingleField.every(function (field) {
|
|
1725
1732
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
1726
|
-
|
|
1733
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1734
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
1735
|
+
} else {
|
|
1736
|
+
data.startDate = 'today';
|
|
1737
|
+
}
|
|
1727
1738
|
}
|
|
1728
1739
|
return true;
|
|
1729
1740
|
});
|
|
@@ -2272,6 +2283,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2272
2283
|
text = atcb_translate_hook(type, data);
|
|
2273
2284
|
}
|
|
2274
2285
|
}
|
|
2286
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2275
2287
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2276
2288
|
return;
|
|
2277
2289
|
}
|
|
@@ -2290,7 +2302,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2290
2302
|
textEl.textContent = text;
|
|
2291
2303
|
parent.append(textEl);
|
|
2292
2304
|
}
|
|
2293
|
-
parent.setAttribute('aria-label', text);
|
|
2294
2305
|
}
|
|
2295
2306
|
function atcb_generate_button(host, button, data) {
|
|
2296
2307
|
const oneOption = (function () {
|
|
@@ -5227,7 +5238,7 @@ async function atcb_build_button(host, data) {
|
|
|
5227
5238
|
} else {
|
|
5228
5239
|
atcb_generate_button(host, rootObj, data);
|
|
5229
5240
|
}
|
|
5230
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5241
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5231
5242
|
atcb_generate_rich_data(data, host.host);
|
|
5232
5243
|
}
|
|
5233
5244
|
}
|
package/dist/atcb-unstyle.js
CHANGED
|
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
|
|
|
974
974
|
* Add to Calendar Button
|
|
975
975
|
* ++++++++++++++++++++++
|
|
976
976
|
*
|
|
977
|
-
* Version: 2.6.
|
|
977
|
+
* Version: 2.6.9
|
|
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.
|
|
984
|
+
const atcbVersion = '2.6.9';
|
|
985
985
|
const atcbCssTemplate = {};
|
|
986
986
|
const atcbIsBrowser = () => {
|
|
987
987
|
if (typeof window === 'undefined') {
|
|
@@ -1707,6 +1707,9 @@ async function atcb_check_required(data) {
|
|
|
1707
1707
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
1708
1708
|
}
|
|
1709
1709
|
if (data.dates != null && data.dates.length > 0) {
|
|
1710
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
1711
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
1712
|
+
}
|
|
1710
1713
|
const requiredMultiField = ['name', 'startDate'];
|
|
1711
1714
|
const requiredMultiFieldFlex = ['name'];
|
|
1712
1715
|
return requiredMultiField.every(function (field) {
|
|
@@ -1715,7 +1718,11 @@ async function atcb_check_required(data) {
|
|
|
1715
1718
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
1716
1719
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
1717
1720
|
) {
|
|
1718
|
-
|
|
1721
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1722
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
1723
|
+
} else {
|
|
1724
|
+
data.dates[`${i}`].startDate = 'today';
|
|
1725
|
+
}
|
|
1719
1726
|
}
|
|
1720
1727
|
}
|
|
1721
1728
|
return true;
|
|
@@ -1724,7 +1731,11 @@ async function atcb_check_required(data) {
|
|
|
1724
1731
|
const requiredSingleField = ['startDate'];
|
|
1725
1732
|
return requiredSingleField.every(function (field) {
|
|
1726
1733
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
1727
|
-
|
|
1734
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1735
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
1736
|
+
} else {
|
|
1737
|
+
data.startDate = 'today';
|
|
1738
|
+
}
|
|
1728
1739
|
}
|
|
1729
1740
|
return true;
|
|
1730
1741
|
});
|
|
@@ -2196,6 +2207,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
2196
2207
|
})();
|
|
2197
2208
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
2198
2209
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
2210
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
2211
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
2212
|
+
try {
|
|
2213
|
+
header = JSON.parse(headerField.default);
|
|
2214
|
+
if (Object.keys(header).length === 0) {
|
|
2215
|
+
header.atcb = true;
|
|
2216
|
+
}
|
|
2217
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
2218
|
+
} catch (e) {
|
|
2219
|
+
/* do nothing */
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2199
2222
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
2200
2223
|
tyData.fields = customForm.fields;
|
|
2201
2224
|
tyContent += customForm.html;
|
|
@@ -2967,6 +2990,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2967
2990
|
text = atcb_translate_hook(type, data);
|
|
2968
2991
|
}
|
|
2969
2992
|
}
|
|
2993
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2970
2994
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2971
2995
|
return;
|
|
2972
2996
|
}
|
|
@@ -2985,7 +3009,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2985
3009
|
textEl.textContent = text;
|
|
2986
3010
|
parent.append(textEl);
|
|
2987
3011
|
}
|
|
2988
|
-
parent.setAttribute('aria-label', text);
|
|
2989
3012
|
}
|
|
2990
3013
|
function atcb_generate_button(host, button, data) {
|
|
2991
3014
|
const oneOption = (function () {
|
|
@@ -5922,7 +5945,7 @@ async function atcb_build_button(host, data) {
|
|
|
5922
5945
|
} else {
|
|
5923
5946
|
atcb_generate_button(host, rootObj, data);
|
|
5924
5947
|
}
|
|
5925
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5948
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5926
5949
|
atcb_generate_rich_data(data, host.host);
|
|
5927
5950
|
}
|
|
5928
5951
|
}
|
package/dist/atcb.js
CHANGED
|
@@ -974,14 +974,14 @@ function tzlib_get_timezones(jsonType = false) {
|
|
|
974
974
|
* Add to Calendar Button
|
|
975
975
|
* ++++++++++++++++++++++
|
|
976
976
|
*
|
|
977
|
-
* Version: 2.6.
|
|
977
|
+
* Version: 2.6.9
|
|
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.
|
|
984
|
+
const atcbVersion = '2.6.9';
|
|
985
985
|
const atcbCssTemplate = {
|
|
986
986
|
if (typeof window === 'undefined') {
|
|
987
987
|
return false;
|
|
@@ -1706,6 +1706,9 @@ async function atcb_check_required(data) {
|
|
|
1706
1706
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
1707
1707
|
}
|
|
1708
1708
|
if (data.dates != null && data.dates.length > 0) {
|
|
1709
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
1710
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
1711
|
+
}
|
|
1709
1712
|
const requiredMultiField = ['name', 'startDate'];
|
|
1710
1713
|
const requiredMultiFieldFlex = ['name'];
|
|
1711
1714
|
return requiredMultiField.every(function (field) {
|
|
@@ -1714,7 +1717,11 @@ async function atcb_check_required(data) {
|
|
|
1714
1717
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
1715
1718
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
1716
1719
|
) {
|
|
1717
|
-
|
|
1720
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1721
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
1722
|
+
} else {
|
|
1723
|
+
data.dates[`${i}`].startDate = 'today';
|
|
1724
|
+
}
|
|
1718
1725
|
}
|
|
1719
1726
|
}
|
|
1720
1727
|
return true;
|
|
@@ -1723,7 +1730,11 @@ async function atcb_check_required(data) {
|
|
|
1723
1730
|
const requiredSingleField = ['startDate'];
|
|
1724
1731
|
return requiredSingleField.every(function (field) {
|
|
1725
1732
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
1726
|
-
|
|
1733
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
1734
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
1735
|
+
} else {
|
|
1736
|
+
data.startDate = 'today';
|
|
1737
|
+
}
|
|
1727
1738
|
}
|
|
1728
1739
|
return true;
|
|
1729
1740
|
});
|
|
@@ -2195,6 +2206,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
2195
2206
|
})();
|
|
2196
2207
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
2197
2208
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
2209
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
2210
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
2211
|
+
try {
|
|
2212
|
+
header = JSON.parse(headerField.default);
|
|
2213
|
+
if (Object.keys(header).length === 0) {
|
|
2214
|
+
header.atcb = true;
|
|
2215
|
+
}
|
|
2216
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
2217
|
+
} catch (e) {
|
|
2218
|
+
/* do nothing */
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2198
2221
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
2199
2222
|
tyData.fields = customForm.fields;
|
|
2200
2223
|
tyContent += customForm.html;
|
|
@@ -2966,6 +2989,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2966
2989
|
text = atcb_translate_hook(type, data);
|
|
2967
2990
|
}
|
|
2968
2991
|
}
|
|
2992
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2969
2993
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2970
2994
|
return;
|
|
2971
2995
|
}
|
|
@@ -2984,7 +3008,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2984
3008
|
textEl.textContent = text;
|
|
2985
3009
|
parent.append(textEl);
|
|
2986
3010
|
}
|
|
2987
|
-
parent.setAttribute('aria-label', text);
|
|
2988
3011
|
}
|
|
2989
3012
|
function atcb_generate_button(host, button, data) {
|
|
2990
3013
|
const oneOption = (function () {
|
|
@@ -5921,7 +5944,7 @@ async function atcb_build_button(host, data) {
|
|
|
5921
5944
|
} else {
|
|
5922
5945
|
atcb_generate_button(host, rootObj, data);
|
|
5923
5946
|
}
|
|
5924
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5947
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
5925
5948
|
atcb_generate_rich_data(data, host.host);
|
|
5926
5949
|
}
|
|
5927
5950
|
}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -7,14 +7,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
7
|
* Add to Calendar Button
|
|
8
8
|
* ++++++++++++++++++++++
|
|
9
9
|
*
|
|
10
|
-
* Version: 2.6.
|
|
10
|
+
* Version: 2.6.9
|
|
11
11
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
12
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
13
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
14
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
17
|
+
const atcbVersion = '2.6.9';
|
|
18
18
|
const atcbCssTemplate = {
|
|
19
19
|
if (typeof window === 'undefined') {
|
|
20
20
|
return false;
|
|
@@ -739,6 +739,9 @@ async function atcb_check_required(data) {
|
|
|
739
739
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
740
740
|
}
|
|
741
741
|
if (data.dates != null && data.dates.length > 0) {
|
|
742
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
743
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
744
|
+
}
|
|
742
745
|
const requiredMultiField = ['name', 'startDate'];
|
|
743
746
|
const requiredMultiFieldFlex = ['name'];
|
|
744
747
|
return requiredMultiField.every(function (field) {
|
|
@@ -747,7 +750,11 @@ async function atcb_check_required(data) {
|
|
|
747
750
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
748
751
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
749
752
|
) {
|
|
750
|
-
|
|
753
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
754
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
755
|
+
} else {
|
|
756
|
+
data.dates[`${i}`].startDate = 'today';
|
|
757
|
+
}
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
return true;
|
|
@@ -756,7 +763,11 @@ async function atcb_check_required(data) {
|
|
|
756
763
|
const requiredSingleField = ['startDate'];
|
|
757
764
|
return requiredSingleField.every(function (field) {
|
|
758
765
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
759
|
-
|
|
766
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
767
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
768
|
+
} else {
|
|
769
|
+
data.startDate = 'today';
|
|
770
|
+
}
|
|
760
771
|
}
|
|
761
772
|
return true;
|
|
762
773
|
});
|
|
@@ -1228,6 +1239,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
1228
1239
|
})();
|
|
1229
1240
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
1230
1241
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
1242
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
1243
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
1244
|
+
try {
|
|
1245
|
+
header = JSON.parse(headerField.default);
|
|
1246
|
+
if (Object.keys(header).length === 0) {
|
|
1247
|
+
header.atcb = true;
|
|
1248
|
+
}
|
|
1249
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
/* do nothing */
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1231
1254
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
1232
1255
|
tyData.fields = customForm.fields;
|
|
1233
1256
|
tyContent += customForm.html;
|
|
@@ -1999,6 +2022,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1999
2022
|
text = atcb_translate_hook(type, data);
|
|
2000
2023
|
}
|
|
2001
2024
|
}
|
|
2025
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2002
2026
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2003
2027
|
return;
|
|
2004
2028
|
}
|
|
@@ -2017,7 +2041,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2017
2041
|
textEl.textContent = text;
|
|
2018
2042
|
parent.append(textEl);
|
|
2019
2043
|
}
|
|
2020
|
-
parent.setAttribute('aria-label', text);
|
|
2021
2044
|
}
|
|
2022
2045
|
function atcb_generate_button(host, button, data) {
|
|
2023
2046
|
const oneOption = (function () {
|
|
@@ -4954,7 +4977,7 @@ async function atcb_build_button(host, data) {
|
|
|
4954
4977
|
} else {
|
|
4955
4978
|
atcb_generate_button(host, rootObj, data);
|
|
4956
4979
|
}
|
|
4957
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4980
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4958
4981
|
atcb_generate_rich_data(data, host.host);
|
|
4959
4982
|
}
|
|
4960
4983
|
}
|
|
@@ -7,14 +7,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
7
|
* Add to Calendar Button
|
|
8
8
|
* ++++++++++++++++++++++
|
|
9
9
|
*
|
|
10
|
-
* Version: 2.6.
|
|
10
|
+
* Version: 2.6.9
|
|
11
11
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
12
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
13
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
14
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
17
|
+
const atcbVersion = '2.6.9';
|
|
18
18
|
const atcbCssTemplate = {
|
|
19
19
|
if (typeof window === 'undefined') {
|
|
20
20
|
return false;
|
|
@@ -739,6 +739,9 @@ async function atcb_check_required(data) {
|
|
|
739
739
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
740
740
|
}
|
|
741
741
|
if (data.dates != null && data.dates.length > 0) {
|
|
742
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
743
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
744
|
+
}
|
|
742
745
|
const requiredMultiField = ['name', 'startDate'];
|
|
743
746
|
const requiredMultiFieldFlex = ['name'];
|
|
744
747
|
return requiredMultiField.every(function (field) {
|
|
@@ -747,7 +750,11 @@ async function atcb_check_required(data) {
|
|
|
747
750
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
748
751
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
749
752
|
) {
|
|
750
|
-
|
|
753
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
754
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
755
|
+
} else {
|
|
756
|
+
data.dates[`${i}`].startDate = 'today';
|
|
757
|
+
}
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
return true;
|
|
@@ -756,7 +763,11 @@ async function atcb_check_required(data) {
|
|
|
756
763
|
const requiredSingleField = ['startDate'];
|
|
757
764
|
return requiredSingleField.every(function (field) {
|
|
758
765
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
759
|
-
|
|
766
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
767
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
768
|
+
} else {
|
|
769
|
+
data.startDate = 'today';
|
|
770
|
+
}
|
|
760
771
|
}
|
|
761
772
|
return true;
|
|
762
773
|
});
|
|
@@ -1305,6 +1316,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1305
1316
|
text = atcb_translate_hook(type, data);
|
|
1306
1317
|
}
|
|
1307
1318
|
}
|
|
1319
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
1308
1320
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
1309
1321
|
return;
|
|
1310
1322
|
}
|
|
@@ -1323,7 +1335,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1323
1335
|
textEl.textContent = text;
|
|
1324
1336
|
parent.append(textEl);
|
|
1325
1337
|
}
|
|
1326
|
-
parent.setAttribute('aria-label', text);
|
|
1327
1338
|
}
|
|
1328
1339
|
function atcb_generate_button(host, button, data) {
|
|
1329
1340
|
const oneOption = (function () {
|
|
@@ -4260,7 +4271,7 @@ async function atcb_build_button(host, data) {
|
|
|
4260
4271
|
} else {
|
|
4261
4272
|
atcb_generate_button(host, rootObj, data);
|
|
4262
4273
|
}
|
|
4263
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4274
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4264
4275
|
atcb_generate_rich_data(data, host.host);
|
|
4265
4276
|
}
|
|
4266
4277
|
}
|
|
@@ -7,14 +7,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
7
|
* Add to Calendar Button
|
|
8
8
|
* ++++++++++++++++++++++
|
|
9
9
|
*
|
|
10
|
-
* Version: 2.6.
|
|
10
|
+
* Version: 2.6.9
|
|
11
11
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
12
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
13
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
14
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
17
|
+
const atcbVersion = '2.6.9';
|
|
18
18
|
const atcbCssTemplate = {};
|
|
19
19
|
const atcbIsBrowser = () => {
|
|
20
20
|
if (typeof window === 'undefined') {
|
|
@@ -740,6 +740,9 @@ async function atcb_check_required(data) {
|
|
|
740
740
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
741
741
|
}
|
|
742
742
|
if (data.dates != null && data.dates.length > 0) {
|
|
743
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
744
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
745
|
+
}
|
|
743
746
|
const requiredMultiField = ['name', 'startDate'];
|
|
744
747
|
const requiredMultiFieldFlex = ['name'];
|
|
745
748
|
return requiredMultiField.every(function (field) {
|
|
@@ -748,7 +751,11 @@ async function atcb_check_required(data) {
|
|
|
748
751
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
749
752
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
750
753
|
) {
|
|
751
|
-
|
|
754
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
755
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
756
|
+
} else {
|
|
757
|
+
data.dates[`${i}`].startDate = 'today';
|
|
758
|
+
}
|
|
752
759
|
}
|
|
753
760
|
}
|
|
754
761
|
return true;
|
|
@@ -757,7 +764,11 @@ async function atcb_check_required(data) {
|
|
|
757
764
|
const requiredSingleField = ['startDate'];
|
|
758
765
|
return requiredSingleField.every(function (field) {
|
|
759
766
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
760
|
-
|
|
767
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
768
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
769
|
+
} else {
|
|
770
|
+
data.startDate = 'today';
|
|
771
|
+
}
|
|
761
772
|
}
|
|
762
773
|
return true;
|
|
763
774
|
});
|
|
@@ -1306,6 +1317,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1306
1317
|
text = atcb_translate_hook(type, data);
|
|
1307
1318
|
}
|
|
1308
1319
|
}
|
|
1320
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
1309
1321
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
1310
1322
|
return;
|
|
1311
1323
|
}
|
|
@@ -1324,7 +1336,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1324
1336
|
textEl.textContent = text;
|
|
1325
1337
|
parent.append(textEl);
|
|
1326
1338
|
}
|
|
1327
|
-
parent.setAttribute('aria-label', text);
|
|
1328
1339
|
}
|
|
1329
1340
|
function atcb_generate_button(host, button, data) {
|
|
1330
1341
|
const oneOption = (function () {
|
|
@@ -4261,7 +4272,7 @@ async function atcb_build_button(host, data) {
|
|
|
4261
4272
|
} else {
|
|
4262
4273
|
atcb_generate_button(host, rootObj, data);
|
|
4263
4274
|
}
|
|
4264
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4275
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4265
4276
|
atcb_generate_rich_data(data, host.host);
|
|
4266
4277
|
}
|
|
4267
4278
|
}
|
|
@@ -7,14 +7,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
7
7
|
* Add to Calendar Button
|
|
8
8
|
* ++++++++++++++++++++++
|
|
9
9
|
*
|
|
10
|
-
* Version: 2.6.
|
|
10
|
+
* Version: 2.6.9
|
|
11
11
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
12
12
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
13
13
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
14
14
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
const atcbVersion = '2.6.
|
|
17
|
+
const atcbVersion = '2.6.9';
|
|
18
18
|
const atcbCssTemplate = {};
|
|
19
19
|
const atcbIsBrowser = () => {
|
|
20
20
|
if (typeof window === 'undefined') {
|
|
@@ -740,6 +740,9 @@ async function atcb_check_required(data) {
|
|
|
740
740
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
741
741
|
}
|
|
742
742
|
if (data.dates != null && data.dates.length > 0) {
|
|
743
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
744
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
745
|
+
}
|
|
743
746
|
const requiredMultiField = ['name', 'startDate'];
|
|
744
747
|
const requiredMultiFieldFlex = ['name'];
|
|
745
748
|
return requiredMultiField.every(function (field) {
|
|
@@ -748,7 +751,11 @@ async function atcb_check_required(data) {
|
|
|
748
751
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
749
752
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
750
753
|
) {
|
|
751
|
-
|
|
754
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
755
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
756
|
+
} else {
|
|
757
|
+
data.dates[`${i}`].startDate = 'today';
|
|
758
|
+
}
|
|
752
759
|
}
|
|
753
760
|
}
|
|
754
761
|
return true;
|
|
@@ -757,7 +764,11 @@ async function atcb_check_required(data) {
|
|
|
757
764
|
const requiredSingleField = ['startDate'];
|
|
758
765
|
return requiredSingleField.every(function (field) {
|
|
759
766
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
760
|
-
|
|
767
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
768
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
769
|
+
} else {
|
|
770
|
+
data.startDate = 'today';
|
|
771
|
+
}
|
|
761
772
|
}
|
|
762
773
|
return true;
|
|
763
774
|
});
|
|
@@ -1229,6 +1240,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
1229
1240
|
})();
|
|
1230
1241
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
1231
1242
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
1243
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
1244
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
1245
|
+
try {
|
|
1246
|
+
header = JSON.parse(headerField.default);
|
|
1247
|
+
if (Object.keys(header).length === 0) {
|
|
1248
|
+
header.atcb = true;
|
|
1249
|
+
}
|
|
1250
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
1251
|
+
} catch (e) {
|
|
1252
|
+
/* do nothing */
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1232
1255
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
1233
1256
|
tyData.fields = customForm.fields;
|
|
1234
1257
|
tyContent += customForm.html;
|
|
@@ -2000,6 +2023,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2000
2023
|
text = atcb_translate_hook(type, data);
|
|
2001
2024
|
}
|
|
2002
2025
|
}
|
|
2026
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2003
2027
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2004
2028
|
return;
|
|
2005
2029
|
}
|
|
@@ -2018,7 +2042,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2018
2042
|
textEl.textContent = text;
|
|
2019
2043
|
parent.append(textEl);
|
|
2020
2044
|
}
|
|
2021
|
-
parent.setAttribute('aria-label', text);
|
|
2022
2045
|
}
|
|
2023
2046
|
function atcb_generate_button(host, button, data) {
|
|
2024
2047
|
const oneOption = (function () {
|
|
@@ -4955,7 +4978,7 @@ async function atcb_build_button(host, data) {
|
|
|
4955
4978
|
} else {
|
|
4956
4979
|
atcb_generate_button(host, rootObj, data);
|
|
4957
4980
|
}
|
|
4958
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4981
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4959
4982
|
atcb_generate_rich_data(data, host.host);
|
|
4960
4983
|
}
|
|
4961
4984
|
}
|
package/dist/module/index.js
CHANGED
|
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.9
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.9';
|
|
17
17
|
const atcbCssTemplate = {
|
|
18
18
|
if (typeof window === 'undefined') {
|
|
19
19
|
return false;
|
|
@@ -738,6 +738,9 @@ async function atcb_check_required(data) {
|
|
|
738
738
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
739
739
|
}
|
|
740
740
|
if (data.dates != null && data.dates.length > 0) {
|
|
741
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
742
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
743
|
+
}
|
|
741
744
|
const requiredMultiField = ['name', 'startDate'];
|
|
742
745
|
const requiredMultiFieldFlex = ['name'];
|
|
743
746
|
return requiredMultiField.every(function (field) {
|
|
@@ -746,7 +749,11 @@ async function atcb_check_required(data) {
|
|
|
746
749
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
747
750
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
748
751
|
) {
|
|
749
|
-
|
|
752
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
753
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
754
|
+
} else {
|
|
755
|
+
data.dates[`${i}`].startDate = 'today';
|
|
756
|
+
}
|
|
750
757
|
}
|
|
751
758
|
}
|
|
752
759
|
return true;
|
|
@@ -755,7 +762,11 @@ async function atcb_check_required(data) {
|
|
|
755
762
|
const requiredSingleField = ['startDate'];
|
|
756
763
|
return requiredSingleField.every(function (field) {
|
|
757
764
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
758
|
-
|
|
765
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
766
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
767
|
+
} else {
|
|
768
|
+
data.startDate = 'today';
|
|
769
|
+
}
|
|
759
770
|
}
|
|
760
771
|
return true;
|
|
761
772
|
});
|
|
@@ -1227,6 +1238,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
1227
1238
|
})();
|
|
1228
1239
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
1229
1240
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
1241
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
1242
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
1243
|
+
try {
|
|
1244
|
+
header = JSON.parse(headerField.default);
|
|
1245
|
+
if (Object.keys(header).length === 0) {
|
|
1246
|
+
header.atcb = true;
|
|
1247
|
+
}
|
|
1248
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
1249
|
+
} catch (e) {
|
|
1250
|
+
/* do nothing */
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1230
1253
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
1231
1254
|
tyData.fields = customForm.fields;
|
|
1232
1255
|
tyContent += customForm.html;
|
|
@@ -1998,6 +2021,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1998
2021
|
text = atcb_translate_hook(type, data);
|
|
1999
2022
|
}
|
|
2000
2023
|
}
|
|
2024
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2001
2025
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2002
2026
|
return;
|
|
2003
2027
|
}
|
|
@@ -2016,7 +2040,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2016
2040
|
textEl.textContent = text;
|
|
2017
2041
|
parent.append(textEl);
|
|
2018
2042
|
}
|
|
2019
|
-
parent.setAttribute('aria-label', text);
|
|
2020
2043
|
}
|
|
2021
2044
|
function atcb_generate_button(host, button, data) {
|
|
2022
2045
|
const oneOption = (function () {
|
|
@@ -4953,7 +4976,7 @@ async function atcb_build_button(host, data) {
|
|
|
4953
4976
|
} else {
|
|
4954
4977
|
atcb_generate_button(host, rootObj, data);
|
|
4955
4978
|
}
|
|
4956
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4979
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4957
4980
|
atcb_generate_rich_data(data, host.host);
|
|
4958
4981
|
}
|
|
4959
4982
|
}
|
|
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.9
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.9';
|
|
17
17
|
const atcbCssTemplate = {
|
|
18
18
|
if (typeof window === 'undefined') {
|
|
19
19
|
return false;
|
|
@@ -738,6 +738,9 @@ async function atcb_check_required(data) {
|
|
|
738
738
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
739
739
|
}
|
|
740
740
|
if (data.dates != null && data.dates.length > 0) {
|
|
741
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
742
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
743
|
+
}
|
|
741
744
|
const requiredMultiField = ['name', 'startDate'];
|
|
742
745
|
const requiredMultiFieldFlex = ['name'];
|
|
743
746
|
return requiredMultiField.every(function (field) {
|
|
@@ -746,7 +749,11 @@ async function atcb_check_required(data) {
|
|
|
746
749
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
747
750
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
748
751
|
) {
|
|
749
|
-
|
|
752
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
753
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
754
|
+
} else {
|
|
755
|
+
data.dates[`${i}`].startDate = 'today';
|
|
756
|
+
}
|
|
750
757
|
}
|
|
751
758
|
}
|
|
752
759
|
return true;
|
|
@@ -755,7 +762,11 @@ async function atcb_check_required(data) {
|
|
|
755
762
|
const requiredSingleField = ['startDate'];
|
|
756
763
|
return requiredSingleField.every(function (field) {
|
|
757
764
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
758
|
-
|
|
765
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
766
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
767
|
+
} else {
|
|
768
|
+
data.startDate = 'today';
|
|
769
|
+
}
|
|
759
770
|
}
|
|
760
771
|
return true;
|
|
761
772
|
});
|
|
@@ -1304,6 +1315,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1304
1315
|
text = atcb_translate_hook(type, data);
|
|
1305
1316
|
}
|
|
1306
1317
|
}
|
|
1318
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
1307
1319
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
1308
1320
|
return;
|
|
1309
1321
|
}
|
|
@@ -1322,7 +1334,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1322
1334
|
textEl.textContent = text;
|
|
1323
1335
|
parent.append(textEl);
|
|
1324
1336
|
}
|
|
1325
|
-
parent.setAttribute('aria-label', text);
|
|
1326
1337
|
}
|
|
1327
1338
|
function atcb_generate_button(host, button, data) {
|
|
1328
1339
|
const oneOption = (function () {
|
|
@@ -4259,7 +4270,7 @@ async function atcb_build_button(host, data) {
|
|
|
4259
4270
|
} else {
|
|
4260
4271
|
atcb_generate_button(host, rootObj, data);
|
|
4261
4272
|
}
|
|
4262
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4273
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4263
4274
|
atcb_generate_rich_data(data, host.host);
|
|
4264
4275
|
}
|
|
4265
4276
|
}
|
|
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.9
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.9';
|
|
17
17
|
const atcbCssTemplate = {};
|
|
18
18
|
const atcbIsBrowser = () => {
|
|
19
19
|
if (typeof window === 'undefined') {
|
|
@@ -739,6 +739,9 @@ async function atcb_check_required(data) {
|
|
|
739
739
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
740
740
|
}
|
|
741
741
|
if (data.dates != null && data.dates.length > 0) {
|
|
742
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
743
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
744
|
+
}
|
|
742
745
|
const requiredMultiField = ['name', 'startDate'];
|
|
743
746
|
const requiredMultiFieldFlex = ['name'];
|
|
744
747
|
return requiredMultiField.every(function (field) {
|
|
@@ -747,7 +750,11 @@ async function atcb_check_required(data) {
|
|
|
747
750
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
748
751
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
749
752
|
) {
|
|
750
|
-
|
|
753
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
754
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
755
|
+
} else {
|
|
756
|
+
data.dates[`${i}`].startDate = 'today';
|
|
757
|
+
}
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
return true;
|
|
@@ -756,7 +763,11 @@ async function atcb_check_required(data) {
|
|
|
756
763
|
const requiredSingleField = ['startDate'];
|
|
757
764
|
return requiredSingleField.every(function (field) {
|
|
758
765
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
759
|
-
|
|
766
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
767
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
768
|
+
} else {
|
|
769
|
+
data.startDate = 'today';
|
|
770
|
+
}
|
|
760
771
|
}
|
|
761
772
|
return true;
|
|
762
773
|
});
|
|
@@ -1305,6 +1316,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1305
1316
|
text = atcb_translate_hook(type, data);
|
|
1306
1317
|
}
|
|
1307
1318
|
}
|
|
1319
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
1308
1320
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
1309
1321
|
return;
|
|
1310
1322
|
}
|
|
@@ -1323,7 +1335,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1323
1335
|
textEl.textContent = text;
|
|
1324
1336
|
parent.append(textEl);
|
|
1325
1337
|
}
|
|
1326
|
-
parent.setAttribute('aria-label', text);
|
|
1327
1338
|
}
|
|
1328
1339
|
function atcb_generate_button(host, button, data) {
|
|
1329
1340
|
const oneOption = (function () {
|
|
@@ -4260,7 +4271,7 @@ async function atcb_build_button(host, data) {
|
|
|
4260
4271
|
} else {
|
|
4261
4272
|
atcb_generate_button(host, rootObj, data);
|
|
4262
4273
|
}
|
|
4263
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4274
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4264
4275
|
atcb_generate_rich_data(data, host.host);
|
|
4265
4276
|
}
|
|
4266
4277
|
}
|
|
@@ -6,14 +6,14 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.6.
|
|
9
|
+
* Version: 2.6.9
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.6.
|
|
16
|
+
const atcbVersion = '2.6.9';
|
|
17
17
|
const atcbCssTemplate = {};
|
|
18
18
|
const atcbIsBrowser = () => {
|
|
19
19
|
if (typeof window === 'undefined') {
|
|
@@ -739,6 +739,9 @@ async function atcb_check_required(data) {
|
|
|
739
739
|
throw new Error('Add to Calendar Button generation failed: required name information missing');
|
|
740
740
|
}
|
|
741
741
|
if (data.dates != null && data.dates.length > 0) {
|
|
742
|
+
if (data.subscribe === true && data.dates.length > 1) {
|
|
743
|
+
throw new Error('Add to Calendar Button generation failed: a subscription calendar cannot be a multi-date setup');
|
|
744
|
+
}
|
|
742
745
|
const requiredMultiField = ['name', 'startDate'];
|
|
743
746
|
const requiredMultiFieldFlex = ['name'];
|
|
744
747
|
return requiredMultiField.every(function (field) {
|
|
@@ -747,7 +750,11 @@ async function atcb_check_required(data) {
|
|
|
747
750
|
(!requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '')) ||
|
|
748
751
|
(requiredMultiFieldFlex.includes(`${field}`) && (!data.dates[`${i}`][`${field}`] || data.dates[`${i}`][`${field}`] === '') && (!data[`${field}`] || data[`${field}`] === ''))
|
|
749
752
|
) {
|
|
750
|
-
|
|
753
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
754
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
|
|
755
|
+
} else {
|
|
756
|
+
data.dates[`${i}`].startDate = 'today';
|
|
757
|
+
}
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
760
|
return true;
|
|
@@ -756,7 +763,11 @@ async function atcb_check_required(data) {
|
|
|
756
763
|
const requiredSingleField = ['startDate'];
|
|
757
764
|
return requiredSingleField.every(function (field) {
|
|
758
765
|
if (!data[`${field}`] || data[`${field}`] === '') {
|
|
759
|
-
|
|
766
|
+
if (!data.subscribe || field !== 'startDate') {
|
|
767
|
+
throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
|
|
768
|
+
} else {
|
|
769
|
+
data.startDate = 'today';
|
|
770
|
+
}
|
|
760
771
|
}
|
|
761
772
|
return true;
|
|
762
773
|
});
|
|
@@ -1228,6 +1239,18 @@ async function atcb_generate_ty(hostEl, dataObj) {
|
|
|
1228
1239
|
})();
|
|
1229
1240
|
tyContent += '<form id="' + data.identifier + '-ty-form" class="pro-form' + (noIntro ? ' no-intro' : '') + '">';
|
|
1230
1241
|
if (tyData.fields && tyData.fields.length > 0) {
|
|
1242
|
+
const headerField = tyData.fields.find((field) => field.name === 'header' && field.type === 'hidden');
|
|
1243
|
+
if (headerField && headerField.default && headerField.default !== '' && headerField.default.startsWith('{')) {
|
|
1244
|
+
try {
|
|
1245
|
+
header = JSON.parse(headerField.default);
|
|
1246
|
+
if (Object.keys(header).length === 0) {
|
|
1247
|
+
header.atcb = true;
|
|
1248
|
+
}
|
|
1249
|
+
tyData.fields = tyData.fields.filter((field) => field.name !== 'header');
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
/* do nothing */
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1231
1254
|
const customForm = atcb_build_form(tyData.fields, data.identifier + '-ty');
|
|
1232
1255
|
tyData.fields = customForm.fields;
|
|
1233
1256
|
tyContent += customForm.html;
|
|
@@ -1999,6 +2022,7 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
1999
2022
|
text = atcb_translate_hook(type, data);
|
|
2000
2023
|
}
|
|
2001
2024
|
}
|
|
2025
|
+
parent.setAttribute('aria-label', oneOption ? atcb_translate_hook('label.addtocalendar', data) + ': ' + data.name + ': ' + text : type === 'trigger' ? text + ': ' + data.name : text);
|
|
2002
2026
|
if (data.buttonStyle === 'date' && (type === 'trigger' || oneOption)) {
|
|
2003
2027
|
return;
|
|
2004
2028
|
}
|
|
@@ -2017,7 +2041,6 @@ function atcb_generate_label_content(data, parent, type, icon, text, oneOption)
|
|
|
2017
2041
|
textEl.textContent = text;
|
|
2018
2042
|
parent.append(textEl);
|
|
2019
2043
|
}
|
|
2020
|
-
parent.setAttribute('aria-label', text);
|
|
2021
2044
|
}
|
|
2022
2045
|
function atcb_generate_button(host, button, data) {
|
|
2023
2046
|
const oneOption = (function () {
|
|
@@ -4954,7 +4977,7 @@ async function atcb_build_button(host, data) {
|
|
|
4954
4977
|
} else {
|
|
4955
4978
|
atcb_generate_button(host, rootObj, data);
|
|
4956
4979
|
}
|
|
4957
|
-
if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4980
|
+
if (!data.hideRichData && !data.subscribe && data.name && data.dates[0].location && data.dates[0].startDate) {
|
|
4958
4981
|
atcb_generate_rich_data(data, host.host);
|
|
4959
4982
|
}
|
|
4960
4983
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "add-to-calendar-button",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.9",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.17.0",
|
|
6
6
|
"npm": ">=9.6.7"
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@open-wc/testing": "^4.0.0",
|
|
103
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
104
|
-
"@typescript-eslint/parser": "^7.
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
104
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
105
105
|
"@web/test-runner": "^0.18.1",
|
|
106
106
|
"eslint": "^8.57.0",
|
|
107
107
|
"eslint-config-prettier": "^9.1.0",
|