/// <summary> /// Método responsável por renderizar uma timeline na view a partir de um IEnumerable<TimelineItem> /// </summary> /// <param name="htmlHelper">Html Helper</param> /// <param name="itens">Itens a serem renderizados na timeline</param> /// <returns></returns> public static MvcHtmlString RenderTimeline(this HtmlHelper htmlHelper, IEnumerable <TimelineItem> itens) { //criação do nó principal da timeline var unorderedListTimeline = new TagBuilder("ul"); unorderedListTimeline.Attributes.Add(new KeyValuePair <string, string>("class", "timeline")); //iteração dos itens para construção da timeline foreach (var timelineItem in itens) { //criação do item da timeline, setando sua cor configurada var timelineColor = new TagBuilder("li"); timelineColor.Attributes.Add(new KeyValuePair <string, string>("class", TimelineHelper.GetCssByTimelineColor(timelineItem.Color))); //criação do nó que conterá as informações sobre a data e hora do evento na timeline var timelineTime = new TagBuilder("div"); timelineTime.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-time")); //criação do nó que conterá a data var spanDate = new TagBuilder("span"); spanDate.Attributes.Add(new KeyValuePair <string, string>("class", "date")); //spanDate.InnerHtml = timelineItem.DateTime.ToString("dd/MM/yyyy"); spanDate.InnerHtml = timelineItem.MarcacaoPatioAtual; //criação do nó que conterá a hora var spanTime = new TagBuilder("span"); spanTime.Attributes.Add(new KeyValuePair <string, string>("class", "time")); //spanTime.InnerHtml = timelineItem.DateTime.ToString("HH:mm"); spanTime.InnerHtml = timelineItem.SiglaPatio; //atribuição do nó de data e de hora ao nó principal relativo a essa informação timelineTime.InnerHtml = spanDate.ToString() + spanTime.ToString(); //criação do nó que conterá o ícone do item da timeline var timelineIcon = new TagBuilder("div"); if (!timelineItem.EntrePatios) { timelineIcon.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-icon")); } //verificação se o item possui css indicando qual ícone a exibir if (timelineItem.MiddleIconCss != "") { var icon = new TagBuilder("i"); icon.Attributes.Add(new KeyValuePair <string, string>("class", timelineItem.MiddleIconCss)); timelineIcon.InnerHtml = icon.ToString(); } //criação do nó que conterá o "corpo" da timeline var timelineBody = new TagBuilder("div"); timelineBody.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-body")); //criação do nó que conterá o título var timelineTitle = new TagBuilder("H2"); timelineTitle.InnerHtml = timelineItem.Title; //criação do nó que conterá a dados antes da descrição do conteúdo do item da timeline var timelineAfterContent = new TagBuilder("div"); timelineAfterContent.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-content")); timelineAfterContent.InnerHtml = timelineItem.AfterDescription; //criação do nó que conterá a descrição do conteúdo do item da timeline var timelineContent = new TagBuilder("div"); timelineContent.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-content")); timelineContent.InnerHtml = timelineItem.Description; //criação do nó que conterá a dados depois da descrição do conteúdo do item da timeline var timelineBeforeContent = new TagBuilder("div"); timelineBeforeContent.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-content")); timelineBeforeContent.InnerHtml = timelineItem.BeforeDescription; //criação do nó que conterá o rodapé do item da timeline var timelineFooter = new TagBuilder("div"); timelineFooter.Attributes.Add(new KeyValuePair <string, string>("class", "timeline-footer")); //criação do nó que conterá o link de "leia mais" no rodapé da timeline var readMoreLink = new TagBuilder("a"); readMoreLink.Attributes.Add(new KeyValuePair <string, string>("class", "nav-link pull-right")); readMoreLink.Attributes.Add(new KeyValuePair <string, string>("href", "javascript:" + timelineItem.LinkContent + ";")); //criação do nó que conterá a imagem alinhada a descrição "Leia mais" no rodapé var readMoreImg = new TagBuilder("i"); readMoreImg.Attributes.Add(new KeyValuePair <string, string>("class", "fa fa-chevron-circle-right")); //atribuição dos valores ao link "Leia mais..." readMoreLink.InnerHtml = timelineItem.LinkDescription + readMoreImg.ToString(); //atribuição dos valores ao nó de cabecalho //timelineTitle.InnerHtml = readMoreLink.ToString(); //atribuição dos valores ao nó de rodapé if (!String.IsNullOrEmpty(timelineItem.LinkDescription)) { timelineFooter.InnerHtml = readMoreLink.ToString(); } //atribuição dos valores ao nó que representa o corpo do item da timeline timelineBody.InnerHtml = timelineTitle.ToString() + timelineBeforeContent.ToString() + "<br/>" + timelineContent.ToString() + "<br/>" + timelineAfterContent.ToString() + timelineFooter.ToString(); //atribuição dos valores ao nó que representa o item completo da timeline timelineColor.InnerHtml = timelineTime.ToString() + timelineIcon.ToString() + timelineBody.ToString(); unorderedListTimeline.InnerHtml += timelineColor.ToString(); } return(new MvcHtmlString(unorderedListTimeline.ToString())); }