modal.js 631 B

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