jquery.message1.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. !
  2. function () {
  3. function t(t, o) {
  4. return t.replace(/#\{([\s\S]+?)\}/g, function (t, i) {
  5. return o[i]
  6. })
  7. }
  8. var o = {
  9. topright: ["flipInX", "flipOutX"],
  10. lowerleft: ["fadeInUp", "fadeOutLeft"],
  11. lowerright: ["tada", "zoomOut"]
  12. },
  13. i = function (t) {
  14. t = $.extend({}, t);
  15. var o = $(".jquery-message-" + t.position),
  16. i = this.appendBox(t),
  17. e = i.outerHeight();
  18. this.bindClose(i, t), this.move(o, e, t)
  19. };
  20. i.prototype.move = function (t, o, i) {
  21. function e(t, i) {
  22. var e = t.position().top,
  23. n = o + 10;
  24. n = "topright" === i.position ? n : -n, t.stop(!0).animate({
  25. top: e + n
  26. }, 200)
  27. }
  28. var n = this;
  29. t.each(function () {
  30. var t = $(this);
  31. "lowerright" === i.position ? n.close(t, i) : e(t, i)
  32. })
  33. }, i.prototype.appendBox = function (t) {
  34. var o = $(this.creatBox(t)).appendTo("body");
  35. return "lowerleft" === t.position && o.css("top", $(window).height() - o.outerHeight() - 20), o
  36. }, i.prototype.creatBox = function (i) {
  37. i.inClass = o[i.position][0], i.fix = "jquery-message";
  38. var e = '<div class="#{fix} #{fix}-#{position}"><div class="animated #{fix}-box #{fix}-#{color} #{inClass}">';
  39. return e += i.title ? '<div class="#{fix}-h2">#{title}</div>' : "", e += i.content ? '<div class="#{fix}-nav">#{content}</div>' : "", e += "<div></div>", t(e, i)
  40. }, i.prototype.bindClose = function (t, o) {
  41. var i = this;
  42. setTimeout(function () {
  43. i.close(t, o)
  44. }, 3e3)
  45. }, i.prototype.close = function (t, i) {
  46. t.find(".jquery-message-box").addClass(o[i.position][1]), setTimeout(function () {
  47. t.remove()
  48. }, 6e3)
  49. },
  50. $.extend({
  51. message: function (t) {
  52. return new i(t)
  53. }
  54. })
  55. }();