コード例 #1
0
ファイル: Index.cs プロジェクト: nbclark/SportsLink
        /// <summary>
        /// Popup for the calendar page showing potential and accepted offers by date.
        /// </summary>
        /// <param name="ev"></param>
        public static void Calendar(jQueryEvent ev)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#calendarCard");

            dialog.Children().First().Html("Loading...");

            JsonObject parameters = new JsonObject("page", 0);

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

            // BUGBUG: currently the sizes are hard-coded and too big - need to fix this.
            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 120,
                    "height", jQuery.Window.GetHeight() - 40,
                    "modal", true,
                    "closeOnEscape", true,
                    "title", "Calendar",
                    "position", "top"
                    )
                );
        }
コード例 #2
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"
                    )
                );
        }
コード例 #3
0
        private void MoreClick(jQueryEvent e)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#playerGridCard");

            dialog.Children().First().Html("Loading...");

            JsonObject parameters = new JsonObject("page", 0);

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

            dialog.Dialog(
                new JsonObject(
                    "width", jQuery.Window.GetWidth() - 40,
                    "height", jQuery.Window.GetHeight() - 20,
                    "modal", true,
                    "title", "Similar Players",
                    "closeOnEscape", true,
                    "position", "top"
                    )
                );
        }
コード例 #4
0
        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"
                    )
                );
        }
コード例 #5
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);
            }
                        );
        }
コード例 #6
0
ファイル: PlayerGrid.cs プロジェクト: nbclark/SportsLink
        public PlayerGrid(Element element)
            : base(element, "PlayerGrid")
        {
            // Wire up the select user even for confirming a user
            jQueryUIObject selectUser = (jQueryUIObject)this.Obj.Find(".selectUser");

            selectUser.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e")));
            selectUser.Click(UserChallenges.SelectUser);

            // Wire up the challenge event for a specific user
            jQueryUIObject requestMatch = (jQueryUIObject)this.Obj.Find(".requestMatch");

            requestMatch.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e")));
            requestMatch.Click(Players.RequestMatch);

            jQueryUIObject selects = (jQueryUIObject)this.Obj.Find("th select");

            selects.Each((ElementIterationCallback) delegate(int index, Element el)
            {
                ((jQueryUIObject)jQuery.FromElement(el)).MultiSelect(new JsonObject(
                                                                         "header", false,
                                                                         "minWidth", "80",
                                                                         "height", "auto",
                                                                         "noneSelectedText", el.Title,
                                                                         "selectedText", el.Title,
                                                                         "close", (Callback) delegate() { DoFilter(this.Obj, true); }));
            });

            this.DoFilter(this.Obj, false);
        }
コード例 #7
0
        public PlayerDetails(Element element)
            : base(element)
        {
            jQueryUIObject sendMessage = (jQueryUIObject)this.Obj.Find("#playerMessage .sendMessage");

            sendMessage.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e")));
            sendMessage.Click(SendMessage);
        }
コード例 #8
0
        public override void Unload()
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#scoredialog");

            dialog.Remove();

            base.Unload();
        }
コード例 #9
0
        public UserOffers(Element element)
            : base(element, "UserOffers")
        {
            jQueryUIObject cancelMatch = (jQueryUIObject)this.Obj.Find(".cancelMatch");

            cancelMatch.Button(new JsonObject("text", false, "icons", new JsonObject("primary", "ui-icon-closethick")));

            cancelMatch.Click(CancelOffer);
        }
コード例 #10
0
        public override void Unload()
        {
            jQueryUIObject dialogScore = (jQueryUIObject)jQuery.Select("#scoredialog");

            dialogScore.Remove();

            jQueryUIObject dialogCancel = (jQueryUIObject)jQuery.Select("#canceldialog");

            dialogCancel.Remove();

            base.Unload();
        }
コード例 #11
0
ファイル: UserDetails.cs プロジェクト: nbclark/SportsLink
        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"));
        }
コード例 #12
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);
            }
                        );
        }
コード例 #13
0
        public Players(Element element)
            : base(element, "Players")
        {
            jQueryUIObject moreButton = (jQueryUIObject)this.Obj.Find(".more");

            jQueryUIObject requestMatch = (jQueryUIObject)this.Obj.Find(".requestMatch");

            requestMatch.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e")));
            requestMatch.Click(RequestMatch);

            // playerGridCard
            moreButton.Click(MoreClick);
        }
コード例 #14
0
        public UserChallenges(Element element)
            : base(element)
        {
            jQueryUIObject cancelMatch = (jQueryUIObject)this.Obj.Find(".cancelMatch");

            cancelMatch.Button(new JsonObject("text", false, "icons", new JsonObject("primary", "ui-icon-closethick")));
            cancelMatch.Click(CancelOffer);

            jQueryUIObject confirmOffers = (jQueryUIObject)this.Obj.Find(".confirmOffers");

            confirmOffers.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e")));
            confirmOffers.Click(SelectUserDialog);
        }
