Пример #1
0
 public static ComponentBuilder <TConfig, Select> AddOptions <TConfig>(this ComponentBuilder <TConfig, Select> builder, IEnumerable <KeyValuePair <string, string> > options)
     where TConfig : BootstrapConfig
 {
     foreach (KeyValuePair <string, string> option in options)
     {
         builder.AddChild(x => x.SelectOption(option.Key, option.Value));
     }
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> AddOptions <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder, IEnumerable <SelectListItem> selectList)
 {
     foreach (SelectListItem item in selectList)
     {
         builder.AddChild(x => x.SelectOption(item.Text, item.Value, item.Selected));
     }
     return(builder);
 }
Пример #3
0
 public static ComponentBuilder <TConfig, Select> AddOptions <TConfig>(this ComponentBuilder <TConfig, Select> builder, params string[] options)
     where TConfig : BootstrapConfig
 {
     foreach (string option in options)
     {
         builder.AddChild(x => x.SelectOption(option));
     }
     return(builder);
 }
Пример #4
0
 public static ComponentBuilder <TConfig, Select> AddOptions <TConfig>(this ComponentBuilder <TConfig, Select> builder, params string[] options)
     where TConfig : BootstrapConfig
 {
     foreach (string option in options)
     {
         var option1 = option;  // Avoid foreach variable access in closure
         builder.AddChild(x => x.SelectOption(option1));
     }
     return(builder);
 }
Пример #5
0
 public static ComponentBuilder <TConfig, Select> AddOptions <TConfig>(this ComponentBuilder <TConfig, Select> builder, IEnumerable <KeyValuePair <string, string> > options)
     where TConfig : BootstrapConfig
 {
     foreach (KeyValuePair <string, string> option in options)
     {
         var option1 = option;  // Avoid foreach variable access in closure
         builder.AddChild(x => x.SelectOption(option1.Key, option1.Value,
                                              builder.Component.ModelValue != null && string.Equals(builder.Component.ModelValue, option1.Value, StringComparison.OrdinalIgnoreCase)));
     }
     return(builder);
 }
        // Panel

        public static ComponentBuilder <TConfig, Panel> Panel <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string title = null, int titleHeadingLevel = 4)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Panel>
        {
            ComponentBuilder <TConfig, Panel> builder = new ComponentBuilder <TConfig, Panel>(helper.Config, new Panel(helper));

            if (!string.IsNullOrWhiteSpace(title))
            {
                builder.AddChild(x => x.PanelHeading().AddChild(y => y.PanelTitle(title, titleHeadingLevel)));
            }
            return(builder);
        }
        public static ComponentBuilder <TConfig, Modal> Modal <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string title = null)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Modal>
        {
            ComponentBuilder <TConfig, Modal> builder = new ComponentBuilder <TConfig, Modal>(helper.Config, new Modal(helper));

            if (!string.IsNullOrWhiteSpace(title))
            {
                builder.AddChild(x => x.ModalHeading().AddChild(y => y.ModalTitle(title)));
            }
            return(builder);
        }
        public static ComponentBuilder <TConfig, TableRow> TableDataRow <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, params object[] content)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <TableRow>
        {
            ComponentBuilder <TConfig, TableRow> builder = new ComponentBuilder <TConfig, TableRow>(helper.Config, new TableRow(helper));

            foreach (object c in content)
            {
                builder.AddChild(x => x.TableData().AddContent(c));
            }
            return(builder);
        }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Select> AddOptions <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Select> builder, IEnumerable <SelectListItem> selectList)
 {
     if (selectList != null)
     {
         foreach (SelectListItem item in selectList)
         {
             var item1 = item; // Avoid foreach variable access in closure
             builder.AddChild(x => x.SelectOption(item1.Text, item1.Value, item1.Selected));
         }
     }
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPages <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, IEnumerable <KeyValuePair <string, ActionResult> > textAndResults, int?activePageNumber = null, int?firstPageNumber = null)
 {
     if (firstPageNumber.HasValue)
     {
         builder.GetComponent().AutoPageNumber = firstPageNumber.Value - 1;
     }
     foreach (KeyValuePair <string, ActionResult> textAndResult in textAndResults)
     {
         KeyValuePair <string, ActionResult> localTextAndResult = textAndResult;  // avoid access in closure
         builder.GetComponent().AutoPageNumber++;
         builder.AddChild(x => x.PageNum(localTextAndResult.Key ?? builder.GetComponent().AutoPageNumber.ToString(), localTextAndResult.Value)
                          .SetActive(builder.GetComponent().AutoPageNumber == activePageNumber)
                          .SetDisabled(localTextAndResult.Value == null));
     }
     return(builder);
 }
