Beispiel #1
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            if (Title.HasValue())
            {
                json["title"] = Title;
            }

            if (HtmlAttributes.Any())
            {
                var attributes = new Dictionary <string, object>();

                HtmlAttributes.Each(attr => {
                    attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString());
                });

                json["attributes"] = attributes;
            }

            if (FooterHtmlAttributes.Any())
            {
                var attributes = new Dictionary <string, object>();

                FooterHtmlAttributes.Each(attr =>
                {
                    attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString());
                });

                json["footerAttributes"] = attributes;
            }

            if (Hidden)
            {
                json["hidden"] = true;
            }

            if (!IncludeInMenu)
            {
                json["menu"] = false;
            }

            if (Width.HasValue())
            {
                json["width"] = Width;
            }

            if (ClientTemplate.HasValue())
            {
                json["template"] = HttpUtility.UrlDecode(ClientTemplate);
            }

            if (ClientFooterTemplate.HasValue())
            {
                json["footerTemplate"] = HttpUtility.UrlDecode(ClientFooterTemplate);
            }

            if (!Encoded)
            {
                json["encoded"] = Encoded;
            }
        }
        protected override void Serialize(IDictionary <string, object> json)
        {
            //>> Serialization

            if (Height.HasValue())
            {
                json["height"] = Height;
            }

            if (Width.HasValue())
            {
                json["width"] = Width;
            }

            //<< Serialization

            if (Direction.HasValue)
            {
                json["direction"] = Direction;
            }
        }
Beispiel #3
0
        protected override void RenderAttributes(XElement element, FoRenderOptions options)
        {
            if (Src.IsNullOrWhiteSpace())
            {
                throw new PropertyNotSetException(nameof(Src));
            }
            element.Add(new XAttribute("src", Src));

            if (Width.HasValue())
            {
                element.Add(new XAttribute("width", Width));
            }
            if (Height.HasValue())
            {
                element.Add(new XAttribute("height", Height));
            }
            if (ContentWidth.HasValue())
            {
                element.Add(new XAttribute("content-width", ContentWidth));
            }
            if (ContentHeight.HasValue())
            {
                element.Add(new XAttribute("content-height", ContentHeight));
            }
            if (Scaling != FoScaling.Unspecified)
            {
                element.Add(new XAttribute("scaling", ToKebabCase(Scaling)));
            }
            if (ScalingMethod != FoScalingMethod.Unspecified)
            {
                element.Add(new XAttribute("scaling-method", ToKebabCase(ScalingMethod)));
            }

            if (Margin.HasValue())
            {
                element.Add(new XAttribute("margin", Margin));
            }
            if (MarginTop.HasValue())
            {
                element.Add(new XAttribute("margin-top", MarginTop));
            }
            if (MarginRight.HasValue())
            {
                element.Add(new XAttribute("margin-right", MarginRight));
            }
            if (MarginBottom.HasValue())
            {
                element.Add(new XAttribute("margin-bottom", MarginBottom));
            }
            if (MarginLeft.HasValue())
            {
                element.Add(new XAttribute("margin-left", MarginLeft));
            }

            if (Padding.HasValue())
            {
                element.Add(new XAttribute("padding", Padding));
            }
            if (PaddingTop.HasValue())
            {
                element.Add(new XAttribute("padding-top", PaddingTop));
            }
            if (PaddingRight.HasValue())
            {
                element.Add(new XAttribute("padding-right", PaddingRight));
            }
            if (PaddingBottom.HasValue())
            {
                element.Add(new XAttribute("padding-bottom", PaddingBottom));
            }
            if (PaddingLeft.HasValue())
            {
                element.Add(new XAttribute("padding-left", PaddingLeft));
            }

            base.RenderAttributes(element, options);
        }
Beispiel #4
0
        protected override void Serialize(IDictionary <string, object> json)
        {
            if (Title.HasValue())
            {
                json["title"] = Title;
            }

            if (HtmlAttributes.Any())
            {
                var attributes = new Dictionary <string, object>();

                var hasAntiXss = HttpEncoder.Current != null && HttpEncoder.Current.GetType().ToString().Contains("AntiXssEncoder");

                HtmlAttributes.Each(attr => {
                    var value = HttpUtility.HtmlAttributeEncode(attr.Value.ToString());
                    if (hasAntiXss)
                    {
                        value = value.Replace("&#32;", " ");
                    }
                    attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = value;
                });

                json["attributes"] = attributes;
            }

            if (FooterHtmlAttributes.Any())
            {
                var attributes = new Dictionary <string, object>();

                FooterHtmlAttributes.Each(attr =>
                {
                    attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString());
                });

                json["footerAttributes"] = attributes;
            }

            if (Hidden)
            {
                json["hidden"] = true;
            }

            if (!IncludeInMenu)
            {
                json["menu"] = false;
            }

            if (Width.HasValue())
            {
                json["width"] = Width;
            }

            if (ClientTemplate.HasValue())
            {
                json["template"] = HttpUtility.UrlDecode(ClientTemplate);
            }

            if (ClientFooterTemplate.HasValue())
            {
                json["footerTemplate"] = HttpUtility.UrlDecode(ClientFooterTemplate);
            }

            if (!Encoded)
            {
                json["encoded"] = Encoded;
            }
        }
Beispiel #5
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            var options         = new Dictionary <string, object>(Events);
            var positionOptions = new Dictionary <string, object>();

            if (Position.Bottom != 20)
            {
                positionOptions.Add("bottom", Position.Bottom);
            }
            if (Position.Right != 20)
            {
                positionOptions.Add("right", Position.Right);
            }
            if (Position.Top != int.MinValue)
            {
                positionOptions.Add("top", Position.Top);
            }
            if (Position.Left != int.MinValue)
            {
                positionOptions.Add("left", Position.Left);
            }
            if (!Position.Pinned)
            {
                positionOptions.Add("pinned", Position.Pinned);
            }

            if (positionOptions.Count > 0)
            {
                options.Add("position", positionOptions);
            }

            if (Stacking != NotificationStackingSettings.Default)
            {
                options["stacking"] = Stacking;
            }

            if (!HideOnClick)
            {
                options["hideOnClick"] = HideOnClick;
            }

            if (Button)
            {
                options["button"] = Button;
            }

            if (AllowHideAfter > 0)
            {
                options["allowHideAfter"] = AllowHideAfter;
            }

            if (AutoHideAfter != 5000)
            {
                options["autoHideAfter"] = AutoHideAfter;
            }

            if (AppendTo.HasValue())
            {
                options["appendTo"] = AppendTo;
            }

            if (Width.HasValue())
            {
                options["width"] = Width;
            }

            if (Height.HasValue())
            {
                options["height"] = Height;
            }

            var animation = Animation.ToJson();

            if (animation.Any())
            {
                if (animation["animation"] is bool)
                {
                    options["animation"] = false;
                }
                else
                {
                    options["animation"] = animation["animation"];
                }
            }

            if (Templates.Any())
            {
                options["templates"] = Templates.Select(t => t.Serialize());
            }

            writer.Write(Initializer.Initialize(Selector, "Notification", options));

            base.WriteInitializationScript(writer);
        }