Extjs 右下角弹出框 可弹出多个 冒泡小窗体

来源:互联网 发布:adobe网络设计师 编辑:程序博客网 时间:2024/05/16 19:50

 Extjs 右下角弹出框 可弹出多个 冒泡小窗体

TipsWindow对象声明

 

view plaincopy to clipboardprint?
  1. Ext.ns('Ext.ux');
  2. /**
  3. * 右下角的小贴士窗口
  4. * @author tipx.javaeye.com
  5. * @params conf 参考Ext.Window
  6. * conf中添加autoHide配置项, 默认3秒自动隐藏, 设置自动隐藏的时间(单位:秒), 不需要自动隐藏时设置为false
  7. * @注: 使用独立的window管理组(manager:new Ext.WindowGroup()), 达到总是显示在最前的效果
  8. */
  9. ; (function($)
  10. {
  11. //新建window组,避免被其它window影响显示在最前的效果
  12. var tipsGroupMgr = new Ext.WindowGroup();
  13. tipsGroupMgr.zseed = 99999; //将小贴士窗口前置
  14. $.TipsWindow = Ext.extend(Ext.Window,
  15. {
  16. width: 500,
  17. height: 150,
  18. layout: 'fit',
  19. modal: false,
  20. plain: true,
  21. shadow: false,
  22. //去除阴影
  23. draggable: false,
  24. //默认不可拖拽
  25. resizable: false,
  26. closable: true,
  27. closeAction: 'hide',
  28. //默认关闭为隐藏
  29. autoHide: 3,
  30. count:1,//设置显示的是第几个tipwindow
  31. //n秒后自动隐藏,为false时,不自动隐藏
  32. manager: tipsGroupMgr,
  33. //设置window所属的组
  34. constructor: function(conf)
  35. {
  36. $.TipsWindow.superclass.constructor.call(this, conf);
  37. this.initPosition(true);
  38. },
  39. initEvents: function()
  40. {
  41. $.TipsWindow.superclass.initEvents.call(this);
  42. //自动隐藏
  43. if (false !== this.autoHide)
  44. {
  45. var task = new Ext.util.DelayedTask(this.hide, this),
  46. second = (parseInt(this.autoHide) || 3) * 1000;
  47. this.on('beforeshow',
  48. function(self)
  49. {
  50. task.delay(second);
  51. });
  52. }
  53. this.on('beforeshow', this.showTips);
  54. this.on('beforehide', this.hideTips);
  55. Ext.EventManager.onWindowResize(this.initPosition, this); //window大小改变时,重新设置坐标
  56. Ext.EventManager.on(window, 'scroll', this.initPosition, this); //window移动滚动条时,重新设置坐标
  57. },
  58. //参数: flag - true时强制更新位置
  59. initPosition: function(flag)
  60. {
  61. if (true !== flag && this.hidden)
  62. { //不可见时,不调整坐标
  63. return false;
  64. }
  65. var doc = document,
  66. bd = (doc.body || doc.documentElement);
  67. //ext取可视范围宽高(与上面方法取的值相同), 加上滚动坐标
  68. var left = bd.scrollLeft + Ext.lib.Dom.getViewWidth() - 4 - this.width;
  69. var top = bd.scrollTop + Ext.lib.Dom.getViewHeight() - 4 - this.height*this.count;
  70. this.setPosition(left, top);
  71. },
  72. showTips: function()
  73. {
  74. var self = this;
  75. if (!self.hidden)
  76. {
  77. return false;
  78. }
  79. self.initPosition(true); //初始化坐标
  80. self.el.slideIn('b',
  81. {
  82. callback: function()
  83. {
  84. //显示完成后,手动触发show事件,并将hidden属性设置false,否则将不能触发hide事件
  85. self.fireEvent('show', self);
  86. self.hidden = false;
  87. }
  88. });
  89. return false; //不执行默认的show
  90. },
  91. hideTips: function()
  92. {
  93. var self = this;
  94. if (self.hidden)
  95. {
  96. return false;
  97. }
  98. self.el.slideOut('b',
  99. {
  100. callback: function()
  101. {
  102. //渐隐动作执行完成时,手动触发hide事件,并将hidden属性设置true
  103. self.fireEvent('hide', self);
  104. self.hidden = true;
  105. }
  106. });
  107. return false; //不执行默认的hide
  108. }
  109. });
  110. })(Ext.ux);

 

调用方法

 

view plaincopy to clipboardprint?
  1. var abc=0,
  2. tipw=[];
  3. 加一个方法调用弹出
  4. abcd = functon(){
  5. tipw[abc] = new Ext.ux.TipsWindow(
  6. {
  7. title: "小贴士<a href="#" mce_href="#">电视发射塔</a>",
  8. autoHide: 5,
  9. count:abc+1,//设置弹出的是第几个
  10. //5秒自动关闭
  11. html: "这是提示"
  12. });
  13. tipw[abc].show();
  14. }
原创粉丝点击