示例#1
0
 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);
         }
     }
 }
示例#2
0
 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = "p";
     output.AddCssClass("form-control-static");
     if (!string.IsNullOrEmpty(Label))
     {
         output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, FormContext));
     }
     if (FormGroupContext != null)
     {
         FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     }
     else if (FormContext != null)
     {
         FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     }
 }
示例#3
0
 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output)
 {
     output.AddCssClass("form-control");
     if (FormGroupContext != null)
     {
         FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     }
     else if (FormContext != null)
     {
         FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     }
     if (!string.IsNullOrEmpty(Label))
     {
         output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, FormContext));
     }
     if (!string.IsNullOrEmpty(HelpText))
     {
         output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
     }
     if (Size != null && Size != BootstrapTagHelpers.Size.Default)
     {
         output.AddCssClass("input-" + Size.Value.GetDescription());
     }
 }
示例#4
0
        private void ProcessNonCheckControl(TagHelperOutput output)
        {
            output.AddCssClass("form-control");
            if (!string.IsNullOrEmpty(PostAddonText) || !string.IsNullOrEmpty(PreAddonText))
            {
                if ((Size ?? BootstrapTagHelpers.Size.Default) != BootstrapTagHelpers.Size.Default)
                {
                    var size = Size == BootstrapTagHelpers.Size.Large
                                   ? BootstrapTagHelpers.Size.Large
                                   : BootstrapTagHelpers.Size.Small;
                    output.PreElement.PrependHtml($"<div class=\"input-group input-group-{size.GetDescription()}\">");
                }
                else
                {
                    output.PreElement.PrependHtml("<div class=\"input-group\">");
                }
                if (!string.IsNullOrEmpty(PreAddonText))
                {
                    output.PreElement.AppendHtml(AddonTagHelper.GenerateAddon(PreAddonText));
                }
                if (!string.IsNullOrEmpty(PostAddonText))
                {
                    output.PostElement.AppendHtml(AddonTagHelper.GenerateAddon(PostAddonText));
                }
                output.PostElement.AppendHtml("</div>");
            }
            else if (Size != null && Size != BootstrapTagHelpers.Size.Default)
            {
                output.AddCssClass("input-" + Size.Value.GetDescription());
            }
            if (!string.IsNullOrEmpty(HelpText))
            {
                if (InputGroupContext != null)
                {
                    InputGroupContext.Output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
                }
                else
                {
                    output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
                }
            }
            if (InputGroupContext == null)
            {
                if (FormGroupContext != null)
                {
                    FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
                }
                else if (FormContext != null)
                {
                    FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
                }
            }
            if (!string.IsNullOrEmpty(Label))
            {
                if (InputGroupContext == null)
                {
                    output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, Id, FormContext));
                }
                else
                {
                    InputGroupContext.Output.PreElement.Prepend(
                        LabelTagHelper.GenerateLabel(
                            Label, Id,
                            FormContext));
                }
            }
            if (FormGroupContext != null && FormGroupContext.HasFeedback &&
                FormGroupContext.ValidationContext != null)
            {
                string cssClass;
                string srText;
                switch (FormGroupContext.ValidationContext.Value)
                {
                case ValidationContext.Success:
                    cssClass = "ok";
                    srText   = Ressources.ValidationSuccess;
                    break;

                case ValidationContext.Warning:
                    cssClass = "warning-sign";
                    srText   = Ressources.ValidationWarning;
                    break;

                case ValidationContext.Error:
                    cssClass = "remove";
                    srText   = Ressources.ValidationError;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                output.PostElement.PrependHtml(
                    $"<span class=\"glyphicon glyphicon-{cssClass} form-control-feedback\" aria-hidden=\"true\"></span>");
                output.PostElement.PrependHtml($"<span class=\"sr-only\">({srText})</span>");
            }
        }
示例#5
0
 public void WrapInDivForHorizontalForm(TagHelperOutput output, bool hasLabel)
 {
     FormContext?.WrapInDivForHorizontalForm(output, hasLabel || HasLabel);
 }