Exemplo n.º 1
0
        public RouteValueDictionary AsHtmlAttributes(object htmlAttributes = null)
        {
            var res = AnonymousHelper.ToDictionary(htmlAttributes);

            res = this.merges.Aggregate(res, (current, attributeMerge) => attributeMerge.Merge(current));
            return(res);
        }
Exemplo n.º 2
0
        public MvcForm BeginForm(Action <BeginFormSetting> action, object attributes = null)
        {
            var setting = new BeginFormSetting();

            action(setting);

            var attr = AnonymousHelper.ToDictionary(attributes);

            if (!attr.ContainsKey("class"))
            {
                attr.Set("class", "form-horizontal");
            }
            attr.Set("action", this.htmlHelper.ViewContext.HttpContext.Request.RawUrl);

            if (setting.IsUploadForm)
            {
                attr.Set("enctype", "multipart/form-data");
            }

            var meta = this.htmlHelper
                       .When(JqueryBind.Submit)
                       .DoWithPreventDefaultAndStopPropagation()
                       .Submit()
                       .OnBegin(dsl => dsl.Self().JqueryPlugIn().Block.Lock(options => { }))
                       .OnError(dsl => dsl.Self().Core().Form.Validation.Refresh())
                       .OnSuccess(dsl =>
            {
                if (setting.CloseDialog)
                {
                    dsl.With(selector => selector.Id(GlobalSelector.DefaultDialogId)).JqueryUI().Dialog.Close();
                }

                if (setting.ReloadSubmit)
                {
                    dsl.With(selector => selector.Id(GlobalSelector.DefaultDialogId)).Core().Insert.Html();
                    dsl.With(selector => selector.Id(GlobalSelector.DefaultDialogId)).Browsio().CenterDialog();
                }

                if (!string.IsNullOrWhiteSpace(setting.NotificationMessage))
                {
                    dsl.Self().JqueryPlugIn().Notification.PinesNoty.Show(options => { options.Text = setting.NotificationMessage; });
                }

                if (setting.RedirectToSelf)
                {
                    dsl.Utilities.Document.RedirectToSelf();
                }

                if (setting.IsBack)
                {
                    dsl.Utilities.Document.HistoryGo(-1);
                }
            })
                       .OnComplete(dsl => dsl.Self().JqueryPlugIn().Block.UnLock())
                       .AsHtmlAttributes(attr);

            return(this.htmlHelper.BeginForm(setting.Action, setting.Controller, FormMethod.Post, meta));
        }
        internal static TagBuilder CreateInput(string value, string type, object attributes)
        {
            var routeValueDictionary = AnonymousHelper.ToDictionary(attributes);

            routeValueDictionary.Merge(new { value, type });
            var input = CreateTag(HtmlTag.Input, HtmlString.Empty, routeValueDictionary);

            return(input);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Set properties for every matched element in context.
        /// </summary>
        /// <param name="attr">Html attributes</param>
        public IExecutableSetting SetProp(object attr)
        {
            var codes = AnonymousHelper
                        .ToDictionary(attr)
                        .Select(valuePair => JavaScriptCodeTemplate.Target_SetProp.F(valuePair.Key.ToLower(), Selector.FromObject(valuePair.Value)))
                        .ToList();

            return(this.plugInDsl.Registry(new ExecutableEval(codes)));
        }
Exemplo n.º 5
0
        public MvcHtmlString Anchor(string href, MvcHtmlString content, object attributes = null)
        {
            var routeValue = AnonymousHelper.ToDictionary(attributes);

            routeValue.Set("href", href);
            var a = CreateTag(HtmlTag.A, content, routeValue);

            return(new MvcHtmlString(a.ToString()));
        }
Exemplo n.º 6
0
        public MvcHtmlString Img(string src, MvcHtmlString content, object attributes = null)
        {
            var routeValueDictionary = AnonymousHelper.ToDictionary(attributes);

            routeValueDictionary.Merge(new { src });
            var img = CreateTag(HtmlTag.Img, content, routeValueDictionary);

            return(new MvcHtmlString(img.ToString()));
        }
        public IHtmlContent Img(string src, IHtmlContent content, object attributes = null)
        {
            var routeValueDictionary = AnonymousHelper.ToDictionary(attributes);

            routeValueDictionary.Merge(new { src });
            var img = CreateTag(HtmlTag.Img, content, routeValueDictionary);

            return(img);
        }
        public IHtmlContent Anchor(string href, IHtmlContent content, object attributes = null)
        {
            var routeValue = AnonymousHelper.ToDictionary(attributes);

            routeValue.Set("href", href);
            var a = CreateTag(HtmlTag.A, content, routeValue);

            return(a);
        }
        public IInventFactoryDsl <T> Tunings(object propertiesMap)
        {
            var dictionary = AnonymousHelper.ToDictionary(propertiesMap);

            foreach (var valuePair in dictionary)
            {
                Tuning(valuePair.Key, valuePair.Value);
            }
            return(this);
        }
Exemplo n.º 10
0
        public static string ActionArea(this IUrlHelper urlHelper, [AspMvcAction] string action, [AspMvcController] string controller, [AspMvcArea] string area, object routes = null)
        {
            Guard.NotNullOrWhiteSpace("action", action);
            Guard.NotNullOrWhiteSpace("controller", controller);

            var routeValues = AnonymousHelper.ToDictionary(routes);

            routeValues.Set("area", area);
            return(urlHelper.Action(action, controller, routeValues));
        }
Exemplo n.º 11
0
            public UrlQueryDispatcher(UrlHelper urlHelper, object query)
            {
                defaultRoutes = new RouteValueDictionary();
                defaultRoutes.Add("incType", GetTypeName(typeof(TQuery)));
                if (typeof(TQuery).IsGenericType)
                {
                    defaultRoutes.Add("incGeneric", typeof(TQuery).GetGenericArguments().Select(r => GetTypeName(r))
                                      .AsString(","));
                }

                this.urlHelper = urlHelper;
                this.query     = AnonymousHelper.ToDictionary(query);
            }
Exemplo n.º 12
0
        /// <summary>
        ///     Mock HttpContext.QueryString object
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public MockController <TController> StubQueryString(object values)
        {
            var dictionary = new Dictionary <string, StringValues>();

            foreach (var keyValuePair in AnonymousHelper.ToDictionary(values))
            {
                dictionary.Set(keyValuePair.Key, keyValuePair.Value.ToString());
            }

            httpContext
            .SetupGet(r => r.Request.Query)
            .Returns(new QueryCollection(dictionary));

            return(this);
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Mock HttpContext.QueryString object
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public MockController <TController> StubQueryString(object values)
        {
            var nameValueCollection = new NameValueCollection();

            foreach (var keyValuePair in AnonymousHelper.ToDictionary(values))
            {
                nameValueCollection.Add(keyValuePair.Key, keyValuePair.Value.ToString());
            }

            httpContext
            .SetupGet(r => r.Request.QueryString)
            .Returns(nameValueCollection);

            return(this);
        }
Exemplo n.º 14
0
        public RouteValueDictionary AsHtmlAttributes(object htmlAttributes = null)
        {
            const string dataIncodingKey = "incoding";
            var          res             = new RouteValueDictionary(AnonymousHelper.ToDictionary(htmlAttributes));
            var          callbacks       = merges.Select(@base => @base.AsObject()).ToArray();

            if (!res.ContainsKey(dataIncodingKey))
            {
                res.Add(dataIncodingKey, callbacks.ToJsonString());
            }
            else
            {
                var newArray = res[dataIncodingKey].ToString().DeserializeFromJson <ExecutableBase.Json[]>().ToList();
                newArray.AddRange(callbacks);
                res[dataIncodingKey] = newArray.ToJsonString();
            }

            return(res);
        }
Exemplo n.º 15
0
        public void Attr(object attr)
        {
            var allAttr = AnonymousHelper.ToDictionary(attr);

            const string dataIncodingKey = "incoding";

            if (allAttr.ContainsKey(dataIncodingKey))
            {
                var meta = new List <object>();
                if (this.attributes.ContainsKey(dataIncodingKey))
                {
                    meta = (this.attributes[dataIncodingKey].ToString().DeserializeFromJson <object>() as JContainer)
                           .Cast <object>()
                           .ToList();
                }

                var newMeta = (allAttr[dataIncodingKey].ToString().DeserializeFromJson <object>() as JContainer).Cast <object>().ToList();
                meta.AddRange(newMeta);

                allAttr.Set(dataIncodingKey, meta.ToJsonString());
            }

            this.attributes.Merge(allAttr);
        }
 public IGridBuilderOptions <T> HeadAttr(object htmlAttributes)
 {
     return(HeadAttr(AnonymousHelper.ToDictionary(htmlAttributes)));
 }
Exemplo n.º 17
0
 public ActionResult ForgotPassword(ForgotUserPasswordCommand command)
 {
     command.Token             = Guid.NewGuid().ToString().Replace("-", string.Empty);
     command.ChangePasswordUrl = Url.Action("ChangePassword", "Account", AnonymousHelper.ToDictionary(new { ResetToken = command.Token }), "http", Request.Url.DnsSafeHost);
     return(TryPush(command, setting => setting.SuccessResult = () => RedirectToAction("LandingAjax", "Notification", new { type = "success", message = "Your new password sent to you by e-mail" })));
 }
 public IGridBuilderOptions <T> HeadClass(B htmlClass)
 {
     return(HeadAttr(AnonymousHelper.ToDictionary(new { @class = htmlClass.ToLocalization() })));
 }
 public IColumn <T> HeadClass(B htmlClass)
 {
     return(HeadAttr(AnonymousHelper.ToDictionary(new { @class = htmlClass.ToLocalization() })));
 }
        public IHtmlContent Li(IHtmlContent content, object attributes = null)
        {
            var tag = CreateTag(HtmlTag.Li, content, AnonymousHelper.ToDictionary(attributes));

            return(tag);
        }
        public IHtmlContent I(object attributes = null)
        {
            var tag = CreateTag(HtmlTag.I, HtmlString.Empty, AnonymousHelper.ToDictionary(attributes));

            return(tag);
        }
        public IHtmlContent Div(IHtmlContent content, object attributes = null)
        {
            var div = CreateTag(HtmlTag.Div, content, AnonymousHelper.ToDictionary(attributes));

            return(div);
        }
 public IGridBuilderOptions <T> HeadClass(string htmlClass)
 {
     return(HeadAttr(AnonymousHelper.ToDictionary(new { @class = htmlClass })));
 }
 public IColumn <T> Class(string htmlClass)
 {
     return(Attr(AnonymousHelper.ToDictionary(new { @class = htmlClass })));
 }
        public IHtmlContent Button(string value, object attributes = null)
        {
            var button = CreateTag(HtmlTag.Button, new HtmlString(value), AnonymousHelper.ToDictionary(attributes));

            return(button);
        }
Exemplo n.º 26
0
        public override MvcHtmlString Render()
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append(Label.Render());

            var controlContainer = IncodingHtmlHelper.CreateTag(HtmlTag.Div, Input.Render(), new RouteValueDictionary(new { @class = "controls" }));

            stringBuilder.Append(controlContainer);

            stringBuilder.Append(Validation.Render());
            stringBuilder.Append(HelpBlock.Render());

            var controlGroup = IncodingHtmlHelper.CreateTag(HtmlTag.Div, new MvcHtmlString(stringBuilder.ToString()), AnonymousHelper.ToDictionary(this.attributes));

            return(new MvcHtmlString(controlGroup.ToString()));
        }
        public IHtmlContent Tag(HtmlTag tag, IHtmlContent content, object attributes = null)
        {
            var res = CreateTag(tag, content, AnonymousHelper.ToDictionary(attributes));

            return(res);
        }
 public BeginTag BeginTag(HtmlTag tag, object attributes = null)
 {
     return(new BeginTag(htmlHelper, tag, AnonymousHelper.ToDictionary(attributes)));
 }
Exemplo n.º 29
0
 public void Attr(object attr)
 {
     Attr(AnonymousHelper.ToDictionary(attr));
 }
 public IColumn <T> HeadAttr(object htmlAttributes)
 {
     return(HeadAttr(AnonymousHelper.ToDictionary(htmlAttributes)));
 }