Пример #1
0
        /// <summary>
        /// Shows the dialog to select users from the player grid
        /// </summary>
        /// <param name="e"></param>
        private void SelectUserDialog(jQueryEvent e)
        {
            jQueryObject button = jQuery.FromElement(e.CurrentTarget);

            // Get the offer id from the button's attribute
            string offerId = button.GetAttribute("data-offerId");

            // Find the user selection dialog and communicate the offer id to the dialog so it can be posted on the dialog's select user event
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerGridCard");

            dialog.Children().First().Html("Loading...");
            dialog.Attribute("data-offerId", offerId);

            // Post the request to get the users who have accepted this offer
            JsonObject parameters = new JsonObject("page", 0, "offerId", offerId);

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

            // Display the dialog in modal fashion
            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 120,
                    "height", jQuery.Window.GetHeight() - 40,
                    "modal", true,
                    "title", "Select Your Opponent",
                    "closeOnEscape", true,
                    "position", "top"
                    )
                );
        }
Пример #2
0
        private 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);
            }
                        );
        }
Пример #3
0
        private void SendMessage(jQueryEvent e)
        {
            jQueryObject   button = jQuery.FromElement(e.CurrentTarget);
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerDetailsCard");

            string text = jQuery.Select("#playerDetailsCard .comments").GetValue();
            string id   = dialog.GetAttribute("data-id");

            Script.Literal("debugger");

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            JsonObject parameters = new JsonObject("userId", id, "comments", text);

            jQuery.Post("/services/SendMessage?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                dialog.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                dialog.Dialog("close");
                Utility.ProcessResponse((Dictionary)data);
            }
                        );
        }
Пример #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);
            }
                        );
        }
Пример #5
0
        /// <summary>
        /// Static method that gets called when a user is selected from the grid (the wiring is hard-coded in PlayerGrid itself for now)
        /// </summary>
        /// <param name="e"></param>
        public static void SelectUser(jQueryEvent e)
        {
            // Get the button that was selected - id should be the FacebookId of the selected user
            jQueryObject button         = jQuery.FromElement(e.CurrentTarget);
            string       selectedUserId = button.GetAttribute("data-fbId");

            // Get the offer id from the dialg attribute
            jQueryUIObject dialog  = (jQueryUIObject)jQuery.Select("#playerGridCard");
            string         offerId = dialog.GetAttribute("data-offerId");

            // Script.Alert("offerId: " + offerId + " uid: " + selectedUserId);

            // Post the confirmation - now that we have the offer id and the selected user
            JsonObject parameters = new JsonObject("offerId", offerId, "uid", selectedUserId);

            dialog.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/ConfirmOfferFromPage?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                dialog.Dialog("close");
                Utility.ProcessResponse((Dictionary)data);
            }
                        );
        }