From 430ffb792eb301146e046fa27af975dfac74e2a1 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 17 Oct 2016 22:14:12 +0200 Subject: [PATCH 1/3] frio: stop the custom cal rendering (if no author-name exist) only for the modes agendaWeek and agendaDay --- view/theme/frio/js/mod_events.js | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/view/theme/frio/js/mod_events.js b/view/theme/frio/js/mod_events.js index 0b6bb6e7b2..7b06990fad 100644 --- a/view/theme/frio/js/mod_events.js +++ b/view/theme/frio/js/mod_events.js @@ -38,38 +38,39 @@ $(document).ready(function() { aspectRatio: 1, eventRender: function(event, element, view) { //console.log(view.name); - if (event.item['author-name'] == null) return; switch(view.name){ case "month": - element.find(".fc-title").html( - "{2}".format( - event.item['author-avatar'], - event.item['author-name'], - event.title, - event.item.desc, - event.item.location - )); - break; + element.find(".fc-title").html( + "{2}".format( + event.item['author-avatar'], + event.item['author-name'], + event.title, + event.item.desc, + event.item.location + )); + break; case "agendaWeek": - element.find(".fc-title").html( - "{1}

{2}

{3}

".format( - event.item['author-avatar'], - event.item['author-name'], - event.item.desc, - formatEventLocationText(event.item.location) - )); + if (event.item['author-name'] == null) return; + element.find(".fc-title").html( + "{1}

{2}

{3}

".format( + event.item['author-avatar'], + event.item['author-name'], + event.item.desc, + formatEventLocationText(event.item.location) + )); break; case "agendaDay": - element.find(".fc-title").html( - "{1}

{2}

{3}

".format( - event.item['author-avatar'], - event.item['author-name'], - event.item.desc, - formatEventLocationText(event.item.location) - )); - break; + if (event.item['author-name'] == null) return; + element.find(".fc-title").html( + "{1}

{2}

{3}

".format( + event.item['author-avatar'], + event.item['author-name'], + event.item.desc, + formatEventLocationText(event.item.location) + )); + break; case "listMonth": - element.find(".fc-list-item-title").html(formatListViewEvent(event)); + element.find(".fc-list-item-title").html(formatListViewEvent(event)); break; } }, From 967c3b3deb89a88275e55f7f972516a07ab07391 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 17 Oct 2016 22:51:51 +0200 Subject: [PATCH 2/3] frio: events - don't show author name if there is no author name --- view/theme/frio/js/mod_events.js | 40 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/view/theme/frio/js/mod_events.js b/view/theme/frio/js/mod_events.js index 7b06990fad..4e900d06ca 100644 --- a/view/theme/frio/js/mod_events.js +++ b/view/theme/frio/js/mod_events.js @@ -131,16 +131,14 @@ function eventHoverBodyTemplate() {
\
\ \ - {6}\ - {7}\ + {5}\ + {6}\ \
\
\ -
{3}
\ -
{5}{4}\ -
\ - {2}\ -
\ +
{2}
\ +
{4}{3}\ + {1}\
\
\
\ @@ -156,9 +154,17 @@ function eventHoverLocationTemplate() { return template; } +function eventHoverProfileNameTemplate() { + var template = '\ +
\ + {1}\ +
'; + return template; +} // transform the event data to html so we can use it in the event hover-card function eventHoverHtmlContent(event) { var eventLocation = ''; + var eventProfileName = ''; // Get the Browser language var locale = window.navigator.userLanguage || window.navigator.language; var data = ''; @@ -176,7 +182,7 @@ function eventHoverHtmlContent(event) { var endTime = moment(event.item.finish).format('HH:mm'); var monthNumber; - var formattedDate = startDate + var formattedDate = startDate; // We only need the to format the end date if the event does have // a finish date. @@ -195,8 +201,8 @@ function eventHoverHtmlContent(event) { // Get the html template data = eventHoverBodyTemplate(); - // Get only template data if there exist location data - if (event.item.location != '') { + // Get only template data if there exists location data + if (event.item.location) { var eventLocationText = formatEventLocationText(event.item.location); // Get the the html template for formatting the location var eventLocationTemplate = eventHoverLocationTemplate(); @@ -207,11 +213,21 @@ function eventHoverHtmlContent(event) { ); } + // Get only template data if there exists a profile name + if (event.item['author-name']) { + // Get the template + var eventProfileNameTemplate = eventHoverProfileNameTemplate(); + // Insert the data into the template + eventProfileName = eventProfileNameTemplate.format( + event.item['author-link'], + event.item['author-name'] + ); + } + // Format the event data according to the event hover template var formatted = data.format( event.item['author-avatar'], // this isn't used at the present time - event.item['author-link'], - event.item['author-name'], + eventProfileName, event.title, eventLocation, formattedDate, From b317f811e7f2208b470342cc99b88c9d33fa2f69 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 17 Oct 2016 22:58:30 +0200 Subject: [PATCH 3/3] frio: better handling of event location in event hover cards --- view/theme/frio/js/mod_events.js | 21 +++------------------ view/theme/frio/js/theme.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/view/theme/frio/js/mod_events.js b/view/theme/frio/js/mod_events.js index 4e900d06ca..5bd7c94498 100644 --- a/view/theme/frio/js/mod_events.js +++ b/view/theme/frio/js/mod_events.js @@ -56,7 +56,7 @@ $(document).ready(function() { event.item['author-avatar'], event.item['author-name'], event.item.desc, - formatEventLocationText(event.item.location) + htmlToText(event.item.location) )); break; case "agendaDay": @@ -66,7 +66,7 @@ $(document).ready(function() { event.item['author-avatar'], event.item['author-name'], event.item.desc, - formatEventLocationText(event.item.location) + htmlToText(event.item.location) )); break; case "listMonth": @@ -203,7 +203,7 @@ function eventHoverHtmlContent(event) { // Get only template data if there exists location data if (event.item.location) { - var eventLocationText = formatEventLocationText(event.item.location); + var eventLocationText = htmlToText(event.item.location); // Get the the html template for formatting the location var eventLocationTemplate = eventHoverLocationTemplate(); // Format the event location data according to the the event location @@ -252,18 +252,3 @@ function formatListViewEvent(event) { return formatted; } - -// Format event location in pure text -function formatEventLocationText(location) { - // Friendica can store the event location as text or as html - // We need to check if the location is html. In this case we need - // to transform it into clean text - if (location.startsWith("", " "); - }; - - return eventLocationText; -} \ No newline at end of file diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index ffe82c24a5..8fbee06e51 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -570,3 +570,13 @@ function scrollToItem(itemID) { $(elm).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 600); }); } + +// format a html string to pure text +function htmlToText(htmlString) { + // Replace line breaks with spaces + var text = htmlString.replace(/
/g, ' '); + // Strip the text out of the html string + text = text.replace(/<[^>]*>/g, ''); + + return text; +}