|
|
@ -1,15 +1,25 @@ |
|
|
using System; |
|
|
using Localization.Resources.AbpUi; |
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering; |
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel |
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel |
|
|
{ |
|
|
{ |
|
|
public class AbpCarouselTagHelperService : AbpTagHelperService<AbpCarouselTagHelper> |
|
|
public class AbpCarouselTagHelperService : AbpTagHelperService<AbpCarouselTagHelper> |
|
|
{ |
|
|
{ |
|
|
|
|
|
protected IStringLocalizer<AbpUiResource> L { get; } |
|
|
|
|
|
|
|
|
|
|
|
public AbpCarouselTagHelperService(IStringLocalizer<AbpUiResource> localizer) |
|
|
|
|
|
{ |
|
|
|
|
|
L = localizer; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) |
|
|
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) |
|
|
{ |
|
|
{ |
|
|
output.TagName = "div"; |
|
|
output.TagName = "div"; |
|
|
@ -58,18 +68,45 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var html = new StringBuilder(""); |
|
|
// create 'previous' item
|
|
|
|
|
|
var prevIcon = new TagBuilder("span"); |
|
|
html.AppendLine("<a class=\"carousel-control-prev\" href=\"#" + TagHelper.Id + "\" role=\"button\" data-slide=\"prev\">"); |
|
|
prevIcon.AddCssClass("carousel-control-prev-icon"); |
|
|
html.AppendLine("<span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span>"); |
|
|
prevIcon.Attributes.Add("aria-hidden", "true"); |
|
|
html.AppendLine("<span class=\"sr-only\">Previous</span>"); |
|
|
|
|
|
html.AppendLine("</a>"); |
|
|
var prevText = new TagBuilder("span"); |
|
|
html.AppendLine("<a class=\"carousel-control-next\" href=\"#" + TagHelper.Id + "\" role=\"button\" data-slide=\"next\">"); |
|
|
prevText.AddCssClass("sr-only"); |
|
|
html.AppendLine("<span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span>"); |
|
|
prevText.InnerHtml.Append(L["Previous"].Value); |
|
|
html.AppendLine("<span class=\"sr-only\">Next</span>"); |
|
|
|
|
|
html.AppendLine("</a>"); |
|
|
var prevAnchor = new TagBuilder("a"); |
|
|
|
|
|
prevAnchor.AddCssClass("carousel-control-prev"); |
|
|
output.PostContent.SetHtmlContent(html.ToString()); |
|
|
prevAnchor.Attributes.Add("href", "#" + TagHelper.Id); |
|
|
|
|
|
prevAnchor.Attributes.Add("role", "button"); |
|
|
|
|
|
prevAnchor.Attributes.Add("data-slide", "prev"); |
|
|
|
|
|
|
|
|
|
|
|
prevAnchor.InnerHtml.AppendHtml(prevIcon); |
|
|
|
|
|
prevAnchor.InnerHtml.AppendHtml(prevText); |
|
|
|
|
|
|
|
|
|
|
|
// create 'next' item
|
|
|
|
|
|
var nextIcon = new TagBuilder("span"); |
|
|
|
|
|
nextIcon.AddCssClass("carousel-control-next-icon"); |
|
|
|
|
|
nextIcon.Attributes.Add("aria-hidden", "true"); |
|
|
|
|
|
|
|
|
|
|
|
var nextText = new TagBuilder("span"); |
|
|
|
|
|
nextText.AddCssClass("sr-only"); |
|
|
|
|
|
nextText.InnerHtml.Append(L["Next"].Value); |
|
|
|
|
|
|
|
|
|
|
|
var nextAnchor = new TagBuilder("a"); |
|
|
|
|
|
nextAnchor.AddCssClass("carousel-control-next"); |
|
|
|
|
|
nextAnchor.Attributes.Add("href", "#" + TagHelper.Id); |
|
|
|
|
|
nextAnchor.Attributes.Add("role", "button"); |
|
|
|
|
|
nextAnchor.Attributes.Add("data-slide", "next"); |
|
|
|
|
|
|
|
|
|
|
|
nextAnchor.InnerHtml.AppendHtml(nextIcon); |
|
|
|
|
|
nextAnchor.InnerHtml.AppendHtml(nextText); |
|
|
|
|
|
|
|
|
|
|
|
// append post content
|
|
|
|
|
|
output.PostContent.AppendHtml(prevAnchor); |
|
|
|
|
|
output.PostContent.AppendHtml(nextAnchor); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void SetIndicators(TagHelperContext context, TagHelperOutput output, List<CarouselItem> itemList) |
|
|
protected virtual void SetIndicators(TagHelperContext context, TagHelperOutput output, List<CarouselItem> itemList) |
|
|
@ -79,20 +116,24 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var html = new StringBuilder("<ol class=\"carousel-indicators\">"); |
|
|
var list = new TagBuilder("ol"); |
|
|
|
|
|
list.AddCssClass("carousel-indicators"); |
|
|
|
|
|
|
|
|
for (var i = 0; i < itemList.Count; i++) |
|
|
for (var i = 0; i < itemList.Count; i++) |
|
|
{ |
|
|
{ |
|
|
html.AppendLine( |
|
|
var listItem = new TagBuilder("li"); |
|
|
"<li " + |
|
|
listItem.Attributes.Add("data-target", "#" + TagHelper.Id); |
|
|
"data-target=\"#" + TagHelper.Id + "\"" + |
|
|
listItem.Attributes.Add("data-slide-to", i.ToString()); |
|
|
" data-slide-to=\"" + i + "\"" + |
|
|
|
|
|
(itemList[i].Active ? " class=\"active\">" : "") + |
|
|
if (itemList[i].Active) |
|
|
"</li>"); |
|
|
{ |
|
|
|
|
|
listItem.AddCssClass("active"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
list.InnerHtml.AppendHtml(listItem); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
html.AppendLine("</ol>"); |
|
|
output.PreContent.SetHtmlContent(list); |
|
|
output.PreContent.SetHtmlContent(html.ToString()); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void SetOneItemAsActive(TagHelperContext context, TagHelperOutput output, List<CarouselItem> itemList) |
|
|
protected virtual void SetOneItemAsActive(TagHelperContext context, TagHelperOutput output, List<CarouselItem> itemList) |
|
|
|