Beispiel #1
0
        /* Useful functions but not part of the emulation layer. Should perhaps be somehwere else
         */

        public static jQueryObject Prev(jQueryObject q, string selector)
        {
            for (q = q.Prev(); q.Size() > 0 && !q.Is(selector); q = q.Prev())
            {
                ;
            }
            return(q);
        }
Beispiel #2
0
        private void EditDetails(jQueryEvent e)
        {
            jQueryObject edits = this.Obj.Find(".keyvaluerow .edit");

            edits.Show(EffectDuration.Fast);
            edits.Prev(".value").Hide(EffectDuration.Fast);

            this.EditButton.Hide(EffectDuration.Fast);
            this.SaveButton.Show(EffectDuration.Fast);
        }
Beispiel #3
0
        public DateTimeEditor(jQueryObject input, DateTimeEditorOptions opt)
            : base(input, opt)
        {
            input.AddClass("dateQ s-DateTimeEditor")
            .DatePicker(new DatePickerOptions
            {
                ShowOn     = "button",
                BeforeShow = new Func <bool>(delegate
                {
                    return(!input.HasClass("readonly"));
                }),
                YearRange = options.YearRange ?? "-100:+50"
            });

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

            time = J("<select/>").AddClass("editor s-DateTimeEditor time");
            var after = input.Next(".ui-datepicker-trigger");

            if (after.Length > 0)
            {
                time.InsertAfter(after);
            }
            else
            {
                after = input.Prev(".ui-datepicker-trigger");
                if (after.Length > 0)
                {
                    time.InsertBefore(after);
                }
                else
                {
                    time.InsertAfter(input);
                }
            }

            foreach (var t in GetTimeOptions(fromHour: options.StartHour ?? 0,
                                             toHour: options.EndHour ?? 23,
                                             stepMins: options.IntervalMinutes ?? 5))
            {
                Q.AddOption(time, t, t);
            }

            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;

            J("<div class='inplace-button inplace-now'><b></b></div>")
            .Attribute("title", "set to now")
            .InsertAfter(time)
            .Click(e =>
            {
                if (this.Element.HasClass("readonly"))
                {
                    return;
                }

                this.ValueAsDate = JsDate.Now;
            });

            time.On("change", e => input.TriggerHandler("change"));
        }