/// <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()); }
/// <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()); }