示例#1
0
        public static TagBuilder Button(
            string modalBody,
            string formAction,
            string success,
            string title,
            string submitbtnInnerText = null,
            string btnColor           = null,
            string btnInnerText       = null,
            ModalSize modalSize       = ModalSize.Default)
        {
            var aHref = Modal(btnColor: btnColor, title: title, btnSize: "btn-sm", formSuccess: success,
                              formAction: formAction, modalBody: modalBody, modalSize: modalSize,
                              submitButtonText: submitbtnInnerText);

            if (btnInnerText == null)
            {
                var item = new TagBuilder("i");
                item.AddCssClass("fa");
                item.AddCssClass("fa-plus");
                aHref.InnerHtml = "Add " + item;
            }
            else
            {
                aHref.SetInnerText(btnInnerText);
            }
            return(aHref);
            //var retVal = MvcHtmlString.Create(aHref.ToString());
            //return retVal;
        }
示例#2
0
        public ExtModal(ViewContext viewContext, string modalId, ModalSize size, string title)
        {
            string modalSizeClass;

            switch (size)
            {
            case ModalSize.Small:
                modalSizeClass = "modal-sm";
                break;

            case ModalSize.Medium:
                modalSizeClass = "modal-md";
                break;

            case ModalSize.Large:
                modalSizeClass = "modal-lg";
                break;

            case ModalSize.ExtraLarge:
                modalSizeClass = "modal-extra-lg";
                break;

            default:
                modalSizeClass = "modal-md";
                break;
            }

            var htmlBegin = string.Format(HtmlBeginModal, modalId, modalSizeClass, title);

            viewContext.Writer.Write(htmlBegin);
            _viewContext = viewContext;
        }
示例#3
0
        public static IHtmlString AddButton(
            string body,
            string formAction,
            string success,
            string title,
            string submitbtnInnerText = null,
            string btnColor           = null,
            string btnInnerText       = null,
            ModalSize modalSize       = ModalSize.Default)
        {
            var aHref = Modal(btnColor: btnColor, title: title, btnSize: "btn-sm", formSuccess: success,
                              formAction: formAction, modalBody: body, modalSize: modalSize,
                              submitButtonText: "Add");

            aHref.AddCssClass("btn");
            aHref.AddCssClass("btn-sm");
            aHref.AddCssClass("purple");

            var item = new TagBuilder("i");

            item.AddCssClass("fa");
            item.AddCssClass("fa-plus");
            aHref.InnerHtml = "Add " + item;
            var retVal = MvcHtmlString.Create(aHref.ToString());

            return(retVal);
        }
示例#4
0
        public static IHtmlString EditLink(string modalBody,
                                           string linkText,
                                           string formAction         = null,
                                           string tableId            = null,
                                           string success            = null,
                                           string title              = null,
                                           string submitbtnInnerText = "Save",
                                           ModalSize modalSize       = ModalSize.Default)
        {
            if (success == null && tableId != null)
            {
                tableId = tableId.Trim('#');
                success = $"refreshParent('#{tableId}')";
            }

            if (string.IsNullOrWhiteSpace(formAction))
            {
                formAction = modalBody;
            }

            var aHref = ModalButton(modalBody: modalBody, formAction: formAction, success: success, title: title,
                                    modalSize: modalSize, submitbtnInnerText: submitbtnInnerText, btnColor: null);

            aHref.SetInnerText(linkText);

            var retVal = MvcHtmlString.Create(aHref.ToString());

            return(retVal);
        }
        private void ShowModal(ModalSize modalSize, int?maxHeight = null, bool centered = false)
        {
            this.centered  = centered;
            this.modalSize = modalSize;
            this.maxHeight = maxHeight;

            modalRef.Show();
        }
