/ext-4.1.0_b3/docs/extjs/examples/qtips/qtips.js

https://bitbucket.org/srogerf/javascript · JavaScript · 108 lines · 101 code · 6 blank · 1 comment · 2 complexity · 78d2a6359df2e2a3c6b1067265107b2f MD5 · raw file

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