Skip to content

Commit

Permalink
fix atcb_action id generation; fix iOS options
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuer committed Feb 1, 2023
1 parent ae1b3ca commit 46e930c
Show file tree
Hide file tree
Showing 29 changed files with 58 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Ignore minified files
*.min.*

# Ignore dist folders
**/dist
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 2

- v2.1 : Romanian language support and a bunch of fixes
- v2.0 : "all" new version 2
- now a universally usable web component, working basically plug and play at almost all frontend stacks
- more customization (hide/show all parts individually) and easy styling (no longer necessary to include the css file manually)
Expand Down
5 changes: 1 addition & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ module.exports = function (grunt) {
},
'.eslintrc.json commonJS': {
'dist/commonjs/.eslintrc.json': function (fs, fd, done) {
fs.writeSync(
fd,
'{ "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }'
);
fs.writeSync(fd, '{ "extends": "../../.eslintrc.json", "env": { "node": true }, "plugins": ["commonjs"] }');
done();
},
},
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-3d.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: 3D
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-date.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Date
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-flat.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Flat
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-neumorphism.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Neumorphism
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-round.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Round
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb-text.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Text
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion assets/css/atcb.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Default
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/public/atcb.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Style: Default
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/FooterArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const { t, locale } = useI18n();
</span>
<div class="mt-6 text-xs sm:mt-5 md:mt-3">
<span class="font-semibold text-zinc-500 dark:text-zinc-400"> &copy; {{new Date().getFullYear()}} </span>
<span class="lowercase text-zinc-400 dark:text-zinc-500"> , Current Version: 2.1.0 </span>
<span class="lowercase text-zinc-400 dark:text-zinc-500"> , Current Version: 2.1.1 </span>
</div>
</div>
<div class="hidden self-center sm:block"><LightModeSwitch /></div>
Expand Down
2 changes: 2 additions & 0 deletions demo/src/views/AdvancedUseView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ onUnmounted(() => {
This might help you to track any user interaction more precisely.
</p>
<p class="font-semibold">Mind that this ID needs to be unique and may not be used at any other element!</p>
<p>It behaves a little different, if you are using the custom <a href="#10">atcb_action function</a>, where the script might take the triggering element's id first, before falling back to the described scheme.</p>
</div>
<div v-else>
<p>
Expand All @@ -646,6 +647,7 @@ onUnmounted(() => {
Dies kann bspw. für Tracking-Funktionalitäten auf deiner Webseite hilfreich sein.
</p>
<p class="font-semibold">Beachte, dass der Wert eindeutig sein muss und für kein weiteres Element genutzt werden darf!</p>
<p>Bei Nutzung der <a href="#10">atcb_action Funktion</a> verhält es sich minimal anders. Das Skript nutzt das genannte Schema nur, wenn das auslösende Element keine ID besitzt.</p>
</div>
<div class="block w-full justify-between pt-4 md:flex">
<div class="flex w-full flex-none justify-center p-6 pt-8 md:w-[300px]">
Expand Down
8 changes: 6 additions & 2 deletions demo/src/views/ConfigView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ const { t, locale } = useI18n();
<td v-if="locale=='en'">
Array of options to use in the list.<br /><br />
You can also override the label per option here. Simply add a pipe between the option name and your label (e.g. "Google|My custom Google Label").<br />
If you only specify 1 calendar type, the button would show the calendar's icon instead of the default one and redirect directly instead of opening a list (singleton case).
If you only specify 1 calendar type, the button would show the calendar's icon instead of the default one and redirect directly instead of opening a list (singleton case).<br />
Some options might be dynamically excluded based on other settings!<br />
"iCal" will be replaced by "Apple" on iOS devices.
</td>
<td v-else>
Array an Kalender-Arten, die in der Liste erscheinen.<br /><br />
Du kannst das Label jeweils direkt überschreiben. Füge hierzu ein Pipe-Symbol nach dem Kalender-Namen, gefolgt von deinem Label-Text ein (bspw. "Google|Mein Google-Label").<br />
Sofern du nur 1 Option definierst wird der Button das Icon dieser Option anzeigen sowie direkt die jeweilige Kalender-Aktion auslösen und keine Auswahlliste öffnen (Singleton-Case).
Sofern du nur 1 Option definierst wird der Button das Icon dieser Option anzeigen sowie direkt die jeweilige Kalender-Aktion auslösen und keine Auswahlliste öffnen (Singleton-Case).<br />
Optionen können deaktiviert werden, wenn sie aufgrund anderere Einstellungen nicht unterstützt werden!<br />
Auf iOS-Geräten wird die iCal-Option durch "Apple" ersetzt.
</td>
</tr>
<tr id="name">
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "add-to-calendar-button",
"version": "2.1.0",
"version": "2.1.1",
"engines": {
"node": ">=16.18.1",
"npm": ">=8.19.2"
Expand Down
4 changes: 3 additions & 1 deletion set-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ const arg = process.argv[2] || 'patch';

execSync('npx grunt version::' + arg, { stdio: [0, 1, 2] });
execSync('npm install', { stdio: [0, 1, 2] });
execSync('npm run build:all', { stdio: [0, 1, 2] });
execSync('npm run build', { stdio: [0, 1, 2] });
execSync('cd demo', { stdio: [0, 1, 2] });
execSync('npm install', { stdio: [0, 1, 2] });
2 changes: 1 addition & 1 deletion src/atcb-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
20 changes: 14 additions & 6 deletions src/atcb-decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down Expand Up @@ -110,13 +110,11 @@ function atcb_decorate_data_rrule(data) {

// cleanup options, standardizing names and splitting off custom labels
function atcb_decorate_data_options(data) {
// for iOS, we force the Apple option (if it is not there, but iCal is)
if (isiOS() && data.options.includes('ical') && !data.options.includes('apple')) {
data.options.push('apple');
}
// next, iterrate over the options and generate the new clean arrays (for options and labels)
// iterrate over the options and generate the new clean arrays (for options and labels)
const newOptions = [];
data.optionLabels = [];
let iCalGiven = false;
let appleGiven = false;
for (let i = 0; i < data.options.length; i++) {
// preparing the input options and labels
const cleanOption = data.options[`${i}`].split('|');
Expand All @@ -127,6 +125,12 @@ function atcb_decorate_data_options(data) {
}
return '';
})();
if (optionName === 'apple') {
appleGiven = true;
}
if (optionName === 'ical') {
iCalGiven = true;
}
// next, fill the new arrays (where the labels array already sits inside the main data object)
// do not consider options, which should not appear on iOS (e.g. iCal, since we have the Apple option instead)
// in the recurrence case, we leave out all options, which do not support it in general, as well as Apple and iCal for rrules with "until"
Expand All @@ -141,6 +145,10 @@ function atcb_decorate_data_options(data) {
newOptions.push(optionName);
data.optionLabels.push(optionLabel);
}
// for iOS, we force the Apple option (if it is not there, but iCal was)
if (isiOS() && iCalGiven && !appleGiven) {
newOptions.push('apple');
}
// last but not least, override the options at the main data object
data.options = newOptions;
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-generate-rich-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
4 changes: 2 additions & 2 deletions src/atcb-globals.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/atcb-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
12 changes: 5 additions & 7 deletions src/atcb-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down Expand Up @@ -417,12 +417,10 @@ function atcb_action(data, triggerElement, keyboardTrigger = false) {
data.identifier = triggerElement.id;
} else {
// however, if the trigger has no id, we set it with the identifier or a default fallback
if (data.identifier != null && data.identifier != '') {
if (!/^[\w\-_]+$/.test(data.identifier)) {
data.identifier = 'atcb-btn-custom';
} else {
data.identifier = 'atcb-btn-' + data.identifier;
}
if (data.identifier != null && data.identifier != '' && /^[\w\-_]+$/.test(data.identifier)) {
data.identifier = 'atcb-btn-' + data.identifier;
} else {
data.identifier = 'atcb-btn-custom';
}
triggerElement.id = data.identifier;
}
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down
2 changes: 1 addition & 1 deletion src/atcb-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Add to Calendar Button
* ++++++++++++++++++++++
*
* Version: 2.1.0
* Version: 2.1.1
* Creator: Jens Kuerschner (https://jenskuerschner.de)
* Project: https://github.com/add2cal/add-to-calendar-button
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
Expand Down

0 comments on commit 46e930c

Please sign in to comment.