protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var tab        = base.Component;
            var hasContent = tab.Items.Any(x => x.Content != null);
            var isTabbable = tab.Position != TabsPosition.Top;

            tab.HtmlAttributes.AppendCssClass("tabbable");

            if (isTabbable)
            {
                tab.HtmlAttributes.AppendCssClass("tabs-{0}".FormatInvariant(tab.Position.ToString().ToLower()));
            }

            writer.AddAttributes(tab.HtmlAttributes);
            writer.RenderBeginTag("div"); // root div

            if (tab.SmartTabSelection)
            {
                this.WriteSelectionScript(writer);
            }

            if (tab.Position == TabsPosition.Below && hasContent)
            {
                RenderTabContent(writer);
            }

            // Tabs
            var ulAttrs = new Dictionary <string, object>();

            ulAttrs.AppendCssClass("nav nav-{0}".FormatInvariant(tab.Style.ToString().ToLower()));
            if (tab.Stacked)
            {
                ulAttrs.AppendCssClass("nav-stacked");
            }
            writer.AddAttributes(ulAttrs);
            writer.RenderBeginTag("ul");

            int i = 1;

            foreach (var item in tab.Items)
            {
                this.RenderItemLink(writer, item, i);
                i++;
            }

            writer.RenderEndTag(); // ul

            if (tab.Position != TabsPosition.Below && hasContent)
            {
                RenderTabContent(writer);
            }

            writer.RenderEndTag(); // div.tabbable
        }
 protected virtual void RenderItemContent(HtmlTextWriter writer, Tab item, int index)
 {
     // <div class="tab-pane fade in [active]" id="{id}">{content}</div>
     item.ContentHtmlAttributes.AppendCssClass("tab-pane");
     item.ContentHtmlAttributes.Add("role", "tabpanel");
     if (base.Component.Fade)
     {
         item.ContentHtmlAttributes.AppendCssClass("fade");
     }
     if (item.Selected)
     {
         if (base.Component.Fade)
         {
             item.ContentHtmlAttributes.AppendCssClass("show");
         }
         item.ContentHtmlAttributes.AppendCssClass("active");
     }
     writer.AddAttributes(item.ContentHtmlAttributes);
     writer.AddAttribute("id", BuildItemId(item, index));
     writer.RenderBeginTag("div");
     {
         if (item.Content != null)
         {
             writer.WriteLine(item.Content.ToHtmlString());
         }
     }
     writer.RenderEndTag();             // div
 }
Example #3
0
        public void Start(T item, string url)
        {
            if (item.Enabled)
            {
                item.LinkHtmlAttributes.Merge("href", url, false);
            }

            item.LinkHtmlAttributes.PrependInValue("class", " ", UIPrimitives.Link);
            writer.AddAttributes(item.LinkHtmlAttributes);
            writer.RenderBeginTag(HtmlTextWriterTag.A);
        }
Example #4
0
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var pager = base.Component;

            if (pager.Model.TotalPages <= 1)
            {
                return; // one page is no page.
            }
            var items = CreateItemList();

            AppendCssClass(pager.HtmlAttributes, pager.Style == PagerStyle.Pagination ? "pagination" : "pager");
            // Size
            if (pager.Size != PagerSize.Medium)
            {
                AppendCssClass(pager.HtmlAttributes, "pagination-{0}".FormatInvariant(pager.Size.ToString().ToLower()));
            }
            // Alignment
            if (pager.Alignment != PagerAlignment.Left)
            {
                AppendCssClass(pager.HtmlAttributes, "pagination-{0}".FormatInvariant(pager.Alignment.ToString().ToLower()));
            }
            writer.AddAttributes(pager.HtmlAttributes);
            //writer.AddAttribute("id", pager.Id);
            writer.RenderBeginTag("div");

            if (pager.ShowSummary && pager.Model.TotalPages > 1)
            {
                writer.AddAttribute("class", "pagination-summary pull-left");
                writer.RenderBeginTag("div");
                writer.WriteEncodedText(pager.CurrentPageText.FormatInvariant(pager.Model.PageNumber, pager.Model.TotalPages, pager.Model.TotalCount));
                writer.RenderEndTag(); // div
            }

            writer.AddAttribute("class", "unstyled");
            writer.RenderBeginTag("ul");

            foreach (var item in items)
            {
                this.RenderItem(writer, item); // create li
            }

            writer.RenderEndTag(); // ul
            writer.RenderEndTag(); // div
        }
