]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * The slider is a way to allow the user to select a value from a given numerical range. You might use it for choosing\r | |
3 | */\r | |
4 | Ext.define('Ext.field.SingleSlider', {\r | |
5 | extend : 'Ext.field.Slider',\r | |
6 | xtype : 'singlesliderfield',\r | |
7 | \r | |
8 | /**\r | |
9 | * @event dragchange\r | |
10 | * Fires when the value changes.\r | |
11 | * @param {Ext.field.Slider} me\r | |
12 | * @param {Number} newValue The new value.\r | |
13 | * @param {Number} oldValue The old value.\r | |
14 | */\r | |
15 | \r | |
16 | /**\r | |
17 | * @event dragchange\r | |
18 | * Fires when the value changes via drag.\r | |
19 | * @param {Ext.field.Slider} me\r | |
20 | * @param {Ext.slider.Slider} sl Slider Component.\r | |
21 | * @param {Number} newValue The new value.\r | |
22 | * @param {Number} oldValue The old value.\r | |
23 | */\r | |
24 | \r | |
25 | /**\r | |
26 | * @event dragstart\r | |
27 | * Fires when the slider thumb starts a drag operation.\r | |
28 | * @param {Ext.field.Slider} this\r | |
29 | * @param {Ext.slider.Slider} sl Slider Component.\r | |
30 | * @param {Ext.slider.Thumb} thumb The thumb being dragged.\r | |
31 | * @param {Array} value The start value.\r | |
32 | * @param {Ext.event.Event} e\r | |
33 | */\r | |
34 | \r | |
35 | /**\r | |
36 | * @event drag\r | |
37 | * Fires when the slider thumb starts a drag operation.\r | |
38 | * @param {Ext.field.Slider} this\r | |
39 | * @param {Ext.slider.Slider} sl Slider Component.\r | |
40 | * @param {Ext.slider.Thumb} thumb The thumb being dragged.\r | |
41 | * @param {Ext.event.Event} e\r | |
42 | */\r | |
43 | \r | |
44 | /**\r | |
45 | * @event dragend\r | |
46 | * Fires when the slider thumb ends a drag operation.\r | |
47 | * @param {Ext.field.Slider} this\r | |
48 | * @param {Ext.slider.Slider} sl Slider Component.\r | |
49 | * @param {Ext.slider.Thumb} thumb The thumb being dragged.\r | |
50 | * @param {Array} value The end value.\r | |
51 | * @param {Ext.event.Event} e\r | |
52 | */\r | |
53 | \r | |
54 | /**\r | |
55 | * @inheritdoc Ext.slider.Slider#value\r | |
56 | * @cfg {Number} value\r | |
57 | * @accessor\r | |
58 | */\r | |
59 | \r | |
60 | defaultBindProperty: 'value',\r | |
61 | \r | |
62 | publishes: {\r | |
63 | value: 1\r | |
64 | },\r | |
65 | \r | |
66 | initialize: function() {\r | |
67 | this.callParent();\r | |
68 | this.publishState('value', this.getValue());\r | |
69 | }, \r | |
70 | \r | |
71 | applyValue: function(value, oldValue) {\r | |
72 | value = this.callParent([value, oldValue]);\r | |
73 | if (value && Ext.isArray(value)) {\r | |
74 | value = value[0];\r | |
75 | }\r | |
76 | return value;\r | |
77 | },\r | |
78 | \r | |
79 | getValue: function() {\r | |
80 | var value = this.callParent();\r | |
81 | if (value && Ext.isArray(value)) {\r | |
82 | value = value[0];\r | |
83 | }\r | |
84 | return value;\r | |
85 | },\r | |
86 | \r | |
87 | onSliderChange: function(slider, thumb, newValue, oldValue) {\r | |
88 | this.setValue(newValue);\r | |
89 | this.fireEvent('dragchange', this, slider, newValue, oldValue);\r | |
90 | },\r | |
91 | \r | |
92 | onSliderDragStart: function(slider, thumb, startValue, e) {\r | |
93 | this.fireEvent('dragstart', this, slider, startValue, e);\r | |
94 | },\r | |
95 | \r | |
96 | onSliderDrag: function(slider, thumb, value, e) {\r | |
97 | var me = this;\r | |
98 | if (me.getLiveUpdate()) {\r | |
99 | me.setValue(value);\r | |
100 | }\r | |
101 | me.fireEvent('drag', me, slider, value, e);\r | |
102 | },\r | |
103 | \r | |
104 | onSliderDragEnd: function(slider, thumb, startValue, e) {\r | |
105 | this.fireEvent('dragend', this, slider, startValue, e);\r | |
106 | }\r | |
107 | });\r |