예제 #1
0
        protected override void OnStart(TextWriter writer)
        {
            // Get the Navbar ID and use it to set this id
            if (string.IsNullOrWhiteSpace(((ITag)this).GetAttribute("id")))
            {
                INavbar navbar = GetComponent <INavbar>();
                if (navbar != null)
                {
                    this.SetId(navbar.GetAttribute("id") + "-collapse");
                }
            }

            base.OnStart(writer);
        }
예제 #2
0
        protected override void OnStart(TextWriter writer)
        {
            // Set the data-target
            if (string.IsNullOrWhiteSpace(DataTarget))
            {
                // Get the Navbar ID and use it to set the data-target
                string  navbarId = string.Empty;
                INavbar navbar   = GetComponent <INavbar>();
                if (navbar != null)
                {
                    navbarId = navbar.GetAttribute("id");
                }
                DataTarget = "#" + navbarId + "-collapse";
            }
            this.MergeAttribute("data-target", DataTarget);

            // Make sure we're in a header, but only if we're also in a navbar
            INavbarHeader header = GetComponent <INavbarHeader>();

            if (GetComponent <INavbar>() != null && header == null)
            {
                new NavbarHeader <THelper>(Helper).Start(writer);
            }
            else if (header != null)
            {
                header.HasToggle = true;
            }

            base.OnStart(writer);

            Helper.Span().AddCss(Css.SrOnly).SetText("Toggle Navigation").StartAndFinish(writer);
            if (Hamburger)
            {
                Helper.Span().AddCss(Css.IconBar).StartAndFinish(writer);
                Helper.Span().AddCss(Css.IconBar).StartAndFinish(writer);
                Helper.Span().AddCss(Css.IconBar).StartAndFinish(writer);
            }
        }