Msg.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * 右下角消息提示类型2
  3. */
  4. Ext.define('erp.view.core.window.Msg', {
  5. extend: 'Ext.window.Window',
  6. alias: 'widget.msg',
  7. frame: true,
  8. closable: false,
  9. bodyStyle: 'background: #E0EEEE',
  10. width: 400,
  11. height: 320,
  12. clientY: 465,
  13. renderTo: Ext.getBody(),
  14. x: screen.width - 400 -10,
  15. y: screen.height - 465 - 10,
  16. tools: [{
  17. type: 'close',
  18. handler: function(btn){
  19. var me = arguments[2].ownerCt;
  20. me.fireEvent('close', me);
  21. me.destroy();
  22. }
  23. }],
  24. autoClose: true,//自动关闭
  25. closeAction: 'destroy',
  26. autoCloseTime: 8000,
  27. isError: true,//是否为出错提示
  28. initComponent: function() {
  29. this.autoCloseTime = this.autoCloseTime || 8000;
  30. this.addEvents({
  31. 'close': true
  32. });
  33. if(!this.isError){
  34. this.buttons = null;
  35. this.clientY = 430;
  36. }
  37. if (this.autoCloseTime <= 3000) {// fast slide in and out
  38. this.width = 300;
  39. this.height = 150;
  40. this.x = screen.width - 300 -10;
  41. this.y = screen.height - 150 - 10;
  42. this.clientY = 300;
  43. this.context = '<font size=4 color=blue>' + this.context + '</font>';
  44. }
  45. this.title = '<div style="height:25;padding-top:5px;color:#FF6A6A;background: #E0EEEE url(' + basePath +
  46. 'resource/ext/resources/themes/images/default/grid/grid-blue-hd.gif) repeat center center">&nbsp;' + this.title + '</div>';
  47. this.callParent(arguments);
  48. this.updatePosition();
  49. this.insertMsg(this.context);
  50. var me = this;
  51. if(me.autoClose){//自动关闭
  52. setTimeout(function(){
  53. me.destroy();
  54. }, me.autoCloseTime);
  55. }
  56. },
  57. buttons: [{
  58. width: 100,
  59. style: {
  60. marginLeft: '3px'
  61. },
  62. text: '发送错误报告',
  63. cls: 'x-btn-blue',
  64. handler: function(btn){
  65. var me = btn.ownerCt.ownerCt;
  66. me.sendError();
  67. me.close();
  68. }
  69. },{
  70. width: 60,
  71. style: {
  72. marginLeft: '3px'
  73. },
  74. text: '帮助',
  75. cls: 'x-btn-blue',
  76. handler: function(btn){
  77. var me = btn.ownerCt.ownerCt;
  78. me.help();
  79. me.close();
  80. }
  81. },{
  82. width: 60,
  83. style: {
  84. marginLeft: '3px'
  85. },
  86. text: '关&nbsp;闭',
  87. cls: 'x-btn-blue',
  88. handler: function(btn){
  89. var me = btn.ownerCt.ownerCt;
  90. me.fireEvent('close', me);
  91. me.destroy();
  92. }
  93. }],
  94. updatePosition: function(){
  95. var count = Ext.ComponentQuery.query('msg').length;
  96. this.setPosition(screen.width - this.width - count*30 - 10, screen.height - this.clientY - 10);
  97. this.show();
  98. this.el.slideIn('r', { duration: 500 });
  99. },
  100. insertMsg: function(msg){
  101. this.insert(0, {
  102. xtype: 'panel',
  103. height: '100%',
  104. autoScroll: true,
  105. html: '<div style="font-size:14px;">' + msg + '</div>'
  106. });
  107. },
  108. sendError: function(){
  109. },
  110. help: function(){
  111. }
  112. });