add-to-calendar-button 1.1.6 → 1.2.0

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/README.md CHANGED
@@ -13,7 +13,7 @@ It is for this simple use case. No strings attached.
13
13
 
14
14
  ## Background // Why this repo exists
15
15
 
16
- While building a personal wedding page, I was confronted with the task to include a button, where invited people could save the event to their calenders.
16
+ While building a personal wedding page, I was confronted with the task to include a button, where invited people could save the event to their calendars.
17
17
  I did not want to build this from scratch (first) and therefore started the usual web research.
18
18
  Unfortunately, all I found where some extremely outdated code snippets, which did not really fit all the modern systems and calendar tools.
19
19
  Beside that, there was only the solution by AddEvent.com - all over the place. I was looking at CodePen and all I found where thousands of pens, which basically only included the AddEvent tool.
@@ -49,7 +49,7 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
49
49
 
50
50
  ## Setup
51
51
 
52
- ### Option 1: Simple
52
+ ### Option 1: simple
53
53
 
54
54
  1. Simply **download** the code from GitHub **or clone** the git repository.
55
55
  2. Copy the css (atcb.min.css) and js (atcb.min.js) files from the assets (not the "npm_dist"!) folders into your project (the **.min.** files are required, but it is recommended to also copy the raw and map files).
@@ -144,6 +144,8 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
144
144
  * timeZoneOffset works with older browsers, but is quite static.
145
145
  * You can set the trigger to "click". This makes the button open on click at desktop. Otherwise, the default would be to open on hover. On touch devices, this makes no difference.
146
146
  * If you want to define a specific name for any generated ics file (iCal), you can specify it via the "iCalFileName" option. The default would be "event-to-save-in-my-calendar".
147
+ * You can use the option "inline":true in order to make the button appear with inline-block instead of block style.
148
+ * If you require line breaks within the description, use `\n` or `<br>`.
147
149
 
148
150
 
149
151
  ## Contributing
@@ -160,8 +162,9 @@ Anyone is welcome to contribute, but mind the [guidelines](.github/CONTRIBUTING.
160
162
  The code is available under the [GPU 3.0 license](LICENSE.txt).
161
163
 
162
164
 
163
- ## Changelog (major only)
165
+ ## Changelog (without bug fixes)
164
166
 
167
+ * v1.2.0 : inline and line break support
165
168
  * v1.1.0 : npm functionality
166
169
  * v1.0.0 : initial release
167
170
 
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  *
6
- * Version: 1.1.6
6
+ * Version: 1.2.0
7
7
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
8
8
  * Project: https://github.com/jekuer/add-to-calendar-button
9
9
  * License: GNU General Public License v3.0 (gpl-3.0)
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  */
6
- const atcbVersion = '1.1.6';
6
+ const atcbVersion = '1.2.0';
7
7
  /* Creator: Jens Kuerschner (https://jenskuerschner.de)
8
8
  * Project: https://github.com/jekuer/add-to-calendar-button
9
9
  * License: GNU General Public License v3.0 (gpl-3.0)
@@ -173,6 +173,8 @@ function atcb_generate(button, buttonId, data) {
173
173
  buttonTrigger.addEventListener('touchstart', atcb_toggle, {passive: true});
174
174
  buttonTrigger.addEventListener('mouseenter', atcb_open, false);
175
175
  }
176
+ // standardize any line breaks in the description
177
+ data['description'] = data['description'].replace(/<br\s*\/?>/gmi, '\n');
176
178
  // generate the options list
177
179
  let optionsList = document.createElement('div');
178
180
  optionsList.id = 'atcb_list_' + buttonId;
@@ -258,7 +260,11 @@ function atcb_generate(button, buttonId, data) {
258
260
  bgOverlay.addEventListener('touchstart', atcb_close_all, {passive: true});
259
261
  bgOverlay.addEventListener('mouseenter', atcb_close_all, false);
260
262
  // show the placeholder div
261
- button.style.display = 'block';
263
+ if (data['inline']) {
264
+ button.style.display = 'inline-block';
265
+ } else {
266
+ button.style.display = 'block';
267
+ }
262
268
  // console log
263
269
  console.log("add-to-calendar button #" + (buttonId + 1) + " created");
264
270
  }
@@ -398,7 +404,7 @@ function atcb_generate_ical(data) {
398
404
  "DTSTAMP:" + formattedDate['start'],
399
405
  "DTSTART" + timeslot + ":" + formattedDate['start'],
400
406
  "DTEND" + timeslot + ":" + formattedDate['end'],
401
- "DESCRIPTION:" + data['description'],
407
+ "DESCRIPTION:" + data['description'].replace(/\n/g, '\\n'),
402
408
  "SUMMARY:" + data['title'],
403
409
  "LOCATION:" + data['location'],
404
410
  "STATUS:CONFIRMED",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.",
5
5
  "main": "npm_dist/atcb_npm.js",
6
6
  "types": "index.d.ts",