protected override void AddPageItemsList(List<PagerItem> items)
        {
            var pager = base.Component;
            var maxPages = pager.MaxPagesToDisplay;
            var pageCount = pager.Model.TotalPages;

            int start = 1;
            if (pageCount > maxPages + 1)
            {
                start = (pageCount + 1) - maxPages;
            }
            int end = pager.Model.TotalPages;

            if (start > 2)
            {
                items.Add(new PagerItem("1", GenerateUrl(1)));
                items.Add(new PagerItem("...", "", PagerItemType.Text));
            }

            for (int i = start; i <= end; i++)
            {
                var item = new PagerItem(i.ToString(), GenerateUrl(i));
                items.Add(item);
            }
        }
        protected override void RenderItemInnerContent(HtmlTextWriter writer, PagerItem item)
        {
            var type = item.Type;

            switch (type)
            {
                case PagerItemType.FirstPage:
                    writer.AddAttribute("class", "fa fa-step-backward");
                    break;
                case PagerItemType.PreviousPage:
                    writer.AddAttribute("class", "fa fa-chevron-left");
                    writer.WriteEncodedText(item.Text);
                    break;
                case PagerItemType.NextPage:
					writer.AddAttribute("class", "fa fa-chevron-right");
                    writer.WriteEncodedText(item.Text);
                    break;
                case PagerItemType.LastPage:
					writer.AddAttribute("class", "fa fa-step-forward");
                    break;
                default:
                    writer.WriteEncodedText(item.Text);
                    break;
            }
        }
Example #3
0
        protected virtual void RenderItem(HtmlTextWriter writer, PagerItem item)
        {
            var attrs = new RouteValueDictionary();

            if (item.State == PagerItemState.Disabled)
            {
                attrs.AppendCssClass("disabled");
            }
            else if (item.State == PagerItemState.Selected)
            {
                attrs.AppendCssClass("active");
            }

            if (item.Type == PagerItemType.Text)
            {
                attrs.AppendCssClass("shrinked");
            }

            if (Component.Style == PagerStyle.Blog && item.IsNavButton)
            {
                // TODO: (mg) BS4 doesn't seem to support this anymore
                attrs.AppendCssClass((item.Type == PagerItemType.PreviousPage || item.Type == PagerItemType.FirstPage) ? "previous" : "next");
            }

            attrs.AppendCssClass("page-item");

            writer.AddAttributes(attrs);
            writer.RenderBeginTag("li");

            if (item.Type == PagerItemType.Page || item.IsNavButton)
            {
                // write anchor
                writer.AddAttribute("href", item.Url);
                if (item.IsNavButton)
                {
                    writer.AddAttribute("title", item.Text.AttributeEncode());
                    writer.AddAttribute("aria-label", item.Text.AttributeEncode());
                    writer.AddAttribute("tab-index", "-1");
                    if (Component.Style != PagerStyle.Blog)
                    {
                        writer.AddAttribute("rel", "tooltip");
                        writer.AddAttribute("class", "page-link page-nav");
                    }
                }
                else
                {
                    var formatStr = Component.ItemTitleFormatString;
                    if (!string.IsNullOrEmpty(formatStr))
                    {
                        writer.AddAttribute("title", string.Format(formatStr, item.Text).AttributeEncode());
                        writer.AddAttribute("rel", "tooltip");
                    }
                }

                writer.AddAttribute("class", "page-link");

                writer.RenderBeginTag("a");
            }
            else
            {
                // write span
                writer.AddAttribute("class", "page-link");
                writer.RenderBeginTag("span");
            }

            this.RenderItemInnerContent(writer, item);

            writer.RenderEndTag(); // a || span

            writer.RenderEndTag(); // li
        }
Example #4
0
        protected List <PagerItem> CreateItemList()
        {
            var pager = base.Component;

            if (!pager.ShowPaginator || pager.Model.TotalPages <= 1)
            {
                return(new List <PagerItem>());
            }

            var pageNumber = pager.Model.PageNumber;
            var pageCount  = pager.Model.TotalPages;

            var results = new List <PagerItem>();

            PagerItem item;

            // first link
            if (pager.ShowFirst && pageNumber > 1)
            {
                item       = new PagerItem(pager.FirstButtonText, GenerateUrl(1), PagerItemType.FirstPage);
                item.State = (pageNumber > 1) ? PagerItemState.Normal : PagerItemState.Disabled;
                results.Add(item);
            }

            // previous link
            if (pager.ShowPrevious && pageNumber > 1)
            {
                item       = new PagerItem(pager.PreviousButtonText, GenerateUrl(pageNumber - 1), PagerItemType.PreviousPage);
                item.State = (pageNumber > 1) ? PagerItemState.Normal : PagerItemState.Disabled;
                results.Add(item);
            }

            // add the page number items
            if (pager.MaxPagesToDisplay > 0)
            {
                this.AddPageItemsList(results);
            }

            // next link
            var hasNext = false;

            if (pager.ShowNext && pageNumber < pageCount)
            {
                item       = new PagerItem(pager.NextButtonText, GenerateUrl(pageNumber + 1), PagerItemType.NextPage);
                item.State = (pageNumber == pageCount) ? PagerItemState.Disabled : PagerItemState.Normal;
                results.Add(item);
                hasNext = true;
            }

            // last link
            if (pager.ShowLast && pageNumber < pageCount)
            {
                item       = new PagerItem(pager.LastButtonText, GenerateUrl(pageCount), PagerItemType.LastPage);
                item.State = (pageNumber == pageCount) ? PagerItemState.Disabled : PagerItemState.Normal;
                if (pager.Style == PagerStyle.Pagination || !hasNext)
                {
                    results.Add(item);
                }
                else
                {
                    // BlogStyle Last-Item is right-aligned, so shift left
                    results.Insert(results.Count - 1, item);
                }
            }

            return(results);
        }