Пример #11
0
 public static ComponentBuilder <TConfig, Pagination> AddPages <TConfig>(this ComponentBuilder <TConfig, Pagination> builder, IEnumerable <KeyValuePair <string, string> > textAndHrefs, int?activePageNumber = null, int?firstPageNumber = null)
     where TConfig : BootstrapConfig
 {
     if (firstPageNumber.HasValue)
     {
         builder.Component.AutoPageNumber = firstPageNumber.Value - 1;
     }
     foreach (KeyValuePair <string, string> textAndHref in textAndHrefs)
     {
         KeyValuePair <string, string> localTextAndHref = textAndHref;  // avoid access in closure
         builder.Component.AutoPageNumber++;
         builder.AddChild(x => x.PageNum(localTextAndHref.Key ?? builder.Component.AutoPageNumber.ToString(), localTextAndHref.Value)
                          .SetActive(builder.Component.AutoPageNumber == activePageNumber)
                          .SetDisabled(localTextAndHref.Value == null));
     }
     return(builder);
 }
Пример #12
0
        // Typography

        public static ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> ListFor <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper,
            Expression <Func <TModel, IEnumerable <TValue> > > expression, Func <TValue, object> item, ListType listType = ListType.Unstyled)
            where TComponent : Component, ICanCreate <Typography.List>
        {
            ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> builder =
                new ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List>(helper.GetConfig(), helper.List(listType).GetComponent());
            IEnumerable <TValue> values = ModelMetadata.FromLambdaExpression(expression, builder.GetConfig().HtmlHelper.ViewData).Model as IEnumerable <TValue>;

            if (values != null)
            {
                foreach (TValue value in values)
                {
                    builder.AddChild(x => x.ListItem(item(value)));
                }
            }
            return(builder);
        }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pager> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pager> builder, string text, ActionResult result, bool disabled = false)
 {
     builder.AddChild(x => x.Page(text, result).SetDisabled(disabled));
     return(builder);
 }
Пример #14
0
 public static ComponentBuilder <TConfig, Pager> AddPage <TConfig>(this ComponentBuilder <TConfig, Pager> builder, string text, string href = "#", bool disabled = false)
     where TConfig : BootstrapConfig
 {
     builder.AddChild(x => x.Page(text, href).SetDisabled(disabled));
     return(builder);
 }
 public static ComponentBuilder <TConfig, Pagination> AddPage <TConfig>(this ComponentBuilder <TConfig, Pagination> builder, string href = "#", bool active = false, bool disabled = false)
     where TConfig : BootstrapConfig
 {
     builder.AddChild(x => x.PageNum((++builder.Component.AutoPageNumber).ToString(), href).SetActive(active).SetDisabled(disabled));
     return(builder);
 }
 public static ComponentBuilder <TConfig, Pagination> AddNext <TConfig>(this ComponentBuilder <TConfig, Pagination> builder, string href = "#", bool active = false, bool disabled = false)
     where TConfig : BootstrapConfig
 {
     builder.AddChild(x => x.PageNum("&raquo;", href).SetActive(active).SetDisabled(disabled));
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddNext <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, ActionResult result, bool active = false, bool disabled = false)
 {
     builder.AddChild(x => x.PageNum("&raquo;", result).SetActive(active).SetDisabled(disabled));
     return(builder);
 }
Пример #18
0
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, string actionName, string controllerName, object routeValues = null, bool active = false, bool disabled = false)
 {
     builder.AddChild(x => x.PageNum((++builder.GetComponent().AutoPageNumber).ToString(), actionName, controllerName, routeValues).SetActive(active).SetDisabled(disabled));
     return(builder);
 }
Пример #19
0
        // Pagination

        public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPrevious <TModel>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, string actionName, string controllerName, object routeValues = null, bool active = false, bool disabled = false)
        {
            builder.AddChild(x => x.PageNum("&laquo;", actionName, controllerName, routeValues).SetActive(active).SetDisabled(disabled));
            return(builder);
        }
Пример #20
0
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pager> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pager> builder, string text, string actionName, string controllerName, object routeValues = null, bool disabled = false)
 {
     builder.AddChild(x => x.Page(text, actionName, controllerName, routeValues).SetDisabled(disabled));
     return(builder);
 }
Пример #21
0
 public static ComponentBuilder <TConfig, Select> AddOption <TConfig>(this ComponentBuilder <TConfig, Select> builder, string text, string value = null, bool selected = false)
     where TConfig : BootstrapConfig
 {
     builder.AddChild(x => x.SelectOption(text, value, selected));
     return(builder);
 }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> AddPage <TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, Pagination> builder, ActionResult result, bool active = false, bool disabled = false)
 {
     builder.AddChild(x => x.PageNum((++builder.GetComponent().AutoPageNumber).ToString(), result).SetActive(active).SetDisabled(disabled));
     return(builder);
 }