예제 #1
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            var idPrefix = "#";

            if (IsInClientTemplate)
            {
                idPrefix = "\\" + idPrefix;
            }

            var animation = Animation.ToJson();

            if (animation.Keys.Any())
            {
                options["animation"] = animation["animation"];
            }

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

            if (Culture.HasValue())
            {
                options["culture"] = Culture;
            }

            options["format"] = Format;

            if (ParseFormats.Any())
            {
                options["parseFormats"] = ParseFormats;
            }

            options["min"] = Min;
            options["max"] = Max;

            if (EnableFooter)
            {
                if (FooterId.HasValue())
                {
                    options["footer"] = new ClientHandlerDescriptor {
                        HandlerName = string.Format("$('{0}{1}').html()", idPrefix, FooterId)
                    };
                }
                else if (Footer.HasValue())
                {
                    options["footer"] = Footer;
                }
            }
            else
            {
                options["footer"] = EnableFooter;
            }

            if (Depth.HasValue())
            {
                options["depth"] = Depth;
            }

            if (Start.HasValue())
            {
                options["start"] = Start;
            }

            MonthTemplate.IdPrefix = idPrefix;

            var month = MonthTemplate.ToJson();

            if (month.Keys.Any())
            {
                options["month"] = month;
            }

            if (Dates.Any())
            {
                options["dates"] = Dates;
            }

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

            base.WriteInitializationScript(writer);
        }
예제 #2
0
파일: Calendar.cs 프로젝트: akhuang/Zing
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            var idPrefix = "#";

            if (IsInClientTemplate)
            {
                idPrefix = "\\" + idPrefix;
            }

            if (Culture.HasValue())
            {
                options["culture"] = Culture;
            }

            if (Value.HasValue)
            {
                options["value"] = Value;
            }

            if (Min.HasValue)
            {
                options["min"] = Min;
            }

            if (Max.HasValue)
            {
                options["max"] = Max;
            }

            if (Format.HasValue())
            {
                options["format"] = Format;
            }

            if (EnableFooter)
            {
                if (FooterId.HasValue())
                {
                    options["footer"] = new ClientHandlerDescriptor {
                        HandlerName = string.Format("$('{0}{1}').html()", idPrefix, FooterId)
                    };
                }
                else if (Footer.HasValue())
                {
                    options["footer"] = Footer;
                }
            }
            else
            {
                options["footer"] = EnableFooter;
            }

            if (Depth.HasValue())
            {
                options["depth"] = Depth;
            }

            if (Start.HasValue())
            {
                options["start"] = Start;
            }

            MonthTemplate.IdPrefix = idPrefix;

            var month = MonthTemplate.ToJson();

            if (month.Keys.Any())
            {
                options["month"] = month;
            }

            if (SelectionSettings.Dates.Any())
            {
                options["dates"] = SelectionSettings.Dates;
            }

            var url = SelectionSettings.GenerateUrl(ViewContext, urlGenerator);

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

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

            base.WriteInitializationScript(writer);
        }