public FluentTagBuilder StartTag(string tagName, string classAttribute = null)
 {
     FluentTagBuilder tag = new FluentTagBuilder();
     tag._tagName = tagName;
     tag._parent = this;
     if (!string.IsNullOrEmpty(classAttribute))
         tag.Attribute("class", classAttribute.Trim());
     return tag;
 }
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            await base.ProcessAsync(context, output);
            ApplyPaginationAttributes(context);

            output.TagName = null;
            FluentTagBuilder builder = new FluentTagBuilder();
            if (Total == 0)
                builder.Append(InfiniteNoRecordsMessage);
            else
                builder = await Create(context, RouteValues);

            output.Content.SetContent(builder);
        }
Example #3
0
        private string CreateStatusList(int pageIndex, int totalItems, int pageSize)
        {
            RouteValues["page"] = pageIndex;
            string[] pageList = PagerSizesFormat.Split(',').Select(s => s.Trim()).ToArray();

            return new FluentTagBuilder()
                .StartTag("div", "dropdown").Style("display: inline-block;")
                    .StartTag("button", "btn btn-default dropdown-toggle").Attribute("data-toggle", "dropdown")
                        .Append($"{pageSize}{Const.NonBreakingSpace}")
                        .StartTag("span", "caret")
                        .EndTag()
                    .EndTag()
                    .StartTag("ul", "dropdown-menu")
                        .Action(menu =>
                        {
                            foreach (string item in pageList)
                            {
                                RouteValues["pageSize"] = item;
                                var li = new FluentTagBuilder()
                                   .StartTag("li").Anchor(UrlHelper.Action(AspAction, AspController, RouteValues, AspProtocol, AspHost, AspFragment), item, AjaxValues).EndTag();
                                menu.Append(li);
                            }
                        })
                    .EndTag()
                .EndTag()
                .StartTag("text").Style("display: inline-block;")
                    .Append($"{Const.NonBreakingSpace}{StringResources.PagerSizesText}")
                .EndTag();
        }
Example #4
0
 private string CreateStatus(int pageIndex, int totalItems, int pageSize)
 {
     return new FluentTagBuilder()
         .StartTag("div")
             .AttributeIfElse(PagerShowSizes || PagerShowStatus, "class", "col-md-6", "col-md-12")
             .Style(PagerHalign == HorizontalAlignment.Left ? "text-align: right;" : "text-align: left;")
             .ActionIf(PagerShowStatus, tag =>
             {
                 var from = ((pageIndex - 1) * pageSize) + 1;
                 var to = pageSize * pageIndex <= Total ? pageSize * pageIndex : Total;
                 var text = new FluentTagBuilder()
                     .StartTag("text").Style("display: inline-block;")
                         .Append(string.Format($"{PagerStatusFormat}{Const.NonBreakingSpace}", from, to, totalItems))
                     .EndTag();
                 tag.Append(text);
             })
             .ActionIf(PagerShowSizes, tag =>
             {
                 tag.Append(CreateStatusList(pageIndex, totalItems, pageSize));
             })
         .EndTag();
 }
        private async Task<FluentTagBuilder> Create(TagHelperContext context, System.Collections.Generic.IDictionary<string, object> routeValues)
        {
            var url = CreateLink(routeValues);
            routeValues.Add("skip", Skip);

            var replaceId = InfiniteReplaceId ?? context.UniqueId;
            var content = (await context.GetChildContentAsync()).ReplaceStringTokens(Explorer);
            if (string.IsNullOrEmpty(content))
                content = StringResources.InfiniteLabelText;

            FluentTagBuilder builder = new FluentTagBuilder()
                .StartTag("div")
                    //if there's no replace id specified, set the newly created div as the replacement area
                    .AttributeIf(string.IsNullOrEmpty(InfiniteReplaceId), "Id", replaceId)
                    .AttributeIf(string.IsNullOrEmpty(InfiniteReplaceId), "Style", InfiniteContainerStyle)
                    .ActionIf(Skip < Total, tag =>
                    {
                        tag.Append(new FluentTagBuilder()
                               .AjaxAnchor(url, "replace-with", replaceId, content, new
                               {
                                   @class = context.AllAttributes["class"]?.Value?.ToString(),
                                   id = InfiniteId,
                                   style = InfiniteStyle
                               })
                        );
                    })
                .EndTag();
            return builder;
        }
 private FluentTagBuilder ProcessNumbers()
 {
     FluentTagBuilder tag = new FluentTagBuilder();
     foreach (var number in DirectoryNumbers.ToCharArray())
     {
         tag.Append(CreateListItem(number));
     }
     return tag;
 }
 private FluentTagBuilder ProcessLetters()
 {
     FluentTagBuilder tag = new FluentTagBuilder();
     foreach (var letter in DirectoryAlphabet.ToCharArray())
     {
         tag.Append(CreateListItem(letter));
     }
     return tag;
 }