Beispiel #1
0
        private void ReportScore(jQueryEvent e)
        {
            jQueryObject   button = jQuery.FromElement(e.CurrentTarget);
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#scoredialog");

            string score       = button.Siblings(".score").GetValue();
            string offerId     = button.Siblings(".offerId").GetValue();
            string requestName = button.Siblings(".requestName").GetValue();
            string acceptName  = button.Siblings(".acceptName").GetValue();

            dialog.Find("input").Value("");
            string[] scores = score.Split(", ");

            for (int i = 0; i < scores.Length; ++i)
            {
                string[] parts = scores[i].Split('-');

                jQuery.Select("#request" + i).Value(parts[0]);
                jQuery.Select("#accept" + i).Value(parts[1]);
            }

            dialog.Find(".requestName").Html(requestName);
            dialog.Find(".acceptName").Html(acceptName);

            dialog.Dialog(
                new JsonObject(
                    "width", "210",
                    "height", "305",
                    "modal", "true",
                    "buttons", new JsonObject(
                        "Report Score", (jQueryEventHandler) delegate(jQueryEvent ex)
            {
                PostResults(dialog, offerId);
            }
                        ),
                    "position", "top"
                    )
                );
        }
Beispiel #2
0
        private void RejectMatch(jQueryEvent e)
        {
            jQueryObject button  = jQuery.FromElement(e.CurrentTarget);
            string       offerId = button.Siblings("input").GetValue();

            jQueryObject parentRow = button.Parents(".offer");

            parentRow.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            jQuery.Post("/services/RejectOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(new JsonObject("id", offerId)), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                parentRow.Hide();

                Utility.ProcessResponse((Dictionary)data);
            });
        }
Beispiel #3
0
        public static void CancelMatch(jQueryEvent e)
        {
            jQueryObject   button = jQuery.FromElement(e.CurrentTarget);
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#canceldialog");

            string offerId = button.Siblings(".offerId").GetValue();

            dialog.Dialog(
                new JsonObject(
                    "width", "210",
                    "height", "140",
                    "modal", "true",
                    "buttons", new JsonObject(
                        "Cancel Match", (jQueryEventHandler) delegate(jQueryEvent ex)
            {
                PostCancel(dialog, offerId);
            }
                        ),
                    "position", "top"
                    )
                );
        }
Beispiel #4
0
        public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context)
        {
            jQueryObject        inputField = jQuery.FromElement(element);
            AutoCompleteOptions options    = (AutoCompleteOptions)((object)allBindingsAccessor()["autocompleteOptions"]);

            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);
            jQueryObject selectButton = inputField.Siblings(".timeSelectButton");

            // Add the click binding to show the drop down
            selectButton.Click(delegate(jQueryEvent e)
            {
                inputField.Plugin <AutoCompleteObject>().AutoComplete(AutoCompleteMethod.Search);
            });

            //handle the field changing
            KnockoutUtils.RegisterEventHandler(element, "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);
            Knockout.BindingHandlers["validationCore"].Init(element, valueAccessor, allBindingsAccessor, null, null);
        }
Beispiel #5
0
        // image preview function, demonstrating the ui.dialog used as a modal window
        static void ViewLargerImage(jQueryObject link)
        {
            string       src   = link.GetAttribute("href");
            string       title = link.Siblings("img").GetAttribute("alt");
            jQueryObject modal = jQuery.Select("img[src$='" + src + "']");

            if (modal.Length > 0)
            {
                modal.Plugin <DialogObject>()
                .Dialog(DialogMethod.Open);
            }
            else
            {
                jQueryObject img
                    = jQuery.FromHtml("<img alt='" + title + "' width='384' height='288' style='display: none; padding: 8px;' />")
                      .Attribute("src", src).AppendTo("body");

                img.Plugin <DialogObject>()
                .Dialog(new DialogOptions(DialogOption.Title, title,
                                          DialogOption.Width, 400,
                                          DialogOption.Modal, true
                                          ));
            }
        }
        // image preview function, demonstrating the ui.dialog used as a modal window
        static void ViewLargerImage(jQueryObject link)
        {
            string src = link.GetAttribute("href");
            string title = link.Siblings("img").GetAttribute("alt");
            jQueryObject modal = jQuery.Select("img[src$='" + src + "']");

            if (modal.Length > 0)
            {
                modal.Plugin<DialogObject>()
                     .Dialog(DialogMethod.Open);
            }
            else
            {
                jQueryObject img
                    = jQuery.FromHtml("<img alt='" + title + "' width='384' height='288' style='display: none; padding: 8px;' />")
                            .Attribute("src", src).AppendTo("body");

                img.Plugin<DialogObject>()
                   .Dialog(new DialogOptions("title", title,
                                            "width", 400,
                                            "modal", true
                ));
            }
        }