public static string GetSizeName(BootstrapSize size) { switch (size) { case BootstrapSize.Auto: return(string.Empty); case BootstrapSize.ExtraSmall: return("xs"); case BootstrapSize.Small: return("sm"); case BootstrapSize.Mediume: return("md"); case BootstrapSize.Large: return("lg"); case BootstrapSize.ExtraLarge: return("xs"); default: throw new ArgumentException("Invalid size " + size); } }
public void BoxTools(BootstrapSize buttonSize = BootstrapSize.Small, bool closable = false, bool collapsible = false) { using (BeginBoxTools(buttonSize, closable, collapsible)) { // NOP } }
public static string GetClassName(string component, BootstrapSize size, int span) { string name = component; if (size != BootstrapSize.Auto) { name += "-" + GetSizeName(size); } if (span >= 0) { name += "-" + span; } return(name); }
internal BoxToolsPanel(Box box, TextWriter writer, BootstrapSize buttonSize = BootstrapSize.Small) : base(box, BoxSection.Tools, writer) { _buttonSize = buttonSize; }
public static MvcHtmlString FormDateBoxFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, DateTime> > expr, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); values["type"] = "date"; return(helper.TextBoxFor(expr, Constants.DateBoxValueFormatString, values.InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString FormNumberBoxFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, bool hideZero = true, int decimals = 0, bool @readonly = false, bool disabled = false, BootstrapSize size = BootstrapSize.Auto, double?min = null, double?max = null, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); string format = null; if (hideZero) { format = "{0:#"; if (decimals > 0) { format += "." + new string('#', decimals); } format += "}"; } values["type"] = "number"; if (min != null) { values["min"] = min; } if (max != null) { values["max"] = max; } return(helper.TextBoxFor(expression, format, values.InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString FormPasswordFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, string> > expression, BootstrapSize size = BootstrapSize.Auto, object htmlAttributes = null) { var attrs = InternalHelper.AddClassName(htmlAttributes, FormControl); return(helper.PasswordFor(expression, attrs.InitializeInputControl(size, false, false))); }
public static MvcHtmlString FormTextBoxFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string format = null, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { IDictionary <string, object> attrs = InternalHelper.AddClassName(htmlAttributes, FormControl); return(helper.TextBoxFor(expression, format, attrs.InitializeInputControl(size, @readonly, disabled))); }
private static IDictionary <string, object> InitializeInputControl(this IDictionary <string, object> htmlAttributes, BootstrapSize size, bool @readonly, bool disabled) { if (size != BootstrapSize.Auto) { InternalHelper.AddClassName(htmlAttributes, "form-control-" + BootstrapHelper.GetSizeName(size)); } if (@readonly) { htmlAttributes.Add("readonly", "readonly"); } if (disabled) { htmlAttributes.Add("disabled", "disabled"); } return(htmlAttributes); }
public static MvcHtmlString FormEnumDropDownListFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string optionLabel = null, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { return(helper.EnumDropDownListFor(expression, optionLabel, InternalHelper.AddClassName(htmlAttributes, FormControl).InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString FormDropDownListFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, bool> > expression, string trueText, string falseText, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { SelectListItem[] items = new SelectListItem[] { new SelectListItem { Text = trueText, Value = "true" }, new SelectListItem { Text = falseText, Value = "false" } }; return(FormDropDownListFor(helper, expression, items, null, size, @readonly, disabled, htmlAttributes)); }
public static MvcHtmlString HLabelFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, BootstrapSize breakpoint = BootstrapSize.Mediume, int columns = 3, string labelText = null, object htmlAttributes = null) { var values = InternalHelper.ToValues(htmlAttributes); if (columns >= 0) { InternalHelper.AddClassName(values, BootstrapHelper.GetClassName("col", breakpoint, columns)); } return(helper.LabelFor(expression, labelText, values)); }
public static MvcHtmlString FormTextAreaFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, int rows = 0, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); if (rows > 0) { values["rows"] = rows; } return(helper.TextAreaFor(expression, values.InitializeInputControl(size, @readonly, disabled))); }
public BoxToolsPanel BeginBoxTools(BootstrapSize buttonSize = BootstrapSize.Small, bool closable = false, bool collapsible = false) { return(new BoxToolsPanel(Box, TextWriter, buttonSize).Closable(closable).Collapsible(collapsible)); }