From ea11a8ffae39f8feece0455173e08a1af781c090 Mon Sep 17 00:00:00 2001 From: Eric Poirier Date: Tue, 16 Nov 2021 14:01:14 -0500 Subject: [PATCH 1/2] Enable multiple featured stories Signed-off-by: Eric Poirier --- js/api/jquery.eclipsefdn.api.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/js/api/jquery.eclipsefdn.api.js b/js/api/jquery.eclipsefdn.api.js index 9767698..c2c5e43 100644 --- a/js/api/jquery.eclipsefdn.api.js +++ b/js/api/jquery.eclipsefdn.api.js @@ -2376,7 +2376,12 @@ const eclipseFdnApi = (function ($, window, document, undefined) { } // make sure we have a promotion to display if (json.length > 0) { - writeFeaturedContainer(json[0], $container, type); + let items = json[0]; + const count = $container.data('count'); + if (count !== "undefined" && typeof count == 'number') { + items = json.slice(0, count); + } + writeFeaturedContainer(items, $container, type); } else { var default_featured_story = { id: 'default-featured-story', @@ -2410,17 +2415,18 @@ const eclipseFdnApi = (function ($, window, document, undefined) { $container.data('template-id') || 'template-featured-' + type; var template = getMustacheTemplate( templateId, - '{{#content}}' + + '{{#featuredStory}}' + '

{{ title }}

' + '

{{ body }}

' + '' + - '{{/content}}' + '{{/featuredStory}}' ); var rendered = Mustache.render(template, { - content: item, + featuredStory: item, }); // set the container HTML to the rendered HTML $featuredContentContainer.html(rendered); + $featuredContentContainer.trigger('shown.ef.featured_story'); }; var convertDataToURLParameters = function ( -- GitLab From c7d1936688cc7234d92a45369b7faf4b322fa0da Mon Sep 17 00:00:00 2001 From: Eric Poirier Date: Wed, 17 Nov 2021 08:13:15 -0500 Subject: [PATCH 2/2] Check if count is not 0 Signed-off-by: Eric Poirier --- js/api/jquery.eclipsefdn.api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/api/jquery.eclipsefdn.api.js b/js/api/jquery.eclipsefdn.api.js index c2c5e43..f7a2f3c 100644 --- a/js/api/jquery.eclipsefdn.api.js +++ b/js/api/jquery.eclipsefdn.api.js @@ -2376,9 +2376,10 @@ const eclipseFdnApi = (function ($, window, document, undefined) { } // make sure we have a promotion to display if (json.length > 0) { + let count = $container.data('count'); + count = parseInt(count); let items = json[0]; - const count = $container.data('count'); - if (count !== "undefined" && typeof count == 'number') { + if (count !== "undefined" && typeof count == 'number' && count >= 1) { items = json.slice(0, count); } writeFeaturedContainer(items, $container, type); -- GitLab