Beispiel #1
0
 public DatePicker(ViewContext viewContext, IJavaScriptInitializer initializer, ViewDataDictionary viewData)
     : base(viewContext, initializer, viewData)
 {
     EnableFooter = true;
     Min = defaultMinDate;
     Max = defaultMaxDate;
     MonthTemplate = new MonthTemplate();
 }
Beispiel #2
0
 public DatePicker(ViewContext viewContext, IJavaScriptInitializer initializer, ViewDataDictionary viewData)
     : base(viewContext, initializer, viewData)
 {
     EnableFooter  = true;
     Min           = defaultMinDate;
     Max           = defaultMaxDate;
     MonthTemplate = new MonthTemplate();
 }
Beispiel #3
0
        public Calendar(ViewContext viewContext, IJavaScriptInitializer initializer, IUrlGenerator urlGenerator)
            : base(viewContext, initializer)
        {
            this.urlGenerator = urlGenerator;

            MonthTemplate = new MonthTemplate();

            SelectionSettings = new CalendarSelectionSettings();
            EnableFooter      = true;
        }
Beispiel #4
0
        public Calendar(ViewContext viewContext, IJavaScriptInitializer initializer, IUrlGenerator urlGenerator)
            : base(viewContext, initializer)
        {
            this.urlGenerator = urlGenerator;

            MonthTemplate = new MonthTemplate();

            SelectionSettings = new CalendarSelectionSettings();
            EnableFooter = true;
        }
Beispiel #5
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 (Culture.HasValue())
            {
                options["culture"] = Culture;
            }

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

            options["format"] = Format;

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

            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;
            }

            options["interval"] = Interval;

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

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

            base.WriteInitializationScript(writer);
        }
Beispiel #6
0
        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);
        }