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" ) ); }
/// <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" ) ); }
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" ) ); }
/// <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" ) ); }
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); } ); }
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); } ); }
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); } ); }
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" ) ); }
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" ) ); }
/// <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); } ); }
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"); }); }