modal.js 636 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @description Build, show and hide a modal.
  3. * @copyright 2014 by Tobias Reich
  4. */
  5. modal = {}
  6. modal.fns = null;
  7. modal.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. modal.close = function() {
  19. modal.fns = null;
  20. $('.message_overlay').removeClass('fadeIn').css('opacity', 0);
  21. setTimeout(function() { $('.message_overlay').remove() }, 300);
  22. }