Example #5
0
        protected virtual void RenderBody(HtmlTextWriter writer)
        {
            var win = base.Component;

            win.BodyHtmlAttributes.PrependCssClass("modal-body");
            writer.AddAttributes(win.BodyHtmlAttributes);
            writer.RenderBeginTag("div");

            if (win.Content != null)
            {
                win.Content.WriteTo(writer);
            }
            else if (win.ContentUrl.HasValue())
            {
                writer.Write("<iframe class='modal-flex-fill-area' frameborder='0' src='{0}' />".FormatInvariant(win.ContentUrl));
            }

            writer.RenderEndTag(); // div.modal-body
        }
Example #6
0
        protected virtual void RenderBody(HtmlTextWriter writer)
        {
            var chart = Component;

            writer.Write("<div class=\"box-body\">");

            if (!chart.Height.IsNullOrEmpty())
            {
                chart.HtmlAttributes.Add("height", chart.Height);
            }
            if (!chart.Width.IsNullOrEmpty())
            {
                chart.HtmlAttributes.Add("width", chart.Width);
            }

            writer.Write("<div class=\"chart\">");
            writer.AddAttributes(chart.HtmlAttributes);
            writer.RenderBeginTag("canvas");
            writer.RenderEndTag();
            writer.Write("</div>");             //chart

            writer.Write("</div>");             //box-body
        }
