public override void Init(TagHelperContext context) { base.Init(context); if (context.HasContextItem <ButtonGroupTagHelper>()) { var buttonGroupContext = context.GetContextItem <ButtonGroupTagHelper>(); this.Size = buttonGroupContext.Size; if (!this.Context.HasValue) { this.Context = buttonGroupContext.Context; } if (buttonGroupContext.Vertical && this.Splitted) { throw new Exception("Splitted dropdowns are not supported inside vertical button groups"); } } else if (context.HasContextItem <ButtonToolbarTagHelper>()) { var buttonToolbarContext = context.GetContextItem <ButtonToolbarTagHelper>(); if (!this.Context.HasValue) { this.Context = buttonToolbarContext.Context; } if (!this.Size.HasValue) { this.Size = buttonToolbarContext.Size; } } }
public override void Init(TagHelperContext context) { base.Init(context); if (context.HasContextItem <ButtonGroupTagHelper>()) { var buttonGroupContext = context.GetContextItem <ButtonGroupTagHelper>(); this.Button = true; this.ButtonGroupJustified = buttonGroupContext.Justified; this.Size = this.ButtonGroupJustified ? buttonGroupContext.Size : BootstrapTagHelpers.Size.Default; if (!this.Context.HasValue) { this.Context = buttonGroupContext.Context; } } else if (context.HasContextItem <ButtonToolbarTagHelper>()) { var buttonToolbarContext = context.GetContextItem <ButtonToolbarTagHelper>(); this.Button = true; this.WrapInButtonGroup = true; if (!this.Context.HasValue) { this.Context = buttonToolbarContext.Context; } if (!this.Size.HasValue) { this.Size = buttonToolbarContext.Size; } } }
protected override void RenderProcess(TagHelperContext context, TagHelperOutput output) { output.TagName = "a"; output.AddCssClass(!context.HasContextItem <NavbarDropdownTagHelper>() ? "nav-link" : "dropdown-item"); // Disabled if (this.IsDisabled) { output.AddCssClass("disabled"); } // Active if (this.Active && context.HasContextItem <NavbarDropdownTagHelper>()) { output.AddCssClass("active"); output.PostContent.AppendHtml($"<span class=\"sr-only\">({Resources.Navbar_Current})</span>"); } else if (this.Active && !context.HasContextItem <NavbarDropdownTagHelper>()) { output.PostContent.AppendHtml($"<span class=\"sr-only\">({Resources.Navbar_Current})</span>"); output.WrapHtmlOutside($"<li class=\"nav-item active\">", "</li>"); } else if (!context.HasContextItem <NavbarDropdownTagHelper>()) { output.WrapHtmlOutside($"<li class=\"nav-item\">", "</li>"); } }
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { output.Attributes.Add("role", "group"); if (context.HasContextItem <InputGroupTagHelper>()) { Size = BootstrapTagHelpers.Size.Default; if (!context.HasContextItem <AddonTagHelper>()) { output.TagName = "span"; output.AddCssClass("input-group-btn"); } context.RemoveContextItem <InputGroupTagHelper>(); } else { output.TagName = "div"; if (this.Vertical) { output.AddCssClass("btn-group-vertical"); } else { output.AddCssClass("btn-group"); } if (this.Size.HasValue) { output.AddCssClass("btn-group-" + this.Size.Value.GetDescription()); } if (this.Justified) { output.AddCssClass("btn-group-justified"); } } }
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { output.AddCssClass("btn"); output.AddCssClass("btn-" + (Context ?? ButtonContext.Default).ToString().ToLower()); if (context.HasContextItem <InputGroupTagHelper>()) { this.Size = BootstrapTagHelpers.Size.Default; if (!context.HasContextItem <AddonTagHelper>()) { output.PreElement.PrependHtml("<span class=\"input-group-btn\">"); output.PostElement.AppendHtml("</span>"); } } if (WrapInButtonGroup || !output.TagName.Equals("a", StringComparison.CurrentCultureIgnoreCase) && ButtonGroupJustified) { if (Size.HasValue && Size.Value != BootstrapTagHelpers.Size.Default) { output.PreElement.SetHtmlContent( $"<div class=\"btn-group btn-group-{Size.Value.GetDescription()}\" role=\"group\">"); } else { output.PreElement.SetHtmlContent( $"<div class=\"btn-group\" role=\"group\">"); } output.PostElement.SetHtmlContent("</div>"); } else if (Size.HasValue && Size.Value != BootstrapTagHelpers.Size.Default) { output.AddCssClass("btn-" + Size.Value.GetDescription()); } if (BlockStyle) { output.AddCssClass("btn-block"); } if (Pressed) { output.AddAriaAttribute("pressed", "true"); output.AddCssClass("active"); } if (Disabled) { if (output.TagName == "a") { output.AddCssClass("disabled"); if (context.AllAttributes.ContainsName("href")) { output.Attributes.RemoveAll("href"); output.Attributes.Add("data-href", context.AllAttributes["href"].Value); } } output.MergeAttribute("role", "button"); } }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (context.HasContextItem <ListGroupTagHelper>()) { base.Process(context, output); } }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (context.HasContextItem <ModalHeaderTagHelper>()) { base.Process(context, output); } }
public override void Init(TagHelperContext context) { base.Init(context); this.IsInLabel = context.HasContextItem <LabelTagHelper>(); Size = Size ?? FormContext?.ControlSize; if (FormGroupContext != null) { FormGroupContext.HasLabel = FormGroupContext.HasLabel || !string.IsNullOrEmpty(Label); } }
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { if (context.HasContextItem <MediaListTagHelper>()) { output.TagName = "li"; context.RemoveContextItem <MediaListTagHelper>(); } else { output.TagName = "div"; } output.AddCssClass("media"); }
private void ProcessCheckControl(TagHelperContext context, TagHelperOutput output) { if (this.InputGroupContext != null) { output.PreElement.Append(this.Label); if (!context.HasContextItem <AddonTagHelper>()) { output.PreElement.AppendHtml("<span class=\"input-group-addon\">"); output.PostElement.PrependHtml("</span>"); } } else if (this.IsInLabel) { output.PostElement.Append(this.Label); } else { LabelTagHelper.WrapInLabel(output, this.Label, null, this.FormContext); } if (!string.IsNullOrEmpty(HelpText)) { if (InputGroupContext != null) { InputGroupContext.Output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText)); } else { output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText)); } } if (!IsInLabel) { output.PreElement.PrependHtml( FormContext?.Inline ?? false ? $"<div class=\"{Type.ToLower()}-inline\">" : $"<div class=\"{Type.ToLower()}\">"); output.PostElement.AppendHtml("</div>"); if (FormGroupContext != null) { FormGroupContext.WrapInDivForHorizontalForm(output, false); } else if (FormContext != null) { FormContext.WrapInDivForHorizontalForm(output, false); } } }
public override void Init(TagHelperContext context) { base.Init(context); if (this.TabsContext.ActiveIndex == this.TabsContext.CurrentIndex) { this.Active = true; } if (context.HasContextItem <TabsPaneGroupTagHelper>()) { var paneGroupContext = context.GetContextItem <TabsPaneGroupTagHelper>(); paneGroupContext.Panes.Add(this); if (this.Active) { paneGroupContext.Active = true; } } else { this.TabsContext.Panes.Add(this); } this.DataToggleTarget = this.TabsContext.Pills ? "pill" : "tab"; }
/// <summary> /// Determines whether the tag helper context [has context item] of the specified type. /// </summary> /// <typeparam name="T">The type of the context item.</typeparam> /// <param name="context">The tag helper context.</param> /// <param name="useInherited">if set to <c>true</c> [use inherited].</param> /// <returns> /// <c>true</c> if [has context item] [the specified context]; otherwise, <c>false</c>. /// </returns> public static bool HasContextItem <T>(this TagHelperContext context, bool useInherited) { return(context.HasContextItem(typeof(T), useInherited)); }
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) { var hasNavContext = context.HasContextItem <NavPillsTagHelper>() || context.HasContextItem <NavTabsTagHelper>() || context.HasContextItem <NavbarTagHelper>(); if (hasNavContext) { output.TagName = "li"; output.Attributes.Add("role", "presentation"); Context = null; Splitted = false; } else { output.TagName = "div"; output.AddCssClass("btn-group"); if (Size.HasValue && Size != BootstrapTagHelpers.Size.Default) { output.AddCssClass("btn-group-" + Size.Value.GetDescription()); } } if (context.HasContextItem <InputGroupTagHelper>()) { this.Size = BootstrapTagHelpers.Size.Default; if (!context.HasContextItem <AddonTagHelper>()) { output.TagName = "span"; output.AddCssClass("input-group-btn"); } } if (Dropup) { output.AddCssClass("dropup"); } var buttonBuilder = new TagBuilder(Href == null && !hasNavContext ? "button" : "a"); buttonBuilder.InnerHtml.AppendHtml(Text); if (!hasNavContext) { buttonBuilder.AddCssClass("btn"); buttonBuilder.AddCssClass("btn-" + (Context ?? ButtonContext.Default).ToString().ToLower()); if (Href == null) { buttonBuilder.Attributes.Add("type", "button"); } if (ButtonId != null) { buttonBuilder.Attributes.Add("id", ButtonId); } else { buttonBuilder.Attributes.Add("href", Href); if (!Splitted) { buttonBuilder.Attributes.Add("role", "button"); } } } else { buttonBuilder.Attributes.Add("href", Href); } if (Splitted) { output.PreContent.AppendHtml(buttonBuilder); buttonBuilder = new TagBuilder("button") { Attributes = { { "type", "button" }, { "class", "btn btn-" + (Context ?? ButtonContext.Default).ToString().ToLower() } } }; } else { buttonBuilder.InnerHtml.AppendHtml(" "); } buttonBuilder.AddCssClass("dropdown-toggle"); buttonBuilder.Attributes.Add("data-toggle", "dropdown"); buttonBuilder.Attributes.Add("aria-haspopup", "true"); buttonBuilder.Attributes.Add("aria-expanded", "false"); buttonBuilder.InnerHtml.AppendHtml("<span class=\"caret\">"); output.PreContent.AppendHtml(buttonBuilder); output.PreContent.AppendHtml( RightAligned ? "<ul class=\"dropdown-menu dropdown-menu-right\">" : "<ul class=\"dropdown-menu\">"); output.PostContent.AppendHtml("</ul>"); }