jquery.messager.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. ( function() {
  2. var ua = navigator.userAgent.toLowerCase();
  3. var is = (ua.match(/\b(chrome|opera|safari|msie|firefox)\b/) || [ '',
  4. 'mozilla' ])[1];
  5. var r = '(?:' + is + '|version)[\\/: ]([\\d.]+)';
  6. var v = (ua.match(new RegExp(r)) || [])[1];
  7. jQuery.browser.is = is;
  8. jQuery.browser.ver = v;
  9. jQuery.browser[is] = true;
  10. })();
  11. ( function(jQuery) {
  12. /*
  13. *
  14. * jQuery Plugin - Messager
  15. *
  16. * Author: corrie Mail: corrie@sina.com Homepage: www.corrie.net.cn
  17. *
  18. * Copyright (c) 2008 corrie.net.cn
  19. *
  20. * @license http://www.gnu.org/licenses/gpl.html [GNU General Public
  21. * License]
  22. *
  23. *
  24. *
  25. * $Date: 2008-12-26
  26. *
  27. * $Vesion: 1.5 @ how to use and example: Please Open index.html
  28. *
  29. */
  30. this.version = '@1.5';
  31. this.layer = {
  32. 'width' :200,
  33. 'height' :100
  34. };
  35. this.title = '信息提示';
  36. this.time = 4000;
  37. this.anims = {
  38. 'type' :'slide',
  39. 'speed' :60000
  40. };
  41. this.timer1 = null;
  42. this.inits = function(divid,title, text) {
  43. var targetWindow=window.top.frames["workspace"].document.body;
  44. $("div[name=showMsg]",targetWindow).css("display", "none");
  45. title="代办提醒";
  46. $(targetWindow)
  47. .prepend(
  48. '<div name="showMsg" id="'+divid+'" style="border:#b9c9ef 1px solid;z-index:100;width:'+ this.layer.width+ 'px;height:'+ this.layer.height+ 'px;position:absolute; display:block;background:#cfdef4; bottom:0; right:0; overflow:hidden;">'
  49. + '<div style="border:1px solid #fff;border-bottom:none;width:100%;height:25px;font-size:12px;overflow:hidden;color:#1f336b;">'
  50. +'<span id="'+divid+'_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:200px;line-height:18px;text-align:left;overflow:hidden;">'
  51. + title +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' id='"+divid+"_back'>上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' id='"+divid+"_next'>下一页</a>"
  52. + '</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:'
  53. + (this.layer.width - 17)
  54. + 'px;height:'
  55. + (this.layer.height - 50)
  56. + 'px;color:#1f336b;text-align:left;overflow:hidden;">'
  57. + text + '</div></div>'
  58. +'</div>');
  59. $("#"+divid+"_message_close",targetWindow).click( function() {
  60. $("#"+divid,targetWindow).remove();
  61. });
  62. $("#"+divid+"_back",targetWindow).click( function() {
  63. var divindex=divid.replace("message","");
  64. if($("#message"+(divindex-1),targetWindow).length>0){
  65. $("#message"+(divindex-1),targetWindow).css("display","block");
  66. $("#"+divid,targetWindow).css("display","none");
  67. }
  68. });
  69. $("#"+divid+"_next",targetWindow).click( function() {
  70. var divindex=divid.replace("message","");
  71. if($("#message"+(divindex+1),targetWindow).length>0){
  72. $("#message"+(divindex+1),targetWindow).css("display","block");
  73. $("#"+divid,targetWindow).css("display","none");
  74. }
  75. });
  76. $("#"+divid,targetWindow).hover( function() {
  77. clearTimeout(timer1);
  78. timer1 = null;
  79. }, function() {
  80. if (time > 0)
  81. timer1 = setTimeout('this.close()', time);
  82. });
  83. $(window).scroll(
  84. function() {
  85. var bottomHeight = "-"+document.documentElement.scrollTop;
  86. $("#"+divid).css("bottom", bottomHeight + "px");
  87. });
  88. };
  89. this.show = function(divid,title, text, time) {
  90. if (title == 0 || !title)
  91. title = this.title;
  92. this.inits(divid,title, text);
  93. if (time >= 0)
  94. this.time = time;
  95. switch (this.anims.type) {
  96. case 'slide':
  97. $("#"+divid).slideDown(this.anims.speed);
  98. break;
  99. case 'fade':
  100. $("#"+divid).fadeIn(this.anims.speed);
  101. break;
  102. case 'show':
  103. $("#"+divid).show(this.anims.speed);
  104. break;
  105. default:
  106. $("#"+divid).slideDown(this.anims.speed);
  107. break;
  108. }
  109. var bottomHeight = "-"+document.documentElement.scrollTop;
  110. $("#"+divid).css("bottom", bottomHeight + "px");
  111. if ($.browser.is == 'chrome') {
  112. setTimeout( function() {
  113. $("#"+divid).remove();
  114. this.inits(title, text);
  115. $("#"+divid).css("display", "block");
  116. }, this.anims.speed - (this.anims.speed / 5));
  117. }
  118. this.rmmessage(this.time);
  119. };
  120. this.lays = function(width, height) {
  121. if (width != 0 && width)
  122. this.layer.width = width;
  123. if (height != 0 && height)
  124. this.layer.height = height;
  125. }
  126. this.anim = function(type, speed) {
  127. if ($("#message").is("div")) {
  128. return;
  129. }
  130. if (type != 0 && type)
  131. this.anims.type = type;
  132. if (speed != 0 && speed) {
  133. switch (speed) {
  134. case 'slow':
  135. ;
  136. break;
  137. case 'fast':
  138. this.anims.speed = 200;
  139. break;
  140. case 'normal':
  141. this.anims.speed = 400;
  142. break;
  143. default:
  144. this.anims.speed = speed;
  145. }
  146. }
  147. }
  148. this.rmmessage = function(time) {
  149. if (time > 0) {
  150. timer1 = setTimeout('this.close()', time);
  151. }
  152. };
  153. this.close = function() {
  154. switch (this.anims.type) {
  155. case 'slide':
  156. $("#message").slideUp(this.anims.speed);
  157. break;
  158. case 'fade':
  159. $("#message").fadeOut(this.anims.speed);
  160. break;
  161. case 'show':
  162. $("#message").hide(this.anims.speed);
  163. break;
  164. default:
  165. $("#message").slideUp(this.anims.speed);
  166. break;
  167. }
  168. ;
  169. setTimeout('$("#message").remove();', this.anims.speed);
  170. this.original();
  171. }
  172. this.original = function() {
  173. this.layer = {
  174. 'width' :200,
  175. 'height' :100
  176. };
  177. this.title = '信息提示';
  178. this.id = 'message';
  179. this.time = 4000;
  180. this.anims = {
  181. 'type' :'slide',
  182. 'speed' :600
  183. };
  184. };
  185. jQuery.messager = this;
  186. return jQuery;
  187. })(jQuery);