Example #7
0
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var win = base.Component;

            win.HtmlAttributes.AppendCssClass("modal");
            win.HtmlAttributes["role"]            = "dialog";
            win.HtmlAttributes["tabindex"]        = "-1";
            win.HtmlAttributes["aria-hidden"]     = "true";
            win.HtmlAttributes["aria-labelledby"] = win.Id + "Label";

            if (win.Fade)
            {
                win.HtmlAttributes.AppendCssClass("fade");
            }

            // Other options
            win.HtmlAttributes["data-keyboard"] = win.CloseOnEscapePress.ToString().ToLower();
            win.HtmlAttributes["data-show"]     = win.Show.ToString().ToLower();
            win.HtmlAttributes["data-focus"]    = win.Focus.ToString().ToLower();
            win.HtmlAttributes["data-backdrop"] = win.BackDrop
                ? (win.CloseOnBackdropClick ? "true" : "static")
                : "false";

            writer.AddAttributes(win.HtmlAttributes);

            writer.RenderBeginTag("div"); // div.modal
            {
                var className = "modal-dialog";
                switch (win.Size)
                {
                case WindowSize.Small:
                    className += " modal-sm";
                    break;

                case WindowSize.Large:
                    className += " modal-lg";
                    break;

                case WindowSize.Flex:
                    className += " modal-flex";
                    break;

                case WindowSize.FlexSmall:
                    className += " modal-flex modal-flex-sm";
                    break;
                }

                if (win.CenterVertically)
                {
                    className += " modal-dialog-centered";
                }

                writer.AddAttribute("class", className);
                win.HtmlAttributes["role"] = "document";
                writer.RenderBeginTag("div"); // div.modal-dialog
                {
                    writer.AddAttribute("class", "modal-content");
                    writer.RenderBeginTag("div"); // div.modal-content
                    {
                        // HEADER
                        if (win.ShowClose && win.Title.HasValue())
                        {
                            this.RenderHeader(writer);
                        }

                        // BODY
                        this.RenderBody(writer);

                        // FOOTER
                        if (win.FooterContent != null)
                        {
                            this.RenderFooter(writer);
                        }
                    }
                    writer.RenderEndTag(); // div.modal-content
                }
                writer.RenderEndTag();     // div.modal-dialog
            }
            writer.RenderEndTag();         // div.modal
        }
        protected virtual string RenderItemLink(HtmlTextWriter writer, Tab item, int index)
        {
            string temp          = "";
            string loadedTabName = null;

            // <li [class="active [hide]"]><a href="#{id}" data-toggle="tab">{text}</a></li>
            item.HtmlAttributes.AppendCssClass("nav-item"); // .active for BS2

            if (!item.Selected && !item.Visible)
            {
                item.HtmlAttributes.AppendCssClass("d-none");
            }

            if (item.Pull == TabPull.Right)
            {
                item.HtmlAttributes.AppendCssClass("float-right");
            }

            writer.AddAttributes(item.HtmlAttributes);

            writer.RenderBeginTag("li");
            {
                var itemId = "#" + BuildItemId(item, index);

                writer.AddAttribute("class", "nav-link" + (item.Selected ? " active" : ""));

                if (item.Content != null)
                {
                    writer.AddAttribute("href", itemId);
                    writer.AddAttribute("data-toggle", "tab");
                    writer.AddAttribute("data-loaded", "true");
                    loadedTabName = GetTabName(item) ?? itemId;
                }
                else
                {
                    // no content, create real link instead
                    var url = item.GenerateUrl(base.ViewContext.RequestContext).NullEmpty();

                    if (url == null)
                    {
                        writer.AddAttribute("href", "#");
                    }
                    else
                    {
                        if (item.Ajax)
                        {
                            writer.AddAttribute("href", itemId);
                            writer.AddAttribute("data-ajax-url", url);
                            writer.AddAttribute("data-toggle", "tab");
                        }
                        else
                        {
                            writer.AddAttribute("href", url);
                        }
                    }
                }

                if (item.BadgeText.HasValue())
                {
                    item.LinkHtmlAttributes.AppendCssClass("clearfix");
                }

                writer.AddAttributes(item.LinkHtmlAttributes);
                writer.RenderBeginTag("a");
                {
                    // Tab Icon
                    if (item.Icon.HasValue())
                    {
                        writer.AddAttribute("class", item.Icon);
                        writer.RenderBeginTag("i");
                        writer.RenderEndTag();                         // i
                    }
                    else if (item.ImageUrl.HasValue())
                    {
                        var url = new UrlHelper(this.ViewContext.RequestContext);
                        writer.AddAttribute("src", url.Content(item.ImageUrl));
                        writer.AddAttribute("alt", "Icon");
                        writer.RenderBeginTag("img");
                        writer.RenderEndTag();                         // img
                    }

                    // Caption
                    writer.AddAttribute("class", "tab-caption");
                    writer.RenderBeginTag("span");
                    writer.WriteEncodedText(item.Text);
                    writer.RenderEndTag();

                    // Badge
                    if (item.BadgeText.HasValue())
                    {
                        // Label/badge
                        temp  = "ml-2 badge";
                        temp += " badge-" + item.BadgeStyle.ToString().ToLower();
                        if (base.Component.Position == TabsPosition.Left)
                        {
                            temp += " float-right";                             // looks nicer
                        }
                        writer.AddAttribute("class", temp);
                        writer.RenderBeginTag("span");
                        writer.WriteEncodedText(item.BadgeText);
                        writer.RenderEndTag();                         // span > badge
                    }

                    // Nav link short summary for collapsed state
                    if (this.Component.IsResponsive && item.Summary.HasValue())
                    {
                        writer.AddAttribute("class", "nav-link-summary");
                        writer.RenderBeginTag("span");
                        writer.WriteEncodedText(item.Summary);
                        writer.RenderEndTag();
                    }

                    writer.RenderEndTag();             // a
                }
                writer.RenderEndTag();                 // li
            }

            return(loadedTabName);
        }
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var tab = base.Component;

            MoveSpecialTabToEnd(tab.Items);

            var hasContent = tab.Items.Any(x => x.Content != null || x.Ajax);
            var isTabbable = tab.Position != TabsPosition.Top;
            var isStacked  = tab.Position == TabsPosition.Left || tab.Position == TabsPosition.Right;
            var urlHelper  = new UrlHelper(this.ViewContext.RequestContext);

            if (tab.Items.Count == 0)
            {
                return;
            }

            tab.HtmlAttributes.AppendCssClass("tabbable");

            if (isTabbable)
            {
                tab.HtmlAttributes.AppendCssClass("tabs-{0}".FormatInvariant(tab.Position.ToString().ToLower()));
            }

            if (tab.SmartTabSelection)
            {
                tab.HtmlAttributes.AppendCssClass("tabs-autoselect");
                tab.HtmlAttributes.Add("data-tabselector-href", urlHelper.Action("SetSelectedTab", "Common", new { area = "admin" }));
            }

            if (isStacked)
            {
                tab.HtmlAttributes.AppendCssClass("row");
            }

            if (tab.OnAjaxBegin.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onbegin", tab.OnAjaxBegin);
            }

            if (tab.OnAjaxSuccess.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onsuccess", tab.OnAjaxSuccess);
            }

            if (tab.OnAjaxFailure.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onfailure", tab.OnAjaxFailure);
            }

            if (tab.OnAjaxComplete.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-oncomplete", tab.OnAjaxComplete);
            }

            if (tab.IsResponsive)
            {
                tab.HtmlAttributes.AppendCssClass("nav-responsive");
                tab.HtmlAttributes.Add("data-breakpoint", tab.Breakpoint);
            }

            writer.AddAttributes(tab.HtmlAttributes);

            writer.RenderBeginTag("div");             // root div
            {
                if (tab.Position == TabsPosition.Below && hasContent)
                {
                    RenderTabContent(writer);
                }

                if (isStacked)
                {
                    writer.AddAttribute("class", "col-lg-auto nav-aside");
                    writer.RenderBeginTag("aside");                     // opening left/right tabs col
                }

                // Tabs
                var ulAttrs = new Dictionary <string, object>();
                ulAttrs.AppendCssClass("nav");

                if (tab.Style == TabsStyle.Tabs)
                {
                    ulAttrs.AppendCssClass("nav-tabs");
                }
                else if (tab.Style == TabsStyle.Pills)
                {
                    ulAttrs.AppendCssClass("nav-pills");
                }
                else if (tab.Style == TabsStyle.Material)
                {
                    ulAttrs.AppendCssClass("nav-tabs nav-tabs-line");
                }

                if (tab.HideSingleItem && tab.Items.Count == 1)
                {
                    ulAttrs.AppendCssClass("d-none");
                }

                if (isStacked)
                {
                    ulAttrs.AppendCssClass("flex-row flex-lg-column");
                }
                writer.AddAttributes(ulAttrs);

                string selector   = null;
                var    loadedTabs = new List <string>();
                writer.RenderBeginTag("ul");
                {
                    // enable smart tab selection
                    if (tab.SmartTabSelection)
                    {
                        selector = TrySelectRememberedTab();
                    }

                    int i = 1;
                    foreach (var item in tab.Items)
                    {
                        var loadedTabName = this.RenderItemLink(writer, item, i);
                        if (loadedTabName.HasValue())
                        {
                            loadedTabs.Add(loadedTabName);
                        }
                        i++;
                    }

                    writer.RenderEndTag();                     // ul
                }

                if (isStacked)
                {
                    writer.RenderEndTag();                     // closing left/right tabs col
                }

                // TODO: (mc) render right positioned tabs also
                if (tab.Position != TabsPosition.Below && hasContent)
                {
                    if (isStacked)
                    {
                        writer.AddAttribute("class", "col-lg nav-content");
                        writer.RenderBeginTag("div");                         // opening left/right content col
                    }

                    RenderTabContent(writer);

                    if (isStacked)
                    {
                        writer.RenderEndTag();                         // closing left/right content col
                    }
                }

                if (selector != null)
                {
                    writer.WriteLine(
                        @"<script>
	$(function() {{
		_.delay(function() {{
			$(""{0}"").trigger(""show"");
		}}, 100);
	}})
</script>".FormatInvariant(selector));
                }

                if (loadedTabs.Count > 0)
                {
                    foreach (var tabName in loadedTabs)
                    {
                        writer.WriteLine("<input type='hidden' class='loaded-tab-name' name='LoadedTabs' value='{0}' />", tabName);
                    }
                }

                writer.RenderEndTag();                 // div.tabbable

                if (tab.IsResponsive /* && tab.TabContentHeaderContent != null*/)
                {
                    writer.WriteLine(@"<script>$(function() {{ $('#{0}').responsiveNav(); }})</script>".FormatInvariant(tab.Id));
                }
            }
        }
