3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * Simple plugin for using an Ext.tip.Tip with a slider to show the slider value. In general this class is not created
17 * directly, instead pass the {@link Ext.slider.Multi#useTips} and {@link Ext.slider.Multi#tipText} configuration
18 * options to the slider directly.
21 * Ext.create('Ext.slider.Single', {
26 * renderTo: Ext.getBody()
29 * Optionally provide your own tip text by passing tipText:
32 * Ext.create('Ext.slider.Single', {
37 * tipText: function(thumb){
38 * return Ext.String.format('**{0}% complete**', thumb.value);
40 * renderTo: Ext.getBody()
43 Ext.define('Ext.slider.Tip', {
44 extend: 'Ext.tip.Tip',
46 alias: 'widget.slidertip',
51 init: function(slider) {
56 dragstart: me.onSlide,
64 * Called whenever a dragstart or drag event is received on the associated Thumb.
65 * Aligns the Tip with the Thumb's new position.
66 * @param {Ext.slider.MultiSlider} slider The slider
67 * @param {Ext.EventObject} e The Event object
68 * @param {Ext.slider.Thumb} thumb The thumb that the Tip is attached to
70 onSlide : function(slider, e, thumb) {
73 me.update(me.getText(thumb));
74 me.doComponentLayout();
75 me.el.alignTo(thumb.el, 'b-t?', me.offsets);
79 * Used to create the text that appears in the Tip's body. By default this just returns the value of the Slider
80 * Thumb that the Tip is attached to. Override to customize.
81 * @param {Ext.slider.Thumb} thumb The Thumb that the Tip is attached to
82 * @return {String} The text to display in the tip
84 getText : function(thumb) {
85 return String(thumb.value);