/// <summary> /// Define an image /// </summary> /// <param name="source">the url for the image</param> /// <param name="alt">alternate text for the image</param> /// <param name="imageType">type of image</param> public MvcHtmlString Image(string source, string alt, ImageType imageType) { var img = new TagBuilderExt("img"); img.MergeAttribute("alt", alt); img.MergeAttribute("src", source); switch (imageType) { case ImageType.Rounded: img.AddCssClass("img-rounded"); break; case ImageType.Circle: img.AddCssClass("img-circle"); break; case ImageType.Polaroid: img.AddCssClass("img-polaroid"); break; default: throw new ArgumentOutOfRangeException("imageType"); } return(img.ToMvcHtmlString()); }
/// <summary> /// Creates one breadcrumb link entry with the specified /// <paramref name="title" /> and link. /// </summary> /// <param name="title">The title of the breadcrumb link</param> /// <param name="stringUrl">The fully quallified URL</param> /// <param name="divider"> /// Specify the divider created after the link. Set to "null" or empty /// for no divider. /// </param> public MvcHtmlString BreadcrumbLink(string title, string stringUrl, string divider) { var listItem = new TagBuilderExt("li"); if (IsCurrentUrl(stringUrl)) { listItem.AddCssClass("active"); listItem.SetInnerText(title); } else { var link = new TagBuilderExt("a"); link.MergeAttribute("href", stringUrl); link.SetInnerText(title); listItem.AddChildTag(link); } if (!string.IsNullOrEmpty(divider)) { var dividerTag = new TagBuilderExt("span", divider); dividerTag.AddCssClass("divider"); listItem.AddChildTag(dividerTag); } return(listItem.ToMvcHtmlString()); }
/// <summary> /// Creates an emphasized paragraph /// </summary> /// <param name="text">Content of the emphasized paragraph</param> /// <param name="emphasisType">Type of the emphasis</param> public MvcHtmlString EmphasizedParagraph(string text, EmphasisType emphasisType) { var p = new TagBuilderExt("p"); switch (emphasisType) { case EmphasisType.Muted: p.AddCssClass("muted"); break; case EmphasisType.Warning: p.AddCssClass("text-warning"); break; case EmphasisType.Error: p.AddCssClass("text-error"); break; case EmphasisType.Info: p.AddCssClass("text-info"); break; case EmphasisType.Success: p.AddCssClass("text-success"); break; default: throw new ArgumentOutOfRangeException("emphasisType"); } p.SetInnerText(text); return(p.ToMvcHtmlString()); }
/// <summary> /// Creates a vertical menu-item separator /// </summary> public MvcHtmlString MenuItemSeparator() { var tag = new TagBuilderExt("li"); tag.AddCssClass("divider-vertical"); return(tag.ToMvcHtmlString()); }
/// <summary> /// Creates a menu <paramref name="title" /> (have to be used inside a /// navbar menu). /// </summary> /// <param name="title">Title of the menu</param> /// <param name="url">A Fully quallified URL</param> public MvcHtmlString MenuTitle(string title, string url) { var a = new TagBuilderExt("a", title); a.AddCssClass("navbar-brand"); a.MergeAttribute("href", url); return(a.ToMvcHtmlString()); }
/// <summary> /// Makes a paragraph using the lead class to make it stand out. /// </summary> /// <param name="text">Content of the paragraph</param> public MvcHtmlString LeadBody(string text) { var p = new TagBuilderExt("p"); p.AddCssClass("lead"); p.SetInnerText(text); return(p.ToMvcHtmlString()); }
/// <summary> /// Creates an HTML abbreviation with it's corresponding definition. /// </summary> /// <param name="title">Definition of the abbreviation.</param> /// <param name="value">The abbreviation.</param> /// <param name="isReduced"> /// Defines if the abbreviation uses the <c>initialism</c> class for a slightly /// smaller font-size. /// </param> public MvcHtmlString Abbreviation(string title, string value, bool isReduced) { var abbr = new TagBuilderExt("abbr", value); if (isReduced) { abbr.AddCssClass("initialism"); } abbr.MergeAttribute("title", title); return(abbr.ToMvcHtmlString()); }
/// <summary> /// Creates one menu link entry with the specified /// <paramref name="title" /> and link. /// </summary> /// <param name="title">The title of the menu link</param> /// <param name="url">The fully quallified URL</param> public MvcHtmlString MenuLink(string title, string url) { var listItem = new TagBuilderExt("li"); if (IsCurrentUrl(url)) { listItem.AddCssClass("active"); } var link = new TagBuilderExt("a"); link.MergeAttribute("href", url); link.SetInnerText(title); listItem.AddChildTag(link); return(listItem.ToMvcHtmlString()); }
/// <summary> /// Creates a Bootstrap progress-bar with a defined /// <paramref name="style" />, <paramref name="color" /> and /// <paramref name="progress" />. /// </summary> /// <param name="style">The style of the progress bar</param> /// <param name="color">The color of the progress bar</param> /// <param name="progress">The current progress percentage</param> public MvcHtmlString ProgressBar(ProgressBarStyle style, ProgressBarColor color, double progress) { var progressTag = new TagBuilderExt("div"); progressTag.AddCssClass("progress"); switch (color) { case ProgressBarColor.Info: progressTag.AddCssClass("progress-info"); break; case ProgressBarColor.Success: progressTag.AddCssClass("progress-success"); break; case ProgressBarColor.Warning: progressTag.AddCssClass("progress-warning"); break; case ProgressBarColor.Danger: progressTag.AddCssClass("progress-danger"); break; } switch (style) { case ProgressBarStyle.Animated: progressTag.AddCssClass("active"); break; case ProgressBarStyle.Striped: progressTag.AddCssClass("progress-striped"); break; } var barTag = progressTag.CreateChildTag("div"); barTag.AddCssClass("progress-bar"); barTag.MergeAttribute("role", "progressbar"); barTag.MergeAttribute("aria-valuenow", progress.ToString(CultureInfo.InvariantCulture)); barTag.MergeAttribute("aria-valuemin", "0"); barTag.MergeAttribute("aria-valuemax", "100"); barTag.MergeAttribute("style", string.Format("width: {0}%", progress)); return(progressTag.ToMvcHtmlString()); }
/// <summary> /// Creates an HTML block-quote. /// </summary> /// <param name="quote">The quote.</param> /// <param name="author">The author.</param> /// <param name="source">The source.</param> /// <param name="sourceTitle"> /// The <paramref name="source" /> title. /// </param> /// <param name="isPulledRight"> /// Set to <see langword="true" /> for a floated, right-aligned /// blockquote. /// </param> public MvcHtmlString BlockQuote(string quote, string author, string source, string sourceTitle, bool isPulledRight) { var blockquote = new TagBuilderExt("blockquote"); if (isPulledRight) { blockquote.AddCssClass("pull-right"); } var cite = new TagBuilderExt("cite", source); cite.MergeAttribute("title", sourceTitle); blockquote.CreateChildTag("p", quote); blockquote.CreateChildTag("small").InnerHtml = String.Concat(author, " ", cite.ToString()); return(blockquote.ToMvcHtmlString()); }
/// <summary> /// Creates a description list with the associated descriptions /// </summary> /// <param name="isHorizontal"> /// Make terms and descriptions in line up side-by-side. /// </param> /// <param name="elements"> /// The dictionary of descriptions by title (key) and description /// (value). /// </param> public MvcHtmlString DescriptionList(bool isHorizontal, IDictionary <string, string> elements) { if (elements == null) { return(null); } var root = new TagBuilderExt("dl"); if (isHorizontal) { root.AddCssClass("dl-horizontal"); } foreach (var element in elements) { root.CreateChildTag("dt", element.Key); root.CreateChildTag("dd", element.Value); } return(root.ToMvcHtmlString()); }