コード例 #15
0
        public PotentialOffers(Element element)
            : base(element, "PotentialOffers")
        {
            jQueryUIObject acceptMatch          = (jQueryUIObject)this.Obj.Find(".acceptMatch");
            jQueryUIObject rejectMatch          = (jQueryUIObject)this.Obj.Find(".rejectMatch");
            jQueryUIObject cancelConfirmedMatch = (jQueryUIObject)this.Obj.Find(".cancelConfirmedMatch");
            jQueryUIObject inputScore           = (jQueryUIObject)this.Obj.Find(".inputScore");

            acceptMatch.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-check")));
            rejectMatch.Button(new JsonObject("text", false, "icons", new JsonObject("primary", "ui-icon-closethick")));

            acceptMatch.Click(AcceptMatch);
            rejectMatch.Click(RejectMatch);
            inputScore.Click(ConfirmedMatches.ReportScore);
            cancelConfirmedMatch.Click(ConfirmedMatches.CancelMatch);

            this.Obj.Find(".more").Click(Index.Calendar);
        }
コード例 #16
0
ファイル: PlayerGrid.cs プロジェクト: nbclark/SportsLink
        public void DoFilter(jQueryObject obj, bool postBack)
        {
            jQueryUIObject selects     = (jQueryUIObject)obj.Find("th select");
            string         filterValue = "";

            selects.Each((ElementIterationCallback) delegate(int index, Element el)
            {
                jQueryUIObject select = (jQueryUIObject)jQuery.FromElement(el);
                Array checkedItems    = select.MultiSelect("getChecked");

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

                    filterValue = filterValue + select.GetAttribute("name") + "=";

                    for (int i = 0; i < checkedItems.Length; ++i)
                    {
                        if (i > 0)
                        {
                            filterValue = filterValue + "||";
                        }

                        filterValue = filterValue + ((InputElement)checkedItems[i]).Value;
                    }
                }
            });

            if (this.Filter != filterValue)
            {
                this.Filter = filterValue;

                if (postBack)
                {
                    PostBack(0);
                }
            }
        }
コード例 #17
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);
            }
                        );
        }
コード例 #18
0
ファイル: PaginatedModule.cs プロジェクト: nbclark/SportsLink
        /// <summary>
        /// Initializes the base class of the paginated module with the DOM element and the service details
        /// </summary>
        /// <param name="element"></param>
        /// <param name="serviceName"></param>
        public PaginatedModule(Element element, string serviceName)
            : base(element)
        {
            // Note: The paginated module contains a hidden input with class "page" and a value equal to the page requested
            // Get the page
            this.Page = int.Parse(this.Obj.Find(".page").GetValue());

            // Store the service name
            this.ServiceName = serviceName;

            // Get the jquery objects for the prev/next anchor elements with class prev/next
            jQueryUIObject prev = (jQueryUIObject)this.Obj.Find(".prev");
            jQueryUIObject next = (jQueryUIObject)this.Obj.Find(".next");

            // Make them buttons
            prev.Button();
            next.Button();

            // Hook into the handlers
            prev.Click(PagePrev);
            next.Click(PageNext);
        }
コード例 #19
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"
                    )
                );
        }
コード例 #20
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"
                    )
                );
        }
コード例 #21
0
        private static void CreateMatch(string id)
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#challengeDialog");

            string date      = dialog.Find(".datepicker").GetValue();
            string time      = dialog.Find(".time").GetValue();
            string ampm      = dialog.Find(".ampm").GetValue();
            string comments  = dialog.Find(".comments").GetValue();
            string courtData = dialog.Find(".placesAutoValue").GetValue();

            string datetime = date + " " + time + ampm;

            ArrayList ids = new ArrayList();

            dialog.Find(".cities input").Each((ElementIterationCallback) delegate(int index, Element element)
            {
                ids.Add(((CheckBoxElement)element).Value);
            });

            JsonObject parameters = new JsonObject("date", datetime, "locations", ids, "comments", comments, "opponentId", 0);

            QuickMatch.DoCreateMatch(dialog, datetime, ids, courtData, comments, id, (Callback) delegate() { dialog.Dialog("close"); });
        }
コード例 #22
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);
            }
                        );
        }
コード例 #23
0
ファイル: Index.cs プロジェクト: nbclark/SportsLink
        public static void FirstRun()
        {
            jQueryUIObject dialog = (jQueryUIObject)jQuery.Select("#welcomeCard");

            dialog.Show();
        }