@import views.support.ImgSrc @(item: layout.ContentCard, containerIndex: Int, index: Int, visibilityDataAttribute: String, isFirstContainer: Boolean, isList: Boolean)(implicit request: RequestHeader) @import layout.{FaciaWidths, FrontendLatestSnap} @import model.{CrosswordSvg, InlineImage, InlineSlideshow, InlineVideo, InlineYouTubeMediaAtom, VideoPlayer} @import views.html.fragments.items.elements.facia_cards._ @import views.html.fragments.items.elements.starRating @import views.html.fragments.items.facia_cards.meta @import views.html.fragments.atoms.youtube @import views.html.fragments.media.video @import views.html.fragments.inlineSvg @import views.support.{CutOut, GetClasses, RemoveOuterParaHtml, RenderClasses, Video640} @import model.ContentDesignType.RichContentDesignType @import Function.const
data-discussion-id="@id" } data-discussion-closed="@item.discussionSettings.isClosedForComments" data-discussion-url="@item.header.url.get(request)#comments" } data-link-name="@item.dataLinkName(index)" data-item-visibility="@visibilityDataAttribute" data-test-id="facia-card" @item.id.map { id => data-id="@id" } @item.snapStuff.map(_.dataAttributes) @item.shortUrl.map { shortUrl => data-loyalty-short-url="@shortUrl" }> @if(item.hasInlineSnapHtml) { @item.snapStuff.map { snap => @snap.embedCss.map { css => } @snap.embedHtml.map(Html(_)) @snap.embedJs.map { js => } } } else { @container(item) }
@mediaMeta(item: layout.ContentCard) = {
@if(item.contentType.name.toLowerCase == "video") { @item.displayElement match { case Some(InlineVideo(videoElement, _, _)) => {
@inlineSvg("video-icon", "icon") @if(videoElement.videos.formattedDuration != "0:00") { @videoElement.videos.formattedDuration }
} case Some(media@InlineYouTubeMediaAtom(youTubeAtom, _)) => {
@inlineSvg("video-icon", "icon") @if(youTubeAtom.formattedDuration.getOrElse("0:00") != "0:00") { @youTubeAtom.formattedDuration }
} case _ => {
@inlineSvg("video-icon", "icon") Video
} } } @if(item.contentType.name.toLowerCase == "audio") {
@inlineSvg("volume-high", "icon") Podcast
} @if(item.contentType.name.toLowerCase == "gallery") {
@inlineSvg("camera", "icon") Gallery
} @meta(item)
} @standfirst(item: layout.ContentCard) = { @item.trailText.filter(const(item.showStandfirst)).map { text =>
@Html(text)
} } @container(item: layout.ContentCard) = {
@item.displayElement.filter(const(item.showDisplayElement)) match { case Some(InlineVideo(videoElement, title, fallback)) if item.cardTypes.showVideoPlayer => { @defining(VideoPlayer( videoElement, Video640, title, autoPlay = false, showControlsAtStart = false, overrideIsRatioHd = Some(false), // We only pass in the ID if this is a video or audio block, as if it's a mainMedia video, the // ID is actually pointing to the article, which is wrong. It would be nice to have the ID on the // ContentCard, but we don't for now. Annoyingly this doesn't allow us to check for if we should // play ads or if the video is expired, but as fronts change really often, this is a non-problem. embedPath = if (item.isMediaLink) item.id else None, path = if (item.isMediaLink) item.id else None )) { player => @fallback.map { fallbackImage =>
@fragments.inlineSvg("play", "icon")
@itemImage( fallbackImage.imageMedia, inlineImage = containerIndex == 0 && index < 4, widthsByBreakpoint = Some(item.mediaWidthsByBreakpoint), shouldLazyLoad = containerIndex > 2 )
} } } case Some(svg@CrosswordSvg(_)) => {
} case Some(media@InlineYouTubeMediaAtom(_,_)) => {
@youtube( media = media.youTubeAtom, displayCaption = false, displayDuration = false, playable = item.cardTypes.showYouTubeMediaAtomPlayer, posterImageOverride = media.posterImageOverride, cardStyle = Some(item.cardStyle))
} case Some(InlineVideo(_, _, Some(fallbackImage))) => {
@itemImage( fallbackImage.imageMedia, inlineImage = containerIndex == 0 && index < 4, widthsByBreakpoint = Some(item.mediaWidthsByBreakpoint), shouldLazyLoad = containerIndex > 2 )
} case Some(InlineImage(images)) => {
@item.starRating.map { rating => @starRating(rating) } @itemImage( images, inlineImage = containerIndex == 0 && index < 4, widthsByBreakpoint = Some(item.mediaWidthsByBreakpoint), shouldLazyLoad = containerIndex > 2 )
} case Some(InlineSlideshow(imageElements)) => { @defining(imageElements.take(10)) { slides =>
@slides.headOption.map { imageElement => @captionedImage( classes = Seq("responsive-img "), widths = item.mediaWidthsByBreakpoint, maybePath = Some(imageElement.url), maybeSrc = if(containerIndex == 0 && index < 4) Some(imageElement.url) else None, caption = imageElement.caption ) @slides.tail.map { imageElement => @captionedImage( classes = Seq("responsive-img "), widths = item.mediaWidthsByBreakpoint, maybePath = Some(imageElement.url), caption = imageElement.caption ) } }
} } case _ => {} }
@title(item.header, index, containerIndex, snapType = item.snapStuff.map(_.snapType), isAction = item.isAction) @item.bylineText.map { byline => } @item.starRating.map { rating => @starRating(rating) }
@if(item.isMediaLink) { @standfirst(item) } else {
@standfirst(item) @meta(item)
@if(item.cardTypes.showCutOut) { @item.cutOut.map { cutout =>
@image( classes = Seq("fc-item__avatar__media", CutOut.cssClass(cutout.orientation)), widths = FaciaWidths.cutOutFromItemClasses(item.cardTypes), maybePath = Some(cutout.imageUrl) )
} } } @if(item.isLive && item.displaySettings.showLivePlayable && !isList) {
} @if(item.isMediaLink) { } else { @if(item.sublinks.nonEmpty) { } }
@if(item.sublinks.nonEmpty) { } @if(item.designType.nameOrDefault == "comment") { @meta(item) }
}