aboutsummaryrefslogtreecommitdiff
path: root/js/components/button.reel/button.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-04-02 16:28:39 -0700
committerJohn Mayhew2012-04-02 16:28:39 -0700
commitb4155fb4c33675a8a7cd37473513718043fdf0ba (patch)
tree3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/components/button.reel/button.js
parent5ba9aeac94c86049423fd5d4b37b277263939c13 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/helper-classes/RDGE/rdge-compiled.js js/helper-classes/RDGE/runtime/GLRuntime.js js/helper-classes/RDGE/src/core/script/MeshManager.js js/helper-classes/RDGE/src/core/script/engine.js js/helper-classes/RDGE/src/core/script/fx/ssao.js js/helper-classes/RDGE/src/core/script/init_state.js js/helper-classes/RDGE/src/core/script/run_state.js js/helper-classes/RDGE/src/core/script/scenegraphNodes.js js/helper-classes/RDGE/src/core/script/utilities.js js/helper-classes/RDGE/src/tools/compile-rdge-core.bat js/helper-classes/RDGE/src/tools/compile-rdge-core.sh js/helper-classes/RDGE/src/tools/rdge-compiled.js js/lib/drawing/world.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/deform-material.js js/lib/rdge/materials/flat-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/linear-gradient-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-blur-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/relief-tunnel-material.js js/lib/rdge/materials/square-tunnel-material.js js/lib/rdge/materials/star-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/tunnel-material.js js/lib/rdge/materials/twist-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/uber-material.js js/lib/rdge/materials/water-material.js js/lib/rdge/materials/z-invert-material.js js/preloader/Preloader.js
Diffstat (limited to 'js/components/button.reel/button.js')
-rwxr-xr-xjs/components/button.reel/button.js225
1 files changed, 0 insertions, 225 deletions
diff --git a/js/components/button.reel/button.js b/js/components/button.reel/button.js
deleted file mode 100755
index 2d26c8b4..00000000
--- a/js/components/button.reel/button.js
+++ /dev/null
@@ -1,225 +0,0 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8Component = require("montage/ui/component").Component;
9
10var Button = exports.Button = Montage.create(Component, {
11 // Button state
12 _focused: {
13 value: false
14 },
15
16 _pressed: {
17 value: false
18 },
19
20 _isToggleButton: {
21 value: false
22 },
23
24 isToggleButton: {
25 serializable: true,
26 enumerable: true,
27 get: function() {
28 return this._isToggleButton;
29 },
30 set: function(value) {
31 if (value !== this._isToggleButton) {
32 this._isToggleButton = value;
33 this.needsDraw = true;
34 }
35 }
36 },
37
38 _value: {
39 value: false
40 },
41
42 value: {
43 serializable: true,
44 enumerable: true,
45 get: function() {
46 return this._value;
47 },
48 set: function(value) {
49 if ( (value !== null) && (value !== this._value) ) {
50 this._value = value;
51 this.needsDraw = true;
52 }
53 }
54 },
55
56 _label: {
57 value: ""
58 },
59
60 label: {
61 serializable: true,
62 enumerable: true,
63 get: function() {
64 return this._label;
65 },
66 set: function(value) {
67 if (value !== this._label) {
68 this._label = value;
69 this.needsDraw = true;
70 }
71 }
72 },
73
74 // TODO - Allow user to specify up, over and down states
75 _onState: {
76 value: "on"
77 },
78
79 onState: {
80 serializable: true,
81 enumerable: true,
82 get: function() {
83 return this._onState;
84 },
85 set: function(value) {
86 if (value !== this._onState) {
87 this._onState = value;
88 this.needsDraw = true;
89 }
90 }
91 },
92
93 _offState: {
94 value: "off"
95 },
96
97 offState: {
98 serializable: true,
99 enumerable: true,
100 get: function() {
101 return this._offState;
102 },
103 set: function(value) {
104 if (value !== this._offState) {
105 this._offState = value;
106 this.needsDraw = true;
107 }
108 }
109 },
110
111 // Low-level event listeners
112 handleTouchstart: {
113 value: function(event) {
114 // TODO preventingDefault disables the magnifying class
115 // sadly it also disables double tapping on the button to zoom...
116 event.preventDefault();
117 this._acknowledgeIntent();
118 }
119 },
120
121 handleMousedown: {
122 value: function(event) {
123 this._acknowledgeIntent();
124 }
125 },
126
127 handleTouchend: {
128 value: function(event) {
129 this._interpretInteraction(event);
130 }
131 },
132
133 handleTouchcancel: {
134 value: function(event) {
135 console.log("cancel!")
136 // this._interpretInteraction(event);
137 }
138 },
139
140 handleMouseup: {
141 value: function(event) {
142 this._interpretInteraction(event);
143 }
144 },
145
146 // Internal state management
147 _acknowledgeIntent: {
148 value: function() {
149 this._pressed = true;
150 this.element.classList.add("pressed");
151 }
152 },
153
154 _interpretInteraction: {
155 value: function(event) {
156
157 if (!this._pressed) {
158 return;
159 }
160
161 this.value = !this.value;
162
163 this._pressed = false;
164 this._dispatchActionEvent();
165 }
166 },
167
168 _dispatchActionEvent: {
169 value: function() {
170 var actionEvent = document.createEvent("CustomEvent");
171 actionEvent.initCustomEvent("action", true, true);
172 actionEvent.type = "action";
173 this.dispatchEvent(actionEvent);
174 }
175 },
176
177 draw: {
178 enumerable: false,
179 value: function() {
180 if(this.isToggleButton)
181 {
182 if(this._value === true)
183 {
184 this.element.classList.remove(this.offState);
185 this.element.classList.add(this.onState);
186 }
187 else
188 {
189 this.element.classList.remove(this.onState);
190 this.element.classList.add(this.offState);
191 }
192 }
193
194 if(this.label && this.label !== "")
195 {
196 this.element.textContent = this.label;
197 }
198 }
199 },
200
201 prepareForDraw: {
202 value: function() {
203
204 // TODO only install low level event listeners for high level
205 // events others listen to us for
206
207 this.element.addEventListener("touchstart", this);
208 // TODO listen to mouseup anywhere within the app
209 document.addEventListener("touchend", this);
210 document.addEventListener("touchcancel", this);
211
212
213 this.element.addEventListener("mousedown", this);
214
215 // TODO listen to mouseup anywhere within the app
216 document.addEventListener("mouseup", this);
217
218 // TODO accept space or enter as a way to trigger action
219 // if element targeted; balancing demans of multitouch
220 // with traditional single focus model
221 document.addEventListener("keydown", this, true);
222 }
223 }
224
225});