From 52aa8b868a205af3c0737c59c8474041b736804c Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Thu, 28 May 2020 10:09:34 +0200 Subject: [PATCH 1/6] Truncate event title --- modules/default/calendar/calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d93f570c..3a23978f 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -396,7 +396,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = event.location; + descCell.innerHTML = this.titleTransform(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); From 6aa0a4a47fbd1a52a12ed30b4417b9a43f26cce9 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Fri, 29 May 2020 23:50:01 +0200 Subject: [PATCH 2/6] Renamed function --- modules/default/calendar/calendar.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 3a23978f..07fd40ab 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -244,7 +244,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.truncateTitle(event.title) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -396,7 +396,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.titleTransform(event.location); + descCell.innerHTML = this.truncateTitle(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -719,8 +719,8 @@ Module.register("calendar", { return string.charAt(0).toUpperCase() + string.slice(1); }, - /* titleTransform(title) - * Transforms the title of an event for usage. + /* truncateTitle(title) + * Transforms the title of an event and the location for usage. * Replaces parts of the text as defined in config.titleReplace. * Shortens title based on config.maxTitleLength and config.wrapEvents * @@ -728,7 +728,7 @@ Module.register("calendar", { * * return string - The transformed title. */ - titleTransform: function (title) { + truncateTitle: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; From f449feb3f822d9a191151ceb9c4b925c36ccbd36 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Fri, 29 May 2020 23:53:07 +0200 Subject: [PATCH 3/6] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a594e6..af9a97af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ _This release is scheduled to be released on 2020-07-01._ - Switch to most of the eslint:recommended rules and fix warnings - Replaced insecure links with https ones - Cleaned up all "no-undef" warnings from eslint +- Added location title wrapping for calendar module ### Deleted From 3d73153e5971c7fbe1974387dafe014dab3d6448 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 20:19:03 +0200 Subject: [PATCH 4/6] Revert "Renamed function" This reverts commit 6aa0a4a4 --- modules/default/calendar/calendar.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d8491a76..7d51ed88 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -241,7 +241,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.truncateTitle(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -389,7 +389,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.truncateTitle(event.location); + descCell.innerHTML = this.titleTransform(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -710,8 +710,8 @@ Module.register("calendar", { return string.charAt(0).toUpperCase() + string.slice(1); }, - /* truncateTitle(title) - * Transforms the title of an event and the location for usage. + /* titleTransform(title) + * Transforms the title of an event for usage. * Replaces parts of the text as defined in config.titleReplace. * Shortens title based on config.maxTitleLength and config.wrapEvents * @@ -719,7 +719,7 @@ Module.register("calendar", { * * return string - The transformed title. */ - truncateTitle: function (title) { + titleTransform: function (title) { for (var needle in this.config.titleReplace) { var replacement = this.config.titleReplace[needle]; From efbb9648c4f2a6e738cf432ae9b0b56cce7e0cf3 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 20:23:59 +0200 Subject: [PATCH 5/6] Introduce new function for location title shortening. --- modules/default/calendar/calendar.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 7d51ed88..f5ecab70 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -389,7 +389,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.titleTransform(event.location); + descCell.innerHTML = this.locationTitleShorten(event.location); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -736,6 +736,19 @@ Module.register("calendar", { return title; }, + /* + * locationTitleShorten(title) + * Shortens the event location title based on config.maxTitleLength and config.wrapEvents + * + * argument title string - the event location title to shorten + * + * return string - The shortened title. + */ + locationTitleShorten: function (title) { + title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); + return title; + }, + /* broadcastEvents() * Broadcasts the events to all other modules for reuse. * The all events available in one array, sorted on startdate. From a692d6be09e4653e4229939bde3e530ed98c35a4 Mon Sep 17 00:00:00 2001 From: Kristof Rado Date: Mon, 1 Jun 2020 22:25:07 +0200 Subject: [PATCH 6/6] Reworked titleTransform. --- modules/default/calendar/calendar.js | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index f5ecab70..9a1cc350 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -17,8 +17,11 @@ Module.register("calendar", { displayRepeatingCountTitle: false, defaultRepeatingCountTitle: "", maxTitleLength: 25, + maxLocationTitleLength: 25, wrapEvents: false, // wrap events to multiple lines breaking at maxTitleLength + wrapLocationEvents: false, maxTitleLines: 3, + maxEventTitleLines: 3, fetchInterval: 5 * 60 * 1000, // Update every 5 minutes. animationSpeed: 2000, fade: true, @@ -45,6 +48,9 @@ Module.register("calendar", { "De verjaardag van ": "", "'s birthday": "" }, + locationTitleReplace: { + "street ": "" + }, broadcastEvents: true, excludedEvents: [], sliceMultiDayEvents: false, @@ -241,7 +247,7 @@ Module.register("calendar", { } } - titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle; + titleWrapper.innerHTML = this.titleTransform(event.title, this.config.titleReplace, this.config.wrapEvents, this.config.maxTitleLength, this.config.maxTitleLines) + repeatingCountTitle; var titleClass = this.titleClassForUrl(event.url); @@ -389,7 +395,7 @@ Module.register("calendar", { var descCell = document.createElement("td"); descCell.className = "location"; descCell.colSpan = "2"; - descCell.innerHTML = this.locationTitleShorten(event.location); + descCell.innerHTML = this.titleTransform(event.location, this.config.locationTitleReplace, this.config.wrapLocationEvents, this.config.maxLocationTitleLength, this.config.maxEventTitleLines); locationRow.appendChild(descCell); wrapper.appendChild(locationRow); @@ -719,9 +725,9 @@ Module.register("calendar", { * * return string - The transformed title. */ - titleTransform: function (title) { - for (var needle in this.config.titleReplace) { - var replacement = this.config.titleReplace[needle]; + titleTransform: function (title, titleReplace, wrapEvents, maxTitleLength, maxTitleLines) { + for (var needle in titleReplace) { + var replacement = titleReplace[needle]; var regParts = needle.match(/^\/(.+)\/([gim]*)$/); if (regParts) { @@ -732,20 +738,7 @@ Module.register("calendar", { title = title.replace(needle, replacement); } - title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); - return title; - }, - - /* - * locationTitleShorten(title) - * Shortens the event location title based on config.maxTitleLength and config.wrapEvents - * - * argument title string - the event location title to shorten - * - * return string - The shortened title. - */ - locationTitleShorten: function (title) { - title = this.shorten(title, this.config.maxTitleLength, this.config.wrapEvents, this.config.maxTitleLines); + title = this.shorten(title, maxTitleLength, wrapEvents, maxTitleLines); return title; },