Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

120 řádky
4.2 KiB

  1. $(function() {
  2. var attachMainBehaviors = function() {
  3. $("select[name=type]").on("change", function() {
  4. var selected = $(this).find("option:selected");
  5. window.location.href = selected.val();
  6. });
  7. $("select[name=filetype]").on("change", function() {
  8. var selected = $(this).find("option:selected"),
  9. val = selected.val(),
  10. dpi = $("input[name=dpi]"),
  11. dpiUnavailable = $("#dpiUnavailable");
  12. if (val === "PNG" || val === "JPEG") {
  13. dpi.prop("disabled", false);
  14. dpiUnavailable.hide();
  15. } else {
  16. dpi.prop("disabled", true);
  17. dpiUnavailable.show();
  18. }
  19. }).change();
  20. var text = $("input[name=text]");
  21. $("#validCharacters").on("click", "[data-output]", function() {
  22. var $this = $(this),
  23. escaped = $this.data("escaped"),
  24. value = $this.data("output");
  25. if (escaped) {
  26. value = unescape(value);
  27. }
  28. text
  29. .val(text.val() + value)
  30. .focus();
  31. });
  32. }, attachUIBehaviors = function() {
  33. $("table").each(function() {
  34. var $this = $(this);
  35. $this.find("tr:even").addClass("even");
  36. $this.find("tr:odd").addClass("odd");
  37. });
  38. }, attachSpecificBehaviors = function() {
  39. $("#specificOptions li").each(function() {
  40. var $this = $(this),
  41. code = $("<tr><td class='title'></td><td class='value'></td></tr>");
  42. code.find(".title").append($this.find(".title"));
  43. code.find(".value").append($this.find(".value"));
  44. $("div.configurations tr:last").before(code);
  45. });
  46. }, attachInfoBehaviors = function() {
  47. var showTooltip = function(object) {
  48. object
  49. .on("mouseover", function() {
  50. var timer = $(this).data("timer");
  51. if (timer) {
  52. clearTimeout(timer);
  53. }
  54. })
  55. .on("mouseout", function() {
  56. var that = $(this);
  57. that.data("timer", setTimeout(function() {
  58. that.removeClass("visible");
  59. }, 1000));
  60. });
  61. return function() {
  62. var $this = $(this),
  63. offset = $this.offset(),
  64. timer = object.data("timer");
  65. if (timer) {
  66. clearTimeout(timer);
  67. }
  68. // Show it once so we can get the outerWidth properly
  69. object
  70. .css({
  71. left: -99999,
  72. top: -99999
  73. })
  74. .addClass("visible")
  75. .css({
  76. left: offset.left + $this.width() - object.outerWidth(),
  77. top: offset.top + $this.height()
  78. });
  79. return false;
  80. };
  81. },
  82. hideTooltip = function(object) {
  83. return function() {
  84. object.data("timer", setTimeout(function() {
  85. object.removeClass("visible");
  86. }, 1000));
  87. };
  88. },
  89. bubbleize = function(object) {
  90. return object
  91. .addClass("bubble")
  92. .attr("role", "tooltip")
  93. .appendTo(document.body);
  94. },
  95. explanation = bubbleize($("#explanation")),
  96. validCharacters = bubbleize($("#validCharacters"));
  97. $(".info.explanation")
  98. .on("mouseover focusin", showTooltip(explanation))
  99. .on("mouseout focusout", hideTooltip(explanation));
  100. $(".info.characters")
  101. .on("mouseover focusin", showTooltip(validCharacters))
  102. .on("mouseout focusout", hideTooltip(validCharacters));
  103. };
  104. attachSpecificBehaviors();
  105. attachMainBehaviors();
  106. attachUIBehaviors();
  107. attachInfoBehaviors();
  108. });