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