qtips.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. Ext.require([
  2. 'Ext.tip.*',
  3. 'Ext.Button',
  4. 'Ext.window.MessageBox'
  5. ]);
  6. Ext.onReady(function() {
  7. // Generate the buttons
  8. var defaultButtonConfig = {
  9. scale: 'medium',
  10. style: {
  11. "margin-right": '10px'
  12. }
  13. };
  14. var buttons = [{
  15. id : 'tip1',
  16. text : 'Basic ToolTip',
  17. renderTo: 'easiest'
  18. },{
  19. id : 'tip2',
  20. text : 'autoHide disabled',
  21. renderTo: 'easiest'
  22. },{
  23. id : 'ajax-tip',
  24. text : 'Ajax ToolTip',
  25. renderTo: 'easiest'
  26. },{
  27. id : 'track-tip',
  28. text : 'Mouse Track',
  29. renderTo: 'easiest'
  30. },{
  31. id : 'leftCallout',
  32. text : 'Anchor right, rich content',
  33. renderTo: 'anchor'
  34. },{
  35. id : 'bottomCallout',
  36. text : 'Anchor below',
  37. width : 200,
  38. renderTo: 'anchor'
  39. },{
  40. id : 'trackCallout',
  41. text : 'Anchor with tracking',
  42. renderTo: 'anchor'
  43. }];
  44. Ext.each(buttons, function(config) {
  45. var btn = Ext.create('Ext.Button', Ext.apply({}, config, defaultButtonConfig));
  46. btn.show();
  47. }, this);
  48. var tooltips = [{
  49. target: 'tip1',
  50. html: 'A very simple tooltip'
  51. },{
  52. target: 'ajax-tip',
  53. width: 200,
  54. autoLoad: {url: 'ajax-tip.html'},
  55. dismissDelay: 15000 // auto hide after 15 seconds
  56. },{
  57. target: 'tip2',
  58. title: 'My Tip Title',
  59. html: 'Click the X to close me',
  60. autoHide : false,
  61. closable : true,
  62. draggable: true
  63. },{
  64. target: 'track-tip',
  65. title: 'Mouse Track',
  66. width: 200,
  67. html: 'This tip will follow the mouse while it is over the element',
  68. trackMouse: true
  69. },{
  70. title: '<a href="#">Rich Content Tooltip</a>',
  71. id: 'content-anchor-tip',
  72. target: 'leftCallout',
  73. anchor: 'left',
  74. html: null,
  75. width: 415,
  76. autoHide: false,
  77. closable: true,
  78. contentEl: 'content-tip', // load content from the page
  79. listeners: {
  80. 'render': function(){
  81. this.header.on('click', function(header, e){
  82. e.stopEvent();
  83. Ext.Msg.alert('Link', 'Link to something interesting.');
  84. Ext.getCmp('content-anchor-tip').hide();
  85. }, this, {delegate:'a'});
  86. }
  87. }
  88. },{
  89. target: 'bottomCallout',
  90. anchor: 'top',
  91. anchorOffset: 85, // center the anchor on the tooltip
  92. html: 'This tip\'s anchor is centered'
  93. },{
  94. target: 'trackCallout',
  95. anchor: 'right',
  96. trackMouse: true,
  97. html: 'Tracking while you move the mouse'
  98. }];
  99. Ext.each(tooltips, function(config) {
  100. Ext.create('Ext.tip.ToolTip', config);
  101. });
  102. Ext.QuickTips.init();
  103. });