Example #10
0
        protected virtual string RenderItemLink(HtmlTextWriter writer, Tab item, int index)
        {
            string temp          = "";
            string loadedTabName = null;

            // <li [class="active [hide]"]><a href="#{id}" data-toggle="tab">{text}</a></li>
            if (item.Selected)
            {
                item.HtmlAttributes.AppendCssClass("active");
            }
            else
            {
                if (!item.Visible)
                {
                    item.HtmlAttributes.AppendCssClass("hide");
                }
            }

            if (item.Pull == TabPull.Right)
            {
                item.HtmlAttributes.AppendCssClass("pull-right");
            }

            writer.AddAttributes(item.HtmlAttributes);

            writer.RenderBeginTag("li");
            {
                var itemId = "#" + BuildItemId(item, index);

                if (item.Content != null)
                {
                    writer.AddAttribute("href", itemId);
                    writer.AddAttribute("data-toggle", "tab");
                    writer.AddAttribute("data-loaded", "true");
                    loadedTabName = GetTabName(item) ?? itemId;
                }
                else
                {
                    // no content, create real link instead
                    var url = item.GenerateUrl(base.ViewContext.RequestContext).NullEmpty();

                    if (url == null)
                    {
                        writer.AddAttribute("href", "#");
                    }
                    else
                    {
                        if (item.Ajax)
                        {
                            writer.AddAttribute("href", itemId);
                            writer.AddAttribute("data-ajax-url", url);
                            writer.AddAttribute("data-toggle", "tab");
                        }
                        else
                        {
                            writer.AddAttribute("href", url);
                        }
                    }
                }

                if (item.BadgeText.HasValue())
                {
                    item.LinkHtmlAttributes.AppendCssClass("clearfix");
                }

                writer.AddAttributes(item.LinkHtmlAttributes);
                writer.RenderBeginTag("a");
                {
                    // Tab Icon
                    if (item.Icon.HasValue())
                    {
                        writer.AddAttribute("class", item.Icon);
                        writer.RenderBeginTag("i");
                        writer.RenderEndTag();                         // i
                    }
                    else if (item.ImageUrl.HasValue())
                    {
                        var url = new UrlHelper(this.ViewContext.RequestContext);
                        writer.AddAttribute("src", url.Content(item.ImageUrl));
                        writer.AddAttribute("alt", "Icon");
                        writer.RenderBeginTag("img");
                        writer.RenderEndTag();                         // img
                    }
                    //writer.WriteEncodedText(item.Text);

                    // Badge
                    if (item.BadgeText.HasValue())
                    {
                        //writer.Write("&nbsp;");

                        // caption
                        writer.AddAttribute("class", "tab-caption");
                        writer.RenderBeginTag("span");
                        writer.WriteEncodedText(item.Text);
                        writer.RenderEndTag();                         // span > badge

                        // label
                        temp = "label";
                        if (item.BadgeStyle != BadgeStyle.Default)
                        {
                            temp += " label-" + item.BadgeStyle.ToString().ToLower();
                        }
                        if (base.Component.Position == TabsPosition.Left)
                        {
                            temp += " pull-right";                             // looks nicer
                        }
                        writer.AddAttribute("class", temp);
                        writer.RenderBeginTag("span");
                        writer.WriteEncodedText(item.BadgeText);
                        writer.RenderEndTag();                         // span > badge
                    }
                    else
                    {
                        writer.WriteEncodedText(item.Text);
                    }
                    writer.RenderEndTag();             // a
                }
                writer.RenderEndTag();                 // li
            }

            return(loadedTabName);
        }
