You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-slider-Tip'>/**
  19. </span> * @class Ext.slider.Tip
  20. * @extends Ext.Tip
  21. * Simple plugin for using an Ext.Tip with a slider to show the slider value. Example usage:
  22. &lt;pre&gt;
  23. new Ext.Slider({
  24. width: 214,
  25. minValue: 0,
  26. maxValue: 100,
  27. plugins: new Ext.slider.Tip()
  28. });
  29. &lt;/pre&gt;
  30. * Optionally provide your own tip text by overriding getText:
  31. &lt;pre&gt;
  32. new Ext.Slider({
  33. width: 214,
  34. minValue: 0,
  35. maxValue: 100,
  36. plugins: new Ext.slider.Tip({
  37. getText: function(thumb){
  38. return String.format('&lt;b&gt;{0}% complete&lt;/b&gt;', thumb.value);
  39. }
  40. })
  41. });
  42. &lt;/pre&gt;
  43. */
  44. Ext.slider.Tip = Ext.extend(Ext.Tip, {
  45. <span id='Ext-slider-Tip-cfg-minWidth'> minWidth: 10,
  46. </span><span id='Ext-slider-Tip-property-offsets'> offsets : [0, -10],
  47. </span>
  48. <span id='Ext-slider-Tip-method-init'> init: function(slider) {
  49. </span> slider.on({
  50. scope : this,
  51. dragstart: this.onSlide,
  52. drag : this.onSlide,
  53. dragend : this.hide,
  54. destroy : this.destroy
  55. });
  56. },
  57. <span id='Ext-slider-Tip-method-onSlide'> /**
  58. </span> * @private
  59. * Called whenever a dragstart or drag event is received on the associated Thumb.
  60. * Aligns the Tip with the Thumb's new position.
  61. * @param {Ext.slider.MultiSlider} slider The slider
  62. * @param {Ext.EventObject} e The Event object
  63. * @param {Ext.slider.Thumb} thumb The thumb that the Tip is attached to
  64. */
  65. onSlide : function(slider, e, thumb) {
  66. this.show();
  67. this.body.update(this.getText(thumb));
  68. this.doAutoWidth();
  69. this.el.alignTo(thumb.el, 'b-t?', this.offsets);
  70. },
  71. <span id='Ext-slider-Tip-method-getText'> /**
  72. </span> * Used to create the text that appears in the Tip's body. By default this just returns
  73. * the value of the Slider Thumb that the Tip is attached to. Override to customize.
  74. * @param {Ext.slider.Thumb} thumb The Thumb that the Tip is attached to
  75. * @return {String} The text to display in the tip
  76. */
  77. getText : function(thumb) {
  78. return String(thumb.value);
  79. }
  80. });
  81. //backwards compatibility - SliderTip used to be a ux before 3.2
  82. Ext.ux.SliderTip = Ext.slider.Tip;</pre>
  83. </body>
  84. </html>