Exemplo n.º 1
0
        public PhoneEditor(jQueryObject input)
            : base(input)
        {
            this.AddValidationRule(this.uniqueName, (e) =>
            {
                string value = this.Value.TrimToNull();
                if (value == null)
                {
                    return(null);
                }

                return(Validate(value, this.Multiple));
            });

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                {
                    return;
                }

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });
        }
Exemplo n.º 2
0
        public PhoneEditor(jQueryObject input)
            : base(input)
        {
            this.AddValidationRule(this.uniqueName, (e) =>
            {
                string value = this.Value.TrimToNull();
                if (value == null)
                    return null;

                return Validate(value, this.Multiple);
            });

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                    return;

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });
        }
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"));
                }),
                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;
        }
        public ViewFocus(ViewBase view, jQueryObject element)
        {
            // Setup initial conditions.
            this.view = view;
            this.element = element;

            // Wire up events.
            element.Bind(Html.Focus, delegate(jQueryEvent e) { HandleFocusChanged(true); });
            element.Bind(Html.Blur, delegate(jQueryEvent e) { HandleFocusChanged(false); });
            view.IsEnabledChanged += HandleIsEnabledChanged;
        }
Exemplo n.º 5
0
        public PhoneEditor(jQueryObject input, PhoneEditorOptions opt)
            : base(input, opt)
        {
            var self = this;

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

                return(Validate(value, options.Multiple, options.Internal, options.Mobile));
            });

            string hint = options.Internal ?
                          "Dahili telefon numarası '456, 8930, 12345' formatlarında" :
                          (options.Mobile ? "Cep telefonu numarası '(533) 342 01 89' formatında" :
                           "Telefon numarası '(216) 432 10 98' formatında");

            if (options.Multiple)
            {
                hint = hint.Replace("numarası", "numaraları") + " ve birden fazlaysa virgülle ayrılarak ";
            }

            hint += " girilmelidir.";

            input.Attribute("title", hint);

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                {
                    return;
                }

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });
        }
Exemplo n.º 6
0
        public DateTimeEditor(jQueryObject input, DateTimeEditorOptions opt)
            : base(input, opt)
        {
            input.AddClass("dateQ s-DateTimeEditor")
            .DatePicker(new DatePickerOptions {
                ShowOn = "button"
            });

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

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

            foreach (var t in GetTimeOptions(fromHour: options.StartHour ?? 0,
                                             toHour: options.EndHour ?? 23,
                                             stepMins: options.IntervalMinutes ?? 30))
            {
                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(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);
            });
        }
Exemplo n.º 7
0
        public static void AddIncludeDeletedToggle <TEntity>(jQueryObject toolDiv,
                                                             SlickRemoteView <TEntity> view, string hint = null, bool initial = false)
        {
            bool includeDeleted = false;

            var oldSubmit = view.OnSubmit;

            view.OnSubmit = (v) =>
            {
                v.Params.IncludeDeleted = includeDeleted;
                if (oldSubmit != null)
                {
                    return(oldSubmit(v));
                }

                return(true);
            };

            AddToggleButton(toolDiv,
                            cssClass: "s-IncludeDeletedToggle",
                            initial: initial,
                            hint: hint ?? "silinmiş kayıtları da göster",
                            callback: (pressed) =>
            {
                includeDeleted  = pressed;
                view.SeekToPage = 1;
                view.Populate();
            });

            toolDiv.Bind("remove", delegate
            {
                view.OnSubmit = null;
                oldSubmit     = null;
            });
        }
