public static void RequestMatch(jQueryEvent e) { jQueryObject button = jQuery.FromElement(e.CurrentTarget); jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#challengeDialog"); jQueryUIObject datePicker = (jQueryUIObject)dialog.Find(".datepicker"); Utility.WireLocationAutoComplete((jQueryUIObject)dialog.Find(".placesAutoFill"), (jQueryUIObject)dialog.Find(".placesAutoValue")); string id = button.GetElement(0).ID; datePicker.DatePicker("disable"); dialog.Dialog( new JsonObject( "width", "260", "height", "324", "modal", true, "title", button.GetAttribute("Title"), "buttons", new JsonObject( "Challenge!", (jQueryEventHandler) delegate(jQueryEvent ex) { CreateMatch(id); } ), "open", (Callback) delegate() { dialog.Find(".comments").Focus(); datePicker.DatePicker("enable"); }, "position", "top" ) ); }
public override void Update(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { jQueryObject textBox = jQuery.FromElement(element).Find(".sparkle-input-textbox-part"); // Use the standard value binding from ko Script.Literal("ko.bindingHandlers.value.update({0},{1},{2},{3},{4})", textBox.GetElement(0), valueAccessor, allBindingsAccessor, viewModel, context); }
public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { // Get the text box element jQueryObject select = jQuery.FromElement(element).Find(".sparkle-input-optionset-part"); jQueryEventHandler onChangeHandler = delegate(jQueryEvent e) { Observable <OptionSetValue> observable = (Observable <OptionSetValue>)valueAccessor(); string newValue = select.GetValue(); int? newValueInt = null; if (!String.IsNullOrEmpty(newValue)) { newValueInt = int.Parse(newValue); } // Set the optionset value OptionSetValue newValueOptionSetValue = new OptionSetValue(newValueInt); newValueOptionSetValue.Name = select.Find("option:selected").GetText(); observable.SetValue(newValueOptionSetValue); }; select.Change(onChangeHandler); allBindingsAccessor()["optionsValue"] = "value"; allBindingsAccessor()["optionsText"] = "name"; OptionSetBindingOptions optionSetOptions = (OptionSetBindingOptions)((object)allBindingsAccessor()["optionSetOptions"]); // Create a value accessor for the optionset options Func <List <OptionSetItem> > optionsValueAccessor = delegate() { return(MetadataCache.GetOptionSetValues(optionSetOptions.entityLogicalName, optionSetOptions.attributeLogicalName, optionSetOptions.allowEmpty)); }; Script.Literal("ko.bindingHandlers.options.update({0},{1},{2},{3},{4})", select.GetElement(0), optionsValueAccessor, allBindingsAccessor, viewModel, context); //Script.Literal("return { controlsDescendantBindings: true };"); }
public override void Update(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { jQueryObject currencyIndicatorSpan = jQuery.FromElement(element).Find(".sparkle-input-currencyprefix-part"); Func <object> interceptAccesor = delegate() { string currencySymbol = getCurrencySymbol(valueAccessor); return(currencySymbol); }; Script.Literal("ko.bindingHandlers.text.update({0},{1},{2},{3},{4})", currencyIndicatorSpan.GetElement(0), interceptAccesor, allBindingsAccessor, viewModel, context); }
public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { string formatString = GetFormatString(); jQueryObject container = jQuery.FromElement(element); jQueryObject inputField = container.Find(".sparkle-input-timeofday-part"); jQueryObject selectButton = container.Find(".sparkle-input-timeofday-button-part"); AutoCompleteOptions options = XrmTimeEditor.GetTimePickerAutoCompleteOptions(formatString); options.Position = new Dictionary <string, object>("collision", "fit"); options.Select = delegate(jQueryEvent e, AutoCompleteSelectEvent uiEvent) { // Note we assume that the binding has added an array of string items string value = ((Dictionary)uiEvent.Item)["value"].ToString(); TrySetObservable(valueAccessor, inputField, value); }; inputField = inputField.Plugin <AutoCompleteObject>().AutoComplete(options); // Add the click binding to show the drop down selectButton.Click(delegate(jQueryEvent e) { inputField.Plugin <AutoCompleteObject>().AutoComplete(AutoCompleteMethod.Search, ""); // Give "" to show all items }); //// Set initial value //Observable<DateTime> dateValueAccessor = (Observable<DateTime>)valueAccessor(); //DateTime intialValue = dateValueAccessor.GetValue(); //FormatterUpdate(inputField, intialValue); //handle the field changing KnockoutUtils.RegisterEventHandler(inputField.GetElement(0), "change", delegate(object sender, EventArgs e) { string value = inputField.GetValue(); TrySetObservable(valueAccessor, inputField, value); }); Action disposeCallBack = delegate() { Script.Literal("$({0}).autocomplete(\"destroy\")", element); }; //handle disposal (if KO removes by the template binding) Script.Literal("ko.utils.domNodeDisposal.addDisposeCallback({0}, {1})", element, (object)disposeCallBack); // Note: Because the time picker is always part of the date picker - we don't need to display validation messages //Knockout.BindingHandlers["validationCore"].Init(element, valueAccessor, allBindingsAccessor, null, null); }
public override void Update(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { jQueryObject textBox = jQuery.FromElement(element).Find(".sparkle-input-textbox-part"); NumberFormatInfo format = GetNumberFormatInfo(allBindingsAccessor); Func <object> interceptAccesor = delegate() { Money value = ((Observable <Money>)valueAccessor()).GetValue(); if (value != null) { return(NumberEx.Format(value.Value, format)); } else { return(String.Empty); } }; // Use the standard value binding from ko Script.Literal("ko.bindingHandlers.value.update({0},{1},{2},{3},{4})", textBox.GetElement(0), interceptAccesor, allBindingsAccessor, viewModel, context); }
public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { jQueryObject container = jQuery.FromElement(element); jQueryObject dateTime = container.Find(".sparkle-input-datepicker-part"); jQueryObject dateButton = container.Find(".sparkle-input-datepicker-button-part"); // Add Date Picker DatePickerOptions2 options = new DatePickerOptions2(); options.ShowOn = ""; options.ButtonImageOnly = true; options.FirstDay = OrganizationServiceProxy.OrganizationSettings != null ? OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value : 0; //options.ButtonImage = @"../images/btn_off_Cal.gif"; string dateFormat = "dd/MM/yy"; if (OrganizationServiceProxy.UserSettings != null) { dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString; } options.DateFormat = dateFormat; dateTime.Plugin <DatePickerPlugIn>().DatePicker(options); //// Get current value //Observable<DateTime> dateValueAccessor = (Observable<DateTime>)valueAccessor(); //DateTime intialValue = dateValueAccessor.GetValue(); //dateTime.Plugin<DatePickerObject>().DatePicker(DatePickerMethod.SetDate, intialValue); dateButton.Click(delegate(jQueryEvent e) { // Note: This is using a custom plugin definition since the standard didn't include show dateTime.Plugin <DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show); }); //handle the field changing KnockoutUtils.RegisterEventHandler(dateTime.GetElement(0), "change", delegate(object sender, EventArgs e) { Observable <DateTime> observable = (Observable <DateTime>)valueAccessor(); bool isValid = true; if (((string)Script.Literal("typeof({0}.IsValid)", observable)) != "undefined") { isValid = ((IValidatedObservable)observable).IsValid() == true; } if (isValid) { DateTime selectedDate = (DateTime)dateTime.Plugin <DatePickerObject>().DatePicker(DatePickerMethod.GetDate); // Get Current observable value - we only want to set the date part DateTime currentValue = observable.GetValue(); DateTimeEx.SetTime(selectedDate, currentValue); observable.SetValue(selectedDate); } dateTime.Blur(); }); Action disposeCallBack = delegate() { Script.Literal("$({0}).datepicker(\"destroy\")", element); }; //handle disposal (if KO removes by the template binding) Script.Literal("ko.utils.domNodeDisposal.addDisposeCallback({0}, {1})", element, (object)disposeCallBack); //Knockout.BindingHandlers["validationCore"].Init(element, valueAccessor, allBindingsAccessor,null,null); }