Example #11
0
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var tab = base.Component;

            MoveSpecialTabToEnd(tab.Items);

            var hasContent = tab.Items.Any(x => x.Content != null || x.Ajax);
            var isTabbable = tab.Position != TabsPosition.Top;
            var urlHelper  = new UrlHelper(this.ViewContext.RequestContext);

            if (tab.Items.Count == 0)
            {
                return;
            }

            tab.HtmlAttributes.AppendCssClass("tabbable");

            if (isTabbable)
            {
                tab.HtmlAttributes.AppendCssClass("tabs-{0}".FormatInvariant(tab.Position.ToString().ToLower()));
            }

            if (tab.SmartTabSelection)
            {
                tab.HtmlAttributes.AppendCssClass("tabs-autoselect");
                tab.HtmlAttributes.Add("data-tabselector-href", urlHelper.Action("SetSelectedTab", "Common", new { area = "admin" }));
            }

            if (tab.OnAjaxBegin.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onbegin", tab.OnAjaxBegin);
            }

            if (tab.OnAjaxSuccess.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onsuccess", tab.OnAjaxSuccess);
            }

            if (tab.OnAjaxFailure.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-onfailure", tab.OnAjaxFailure);
            }

            if (tab.OnAjaxComplete.HasValue())
            {
                tab.HtmlAttributes.Add("data-ajax-oncomplete", tab.OnAjaxComplete);
            }

            writer.AddAttributes(tab.HtmlAttributes);

            writer.RenderBeginTag("div");             // root div
            {
                if (tab.Position == TabsPosition.Below && hasContent)
                {
                    RenderTabContent(writer);
                }

                // Tabs
                var ulAttrs = new Dictionary <string, object>();
                ulAttrs.AppendCssClass("nav nav-{0}".FormatInvariant(tab.Style.ToString().ToLower()));
                if (tab.Stacked)
                {
                    ulAttrs.AppendCssClass("nav-stacked");
                }
                writer.AddAttributes(ulAttrs);

                string selector   = null;
                var    loadedTabs = new List <string>();
                writer.RenderBeginTag("ul");
                {
                    // enable smart tab selection
                    if (tab.SmartTabSelection)
                    {
                        selector = TrySelectRememberedTab();
                    }

                    int i = 1;
                    foreach (var item in tab.Items)
                    {
                        var loadedTabName = this.RenderItemLink(writer, item, i);
                        if (loadedTabName.HasValue())
                        {
                            loadedTabs.Add(loadedTabName);
                        }
                        i++;
                    }

                    writer.RenderEndTag();                     // ul
                }

                if (tab.Position != TabsPosition.Below && hasContent)
                {
                    RenderTabContent(writer);
                }

                if (selector != null)
                {
                    writer.WriteLine(
                        @"<script>
	$(function() {{
		_.delay(function() {{
			$('{0}').trigger('show');
		}}, 100);
	}})
</script>".FormatInvariant(selector));
                }

                if (loadedTabs.Count > 0)
                {
                    foreach (var tabName in loadedTabs)
                    {
                        writer.WriteLine("<input type='hidden' class='loaded-tab-name' name='LoadedTabs' value='{0}' />", tabName);
                    }
                }

                writer.RenderEndTag();                 // div.tabbable
            }
        }
