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; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-slider-Tip'>/**
19 </span> * Simple plugin for using an Ext.tip.Tip with a slider to show the slider value. In general this class is not created
20 * directly, instead pass the {@link Ext.slider.Multi#useTips} and {@link Ext.slider.Multi#tipText} configuration
21 * options to the slider directly.
24 * Ext.create('Ext.slider.Single', {
29 * renderTo: Ext.getBody()
32 * Optionally provide your own tip text by passing tipText:
35 * Ext.create('Ext.slider.Single', {
40 * tipText: function(thumb){
41 * return Ext.String.format('**{0}% complete**', thumb.value);
43 * renderTo: Ext.getBody()
46 Ext.define('Ext.slider.Tip', {
47 extend: 'Ext.tip.Tip',
49 alias: 'widget.slidertip',
54 init: function(slider) {
59 dragstart: me.onSlide,
65 <span id='Ext-slider-Tip-method-onSlide'> /**
67 * Called whenever a dragstart or drag event is received on the associated Thumb.
68 * Aligns the Tip with the Thumb's new position.
69 * @param {Ext.slider.MultiSlider} slider The slider
70 * @param {Ext.EventObject} e The Event object
71 * @param {Ext.slider.Thumb} thumb The thumb that the Tip is attached to
73 onSlide : function(slider, e, thumb) {
76 me.update(me.getText(thumb));
77 me.doComponentLayout();
78 me.el.alignTo(thumb.el, 'b-t?', me.offsets);
81 <span id='Ext-slider-Tip-method-getText'> /**
82 </span> * Used to create the text that appears in the Tip's body. By default this just returns the value of the Slider
83 * Thumb that the Tip is attached to. Override to customize.
84 * @param {Ext.slider.Thumb} thumb The Thumb that the Tip is attached to
85 * @return {String} The text to display in the tip
87 getText : function(thumb) {
88 return String(thumb.value);