Exemplo n.º 8
0
        public XrmDateEditor(EditorArguments args) : base(args)
        {
            XrmDateEditor self = this;

            _container = jQuery.FromHtml("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr>" +
                                         "<td><INPUT type=text class='sparkle-input-inline' /></td>" +
                                         "<td class='lookup-button-td'><input type=button class='sparkle-imagestrip-inlineedit_calendar_icon' /></td></tr></table></div>");
            _container.AppendTo(_args.Container);

            _input = _container.Find(".sparkle-input-inline");
            _input.Bind("keydown.nav", delegate(jQueryEvent e)
            {
                if (!_calendarOpen && (e.Which == 38 || e.Which == 40) && e.CtrlKey) // Ctrl-Up/Down shows date picker
                {
                    _input.Plugin <DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                    e.StopImmediatePropagation();
                }
                else if (_calendarOpen && e.Which == 13)
                {
                    e.PreventDefault();
                }
            });
            jQueryObject selectButton = _container.Find(".sparkle-imagestrip-inlineedit_calendar_icon");

            _input.Focus().Select();
            DatePickerOptions2 options2 = new DatePickerOptions2();

            options2.ShowOtherMonths = true;
            options2.ShowOn          = ""; // Date Pickers in CRM do not show when they are focused - you click the button
            options2.FirstDay        = OrganizationServiceProxy.OrganizationSettings != null ? OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value : 0;
            options2.BeforeShow      = delegate()
            {
                this._calendarOpen = true;
            };

            options2.OnClose = delegate()
            {
                this._calendarOpen = false;
                _selectedValue     = GetSelectedValue();
            };

            options2.OnSelect = delegate(string dateString, object instance)
            {
                // Select the date text field when selecting a date
                Focus();
            };

            if (OrganizationServiceProxy.UserSettings != null)
            {
                _dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }
            options2.DateFormat = _dateFormat;
            _input.Plugin <DatePickerPlugIn>().DatePicker(options2);

            // Wire up the date picker button
            selectButton.Click(delegate(jQueryEvent e){
                _input.Plugin <DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                Focus();
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a widget on given element. Widget gets a unique name like MyNamespace_MyWidget1234.
        /// </summary>
        /// <remarks>
        /// * A data value is added to element with this unique name as key, and the widget object as value.
        /// * Only one widget instance of same class can be created on a element.
        /// * All events attached by this widget class will be unbound when element is removed from document.
        /// * Elements gets a css class like "s-MyWidget" (it has no namespace by default, but this can be customized)
        /// </remarks>
        protected Widget(jQueryObject element)
        {
            this.element    = element;
            this.widgetName = WidgetExtensions.GetWidgetName(this.GetType());
            this.uniqueName = widgetName + (NextWidgetNumber++).ToString();

            if (element.GetDataValue(widgetName) != null)
            {
                throw new Exception(String.Format("The element already has widget '{0}'!", widgetName));
            }

            var self = this;

            element.Bind("remove." + widgetName, (e) => self.Destroy())
            .Data(widgetName, this);

            AddCssClass();

            if (IsAsyncWidget())
            {
                Window.SetTimeout(delegate()
                {
                    if (element != null && asyncPromise == null)
                    {
                        asyncPromise = this.InitializeAsync();
                    }
                }, 0);
            }
        }
Exemplo n.º 10
0
        public URLEditor(jQueryObject input)
            : base(input)
        {
            input.AddClass("url").Attribute("title",
                                            "URL 'http://www.site.com/sayfa' formatında girilmelidir.");

            input.Bind("blur." + this.uniqueName, delegate
            {
                var validator = input.Closest("form").GetDataValue("validator").As <jQueryValidator>();
                if (validator == null)
                {
                    return;
                }

                if (!input.HasClass("error"))
                {
                    return;
                }

                var value = input.GetValue().TrimToNull();
                if (value == null)
                {
                    return;
                }

                value = "http://" + value;

                if (((dynamic)(jQueryValidator.Methods["url"])).apply(validator, new object[] { value, input[0] }) == true)
                {
                    input.Value(value);
                    validator.ValidateElement(input[0]);
                }
            });
        }
Exemplo n.º 11
0
        public URLEditor(jQueryObject input)
            : base(input)
        {
            input.AddClass("url").Attribute("title",
                "URL 'http://www.site.com/sayfa' formatında girilmelidir.");

            input.Bind("blur." + this.uniqueName, delegate
            {
                var validator = input.Closest("form").GetDataValue("validator").As<jQueryValidator>();
                if (validator == null)
                    return;

                if (!input.HasClass("error"))
                    return;

                var value = input.GetValue().TrimToNull();
                if (value == null)
                    return;

                value = "http://" + value;

                if (((dynamic)(jQueryValidator.Methods["url"])).apply(validator, new object[] { value, input[0] }) == true)
                {
                    input.Value(value);
                    validator.ValidateElement(input[0]);
                }
            });
        }
Exemplo n.º 12
0
        public XrmDateEditor(EditorArguments args)
            : base(args)
        {
            XrmDateEditor self = this;
            _container = jQuery.FromHtml("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr>" +
                "<td><INPUT type=text class='sparkle-input-inline' /></td>" +
                "<td class='lookup-button-td'><input type=button class='sparkle-imagestrip-inlineedit_calendar_icon' /></td></tr></table></div>");
            _container.AppendTo(_args.Container);

            _input = _container.Find(".sparkle-input-inline");
            _input.Bind("keydown.nav", delegate(jQueryEvent e)
            {
                if (!_calendarOpen && (e.Which == 38 || e.Which == 40) && e.CtrlKey) // Ctrl-Up/Down shows date picker
                {
                    _input.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                    e.StopImmediatePropagation();
                }
                else if (_calendarOpen && e.Which == 13)
                {
                    e.PreventDefault();
                }

            });
            jQueryObject selectButton = _container.Find(".sparkle-imagestrip-inlineedit_calendar_icon");
            _input.Focus().Select();
            DatePickerOptions2 options2 = new DatePickerOptions2();
            options2.ShowOtherMonths = true;
            options2.ShowOn = ""; // Date Pickers in CRM do not show when they are focused - you click the button
            options2.FirstDay = OrganizationServiceProxy.OrganizationSettings != null ? OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value : 0;
            options2.BeforeShow = delegate()
            {
                this._calendarOpen = true;
            };

            options2.OnClose = delegate()
            {
                this._calendarOpen = false;
                _selectedValue = GetSelectedValue();
            };

            options2.OnSelect = delegate(string dateString, object instance)
            {
                // Select the date text field when selecting a date
                Focus();
            };

            if (OrganizationServiceProxy.UserSettings != null)
            {
                _dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }
            options2.DateFormat = _dateFormat;
            _input.Plugin<DatePickerPlugIn>().DatePicker(options2);

            // Wire up the date picker button
            selectButton.Click(delegate(jQueryEvent e){
                _input.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                Focus();
            });
        }
Exemplo n.º 13
0
        public EmailEditor(jQueryObject input, EmailEditorOptions opt)
            : base(input, opt)
        {
            RegisterValidationMethods();

            input.AddClass("emailuser").RemoveClass("flexify");

            var spanAt = J("<span/>")
                         .Text("@")
                         .AddClass("emailat")
                         .InsertAfter(input);

            var domain = J("<input type=\"text\"/>")
                         .AddClass("emaildomain")
                         .AddClass("flexify")
                         .InsertAfter(spanAt);

            domain.Bind("blur." + this.uniqueName, delegate
            {
                var validator = domain.Closest("form").GetDataValue("validator").As <jQueryValidator>();
                if (validator != null)
                {
                    validator.ValidateElement(input[0]);
                }
            });

            if (!options.Domain.IsEmptyOrNull())
            {
                domain.Value(options.Domain);
            }

            if (options.ReadOnlyDomain)
            {
                domain.Attribute("readonly", "readonly").AddClass("disabled").Attribute("tabindex", "-1");
            }

            input.Bind("keypress." + this.uniqueName, delegate(jQueryEvent e)
            {
                if (e.Which == (int)'@')
                {
                    e.PreventDefault();

                    if (!options.ReadOnlyDomain)
                    {
                        domain.Focus();
                        domain.Select();
                    }
                }
            });

            domain.Bind("keypress." + this.uniqueName, delegate(jQueryEvent e)
            {
                if (e.Which == (int)'@')
                {
                    e.PreventDefault();
                }
            });
        }
Exemplo n.º 14
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;
        }
Exemplo n.º 15
0
        public ModalBase(string template, string templateId)
        {
            attachedObject = Template.Get(template, templateId).AppendTo(jQuery.Select("body"));

            if (Settings.UseAnimation)
            {
                attachedObject.AddClass("fade");
            }

            Initialize();

            attachedObject.Bind("shown", OnShown);
        }
Exemplo n.º 16
0
        public static jQueryObject DialogCloseOnEnter(this jQueryObject dialog)
        {
            dialog.Bind("keydown", delegate(jQueryEvent e)
            {
                if (e.Which != EnterKeyCode)
                {
                    return;
                }

                var tagName = e.Target.TagName.ToLowerCase();

                if (tagName == "button" ||
                    tagName == "select" || // dropdown popup açık olabilir?
                    tagName == "textarea" ||
                    tagName == "input" && (string)e.Target.GetAttribute("type") == "button")
                {
                    return;
                }

                var dlg = jQuery.FromObject(Script.This);
                if (!dlg.HasClass("ui-dialog"))
                {
                    dlg = dlg.Closest(".ui-dialog");
                }

                var buttons = dlg.Children(".ui-dialog-buttonpane")
                              .Find("button");

                if (buttons.Length > 0)
                {
                    var defaultButton = buttons.Find(".default-button");
                    if (defaultButton.Length > 0)
                    {
                        buttons = defaultButton;
                    }
                }

                var button = buttons.Eq(0);
                if (!button.Is(":disabled"))
                {
                    e.PreventDefault();
                    button.Trigger("click");
                }
            });

            return(dialog);
        }
Exemplo n.º 17
0
        public static void ExecuteEverytimeWhenShown(jQueryObject element, Action callback,
                                                     bool callNowIfVisible)
        {
            autoIncrement++;
            string eventClass = "ExecuteEverytimeWhenShown" + autoIncrement;

            bool wasVisible = element.Is(":visible");

            if (wasVisible && callNowIfVisible)
            {
                callback();
            }

            jQueryEventHandler check = delegate(jQueryEvent e)
            {
                if (element.Is(":visible"))
                {
                    if (!wasVisible)
                    {
                        wasVisible = true;
                        callback();
                    }
                }
                else
                {
                    wasVisible = false;
                }
            };

            var uiTabs = element.Closest(".ui-tabs");

            if (uiTabs.Length > 0)
            {
                uiTabs.Bind("tabsactivate." + eventClass, check);
            }

            var dialog = element.Closest(".ui-dialog-content");

            if (dialog.Length > 0)
            {
                dialog.Bind("dialogopen." + eventClass, check);
            }

            element.Bind("shown." + eventClass, check);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates a widget on given element. Widget gets a unique name like MyNamespace_MyWidget1234.
        /// </summary>
        /// <remarks>
        /// * A data value is added to element with this unique name as key, and the widget object as value.
        /// * Only one widget instance of same class can be created on a element.
        /// * All events attached by this widget class will be unbound when element is removed from document.
        /// * Elements gets a css class like "s-MyWidget" (it has no namespace by default, but this can be customized)
        /// </remarks>
        protected Widget(jQueryObject element)
        {
            this.element    = element;
            this.widgetName = WidgetExtensions.GetWidgetName(this.GetType());
            this.uniqueName = widgetName + (NextWidgetNumber++).ToString();

            if (element.GetDataValue(widgetName) != null)
            {
                throw new Exception(String.Format("The element already has widget '{0}'!", widgetName));
            }

            var self = this;

            element.Bind("remove." + widgetName, (e) => self.Destroy())
            .Data(widgetName, this);

            AddCssClass();

            OnInit();
        }
Exemplo n.º 19
0
        public static void PendingChangesConfirmation(jQueryObject element,
            Func<bool> hasPendingChanges)
        {
            element.Bind("dialogbeforeclose", e =>
            {
                if (!e.HasOriginalEvent() || !hasPendingChanges())
                    return;

                e.PreventDefault();

                Q.Confirm("You have pending changes. Save them?", () =>
                {
                    element.Find("div.save-and-close-button").Click();
                }, new ConfirmOptions
                {
                    OnNo = () =>
                    {
                        element.Dialog().Close();
                    }
                });
            });
        }
Exemplo n.º 20
0
        public static void PendingChangesConfirmation(jQueryObject element,
                                                      Func <bool> hasPendingChanges)
        {
            element.Bind("dialogbeforeclose", e =>
            {
                if (!e.HasOriginalEvent() || !hasPendingChanges())
                {
                    return;
                }

                e.PreventDefault();

                Q.Confirm("You have pending changes. Save them?", () =>
                {
                    element.Find("div.save-and-close-button").Click();
                }, new ConfirmOptions
                {
                    OnNo = () =>
                    {
                        element.Dialog().Close();
                    }
                });
            });
        }
Exemplo n.º 21
0
        public static void ExecuteOnceWhenShown(jQueryObject element, Action callback)
        {
            autoIncrement++;
            string eventClass = "ExecuteOnceWhenShown" + autoIncrement;

            bool executed = false;

            if (element.Is(":visible"))
            {
                callback();
            }
            else
            {
                jQueryObject uiTabs = element.Closest(".ui-tabs");
                if (uiTabs.Length > 0)
                {
                    uiTabs.Bind("tabsshow." + eventClass, delegate(jQueryEvent e)
                    {
                        if (element.Is(":visible"))
                        {
                            uiTabs.Unbind("tabsshow." + eventClass);

                            if (!executed)
                            {
                                executed = true;
                                element.Unbind("shown." + eventClass);
                                callback();
                            }
                        }
                    });
                }

                jQueryObject dialog;
                if (element.HasClass("ui-dialog"))
                {
                    dialog = element.Children(".ui-dialog-content");
                }
                else
                {
                    dialog = element.Closest(".ui-dialog-content");
                }

                if (dialog.Length > 0)
                {
                    dialog.Bind("dialogopen." + eventClass, delegate
                    {
                        dialog.Unbind("dialogopen." + eventClass);

                        if (element.Is(":visible") && !executed)
                        {
                            executed = true;
                            element.Unbind("shown." + eventClass);
                            callback();
                        }
                    });
                }

                element.Bind("shown." + eventClass, delegate
                {
                    if (element.Is(":visible"))
                    {
                        element.Unbind("shown." + eventClass);

                        if (!executed)
                        {
                            executed = true;
                            callback();
                        }
                    }
                });
            }
        }
Exemplo n.º 22
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"));
        }
Exemplo n.º 23
0
        public static void ExecuteOnceWhenShown(jQueryObject element, Action callback)
        {
            autoIncrement++;
            string eventClass = "ExecuteOnceWhenShown" + autoIncrement;

            bool executed = false;

            if (element.Is(":visible"))
                callback();
            else
            {
                jQueryObject uiTabs = element.Closest(".ui-tabs");
                if (uiTabs.Length > 0)
                {
                    uiTabs.Bind("tabsshow." + eventClass, delegate(jQueryEvent e)
                    {
                        if (element.Is(":visible"))
                        {
                            uiTabs.Unbind("tabsshow." + eventClass);

                            if (!executed)
                            {
                                executed = true;
                                element.Unbind("shown." + eventClass);
                                callback();
                            }
                        }
                    });
                }

                jQueryObject dialog;
                if (element.HasClass("ui-dialog"))
                    dialog = element.Children(".ui-dialog-content");
                else
                    dialog = element.Closest(".ui-dialog-content");

                if (dialog.Length > 0)
                    dialog.Bind("dialogopen." + eventClass, delegate
                    {
                        dialog.Unbind("dialogopen." + eventClass);

                        if (element.Is(":visible") && !executed)
                        {
                            executed = true;
                            element.Unbind("shown." + eventClass);
                            callback();
                        }
                    });

                element.Bind("shown." + eventClass, delegate
                {
                    if (element.Is(":visible"))
                    {
                        element.Unbind("shown." + eventClass);

                        if (!executed)
                        {
                            executed = true;
                            callback();
                        }
                    }
                });
            }
        }
Exemplo n.º 24
0
        public static void ExecuteEverytimeWhenShown(jQueryObject element, Action callback,
            bool callNowIfVisible)
        {
            autoIncrement++;
            string eventClass = "ExecuteEverytimeWhenShown" + autoIncrement;

            bool wasVisible = element.Is(":visible");

            if (wasVisible && callNowIfVisible)
                callback();

            jQueryEventHandler check = delegate(jQueryEvent e)
            {
                if (element.Is(":visible"))
                {
                    if (!wasVisible)
                    {
                        wasVisible = true;
                        callback();
                    }
                }
                else
                    wasVisible = false;
            };

            var uiTabs = element.Closest(".ui-tabs");
            if (uiTabs.Length > 0)
                uiTabs.Bind("tabsactivate." + eventClass, check);

            var dialog = element.Closest(".ui-dialog-content");
            if (dialog.Length > 0)
                dialog.Bind("dialogopen." + eventClass, check);

            element.Bind("shown." + eventClass, check);
        }
Exemplo n.º 25
0
        public PhoneEditor(jQueryObject input, PhoneEditorOptions opt)
            : base(input, opt)
        {
            var self = this;

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

                return(Validate(value));
            });

            string hint = options.Internal ?
                          "Dahili telefon numarası '456, 8930, 12345' formatlarında" :
                          (options.Mobile ? "Cep telefonu numarası '(533) 342 01 89' formatında" :
                           "Telefon numarası '(216) 432 10 98' formatında");

            if (options.Multiple)
            {
                hint = hint.Replace("numarası", "numaraları") + " ve birden fazlaysa virgülle ayrılarak ";
            }

            hint += " girilmelidir.";

            input.Attribute("title", hint);

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                {
                    return;
                }

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });

            input.Bind("keyup", delegate(jQueryEvent e)
            {
                if (options.Internal)
                {
                    return;
                }

                var val = (input.GetValue() ?? "");
                if (val.Length > 0 && ((dynamic)input[0]).selectionEnd == val.Length &&
                    ((e.Which >= 48 && e.Which <= 57) || (e.Which >= 96 && e.Which <= 105)) &&
                    val[val.Length - 1] >= '0' && val[val.Length - 1] <= '9' && !val.StartsWith("+") && val.IndexOf('/') < 0)
                {
                    if (Validate(val) == null)
                    {
                        FormatValue();
                    }
                    else
                    {
                        for (var i = 1; i <= 7; i++)
                        {
                            val += "9";
                            if (Validate(val) == null)
                            {
                                this.Value = val;
                                FormatValue();
                                val = this.Value;
                                for (var j = 1; j <= i; j++)
                                {
                                    val = val.Trim();
                                    val = val.Substr(0, val.Length - 1);
                                }
                                this.Value = val;
                                break;
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 26
0
 public static void FixDropdownTouch(jQueryObject dropdown)
 {
     dropdown.Bind("touchstart", delegate(jQueryEvent e) { e.StopPropagation(); });
 }