Ejemplo n.º 1
0
        public static void ShowPlayerDetails(string dialogContainerId, string name, long id)
        {
            jQueryUIObject container = (jQueryUIObject)jQuery.Select("#" + dialogContainerId);

            if (container.Length > 0)
            {
                container.Children().First().Html("Loading...");
                container.Attribute("title", name);
                container.Attribute("data-id", id.ToString());

                JsonObject parameters = new JsonObject("id", id);

                jQuery.Post("/services/PlayerDetails?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
                {
                    ProcessResponse((Dictionary)data);
                }
                            );

                container.Dialog
                (
                    new JsonObject
                    (
                        "title", name,
                        "width", "340",
                        "height", "160",
                        "modal", "true"
                    )
                );
            }
        }
Ejemplo n.º 2
0
        public static void PostResults(jQueryUIObject dialog, string offerId)
        {
            string comments = jQuery.Select("#scoreComments").GetValue();

            string score = "";

            for (int i = 0; i < 5; ++i)
            {
                string requestValue = jQuery.Select("#request" + i).GetValue();
                string acceptValue = jQuery.Select("#accept" + i).GetValue();

                if (string.IsNullOrEmpty(requestValue) || string.IsNullOrEmpty(acceptValue))
                {
                    break;
                }

                if (score.Length > 0)
                {
                    score = score + ", ";
                }

                score = score + requestValue + "-" + acceptValue;
            }

            JsonObject parameters = new JsonObject("offerId", offerId, "comments", comments, "scores", score);

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/PostScore?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Dialog("destroy");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
Ejemplo n.º 3
0
        public UserDetails(Element element)
            : base(element)
        {
            EditButton = (jQueryUIObject)this.Obj.Find("a.edit");
            EditButton.Click(EditDetails);

            SaveButton = (jQueryUIObject)this.Obj.Find("a.save");
            SaveButton.Click(SaveDetails);

            ((jQueryUIObject)this.Obj.Find("select")).SelectMenu();
            Utility.WireLocationAutoComplete((jQueryUIObject)this.Obj.Find(".placesAutoFill"), (jQueryUIObject)this.Obj.Find(".placesAutoValue"));
        }
Ejemplo n.º 4
0
        public static void PostCancel(jQueryUIObject dialog, string offerId)
        {
            JsonObject parameters = new JsonObject("offerId", offerId);

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

            jQuery.Post("/services/CancelOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                dialog.Dialog("destroy");
                Utility.ProcessResponse((Dictionary)data);
            }
            );
        }
Ejemplo n.º 5
0
        internal static void WireLocationAutoComplete(jQueryUIObject autoFill, jQueryUIObject hiddenField)
        {
            string accessToken = autoFill.GetAttribute("data-accesstoken");
            string location    = autoFill.GetAttribute("data-location");

            autoFill.AutoComplete
            (
                new JsonObject
                (
                    "minLength", 2,
                    "position", new JsonObject("my", "right top", "at", "right bottom"),
                    "open", (Callback) delegate()
            {
                jQuery.This.RemoveClass("ui-corner-all").AddClass("ui-corner-top");
            },
                    "close", (Callback) delegate()
            {
                jQuery.This.RemoveClass("ui-corner-top").AddClass("ui-corner-all");
            },
                    "select", (jQuerySelectItemHandler) delegate(jQueryEvent ev, object obj)
            {
                if (null != hiddenField)
                {
                    jQueryAutoCompleteData data = (jQueryAutoCompleteData)obj;
                    autoFill.Value(data.Item.Label);

                    hiddenField.Value(data.Item.Value);
                    ev.StopPropagation();
                }

                return(false);
            },
                    "source", (jQueryAutoCompleteHandler) delegate(jQueryAutoCompleteRequest request, jQueryAutoCompleteResponse response)
            {
                string term = request.Term;

                if (Cache[term] != null)
                {
                    response((ArrayList)Cache[term]);
                    return;
                }

                LastRequest = jQuery.Post
                              (
                    "/services/serviceproxy",
                    Json.Stringify(new JsonObject("url", "https://maps.googleapis.com/maps/api/place/search/json?location=" + location.EncodeUriComponent() + "&radius=5000&name=" + term.EncodeUriComponent() + "&sensor=false&key=AIzaSyBnD3R38Jh9IhcT7VOJ4Mh8vE7AkSuP_zE")),
                    (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> xhr)
                {
                    // build up the data
                    if (xhr == LastRequest)
                    {
                        PlacesResponse placesData = (PlacesResponse)data;
                        ArrayList places          = new ArrayList();

                        for (int i = 0; i < placesData.Results.Length; ++i)
                        {
                            PlacesItem item      = (PlacesItem)placesData.Results[i];
                            JsonObject placeJson = new JsonObject("id", item.Id, "name", item.Name, "latitude", item.Geometry.Location.Latitude, "longitude", item.Geometry.Location.Longitude);
                            places.Add(new JsonObject("value", Json.Stringify(placeJson), "label", item.Name, "icon", item.Icon, "description", item.Vicinity));
                        }

                        Cache[term] = places;
                        response(places);
                    }
                }
                              );
            }
                )
            ).Data("autocomplete")._renderItem = (jQueryRenderItemHandler) delegate(Element element, JsonObject item)
            {
                jQueryAutoCompleteItem acItem = (jQueryAutoCompleteItem)item;

                return
                    (jQuery.Select("<li class='acItem'></li>")
                     .Data("item.autocomplete", item)
                     .Append("<a><div class='acName'>" + acItem.Label + "</div><div class='acLoc'>" + acItem.Description + "</div></a>")
                     .AppendTo(element));
            };
        }