Example #12
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 #13
0
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var pager = base.Component;

            if (pager.Model.TotalPages <= 1)
            {
                return; // one page is no page.
            }
            var items = CreateItemList();

            // Alignment
            if (pager.Alignment == PagerAlignment.Right)
            {
                pager.HtmlAttributes.AppendCssClass("text-right");
            }
            else if (pager.Alignment == PagerAlignment.Centered)
            {
                pager.HtmlAttributes.AppendCssClass("text-center");
            }

            writer.AddAttributes(pager.HtmlAttributes);
            writer.AddAttribute("id", pager.Id);
            writer.AddAttribute("aria-label", "Page navigation");
            writer.RenderBeginTag("nav");

            if (pager.ShowSummary && pager.Model.TotalPages > 1)
            {
                writer.AddAttribute("class", "pagination-summary float-left");
                writer.RenderBeginTag("div");
                writer.WriteEncodedText(pager.CurrentPageText.FormatInvariant(pager.Model.PageNumber, pager.Model.TotalPages, pager.Model.TotalCount));
                writer.RenderEndTag(); // div
            }

            var ulAttrs = new RouteValueDictionary();

            ulAttrs.AppendCssClass(pager.Style == PagerStyle.Pagination ? "pagination" : "pagination" /* formerly "pager" */); // TODO: (mc) Seems there's no "pager" in BS4 anymore

            // Size
            if (pager.Size == PagerSize.Large)
            {
                ulAttrs.AppendCssClass("pagination-lg");
            }
            else if (pager.Size == PagerSize.Small)
            {
                ulAttrs.AppendCssClass("pagination-sm");
            }
            else if (pager.Size == PagerSize.Mini)
            {
                ulAttrs.AppendCssClass("pagination-xs");
            }

            // BS 4 alignment
            if (pager.Alignment == PagerAlignment.Centered)
            {
                ulAttrs.AppendCssClass("justify-content-center");
            }
            else if (pager.Alignment == PagerAlignment.Right)
            {
                ulAttrs.AppendCssClass("justify-content-end");
            }

            writer.AddAttributes(ulAttrs);
            writer.RenderBeginTag("ul");

            foreach (var item in items)
            {
                this.RenderItem(writer, item); // create li
            }

            writer.RenderEndTag(); // ul
            writer.RenderEndTag(); // div
        }
