Skip to content

Commit 5cf3e3a

Browse files
authored
Merge pull request #52 from jekuer/new-style
New style
2 parents d023e99 + 93cfcc2 commit 5cf3e3a

12 files changed

+116
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
6969
### Option 2: simple (CDN)
7070

7171
1. Instead of downloading the files, you can use the jsDeliver CDN.
72-
3. Put `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/add-to-calendar-button@1.7/assets/css/atcb.min.css">` into the <head> and `<script src="https://cdn.jsdelivr.net/npm/add-to-calendar-button@1.7" defer></script>` into the <body> footer of your website.
72+
3. Put `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/add-to-calendar-button@1.8/assets/css/atcb.min.css">` into the <head> and `<script src="https://cdn.jsdelivr.net/npm/add-to-calendar-button@1.8" defer></script>` into the <body> footer of your website.
7373
4. Create your button as can be seen in the "Configuration" section below.
7474
5. Done. And this setup also automatically keeps track of any bug fixes and minor updates!
7575

assets/css/atcb.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*
6-
* Version: 1.7.8
6+
* Version: 1.8.0
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0
@@ -60,10 +60,11 @@
6060
.atcb_button.atcb_active {
6161
background: rgb(255, 255, 255);
6262
border-radius: 6px 6px 3px 3px;
63-
-webkit-box-shadow: 1px 5px 15px 0px rgba(0,0,0,.5);
64-
box-shadow: 1px 5px 15px 0px rgba(0,0,0,.5);
65-
margin: -2px -4px;
66-
padding: 12px 20px 13px 20px;
63+
-webkit-box-shadow: 1px 8px 12px 0px rgba(0,0,0,.5);
64+
box-shadow: 1px 8px 12px 0px rgba(0,0,0,.5);
65+
margin: 0 -4px;
66+
padding: 10px 20px 12px 20px;
67+
transform: perspective(100px) rotateX(12deg);
6768
z-index: 90;
6869
}
6970

assets/css/atcb.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/atcb.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/atcb.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.7.8';
6+
const atcbVersion = '1.8.0';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: MIT with “Commons Clause” License Condition v1.0
@@ -12,6 +12,13 @@ const atcbVersion = '1.7.8';
1212

1313

1414

15+
const isBrowser = new Function("try { return this===window; }catch(e){ return false; }");
16+
if (isBrowser()) {
17+
const isiOS = new Function("if ((/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)){ return true; }else{ return false; }");
18+
} else {
19+
const isiOS = new Function("return false;");
20+
}
21+
1522
// INITIALIZE THE SCRIPT AND FUNCTIONALITY
1623
function atcb_init() {
1724
// let's get started
@@ -521,14 +528,23 @@ function atcb_generate_google(data) {
521528
let formattedDate = atcb_generate_time(data, 'clean', 'google');
522529
url += '&dates=' + formattedDate['start'] + '%2F' + formattedDate['end'];
523530
// add details (if set)
524-
if (data['description'] != null && data['description'] != '') {
525-
url += '&details=' + encodeURIComponent(data['description']);
531+
if (data['name'] != null && data['name'] != '') {
532+
url += '&text=' + encodeURIComponent(data['name']);
526533
}
527534
if (data['location'] != null && data['location'] != '') {
528535
url += '&location=' + encodeURIComponent(data['location']);
536+
// TODO: Find a better solution for the next temporary workaround.
537+
if (isiOS()) { // workaround to cover a bug, where, when using Google Calendar on an iPhone, the location is not recognized. So, for the moment, we simply add it to the description.
538+
if (data['description'] == null || data['description'] == '') {
539+
data['description'] = '';
540+
} else {
541+
data['description'] += '<br><br>';
542+
}
543+
data['description'] += '&#128205;: ' + data['location'];
544+
}
529545
}
530-
if (data['name'] != null && data['name'] != '') {
531-
url += '&text=' + encodeURIComponent(data['name']);
546+
if (data['description'] != null && data['description'] != '') {
547+
url += '&details=' + encodeURIComponent(data['description']);
532548
}
533549
window.open(url, '_blank').focus();
534550
}
@@ -546,14 +562,14 @@ function atcb_generate_yahoo(data) {
546562
url += '&dur=allday';
547563
}
548564
// add details (if set)
549-
if (data['description'] != null && data['description'] != '') {
550-
url += '&desc=' + encodeURIComponent(data['description']);
565+
if (data['name'] != null && data['name'] != '') {
566+
url += '&title=' + encodeURIComponent(data['name']);
551567
}
552568
if (data['location'] != null && data['location'] != '') {
553569
url += '&in_loc=' + encodeURIComponent(data['location']);
554570
}
555-
if (data['name'] != null && data['name'] != '') {
556-
url += '&title=' + encodeURIComponent(data['name']);
571+
if (data['description'] != null && data['description'] != '') {
572+
url += '&desc=' + encodeURIComponent(data['description']);
557573
}
558574
window.open(url, '_blank').focus();
559575
}
@@ -577,14 +593,14 @@ function atcb_generate_microsoft(data, type = '365') {
577593
url += '&allday=true';
578594
}
579595
// add details (if set)
580-
if (data['description'] != null && data['description'] != '') {
581-
url += '&body=' + encodeURIComponent(data['description'].replace(/\n/g, '<br>'));
596+
if (data['name'] != null && data['name'] != '') {
597+
url += '&subject=' + encodeURIComponent(data['name']);
582598
}
583599
if (data['location'] != null && data['location'] != '') {
584600
url += '&location=' + encodeURIComponent(data['location']);
585601
}
586-
if (data['name'] != null && data['name'] != '') {
587-
url += '&subject=' + encodeURIComponent(data['name']);
602+
if (data['description'] != null && data['description'] != '') {
603+
url += '&body=' + encodeURIComponent(data['description'].replace(/\n/g, '<br>'));
588604
}
589605
window.open(url, '_blank').focus();
590606
}
@@ -602,6 +618,9 @@ function atcb_generate_teams(data) {
602618
url += '&startTime=' + formattedDate['start'] + '&endTime=' + formattedDate['end'];
603619
// add details (if set)
604620
let locationString = '';
621+
if (data['name'] != null && data['name'] != '') {
622+
url += '&subject=' + encodeURIComponent(data['name']);
623+
}
605624
if (data['location'] != null && data['location'] != '') {
606625
locationString = encodeURIComponent(data['location']);
607626
url += '&location=' + locationString; // workaround putting the location into the description, since the native field is not supported yet
@@ -610,9 +629,6 @@ function atcb_generate_teams(data) {
610629
if (data['description_iCal'] != null && data['description_iCal'] != '') { // using description_iCal instead of description, since Teams does not support html tags
611630
url += '&content=' + locationString + encodeURIComponent(data['description_iCal']);
612631
}
613-
if (data['name'] != null && data['name'] != '') {
614-
url += '&subject=' + encodeURIComponent(data['name']);
615-
}
616632
window.open(url, '_blank').focus();
617633
}
618634

@@ -736,8 +752,6 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
736752
return returnObject;
737753
}
738754

739-
const isBrowser=new Function("try {return this===window;}catch(e){ return false;}");
740-
741755
if (isBrowser()) {
742756
// Global listener to ESC key to close dropdown
743757
document.addEventListener('keydown', evt => {

assets/js/atcb.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)