public BarPart(int percentage, HtmlAttributes commonAttributes) { HtmlAttributes = commonAttributes.Clone(); HtmlTag = "div"; HtmlAttributes["class"] = "bar"; HtmlAttributes["style"] = "width:" + percentage + "%"; }
public static MvcHtmlString Toolbar(this HtmlHelper html, object htmlAttributes, params MvcHtmlString[] groups) { var attributes = new HtmlAttributes(htmlAttributes ?? new {}); attributes["class"] = "btn-toolbar"; return MvcHtmlString.Create(string.Format( "<div {0}>{1}</div>", attributes, string.Join("", groups.Select(x => x.ToString()))) ); }
public static MvcHtmlString ButtonGroup(this HtmlHelper html, object htmlAttributes, bool vertical, params Button[] buttons) { var attributes = new HtmlAttributes(htmlAttributes ?? new {}); attributes["class"] = "btn-group"; if (vertical) attributes["class"] = "btn-group-vertical"; return MvcHtmlString.Create(string.Format( "<div {0}>{1}</div>", attributes, string.Join("", buttons.Select(x => x.ToHtmlString())) )); }
public void UpdateAttributes(HtmlAttributes htmlAttributes) { if (Category.HasValue) htmlAttributes["class"] = "btn-" + Category.ToString().ToLower(); if (Size != Size.Default) htmlAttributes["class"] = "btn-" + Size.ToString().ToLower(); if (BlockLevel) htmlAttributes["class"] = "btn-block"; if (!string.IsNullOrEmpty(Url)) { htmlAttributes["href"] = Url; Tag = Tag.A; } if (Tag != Tag.A) htmlAttributes["type"] = "button"; if (Disabled) htmlAttributes[Tag == Tag.A ? "class" : "disabled"] = "disabled"; }
public Button(string text, ButtonSettings settings, object htmlAttributes) { _text = text; _settings = settings ?? new ButtonSettings(); HtmlAttributes = new HtmlAttributes(htmlAttributes); _settings.UpdateAttributes(HtmlAttributes); HtmlAttributes["class"] = "btn"; if (_settings.Tag == Tag.Input) { HtmlTag = "input"; HtmlAttributes["value"] = text; } else { HtmlTag = _settings.Tag.ToString().ToLower(); InnerHtml = text; } }
public Navbar(Action<NavbarBuilder> navbarBuilder, object htmlAttributes = null, string activeLink = null) { if (htmlAttributes != null) HtmlAttributes = new HtmlAttributes(htmlAttributes); if (navbarBuilder != null) navbarBuilder(new NavbarBuilder(this, activeLink)); }
public HtmlList(Action<HtmlListBuilder> listBuilder, object htmlAttributes = null) { HtmlAttributes = new HtmlAttributes(htmlAttributes); if (listBuilder != null) listBuilder(new HtmlListBuilder(this)); InnerHtml = string.Join("", ListItems.Select(x => x.ToHtmlString())); }
public Form(Action<FormBuilder> formBuilder, FormSettings settings, object htmlAttributes) { _settings = settings; if (htmlAttributes != null) HtmlAttributes = new HtmlAttributes(htmlAttributes); if (formBuilder != null) formBuilder(new FormBuilder(this)); }
public HtmlListItem Link(string text, string url, object htmlAttributes, string identifier = null) { var attrs = new HtmlAttributes(htmlAttributes); var link = new HtmlListItem(string.Format("<a href=\"{0}\" {2}>{1}</a>", url, text, attrs)); var currActive = _list.HtmlAttributes["data-activeLink"]; if (!string.IsNullOrEmpty(identifier) && currActive == identifier) link.Active(); _list.ListItems.Add(link); return link; }
public ProgressBar(Action<ProgressBarBuilder> progressBarBuilder, object htmlAttributes) { _progressBarBuilder = progressBarBuilder; HtmlAttributes = new HtmlAttributes(htmlAttributes); }
public ProgressBarBuilder(ProgressBar progressBar, HtmlAttributes commonAttributes) { _progressBar = progressBar; _commonAttributes = commonAttributes; }