1
1
/**
2
- A control that looks like a switch with labels for two states. Each time a ToggleButton is tapped,
3
- it switches its value and fires an onChange event.
4
-
5
- {kind: "onyx.ToggleButton", onContent: "foo", offContent: "bar", onChange: "buttonToggle"}
6
-
7
- buttonToggle: function(inSender, inEvent) {
8
- this.log("Toggled to value " + inEvent.value);
9
- }
10
-
11
- To find out the value of the button, use getValue:
12
-
13
- queryToggleValue: function() {
14
- return this.$.toggleButton.getValue();
15
- }
2
+ An extension fo the ToggleButton kind that animates between the on and off position and allows actual dragging of the knob.
16
3
*/
17
4
enyo . kind ( {
18
5
name : "onyx.AnimatedToggleButton" ,
@@ -34,10 +21,6 @@ enyo.kind({
34
21
}
35
22
36
23
} ,
37
- activeChanged : function ( ) {
38
- this . setValue ( this . active ) ;
39
- this . bubble ( "onActivate" ) ;
40
- } ,
41
24
onContentChanged : function ( ) {
42
25
this . inherited ( arguments ) ;
43
26
this . calculateSlidingBounds ( ) ;
@@ -54,11 +37,14 @@ enyo.kind({
54
37
} ,
55
38
rendered : function ( ) {
56
39
this . inherited ( arguments ) ;
40
+ // Do this after the Control has been rendered so that the sliding bounds can be calculated properly
57
41
this . valueChanged ( ) ;
58
42
} ,
43
+ // Calculate the maximum sliding position for the knob
59
44
calculateSlidingBounds : function ( ) {
60
45
this . $ . knob . setMax ( this . getBounds ( ) . width - this . $ . knob . getBounds ( ) . width - 2 ) ;
61
46
} ,
47
+ // Prevent the drag handling of the super kind
62
48
dragstart : function ( inSender , inEvent ) {
63
49
} ,
64
50
drag : function ( inSender , inEvent ) {
0 commit comments