示例#6
0
        public static IHtmlString AddButton(this object model,
                                            string controller,
                                            string success,
                                            object id             = null,
                                            string action         = "Add",
                                            string actionOverride = null,
                                            string body           = null,
                                            string title          = null,
                                            string btnColor       = "purple",
                                            string innerText      = null,
                                            ModalSize modalSize   = ModalSize.Default)
        {
            if (id == null && model == null)
            {
                id = string.Empty;
            }
            else
            {
                dynamic modelD = model;
                if (id == null && modelD.Id != null)
                {
                    id = modelD.Id;
                }
            }

            if (body == null)
            {
                body = action;
            }

            controller = controller.Trim('/');

            var formAction = $"/{controller}/{action}/{id}";

            if (actionOverride != null)
            {
                formAction = actionOverride;
            }
            var aHref = ViewUtils.Modal(btnColor: btnColor, title: title, btnSize: "btn-sm", formSuccess: success,
                                        formAction: formAction, modalBody: $"/{controller}/{body}/{id}", modalSize: modalSize,
                                        submitButtonText: "Add");

            if (innerText == null)
            {
                var item = new TagBuilder("i");
                item.AddCssClass("fa");
                item.AddCssClass("fa-plus");
                aHref.InnerHtml = "Add " + item;
            }
            else
            {
                aHref.SetInnerText(innerText);
            }

            var retVal = MvcHtmlString.Create(aHref.ToString());

            return(retVal);
        }
示例#7
0
        public static IHtmlString EditButton(string modalBody,
                                             string formAction         = null,
                                             string tableId            = null,
                                             string success            = null,
                                             string title              = null,
                                             string submitbtnInnerText = "Save",
                                             FontAwesomeSize?fontSize  = null,
                                             ModalSize modalSize       = ModalSize.Default)
        {
            if (success == null && tableId != null)
            {
                tableId = tableId.Trim('#');
                success = $"refreshParent('#{tableId}')";
            }

            if (string.IsNullOrWhiteSpace(formAction))
            {
                formAction = modalBody;
            }

            var aHref = ModalButton(modalBody: modalBody, formAction: formAction, success: success, title: title,
                                    modalSize: modalSize, submitbtnInnerText: submitbtnInnerText, btnColor: null);
            //var aHref = ViewUtils.Modal(title: title, formSuccess: success, formAction: $"/{controller}/{action}/{id}",
            //    modalBody: $"/{controller}/{body}/{id}", modalSize: modalSize, submitButtonText: "Save");

            var item = new TagBuilder("i");

            item.AddCssClass("fa");
            string faSize;

            switch (fontSize)
            {
            case FontAwesomeSize.fa2X:
                faSize = "fa-2x";
                break;

            case FontAwesomeSize.fa1x:
                faSize = "";
                break;

            case FontAwesomeSize.fa3X:
                faSize = "fa-3x";
                break;

            default:
                faSize = "fa-2x";
                break;
            }

            item.AddCssClass(value: faSize);
            item.AddCssClass("fa-edit");
            item.Attributes["style"] = "color:#a48334;";
            aHref.InnerHtml          = item.ToString();

            var retVal = MvcHtmlString.Create(aHref.ToString());

            return(retVal);
        }
示例#8
0
 public static string GetCssClass(this ModalSize modalSize)
 {
     return(modalSize switch
     {
         ModalSize.Small => "modal-sm",
         ModalSize.Large => "modal-lg",
         ModalSize.ExtraLarge => "modal-xl",
         _ => string.Empty,
     });
示例#9
0
        public static TagBuilder Modal(string title            = null,
                                       string btnColor         = null,
                                       string btnSize          = null,
                                       string formSuccess      = null,
                                       string formAction       = null,
                                       string modalBody        = null,
                                       ModalSize modalSize     = ModalSize.Default,
                                       string modalId          = null,
                                       string submitButtonText = "Submit")
        {
            var aHref = new TagBuilder("a");

            aHref.AddCssClass("dynamicAction");
            if (btnColor != null)
            {
                aHref.AddCssClass("btn");
                aHref.AddCssClass(btnSize);
                aHref.AddCssClass(btnColor);
            }
            if (modalId == null)
            {
                modalId = Guid.NewGuid().ToString("N");
            }
            string modalS = "";

            switch (modalSize)
            {
            case ModalSize.Default:
                modalS = "";
                break;

            case ModalSize.Small:
                modalS = "modal-sm";
                break;

            case ModalSize.Large:
                modalS = "modal-lg";
                break;

            case ModalSize.FullScreen:
                modalS = "modal-full";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(modalSize), modalSize, null);
            }
            aHref.Attributes["modal-Name"]   = modalId;
            aHref.Attributes["modal-submit"] = submitButtonText;
            aHref.Attributes["modal-class"]  = modalS;
            aHref.Attributes["modal-title"]  = title;
            aHref.Attributes["modal-body"]   = modalBody;
            aHref.Attributes["form-action"]  = formAction;
            aHref.Attributes["form-success"] = formSuccess;

            return(aHref);
        }
