spotlight-example.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Ext.Loader.setConfig({
  2. enabled: true
  3. });
  4. Ext.Loader.setPath('Ext.ux', '../ux');
  5. Ext.require([
  6. 'Ext.layout.container.Table',
  7. 'Ext.ux.Spotlight'
  8. ]);
  9. //Create a DemoPanel which is the base for each panel in the example
  10. Ext.define('DemoPanel', {
  11. extend: 'Ext.panel.Panel',
  12. title: 'Demo Panel',
  13. frame: true,
  14. width: 200,
  15. height: 150,
  16. html: 'Some panel content goes here!',
  17. bodyPadding: 5,
  18. /**
  19. * Custom method which toggles a Ext.Button for the current panel on/off depending on the only argument
  20. */
  21. toggle: function(on) {
  22. var btns = this.dockedItems.last(),
  23. btn = btns.items.first();
  24. if (btn) {
  25. btn.setDisabled(!on);
  26. }
  27. }
  28. });
  29. Ext.onReady(function() {
  30. //Create the spotlight component
  31. var spot = Ext.create('Ext.ux.Spotlight', {
  32. easing: 'easeOut',
  33. duration: 300
  34. });
  35. var p1, p2, p3;
  36. /**
  37. * Method which changes the spotlight to be active on a spefied panel
  38. */
  39. var updateSpot = function(id) {
  40. if (typeof id == 'string') {
  41. spot.show(id);
  42. } else if (!id && spot.active) {
  43. spot.hide();
  44. }
  45. p1.toggle(id == p1.id);
  46. p2.toggle(id == p2.id);
  47. p3.toggle(id == p3.id);
  48. };
  49. Ext.widget('panel', {
  50. renderTo: Ext.getBody(),
  51. id: 'demo-ct',
  52. border: false,
  53. layout: {
  54. type: 'table',
  55. columns: 3
  56. },
  57. items: [
  58. p1 = Ext.create('DemoPanel', {
  59. id: 'panel1',
  60. buttons: [{
  61. text: 'Next Panel',
  62. disabled: true,
  63. handler: function() {
  64. updateSpot('panel2');
  65. }
  66. }]
  67. }), p2 = Ext.create('DemoPanel', {
  68. id: 'panel2',
  69. buttons: [{
  70. text: 'Next Panel',
  71. disabled: true,
  72. handler: function() {
  73. updateSpot('panel3');
  74. }
  75. }]
  76. }), p3 = Ext.create('DemoPanel', {
  77. id: 'panel3',
  78. buttons: [{
  79. text: 'Done',
  80. disabled: true,
  81. handler: function() {
  82. updateSpot(false);
  83. }
  84. }]
  85. })]
  86. });
  87. //The start button, which starts everything
  88. Ext.create('Ext.button.Button', {
  89. text: 'Start',
  90. renderTo: 'start-ct',
  91. handler: function() {
  92. updateSpot('panel1');
  93. }
  94. });
  95. });