public TodoApplication() { _todoList = new TodoList(); _itemTemplate = jQuery.Select("#itemTemplate").Plugin<jQueryTemplateObject>(); _newItem = jQuery.Select("#new-todo"); _list = jQuery.Select("#todo-list"); _activeCount = jQuery.Select("#todo-count"); _clearButton = jQuery.Select("#clear-completed"); _newItem.On("keyup", OnNewItemKeyUp); _list.On("change", ".toggle", OnItemToggle); _list.On("click", ".destroy", OnItemDelete); _list.On("dblclick", "label", OnItemEditBegin); _list.On("keypress", "input", OnItemEdit); _list.On("blur", "input", OnItemEditComplete); _clearButton.On("click", OnClearCompletedClick); UpdateRendering(); }
public TodoApplication() { _todoList = new TodoList(); _itemTemplate = jQuery.Select("#itemTemplate").Plugin <jQueryTemplateObject>(); _newItem = jQuery.Select("#new-todo"); _list = jQuery.Select("#todo-list"); _activeCount = jQuery.Select("#todo-count"); _clearButton = jQuery.Select("#clear-completed"); _newItem.On("keyup", OnNewItemKeyUp); _list.On("change", ".toggle", OnItemToggle); _list.On("click", ".destroy", OnItemDelete); _list.On("dblclick", "label", OnItemEditBegin); _list.On("keypress", "input", OnItemEdit); _list.On("blur", "input", OnItemEditComplete); _clearButton.On("click", OnClearCompletedClick); UpdateRendering(); }
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")); }