示例#10
0
        public static MvcHtmlString Modal(this HtmlHelper helper, string titulo, ModalSize size = ModalSize.Normal)
        {
            var html = String.Format("<div id=\"{0}\" class=\"modal fade\" id=\"myModal\" role=\"dialog\" aria-labelledby=\"{0}\" aria-hidden=\"true\">"
                                     + "<div class=\"modal-dialog " + GetModalSizeClass(size) + "\" >"
                                     + "<div class=\"modal-content\"></div>"
                                     + "</div>"
                                     + "</div>", titulo);

            return(MvcHtmlString.Create(html));
        }
        public RevealModal(HtmlHelper html, string id, ModalSize size)
        {
            _html = html;

            var modal = new TagBuilder("div");
            modal.AddCssClass("reveal-modal");
            modal.Attributes.Add("id", id);
            modal.AddCssClass(size.GetStringValue());

            _html.ViewContext.Writer.Write(modal.ToString(TagRenderMode.StartTag));
            _html.ViewContext.Writer.Write("<a class=\"close-reveal-modal\">&#215;</a>");
        }
示例#12
0
        private static string GetModalSizeClass(ModalSize size)
        {
            switch (size)
            {
            case ModalSize.Small:
                return("modal-sm");

            case ModalSize.Large:
                return("modal-lg");

            default:
                return(string.Empty);
            }
        }
示例#13
0
        public static IHtmlString AddButton(string modalBody,
                                            string title,
                                            string formAction    = null,
                                            string refreshAction = null,
                                            string btnText       = null,
                                            ModalSize modalSize  = ModalSize.Default)
        {
            string success = null;

            if (refreshAction != null)
            {
                refreshAction = refreshAction.Trim('\'', '/', '(', ')');
                refreshAction = $"refreshDiv('/{refreshAction}')";
                success       = refreshAction;
            }

            string submitbtnInnerText = "Add";
            string btnColor           = null;

            var addButton = ModalButton(modalBody: modalBody, formAction: formAction, success: success, title: title,
                                        submitbtnInnerText: submitbtnInnerText, btnColor: btnColor, btnInnerText: btnText,
                                        modalSize: modalSize);

            addButton.AddCssClass("btn");
            addButton.AddCssClass("purple");
            var item = new TagBuilder("i");

            item.AddCssClass("fa");
            item.AddCssClass("fa-plus");
            if (btnText.IsNullOrWhiteSpace())
            {
                btnText = "Add";
            }
            addButton.InnerHtml = $"{btnText} " + item;
            var retVal = MvcHtmlString.Create(addButton.ToString());

            return(retVal);
        }
示例#14
0
        public static TagBuilder ModalButton(string modalBody,
                                             string formAction,
                                             string success,
                                             string title,
                                             string submitbtnInnerText = null,
                                             string btnColor           = null,
                                             string btnInnerText       = null,
                                             ModalSize modalSize       = ModalSize.Default)
        {
            if (formAction == null)
            {
                formAction = modalBody;
            }
            var aHref = Modal(btnColor: btnColor, title: title, btnSize: "btn-sm", formSuccess: success,
                              formAction: formAction, modalBody: modalBody, modalSize: modalSize,
                              submitButtonText: submitbtnInnerText);

            if (btnInnerText != null)
            {
                aHref.SetInnerText(innerText: btnInnerText);
            }

            return(aHref);
        }
