Нет описания

jquery.messager.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. (function (jQuery){
  2. this.version = '@1.3';
  3. this.layer = {'width' : 200, 'height': 100};
  4. this.title = '信息提示';
  5. this.time = 4000;
  6. this.anims = {'type' : 'slide', 'speed' : 600};
  7. this.timer1 = null;
  8. this.inits = function(title, text){
  9. if($("#message").is("div")){ return; }
  10. $(document.body).prepend('<div id="message" style="border:#b9c9ef 1px solid;z-index:100;width:'+this.layer.width+'px;height:'+this.layer.height+'px;position:absolute; display:none;background:#cfdef4; bottom:0; right:0; overflow:hidden;"><div style="border:1px solid #fff;border-bottom:none;width:100%;height:25px;font-size:12px;overflow:hidden;color:#1f336b;"><span id="message_close" style="float:right;padding:5px 0 5px 0;width:16px;line-height:auto;color:red;font-size:12px;font-weight:bold;text-align:center;cursor:pointer;overflow:hidden;">×</span><div style="padding:5px 0 5px 5px;width:100px;line-height:18px;text-align:left;overflow:hidden;">'+title+'</div><div style="clear:both;"></div></div> <div style="padding-bottom:5px;border:1px solid #fff;border-top:none;width:100%;height:auto;font-size:12px;"><div id="message_content" style="margin:0 5px 0 5px;border:#b9c9ef 1px solid;padding:10px 0 10px 5px;font-size:12px;width:'+(this.layer.width-17)+'px;height:'+(this.layer.height-50)+'px;color:#1f336b;text-align:left;overflow:hidden;">'+text+'</div></div></div>');
  11. $("#message_close").click(function(){
  12. setTimeout('this.close()', 1);
  13. });
  14. $("#message").hover(function(){
  15. clearTimeout(timer1);
  16. timer1 = null;
  17. },function(){
  18. timer1 = setTimeout('this.close()', time);
  19. //alert(timer1);
  20. });
  21. };
  22. this.show = function(title, text, time){
  23. if($("#message").is("div")){ return; }
  24. if(title==0 || !title)title = this.title;
  25. this.inits(title, text);
  26. if(time>=0)this.time = time;
  27. switch(this.anims.type){
  28. case 'slide':$("#message").slideDown(this.anims.speed);break;
  29. case 'fade':$("#message").fadeIn(this.anims.speed);break;
  30. case 'show':$("#message").show(this.anims.speed);break;
  31. default:$("#message").slideDown(this.anims.speed);break;
  32. }
  33. if($.browser.is=='chrome'){
  34. setTimeout(function(){
  35. $("#message").remove();
  36. this.inits(title, text);
  37. $("#message").css("display","block");
  38. },this.anims.speed-(this.anims.speed/5));
  39. }
  40. //$("#message").slideDown('slow');
  41. this.rmmessage(this.time);
  42. };
  43. this.lays = function(width, height){
  44. if($("#message").is("div")){ return; }
  45. if(width!=0 && width)this.layer.width = width;
  46. if(height!=0 && height)this.layer.height = height;
  47. }
  48. this.anim = function(type,speed){
  49. if($("#message").is("div")){ return; }
  50. if(type!=0 && type)this.anims.type = type;
  51. if(speed!=0 && speed){
  52. switch(speed){
  53. case 'slow' : ;break;
  54. case 'fast' : this.anims.speed = 200; break;
  55. case 'normal' : this.anims.speed = 400; break;
  56. default:
  57. this.anims.speed = speed;
  58. }
  59. }
  60. }
  61. this.rmmessage = function(time){
  62. if(time>0){
  63. timer1 = setTimeout('this.close()', time);
  64. //setTimeout('$("#message").remove()', time+1000);
  65. }
  66. };
  67. this.close = function(){
  68. switch(this.anims.type){
  69. case 'slide':$("#message").slideUp(this.anims.speed);break;
  70. case 'fade':$("#message").fadeOut(this.anims.speed);break;
  71. case 'show':$("#message").hide(this.anims.speed);break;
  72. default:$("#message").slideUp(this.anims.speed);break;
  73. };
  74. setTimeout('$("#message").remove();', this.anims.speed);
  75. this.original();
  76. }
  77. this.original = function(){
  78. this.layer = {'width' : 200, 'height': 100};
  79. this.title = '信息提示';
  80. this.time = 4000;
  81. this.anims = {'type' : 'slide', 'speed' : 600};
  82. };
  83. jQuery.messager = this;
  84. return jQuery;
  85. })(jQuery);
  86. /*
  87. 本代码由js代码收集并编辑整理;
  88. 尊重他人劳动成果;
  89. 转载请保留js代码链接 - www.jsdaima.com
  90. */