A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.js 2.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var overlaps = function(needle, haystack) {
  2. return haystack.is(needle) || haystack.has(needle).length > 0;
  3. };
  4. $(function() {
  5. /* ============================= Universal ============================= */
  6. // Install logout auto-POST form:
  7. $("#logout").click(function() {
  8. $("<form>", {
  9. "action": this.href,
  10. "method": "post"
  11. }).appendTo($("body")).submit();
  12. return false;
  13. });
  14. // Allow user to dismiss flashes:
  15. $("#flashes > div").each(function() {
  16. $(this).prepend($("<a>", {
  17. addClass: "dismiss",
  18. href: "#"
  19. }).html("[&times;]").click(function() {
  20. $(this).parent().remove();
  21. return false;
  22. }));
  23. });
  24. // Toggle character options on click:
  25. var charopts = $("#character-options");
  26. charopts.hide();
  27. $("#character-portrait img").click(function() {
  28. if (charopts.is(":visible")) {
  29. charopts.hide();
  30. $(document).off("mouseup.charopts");
  31. } else {
  32. charopts.show();
  33. $(document).on("mouseup.charopts", function(e) {
  34. if (!overlaps(e.target, charopts) &&
  35. !overlaps(e.target, $("#character-portrait img"))) {
  36. charopts.hide();
  37. $(document).off("mouseup.charopts");
  38. }
  39. });
  40. }
  41. }).css("cursor", "pointer").keypress(function (e) {
  42. if (e.which === 13)
  43. $(this).click();
  44. }).prop("title", "Options").prop("alt", "Options").prop("tabindex", 0);
  45. // Switch style immediately without reloading the page:
  46. $("#style-options form").submit(function() {
  47. var style = $(this).find('input[type="submit"]').data("style");
  48. var stylesheet = "/static/styles/" + style + ".css";
  49. $("#user-style").prop("href", stylesheet);
  50. $("#style-options .cur").removeClass("cur").find(":submit")
  51. .prop("disabled", false);
  52. $(this).addClass("cur").find(":submit").prop("disabled", true);
  53. });
  54. /* ============================== Modules ============================== */
  55. // Campaigns: enable form auto-submit on campaign change:
  56. $("#campaigns-select select").change(function() {
  57. this.form.submit();
  58. });
  59. $('#campaigns-select input[type="submit"]').hide();
  60. });