Exemplo n.º 1
0
        public DateEditor(jQueryObject input)
            : base(input, new object())
        {
            input.AddClass("dateQ");
            input.DatePicker(new DatePickerOptions
            {
                ShowOn     = "button",
                BeforeShow = new Func <bool>(delegate
                {
                    return(!input.HasClass("readonly"));
                }),
                YearRange = YearRange ?? "-100:+50"
            });

            input.Bind("keyup." + this.uniqueName, e => {
                if (e.Which == 32 && !ReadOnly)
                {
                    if (this.ValueAsDate != JsDate.Today)
                    {
                        this.ValueAsDate = JsDate.Today;
                        this.element.Trigger("change");
                    }
                }
                else
                {
                    DateInputKeyup(e);
                }
            });

            input.Bind("change." + this.uniqueName, DateInputChange);

            input.AddValidationRule(this.uniqueName, e =>
            {
                var value = this.Value;
                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }

                if (!string.IsNullOrEmpty(MinValue) &&
                    String.Compare(value, MinValue) < 0)
                {
                    return(String.Format(Q.Text("Validation.MinDate"),
                                         Q.FormatDate(MinValue)));
                }

                if (!string.IsNullOrEmpty(MaxValue) &&
                    String.Compare(value, MaxValue) >= 0)
                {
                    return(String.Format(Q.Text("Validation.MaxDate"),
                                         Q.FormatDate(MaxValue)));
                }

                return(null);
            });

            SqlMinMax = true;
        }
Exemplo n.º 2
0
 public DateEditor(jQueryObject input)
     : base(input, new object())
 {
     input.AddClass("dateQ");
     input.DatePicker(new DatePickerOptions
     {
         ShowOn     = "button",
         BeforeShow = new Func <bool>(delegate
         {
             return(!input.HasClass("readonly"));
         })
     });
 }
Exemplo n.º 3
0
        public DateEditor(jQueryObject input)
            : base(input, new object())
        {
            input.AddClass("dateQ");
            input.DatePicker(new DatePickerOptions
            {
                ShowOn     = "button",
                BeforeShow = new Func <bool>(delegate
                {
                    return(!input.HasClass("readonly"));
                })
            });

            input.Bind("keyup." + this.uniqueName, DateInputKeyup);

            input.Bind("change." + this.uniqueName, DateInputChange);

            input.AddValidationRule(this.uniqueName, e =>
            {
                var value = this.Value;
                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }

                if (!string.IsNullOrEmpty(MinValue) &&
                    String.Compare(value, MinValue) < 0)
                {
                    return(String.Format(Q.Text("Validation.MinDate"),
                                         Q.FormatDate(Q.ParseISODateTime(MinValue))));
                }

                if (!string.IsNullOrEmpty(MaxValue) &&
                    String.Compare(value, MaxValue) >= 0)
                {
                    return(String.Format(Q.Text("Validation.MaxDate"),
                                         Q.FormatDate(Q.ParseISODateTime(MaxValue))));
                }

                return(null);
            });

            SqlMinMax = true;
        }