modal.js 635 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @description Build, show and hide a modal.
  3. * @copyright 2014 by Tobias Reich
  4. */
  5. modal = {
  6. fns: null,
  7. show: function(title, text, buttons, marginTop, closeButton) {
  8. if (!buttons) {
  9. buttons = [
  10. ["", function() {}],
  11. ["", function() {}]
  12. ];
  13. }
  14. modal.fns = [buttons[0][1], buttons[1][1]];
  15. $("body").append(build.modal(title, text, buttons, marginTop, closeButton));
  16. $(".message input:first-child").focus().select();
  17. },
  18. close: function() {
  19. modal.fns = null;
  20. $(".message_overlay").removeClass("fadeIn").css("opacity", 0);
  21. setTimeout(function() { $(".message_overlay").remove() }, 300);
  22. }
  23. };