internal Placeholder(BootstrapHelper helper, int width, int? height = null) : base(helper) { OutputEndTag = false; Width = width; Height = height; }
internal Input(BootstrapHelper helper, FormInputType inputType) : base(helper, "input", Css.FormControl) { OutputEndTag = false; Icon = Icon.None; MergeAttribute("type", inputType.GetDescription()); }
internal NavbarToggle(BootstrapHelper helper) : base(helper, "button", Css.NavbarToggle, "collapsed") { Hamburger = true; MergeAttribute("type", "button"); MergeAttribute("data-toggle", "collapse"); }
internal ProgressBar(BootstrapHelper helper) : base(helper, "div", Css.ProgressBar) { MergeAttribute("role", "progressbar"); Value = 50; Min = 0; Max = 100; }
internal PanelTitle(BootstrapHelper helper, string text, int headingLevel) : base(helper, "h" + headingLevel, Css.PanelTitle) { if (headingLevel < 1 || headingLevel > 6) { throw new ArgumentOutOfRangeException("headingLevel"); } TextContent = text; }
internal NavbarButton(BootstrapHelper helper) : base(helper, "button", Css.Btn, Css.BtnDefault, Css.NavbarBtn, Css.NavbarLeft) { MergeAttribute("type", "button"); }
internal Progress(BootstrapHelper helper) : base(helper, "div", Css.Progress) { }
public FormControlListFor(BootstrapHelper helper, bool editor, Expression <Func <TModel, IEnumerable <TValue> > > expression, ListType listType) : base(helper, editor, expression) { _listType = listType; }
internal ListGroupItem(BootstrapHelper helper) : base(helper, "a", Css.ListGroupItem) { }
internal Jumbotron(BootstrapHelper helper) : base(helper, "div", Css.Jumbotron) { }
internal Description(BootstrapHelper helper) : base(helper, "dd") { }
public static string RenderTextBox(HtmlHelper html, BootstrapTextBoxModel model, bool isPassword) { var combinedHtml = "{0}{1}{2}"; model.htmlAttributes.MergeHtmlAttributes(html.GetUnobtrusiveValidationAttributes(model.htmlFieldName, model.metadata)); model.htmlAttributes.AddOrMergeCssClass("class", "form-control"); if (!string.IsNullOrEmpty(model.id)) { model.htmlAttributes.Add("id", model.id); } if (model.tooltipConfiguration != null) { model.htmlAttributes.MergeHtmlAttributes(model.tooltipConfiguration.ToDictionary()); } if (model.tooltip != null) { model.htmlAttributes.MergeHtmlAttributes(model.tooltip.ToDictionary()); } if (model.typehead != null) { model.htmlAttributes.MergeHtmlAttributes(model.typehead.ToDictionary(html)); } // assign placeholder class if (!string.IsNullOrEmpty(model.placeholder)) { model.htmlAttributes.Add("placeholder", model.placeholder); } // assign size class model.htmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForInputSize(model.size)); if (model.disabled) { model.htmlAttributes.Add("disabled", "disabled"); } var widthlg = ""; if (model.InputWidthLg != 0) { var width = model.InputWidthLg.ToString(); widthlg = " col-lg-" + width; } var widthMd = ""; if (model.InputWidthMd != 0) { var width = model.InputWidthMd.ToString(); widthMd = " col-md-" + width; } var widthSm = ""; if (model.InputWidthSm != 0) { var width = model.InputWidthSm.ToString(); widthSm = " col-sm-" + width; } var widthXs = ""; if (model.InputWidthXs != 0) { var width = model.InputWidthXs.ToString(); widthXs = " col-xs-" + width; } var offsetlg = ""; if (model.InputOffsetLg != 0) { var offset = model.InputOffsetLg.ToString(); offsetlg = " col-lg-offset-" + offset; } var offsetMd = ""; if (model.InputOffsetMd != 0) { var offset = model.InputOffsetMd.ToString(); offsetMd = " col-md-offset-" + offset; } var offsetSm = ""; if (model.InputOffsetSm != 0) { var offset = model.InputOffsetSm.ToString(); offsetSm = " col-sm-offset-" + offset; } var offsetXs = ""; if (model.InputOffsetXs != 0) { var offset = model.InputOffsetXs.ToString(); offsetXs = " col-xs-offset-" + offset; } var widthoffset = widthlg + widthMd + widthSm + widthXs + offsetlg + offsetMd + offsetSm + offsetXs; // account for appendString, prependString, and AppendButtons if (!string.IsNullOrEmpty(model.prependString) || !string.IsNullOrEmpty(model.appendString) || model.prependButtons.Any() || model.appendButtons.Any() || !string.IsNullOrEmpty(model.iconPrepend) || !string.IsNullOrEmpty(model.iconAppend) || !string.IsNullOrEmpty(model.iconPrependCustomClass) || !string.IsNullOrEmpty(model.iconAppendCustomClass) || !string.IsNullOrEmpty(widthoffset)) { var appendPrependContainer = new TagBuilder("div"); var addOnPrependString = ""; var addOnAppendString = ""; var addOnPrependButtons = ""; var addOnAppendButtons = ""; var addOnPrependIcon = ""; var addOnAppendIcon = ""; var addOn = new TagBuilder("span"); addOn.AddCssClass("input-group-addon"); if (!string.IsNullOrEmpty(model.prependString)) { appendPrependContainer.AddOrMergeCssClass("input-group"); addOn.InnerHtml = model.prependString; addOnPrependString = addOn.ToString(); } if (!string.IsNullOrEmpty(model.appendString)) { appendPrependContainer.AddOrMergeCssClass("input-group"); addOn.InnerHtml = model.appendString; addOnAppendString = addOn.ToString(); } if (model.prependButtons.Count > 0) { appendPrependContainer.AddOrMergeCssClass("input-group"); var span = new TagBuilder("span"); span.AddOrMergeCssClass("input-group-btn"); model.prependButtons.ForEach(x => addOnPrependButtons += x.ToHtmlString()); span.InnerHtml = addOnPrependButtons; addOnPrependButtons = span.ToString(); } if (model.appendButtons.Count > 0) { appendPrependContainer.AddOrMergeCssClass("input-group"); var span = new TagBuilder("span"); span.AddOrMergeCssClass("input-group-btn"); model.appendButtons.ForEach(x => addOnAppendButtons += x.ToHtmlString()); span.InnerHtml = addOnAppendButtons; addOnAppendButtons = span.ToString(); } if (!string.IsNullOrEmpty(model.iconPrepend)) { appendPrependContainer.AddOrMergeCssClass("input-icon icon-left"); addOnPrependIcon = new BootstrapIcon(model.iconPrepend, model.iconPrependIsWhite).HtmlAttributes(new { @class = model.prependIconStyle }).ToHtmlString(); } if (!string.IsNullOrEmpty(model.iconAppend)) { appendPrependContainer.AddOrMergeCssClass("input-icon icon-right"); addOnAppendIcon = new BootstrapIcon(model.iconAppend, model.iconAppendIsWhite).HtmlAttributes(new { @class = model.appendIconStyle }).ToHtmlString(); } if (!string.IsNullOrEmpty(model.iconPrependCustomClass)) { appendPrependContainer.AddOrMergeCssClass("input-prepend"); var i = new TagBuilder("i"); i.AddCssClass(model.iconPrependCustomClass); addOn.InnerHtml = i.ToString(TagRenderMode.Normal); addOnPrependIcon = addOn.ToString(); } if (!string.IsNullOrEmpty(model.iconAppendCustomClass)) { appendPrependContainer.AddOrMergeCssClass("input-append"); var i = new TagBuilder("i"); i.AddCssClass(model.iconAppendCustomClass); addOn.InnerHtml = i.ToString(TagRenderMode.Normal); addOnAppendIcon = addOn.ToString(); } appendPrependContainer.AddOrMergeCssClass(widthlg + widthMd + widthSm + widthXs); appendPrependContainer.AddOrMergeCssClass(offsetlg + offsetMd + offsetSm + offsetXs); switch (model.size) { case InputSize.XSmall: appendPrependContainer.AddOrMergeCssClass("input-group-xs"); break; case InputSize.Small: appendPrependContainer.AddOrMergeCssClass("input-group-sm"); break; case InputSize.Large: appendPrependContainer.AddOrMergeCssClass("input-group-lg"); break; case InputSize.XLarge: appendPrependContainer.AddOrMergeCssClass("input-group-xl"); break; } appendPrependContainer.InnerHtml = addOnPrependButtons + addOnPrependString + "{0}" + addOnPrependIcon + addOnAppendString + addOnAppendIcon + addOnAppendButtons + "{1}"; combinedHtml = appendPrependContainer.ToString(TagRenderMode.Normal) + "{2}"; } // build html for input var input = isPassword ? html.Password(model.htmlFieldName, null, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString() : html.TextBox(model.htmlFieldName, model.value, model.format, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString(); var helpText = model.helpText != null?model.helpText.ToHtmlString() : string.Empty; var validationMessage = ""; if (model.displayValidationMessage) { var validation = html.ValidationMessage(model.htmlFieldName).ToHtmlString(); validationMessage = new BootstrapHelpText(validation, model.validationMessageStyle).ToHtmlString(); } return(MvcHtmlString.Create(string.Format(combinedHtml, input, helpText, validationMessage)).ToString()); }
protected PanelSection(BootstrapHelper helper, params string[] cssClasses) : base(helper, "div", cssClasses) { }
public static string RenderPassword(HtmlHelper html, BootstrapTextBoxModel model) { if (model == null || string.IsNullOrEmpty(model.htmlFieldName)) { return(null); } string combinedHtml = "{0}{1}{2}"; if (!string.IsNullOrEmpty(model.id)) { model.htmlAttributes.Add("id", model.id); } if (model.tooltipConfiguration != null) { model.htmlAttributes.AddRange(model.tooltipConfiguration.ToDictionary()); } // assign placeholder class if (!string.IsNullOrEmpty(model.placeholder)) { model.htmlAttributes.Add("placeholder", model.placeholder); } // assign size class model.htmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForInputSize(model.size)); // build html for input var input = html.Password(model.htmlFieldName, model.value, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString(); // account for appendString, prependString, and AppendButtons TagBuilder appendPrependContainer = new TagBuilder("div"); if (!string.IsNullOrEmpty(model.prependString) | !string.IsNullOrEmpty(model.appendString) | model.appendButtons.Count() > 0) { string addOnPrependString = ""; string addOnAppendString = ""; string addOnPrependButtons = ""; string addOnAppendButtons = ""; TagBuilder addOn = new TagBuilder("span"); addOn.AddCssClass("add-on"); if (!string.IsNullOrEmpty(model.prependString)) { appendPrependContainer.AddOrMergeCssClass("input-prepend"); addOn.InnerHtml = model.prependString; addOnPrependString = addOn.ToString(); } if (!string.IsNullOrEmpty(model.appendString)) { appendPrependContainer.AddOrMergeCssClass("input-append"); addOn.InnerHtml = model.appendString; addOnAppendString = addOn.ToString(); } if (model.appendButtons.Count() > 0) { appendPrependContainer.AddOrMergeCssClass("input-append"); model.appendButtons.ForEach(x => addOnAppendButtons += x.ToHtmlString()); } if (model.prependButtons.Count() > 0) { appendPrependContainer.AddOrMergeCssClass("input-append"); model.prependButtons.ForEach(x => addOnPrependButtons += x.ToHtmlString()); } appendPrependContainer.InnerHtml = addOnPrependButtons + addOnPrependString + "{0}" + addOnAppendString + addOnAppendButtons; combinedHtml = appendPrependContainer.ToString(TagRenderMode.Normal) + "{1}{2}"; } string helpText = model.helpText != null?model.helpText.ToHtmlString() : string.Empty; string validationMessage = ""; if (model.displayValidationMessage) { string validation = html.ValidationMessage(model.htmlFieldName).ToHtmlString(); validationMessage = new BootstrapHelpText(validation, model.validationMessageStyle).ToHtmlString(); } return(MvcHtmlString.Create(string.Format(combinedHtml, input, validationMessage, helpText)).ToString()); }
internal TextArea(BootstrapHelper helper) : base(helper, "textarea", Css.FormControl) { }
public BootstrapError(T curve, BootstrapHelper <U> helper, int segment) { curve_ = curve; helper_ = helper; segment_ = segment; }
internal Badge(BootstrapHelper helper) : base(helper, "span", Css.Badge) { }
internal NavbarForm(BootstrapHelper helper) : base(helper, Css.NavbarForm, Css.NavbarLeft) { }
internal TableBodySection(BootstrapHelper helper) : base(helper, "tbody") { }
internal IconSpan(BootstrapHelper helper, string cssClass, Icon icon) : base(helper, "span", cssClass, icon.GetDescription()) { }
internal InputButton(BootstrapHelper helper, ButtonType buttonType) : base(helper, "input", Css.Btn, Css.BtnDefault) { OutputEndTag = false; MergeAttribute("type", buttonType.GetDescription()); }
internal IconSpan(BootstrapHelper helper, string cssClass, string icon) : base(helper, "span", cssClass, icon) { }
internal Tab(BootstrapHelper helper) : base(helper) { }
public static string RenderSelectElement(HtmlHelper html, BootstrapSelectElementModel model, BootstrapInputType inputType) { if (model == null || string.IsNullOrEmpty(model.htmlFieldName) || model.selectList == null) { return(null); } string combinedHtml = "{0}{1}{2}"; if (model.selectedValue != null) { foreach (var item in model.selectList) { if (item.Value == model.selectedValue.ToString()) { item.Selected = true; } } } if (model.tooltipConfiguration != null) { model.htmlAttributes.AddRange(model.tooltipConfiguration.ToDictionary()); } if (!string.IsNullOrEmpty(model.id)) { model.htmlAttributes.AddOrReplace("id", model.id); } // assign size class model.htmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForInputSize(model.size)); // build html for input string input = string.Empty; if (inputType == BootstrapInputType.DropDownList) { input = html.DropDownList(model.htmlFieldName, model.selectList, model.optionLabel, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString(); } if (inputType == BootstrapInputType.ListBox) { input = html.ListBox(model.htmlFieldName, model.selectList, model.htmlAttributes.FormatHtmlAttributes()).ToHtmlString(); } // account for appendString, prependString, and AppendButtons TagBuilder appendPrependContainer = new TagBuilder("div"); if (!string.IsNullOrEmpty(model.prependString) | !string.IsNullOrEmpty(model.appendString) | model.appendButtons.Count() > 0) { string addOnPrependString = ""; string addOnAppendString = ""; string addOnPrependButtons = ""; string addOnAppendButtons = ""; TagBuilder addOn = new TagBuilder("span"); addOn.AddCssClass("add-on"); if (!string.IsNullOrEmpty(model.prependString)) { appendPrependContainer.AddOrMergeCssClass("input-prepend"); addOn.InnerHtml = model.prependString; addOnPrependString = addOn.ToString(); } if (!string.IsNullOrEmpty(model.appendString)) { appendPrependContainer.AddOrMergeCssClass("input-append"); addOn.InnerHtml = model.appendString; addOnAppendString = addOn.ToString(); } if (model.appendButtons.Count() > 0) { appendPrependContainer.AddOrMergeCssClass("input-append"); ((List <BootstrapButton>)model.appendButtons).ForEach(x => addOnAppendButtons += x.ToHtmlString()); } if (model.prependButtons.Count() > 0) { appendPrependContainer.AddOrMergeCssClass("input-append"); ((List <BootstrapButton>)model.prependButtons).ForEach(x => addOnPrependButtons += x.ToHtmlString()); } appendPrependContainer.InnerHtml = addOnPrependButtons + addOnPrependString + "{0}" + addOnAppendString + addOnAppendButtons; combinedHtml = appendPrependContainer.ToString(TagRenderMode.Normal) + "{1}{2}"; } string helpText = model.helpText != null?model.helpText.ToHtmlString() : string.Empty; string validationMessage = ""; if (model.displayValidationMessage) { string validation = html.ValidationMessage((string)model.htmlFieldName).ToHtmlString(); validationMessage = new BootstrapHelpText(validation, model.validationMessageStyle).ToHtmlString(); } return(MvcHtmlString.Create(string.Format(combinedHtml, input, validationMessage, helpText)).ToString()); }
internal SelectOption(BootstrapHelper helper) : base(helper, "option") { }
protected NavbarSection(BootstrapHelper helper, string tagName, params string[] cssClasses) : base(helper, tagName, cssClasses) { }
internal FormButton(BootstrapHelper helper, ButtonType buttonType) : base(helper, "button", Css.Btn, Css.BtnDefault) { MergeAttribute("type", buttonType.GetDescription()); }
internal Small(BootstrapHelper helper) : base(helper, "small") { }
internal IconSpan(BootstrapHelper helper, Icon icon) : base(helper, "span", Css.Glyphicon, icon.GetDescription()) { }
internal Hidden(BootstrapHelper helper) : base(helper, "input") { MergeAttribute("type", "hidden"); }
internal TableData(BootstrapHelper helper) : base(helper, "td") { }
internal InputGroupAddon(BootstrapHelper helper) : base(helper, "span", Css.InputGroupAddon) { }
internal CheckedControl(BootstrapHelper helper, string type) : base(helper, "input") { OutputEndTag = false; MergeAttribute("type", type); }
public override string ToHtmlString() { var mergedHtmlAttributes = _model.htmlAttributes; mergedHtmlAttributes.AddOrMergeCssClass("class", "btn"); if (!string.IsNullOrEmpty(_model.id)) { mergedHtmlAttributes.AddIfNotExist("id", _model.id); } mergedHtmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForButtonSize(_model.size)); mergedHtmlAttributes.AddOrMergeCssClass("class", BootstrapHelper.GetClassForButtonColor(_model.color)); if (_model.buttonBlock) { mergedHtmlAttributes.AddOrMergeCssClass("class", "btn-block"); } if (_model.isDropDownToggle) { mergedHtmlAttributes.AddOrMergeCssClass("class", "dropdown-toggle"); mergedHtmlAttributes.AddIfNotExist("data-toggle", "dropdown"); } if (_model.disabled) { mergedHtmlAttributes.AddOrMergeCssClass("class", "disabled"); } if (!string.IsNullOrEmpty(_model.loadingText)) { mergedHtmlAttributes.AddOrReplace("data-loading-text", _model.loadingText); } if (!string.IsNullOrWhiteSpace(_title)) { mergedHtmlAttributes.Add("title", _title); } var input = string.Empty; if (_model.iconPrepend != string.Empty || _model.iconAppend != string.Empty || !string.IsNullOrEmpty(_model.iconPrependCustomClass) || !string.IsNullOrEmpty(_model.iconAppendCustomClass)) { var iPrependString = string.Empty; var iAppendString = string.Empty; if (_model.iconPrepend != string.Empty) { iPrependString = new BootstrapIcon(_model.iconPrepend, _model.iconPrependIsWhite).ToHtmlString(); } if (_model.iconAppend != string.Empty) { iAppendString = new BootstrapIcon(_model.iconAppend, _model.iconAppendIsWhite).ToHtmlString(); } if (!string.IsNullOrEmpty(_model.iconPrependCustomClass)) { var i = new TagBuilder("i"); i.AddCssClass(_model.iconPrependCustomClass); iPrependString = i.ToString(TagRenderMode.Normal); } if (!string.IsNullOrEmpty(_model.iconAppendCustomClass)) { var i = new TagBuilder("i"); i.AddCssClass(_model.iconAppendCustomClass); iAppendString = i.ToString(TagRenderMode.Normal); } var combined = iPrependString + (!string.IsNullOrEmpty(iPrependString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iAppendString)) ? " " : "") + _model.text + (!string.IsNullOrEmpty(iAppendString) && (!string.IsNullOrEmpty(_model.text) || !string.IsNullOrEmpty(iPrependString)) ? " " : "") + iAppendString; var holder = Guid.NewGuid().ToString(); input = GenerateActionLink(holder, mergedHtmlAttributes); input = input.Replace(holder, combined); } else { input = GenerateActionLink(_model.text, mergedHtmlAttributes); } return(MvcHtmlString.Create(input).ToString()); }
internal Well(BootstrapHelper helper) : base(helper, "div", Css.Well) { }
internal Abbr(BootstrapHelper helper) : base(helper, "abbr") { }
internal MediaObject(BootstrapHelper helper) : base(helper, "a", Css.MediaLeft) { }
internal Pills(BootstrapHelper helper) : base(helper, Css.Nav, Css.NavPills) { }
internal DropdownLink(BootstrapHelper helper) : base(helper, "a") { MergeAttribute("role", "menuitem"); }
internal ControlLabel(BootstrapHelper helper, string text) : base(helper, "label", Css.ControlLabel) { TextContent = text; }
internal Pre(BootstrapHelper helper) : base(helper, "pre") { }
protected NavLink(BootstrapHelper helper) : base(helper, "a") { }
internal ListItem(BootstrapHelper helper) : base(helper, "li") { }
internal IconSpan(BootstrapHelper helper, IconFontAwesome icon) : base(helper, "span", CssFontAwesome.Fa, icon.GetDescription()) { }
internal PageNum(BootstrapHelper helper) : base(helper, "a") { }
protected ImageBase(BootstrapHelper helper) : base(helper, "img") { OutputEndTag = false; }
protected TableCell(BootstrapHelper helper, string tagName, params string[] cssClasses) : base(helper, tagName, cssClasses) { }
internal ThumbnailContainer(BootstrapHelper helper) : base(helper, "div", Css.Thumbnail) { }
internal Blockquote(BootstrapHelper helper) : base(helper, "blockquote") { }
internal PanelTable(BootstrapHelper helper) : base(helper, Css.Table) { }
protected FormControl(BootstrapHelper helper, string tagName, params string[] cssClasses) : base(helper, tagName, cssClasses) { EnsureFormGroup = true; }
internal Label(BootstrapHelper helper) : base(helper, "span", Css.Label, Css.LabelDefault) { }
internal FormControl(BootstrapHelper helper) : this(helper, "div") { }
internal DescriptionTerm(BootstrapHelper helper) : base(helper, "dt") { }
internal MediaList(BootstrapHelper helper) : base(helper, "ul", Css.MediaList) { }
internal Button(BootstrapHelper helper, ButtonType buttonType) : base(helper, "button", Css.Btn, Css.BtnDefault) { MergeAttribute("type", buttonType.GetDescription()); }
internal MediaBody(BootstrapHelper helper) : base(helper, "div", Css.MediaBody) { }