コード例 #1
0
        internal IHtmlContent BuildTabNav(TabsContext tabsContext)
        {
            var nav = new TagBuilder("ul");

            nav.Attributes.Add("class", NavClasses);

            nav.Attributes.Add("role", "tabnav");

            TagBuilder dropdownMenu = null;

            for (var i = 0; i < tabsContext.TabPanes.Count; i++)
            {
                var tab = tabsContext.TabPanes[i];

                var icon = tab.Item1.Icon.IsUsed() ? tab.Item1.Icon.ToIconContent() : "";

                var disabled = tab.Item1.IsDisabled ? "disabled" : "";

                if (Limit > i)
                {
                    var active = ActiveIndex == i ? "active" : "";

                    nav.InnerHtml.AppendHtml($@"<li class='nav-item'>
											        <a class='nav-link {active} {disabled}' data-toggle='tab' href='#{tab.Item1.Id}'>
                                                        {icon}
                                                        {tab.Item1.Name}
                                                    </a>
											    </li>"                                            );
                }
                else
                {
                    if (dropdownMenu == null)
                    {
                        dropdownMenu = new TagBuilder("div");

                        dropdownMenu.Attributes.Add("class", "dropdown-menu");
                    }

                    dropdownMenu.InnerHtml.AppendHtml($@"<a class='dropdown-item {disabled}' data-toggle='tab' href='#{tab.Item1.Id}'>
                                                             {icon}
                                                             {tab.Item1.Name}
                                                         </a>");
                }
            }

            if (dropdownMenu.IsNotNull())
            {
                var active = ActiveIndex >= Limit ? "active" : "";

                var dropdown = $@"<li class='nav-item dropdown'>
								    <a class='nav-link dropdown-toggle {active}' data-toggle='dropdown' href='javascript:;' role='button' aria-haspopup='true' aria-expanded='false'>{LimitText}</a>
								    {dropdownMenu.ToHtml()}
								  </li>"                                ;

                nav.InnerHtml.AppendHtml(dropdown);
            }

            return(nav);
        }
コード例 #2
0
        internal IHtmlContent BuildTabContent(TabsContext tabsContext)
        {
            var content = new TagBuilder("div");

            content.Attributes.Add("class", "tab-content");

            for (var i = 0; i < tabsContext.TabPanes.Count; i++)
            {
                var pane = (TagBuilder)tabsContext.TabPanes[i].Item2;

                var active = ActiveIndex == i ? "active" : "";

                pane.AddCssClass(active);

                content.InnerHtml.AppendHtml(pane);
            }

            return(content);
        }