Example #14
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
        }
Example #15
0
        protected override void WriteHtmlCore(HtmlTextWriter writer)
        {
            var win = base.Component;

            win.HtmlAttributes.AppendCssClass("modal");
            win.HtmlAttributes["role"]            = "dialog";
            win.HtmlAttributes["tabindex"]        = "-1";
            win.HtmlAttributes["aria-labelledby"] = win.Id + "Label";

            if (win.Width.GetValueOrDefault() > 0)
            {
                win.HtmlAttributes["style"] = "width:{0}px; margin-left:-{1}px".FormatInvariant(win.Width.Value, Math.Ceiling((double)(win.Width.Value / 2)));
            }

            if (!win.Visible)
            {
                win.HtmlAttributes["aria-hidden"] = "true";
                win.HtmlAttributes.AppendCssClass("hide");
            }
            else
            {
                win.HtmlAttributes["aria-hidden"] = "false";
            }

            if (win.Fade)
            {
                win.HtmlAttributes.AppendCssClass("fade");
                if (win.Visible)
                {
                    win.HtmlAttributes.AppendCssClass("in");
                }
            }

            // other options
            win.HtmlAttributes["data-backdrop"] = win.BackDrop.ToString().ToLower();
            win.HtmlAttributes["data-keyboard"] = win.CloseOnEscapePress.ToString().ToLower();
            //win.HtmlAttributes["data-show"] = win.Visible.ToString().ToLower();
            if (win.ContentUrl.HasValue())
            {
                win.HtmlAttributes["data-remote"] = win.ContentUrl;
            }

            writer.AddAttributes(win.HtmlAttributes);
            writer.RenderBeginTag("div"); // root div

            // HEADER
            if (win.ShowClose && win.Title.HasValue())
            {
                this.RenderHeader(writer);
            }

            // BODY
            this.RenderBody(writer);

            // FOOTER
            if (win.FooterContent != null)
            {
                this.RenderFooter(writer);
            }

            writer.RenderEndTag(); // div.modal
        }