Пример #1
0
        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);
            }
        }
Пример #2
0
 public void BoxTools(BootstrapSize buttonSize = BootstrapSize.Small, bool closable = false,
                      bool collapsible         = false)
 {
     using (BeginBoxTools(buttonSize, closable, collapsible))
     {
         // NOP
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
 internal BoxToolsPanel(Box box, TextWriter writer, BootstrapSize buttonSize = BootstrapSize.Small)
     : base(box, BoxSection.Tools, writer)
 {
     _buttonSize = buttonSize;
 }
Пример #5
0
        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)));
        }
Пример #6
0
        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)));
        }
Пример #7
0
        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)));
        }
Пример #8
0
        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)));
        }
Пример #9
0
        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);
        }
Пример #10
0
 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)));
 }
Пример #11
0
        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));
        }
Пример #12
0
        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));
        }
Пример #13
0
        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)));
        }
Пример #14
0
 public BoxToolsPanel BeginBoxTools(BootstrapSize buttonSize = BootstrapSize.Small, bool closable = false,
                                    bool collapsible         = false)
 {
     return(new BoxToolsPanel(Box, TextWriter, buttonSize).Closable(closable).Collapsible(collapsible));
 }