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.
 
 
 
 
 

87 lines
3.1 KiB

  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. //Campaigns: selectively reveal operation summary details:
  61. $(".operation .killboard tr").mouseenter(function() {
  62. var div = $("<table>", {addClass: "killboard expanded"})
  63. .css($(this).position())
  64. .css("background-color", $(this).css("background-color"))
  65. .css("position", "fixed")
  66. .append($("<tr>").html($(this).html()))
  67. .mouseleave(function() { $(this).remove(); });
  68. div.find(".spacer").remove();
  69. $(this).closest(".summary").find(".expanded").remove();
  70. $(this).closest(".contents").prepend(div);
  71. div.css("width", Math.max(div.width(), $(this).width()));
  72. div.css("position", "");
  73. div.css("clip-path", "inset(0 0% 0 0)");
  74. });
  75. $(".operation .summary").mouseleave(function() {
  76. $(this).find(".expanded").remove();
  77. });
  78. });