示例#15
0
        public virtual IHtmlString ModalLink(string actionName, string controllerName, object routeValues, ModalSize size)
        {
            var modalSize = string.Empty;

            switch (size)
            {
            case ModalSize.Small:
                modalSize = "modal-sm";
                break;

            case ModalSize.Normal:
                modalSize = "modal-md";
                break;

            case ModalSize.Large:
                modalSize = "modal-lg";
                break;

            default:
                break;
            }
            var result = $"href=\"#\" data-type=\"modal-link\" data-url=\"{ Url.Action(actionName, controllerName, routeValues) }\" data-modal-size=\"{ modalSize }\"";

            return(new HtmlString(result));
        }
示例#16
0
        public static IHtmlString DynamicAction(string modalTitle,
                                                string body,
                                                string formAction               = null,
                                                string onFormSuccess            = null,
                                                string refreshAction            = null,
                                                string fontAwsomIcon            = null,
                                                string @class                   = "",
                                                ModalSize modalSize             = ModalSize.Default,
                                                FontAwesomeSize fontAwesomeSize = FontAwesomeSize.fa2X)
        {
            if (refreshAction != null)
            {
                refreshAction = refreshAction.Trim('\'', '(', ')');
                refreshAction = $"refreshDiv('{refreshAction}')";
                onFormSuccess = refreshAction;
            }
            var size = string.Empty;

            switch (fontAwesomeSize)
            {
            case FontAwesomeSize.fa1x:
                break;

            case FontAwesomeSize.fa2X:
                size = "fa-2x";
                break;

            case FontAwesomeSize.fa3X:
                size = "fa-3x";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(fontAwesomeSize), actualValue: fontAwesomeSize,
                                                      message: null);
            }

            string modal_Size;

            switch (modalSize)
            {
            case ModalSize.Default:
                modal_Size = "";
                break;

            case ModalSize.Small:
                modal_Size = "modal-sm";
                break;

            case ModalSize.Large:
                modal_Size = "modal-lg";
                break;

            case ModalSize.FullScreen:
                modal_Size = "modal-full";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(modalSize), actualValue: modalSize, message: null);
            }

            var tag = new TagBuilder("a");

            tag.AddCssClass($"dynamicAction {@class}".TrimEnd());
            tag.Attributes["modal-class"]  = modal_Size;
            tag.Attributes["modal-title"]  = modalTitle;
            tag.Attributes["modal-body"]   = body;
            tag.Attributes["form-action"]  = formAction;
            tag.Attributes["form-success"] = onFormSuccess;
            tag.Attributes["modal-Name"]   = Guid.NewGuid().ToString("N");

            var i = new TagBuilder("i");

            i.AddCssClass($"fa {fontAwsomIcon} {size}");
            tag.InnerHtml = i.ToString();

            var retVal = MvcHtmlString.Create(tag.ToString(renderMode: TagRenderMode.Normal));

            return(retVal);
        }