Example #5
0
        protected override void RenderItem(HtmlTextWriter writer, PagerItem item)
        {
            var attrs = new RouteValueDictionary();

            if (item.State == PagerItemState.Disabled)
            {
                //writer.AddAttribute("class", "disabled");
                AppendCssClass(attrs, "disabled");
            }
            else if (item.State == PagerItemState.Selected)
            {
                //writer.AddAttribute("class", "active");
                AppendCssClass(attrs, "active");
            }

            if (item.Type == PagerItemType.Text)
            {
                AppendCssClass(attrs, "shrinked");
            }

            if (Component.Style == PagerStyle.Blog && item.IsNavButton)
            {
                AppendCssClass(attrs, (item.Type == PagerItemType.PreviousPage || item.Type == PagerItemType.FirstPage) ? "previous" : "next");
            }

            writer.AddAttributes(attrs);
            writer.RenderBeginTag("li");

            if (item.Type == PagerItemType.Page || item.IsNavButton)
            {
                // write anchor
                writer.AddAttribute("href", item.Url);
                if (item.IsNavButton)
                {
                    writer.AddAttribute("title", item.Text.AttributeEncode());
                    if (Component.Style != PagerStyle.Blog)
                    {
                        writer.AddAttribute("rel", "tooltip");
                        writer.AddAttribute("class", "pager-nav");
                    }
                }
                else
                {
                    var formatStr = Component.ItemTitleFormatString;
                    if (!string.IsNullOrEmpty(formatStr))
                    {
                        writer.AddAttribute("title", string.Format(formatStr, item.Text).AttributeEncode());
                        writer.AddAttribute("rel", "tooltip");
                    }
                }
                writer.RenderBeginTag("a");
            }
            else
            {
                // write span
                writer.RenderBeginTag("span");
            }

            this.RenderItemInnerContent(writer, item);

            writer.RenderEndTag(); // a || span

            writer.RenderEndTag(); // li
        }
        protected override void RenderItem(HtmlTextWriter writer, PagerItem item)
        {
            var attrs = new RouteValueDictionary();

            if (item.State == PagerItemState.Disabled)
            {
                //writer.AddAttribute("class", "disabled");
                AppendCssClass(attrs, "disabled");
            }
            else if (item.State == PagerItemState.Selected)
            {
                //writer.AddAttribute("class", "active");
                AppendCssClass(attrs, "active");
            }

            if (item.Type == PagerItemType.Text)
            {
                AppendCssClass(attrs, "shrinked");
            }

            if (Component.Style == PagerStyle.Blog && item.IsNavButton)
            {
                AppendCssClass(attrs, (item.Type == PagerItemType.PreviousPage || item.Type == PagerItemType.FirstPage) ? "previous" : "next");
            }

            writer.AddAttributes(attrs);
            writer.RenderBeginTag("li");

            if (item.Type == PagerItemType.Page || item.IsNavButton)
            {
                // write anchor
                writer.AddAttribute("href", item.Url);
                if (item.IsNavButton)
                {
                    writer.AddAttribute("title", item.Text.AttributeEncode());
                    if (Component.Style != PagerStyle.Blog)
                    {
                        writer.AddAttribute("rel", "tooltip");
                        writer.AddAttribute("class", "pager-nav");
                    }
                }
                else
                {
                    var formatStr = Component.ItemTitleFormatString;
                    if (!string.IsNullOrEmpty(formatStr))
                    {
                        writer.AddAttribute("title", string.Format(formatStr, item.Text).AttributeEncode());
                        writer.AddAttribute("rel", "tooltip");
                    }
                }
                writer.RenderBeginTag("a");
            }
            else
            {
                // write span
                writer.RenderBeginTag("span");
            }

            this.RenderItemInnerContent(writer, item);

            writer.RenderEndTag(); // a || span

            writer.RenderEndTag(); // li
        }