Example #1
0
 /// <summary>
 /// Initializes the group
 /// </summary>
 public BsSubmitButton(string value, BsButtonTheme theme = BsButtonTheme.Default) : base(HtmlTag.Input)
 {
     CssClass(BsClass.Button);
     CssClass(BsClass.ButtonTheme.From(theme));
     Attr(HtmlAttr.Type, HtmlInputType.Submit);
     Attr(HtmlAttr.Value, value);
 }
Example #2
0
        /// <summary>
        /// Renders a submit button
        /// </summary>
        /// <param name="value">Button text</param>
        /// <param name="theme">Button theme</param>
        /// <param name="outerHtmlAttributes">HTML attributes of the form group</param>
        /// <param name="innerHtmlAttributes">HTML attributes of the inner div</param>
        /// <param name="buttonHtmlAttributes">HTML attributes of the button</param>
        public MvcHtmlString SubmitButton(string value, BsButtonTheme theme = BsButtonTheme.Default,
                                          object outerHtmlAttributes        = null,
                                          object innerHtmlAttributes        = null,
                                          object buttonHtmlAttributes       = null)
        {
            // --- The form group that encapsulates the button
            var formGroup = new BsFormGroup {
                Depth = Depth + 1
            };

            formGroup.SetHtmlAttributes(outerHtmlAttributes);

            // --- The div with the buttons
            var div = new BsHtmlElement(HtmlTag.Div);

            div.SetHtmlAttributes(innerHtmlAttributes);
            div.ApplyColumnWidths(null, _form.InputWidthXs, _form.InputWidthSm, _form.InputWidthMd, _form.InputWidthLg);
            div.ApplyColumnOffsets(null, _form.LabelWidthXs, _form.LabelWidthSm, _form.LabelWidthMd, _form.LabelWidthLg);
            formGroup.AddChild(div);

            // --- The button in the div
            var button = new BsSubmitButton(value, theme);

            button.SetHtmlAttributes(buttonHtmlAttributes);
            button.Attr(NgTag.NgDisabled, string.Format("{0}.$invalid", _form.FormName));
            div.AddChild(button);

            return(formGroup.Markup);
        }
Example #3
0
 /// <summary>
 /// Initializes the instance with the specified value and theme
 /// </summary>
 /// <param name="value"></param>
 /// <param name="theme"></param>
 private void InitInstance(string value, BsButtonTheme theme)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     Text  = value;
     Theme = theme;
 }
Example #4
0
        /// <summary>
        /// Renders a cancel button for a modal dialog
        /// </summary>
        /// <param name="ngClick">ng-click attribute value (cancel() by default)</param>
        /// <param name="theme">Button theme</param>
        /// <param name="buttonText">Button text (Resources.Gen_Cancel by default)</param>
        public MvcHtmlString CancelButton(string ngClick = null, BsButtonTheme theme = BsButtonTheme.Default, string buttonText = null)
        {
            if (ngClick == null)
            {
                ngClick = "cancel()";
            }
            if (buttonText == null)
            {
                buttonText = Resources.Gen_Cancel;
            }
            var button = new BsHtmlElement(HtmlTag.Button);

            button
            .CssClass(BsClass.Button)
            .CssClass(BsClass.ButtonTheme.From(theme))
            .Attr(NgTag.NgClick, ngClick);
            button.AddChild(new HtmlText(buttonText));
            return(button.Markup);
        }
Example #5
0
        /// <summary>
        /// Renders a cancel button for a modal dialog
        /// </summary>
        /// <param name="ngClick">ng-click attribute value (cancel() by default)</param>
        /// <param name="theme">Button theme</param>
        /// <param name="buttonText">Button text (Resources.Gen_Cancel by default)</param>
        public MvcHtmlString OkButton(string ngClick = null, BsButtonTheme theme = BsButtonTheme.Success, string buttonText = null)
        {
            if (ngClick == null)
            {
                ngClick = "ok()";
            }
            if (buttonText == null)
            {
                buttonText = Resources.Gen_Ok;
            }
            var button = new BsHtmlElement(HtmlTag.Button);

            button
            .CssClass(BsClass.Button)
            .CssClass(BsClass.ButtonTheme.From(theme))
            .Attr(NgTag.NgClick, ngClick)
            .Attr(NgTag.NgDisabled, _form.FormName + ".$invalid || disableOk");
            button.AddChild(new HtmlText(buttonText));
            return(button.Markup);
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance with the specified extra attributes
 /// </summary>
 /// <param name="value">Button value</param>
 /// <param name="theme">Button theme</param>
 /// <param name="attribs">Attribute enumeration</param>
 public NgButton(string value, BsButtonTheme theme, params object[] attribs)
     : base(HtmlTag.Button, attribs)
 {
     InitInstance(value, theme);
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance with the specified extra attributes
 /// </summary>
 /// <param name="value">Button value</param>
 /// <param name="theme">Button theme</param>
 /// <param name="attribs">Attribute enumeration</param>
 public NgButton(string value, BsButtonTheme theme, IDictionary <string, object> attribs)
     : base(HtmlTag.Button, attribs)
 {
     InitInstance(value, theme);
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance
 /// </summary>
 /// <param name="value">Button value</param>
 /// <param name="theme">Button theme</param>
 public NgButton(string value, BsButtonTheme theme = BsButtonTheme.Default)
     : base(HtmlTag.Button)
 {
     InitInstance(value, theme);
 }
Example #9
0
 public static string From(BsButtonTheme theme)
 {
     return(String.Format("btn-{0}", theme.ToString().ToLower()));
 }