示例#17
0
        public static IHtmlString Modal(this WebViewPage webViewPage,
                                        string title            = null,
                                        string btnColor         = null,
                                        string btnSize          = null,
                                        string formSuccess      = null,
                                        string formAction       = null,
                                        string modalBody        = null,
                                        ModalSize modalSize     = ModalSize.Default,
                                        string icon             = null,
                                        string innerText        = null,
                                        string modalId          = null,
                                        string submitButtonText = "Submit")
        {
            var modalTag = new TagBuilder("a");

            modalTag.AddCssClass("dynamicAction");
            if (btnColor != null)
            {
                modalTag.AddCssClass("btn");
                modalTag.AddCssClass(value: btnSize);
                modalTag.AddCssClass(value: btnColor);
            }

            if (modalId == null)
            {
                modalId = Guid.NewGuid().ToString("N");
            }
            var modalS = "";

            switch (modalSize)
            {
            case ModalSize.Default:
                modalS = "";
                break;

            case ModalSize.Small:
                modalS = "modal-sm";
                break;

            case ModalSize.Large:
                modalS = "modal-lg";
                break;

            case ModalSize.FullScreen:
                modalS = "modal-full";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(modalSize), actualValue: modalSize, message: null);
            }

            modalTag.Attributes["modal-Name"]   = modalId;
            modalTag.Attributes["modal-submit"] = submitButtonText;
            modalTag.Attributes["modal-class"]  = modalS;
            modalTag.Attributes["modal-title"]  = title;
            modalTag.Attributes["modal-body"]   = modalBody;
            modalTag.Attributes["form-action"]  = formAction;
            modalTag.Attributes["form-success"] = formSuccess;

            var item = new TagBuilder("i");

            item.AddCssClass("fa");

            if (!string.IsNullOrWhiteSpace(value: icon))
            {
                item.AddCssClass(value: icon);
            }

            if (!string.IsNullOrWhiteSpace(value: innerText))
            {
                modalTag.SetInnerText(innerText: innerText);
            }

            var retVal = MvcHtmlString.Create(modalTag.ToString());

            return(retVal);
        }
 /// <summary>
 /// Creates a reveal modal.
 /// </summary>
 /// <param name="html">The current HtmlHelper instance</param>
 /// <param name="id">The id of the element</param>
 /// <param name="size">The size of modal to create</param>
 /// <returns>A RevealModal</returns>
 public static RevealModal BeginZurbModal(this HtmlHelper html, string id, ModalSize size)
 {
     return new RevealModal(html, id, size);
 }
示例#19
0
 public virtual IHtmlString ModalLink(string actionName, string controllerName, ModalSize size) => ModalLink(actionName, controllerName, null, size);
示例#20
0
        public static IHtmlString EditButton(this object model,
                                             string controller,
                                             string tableId           = null,
                                             string success           = null,
                                             string action            = null,
                                             string body              = null,
                                             string title             = null,
                                             object id                = null,
                                             FontAwesomeSize?fontSize = null,
                                             ModalSize modalSize      = ModalSize.Default
                                             )
        {
            if (id == null)
            {
                dynamic modelD = model;
                id = modelD.Id;
            }
            controller = controller.Trim('/');

            if (success == null && tableId != null)
            {
                tableId = tableId.Trim('#');
                success = $"refreshParent('#{tableId}')";
            }
            if (action == null)
            {
                action = "edit";
            }
            if (body == null)
            {
                body = action;
            }
            string modalBody          = $"/{controller}/{body}/{id}";
            string formAction         = $"/{controller}/{action}/{id}";
            string submitbtnInnerText = "Save";
            var    aHref = ViewUtils.Button(modalBody: modalBody, formAction: formAction, success: success,
                                            title: title, modalSize: modalSize, submitbtnInnerText: submitbtnInnerText, btnColor: null);
            //var aHref = ViewUtils.Modal(title: title, formSuccess: success, formAction: $"/{controller}/{action}/{id}",
            //    modalBody: $"/{controller}/{body}/{id}", modalSize: modalSize, submitButtonText: "Save");

            var item = new TagBuilder("i");

            item.AddCssClass("fa");
            string faSize;

            switch (fontSize)
            {
            case FontAwesomeSize.fa2X:
                faSize = "fa-2x";
                break;

            case FontAwesomeSize.fa1x:
                faSize = "";
                break;

            case FontAwesomeSize.fa3X:
                faSize = "fa-3x";
                break;

            default:
                faSize = "fa-2x";
                break;
            }

            item.AddCssClass(faSize);
            item.AddCssClass("fa-edit");
            item.Attributes["style"] = "color:#a48334;";
            aHref.InnerHtml          = item.ToString();


            var retVal = MvcHtmlString.Create(aHref.ToString());

            return(retVal);
        }
 public Size(ModalSize size)
 {
     this.size = size;
 }
示例#22
0
 public virtual IHtmlString ModalLink(string actionName, object routeValues, ModalSize size) => ModalLink(actionName, null, routeValues, size);