Ejemplo n.º 1
0
        /// <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());
        }
Ejemplo n.º 2
0
        /// <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());
        }
Ejemplo n.º 3
0
        /// <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());
        }
Ejemplo n.º 4
0
        /// <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());
        }
Ejemplo n.º 5
0
        /// <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());
        }
Ejemplo n.º 6
0
        /// <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());
        }
Ejemplo n.º 7
0
        /// <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());
        }
Ejemplo n.º 8
0
        private TagBuilderExt CreateBaseButton(string tagName, ButtonStyle buttonStyle, ButtonSize buttonSize,
                                               bool isDisabled)
        {
            var tag = new TagBuilderExt(tagName);

            tag.AddCssClass("btn");

            switch (buttonStyle)
            {
            case ButtonStyle.Primary:
                tag.AddCssClass("btn-primary");
                break;

            case ButtonStyle.Info:
                tag.AddCssClass("btn-info");
                break;

            case ButtonStyle.Success:
                tag.AddCssClass("btn-success");
                break;

            case ButtonStyle.Warning:
                tag.AddCssClass("btn-warning");
                break;

            case ButtonStyle.Danger:
                tag.AddCssClass("btn-danger");
                break;

            case ButtonStyle.Inverse:
                tag.AddCssClass("btn-inverse");
                break;

            case ButtonStyle.Link:
                tag.AddCssClass("btn-link");
                break;
            }

            switch (buttonSize)
            {
            case ButtonSize.Large:
                tag.AddCssClass("btn-large");
                break;

            case ButtonSize.Small:
                tag.AddCssClass("btn-small");
                break;

            case ButtonSize.Mini:
                tag.AddCssClass("btn-mini");
                break;
            }

            if (isDisabled)
            {
                tag.AddCssClass("disabled");
            }

            return(tag);
        }