aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ninja-components/hottext.reel/hottext.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ninja-components/hottext.reel/hottext.js')
-rw-r--r--node_modules/ninja-components/hottext.reel/hottext.js376
1 files changed, 0 insertions, 376 deletions
diff --git a/node_modules/ninja-components/hottext.reel/hottext.js b/node_modules/ninja-components/hottext.reel/hottext.js
deleted file mode 100644
index b593e175..00000000
--- a/node_modules/ninja-components/hottext.reel/hottext.js
+++ /dev/null
@@ -1,376 +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").Montage,
8 SliderBase = require("ui/slider-base").SliderBase;
9
10var HotText = exports.HotText = Montage.create(SliderBase, {
11 /* Allow users to specify a function to format the display.
12 * For example, the Color Picker can specify a function to map
13 * the numeric hot text value to hex color values.
14 */
15 labelFunction: {
16 serializable: true,
17 enumerable: true,
18 value: null
19 },
20
21 inputFunction: {
22 serializable: true,
23 enumerable: true,
24 value: parseFloat
25 },
26
27 _numValue: {
28 enumerable: false,
29 value: 0
30 },
31
32 numValue: {
33 serializable: false,
34 enumerable: true,
35 get: function() {
36 return this._numValue;
37 },
38 set: function(value) {
39 if (value < this._minValue) {
40 value = this._minValue;
41 }
42 if (value > this._maxValue) {
43 value = this._maxValue;
44 }
45 if (value !== this._numValue) {
46 this._numValue = Math.round(value * this._decimalPlace)/this._decimalPlace;
47 }
48 }
49 },
50
51 _previousValue: {
52 enumerable: false,
53 value: null
54 },
55
56 _stepSize: {
57 enumerable: false,
58 value: 1
59 },
60
61 stepSize: {
62 serializable: true,
63 enumerable: true,
64 get: function() {
65 return this._stepSize;
66 },
67 set: function(value) {
68 if (value !== this._stepSize) {
69 this._stepSize = value;
70 this.needsDraw = true;
71 }
72 }
73 },
74
75 _stepSizeShift: {
76 enumerable: false,
77 value: 10
78 },
79
80 _xStart: {
81 enumerable: false,
82 value: 0
83 },
84
85 _yStart: {
86 enumerable: false,
87 value: 0
88 },
89
90 // Needed to determine when to commit a value change
91 _wasShiftKeyPressed: {
92 enumerable: false,
93 value: false
94 },
95
96 // for ones, use 1
97 // for tenths, use 10
98 // for hundredths, use 100, etc.
99 _decimalPlace: {
100 enumerable: false,
101 value: 1
102 },
103
104 decimalPlace: {
105 serializable: true,
106 enumerable: true,
107 get: function() {
108 return this._decimalPlace;
109 },
110 set: function(value) {
111 if (value !== this._decimalPlace) {
112 this._decimalPlace = value;
113 this.needsDraw = true;
114 }
115 }
116 },
117
118 value: {
119 serializable: true,
120 enumerable: true,
121 get: function() {
122 return this._value;
123 },
124 set: function(value, fromInput) {
125 if (isNaN(value)) {
126 this._valueSyncedWithInputField = false;
127 this.needsDraw = true;
128 return;
129 }
130
131 if (value < this._minValue) {
132 value = this._minValue;
133 this._valueSyncedWithInputField = false;
134 this.needsDraw = true;
135 }
136 else if (value > this._maxValue) {
137 value = this._maxValue;
138 this._valueSyncedWithInputField = false;
139 this.needsDraw = true;
140 }
141
142 if (value !== this._value) {
143 this._value = this._numValue = Math.round(value * this._decimalPlace)/this._decimalPlace;
144 this._valueSyncedWithInputField = false;
145 this.needsDraw = true;
146 this._dispatchActionEvent();
147 }
148 }
149 },
150
151 _valueSyncedWithInputField: {
152 enumerable: false,
153 value: false
154 },
155
156 // We don't want to handle every input; we only want to handle input from tab or enter
157 // Thus, we don't listen for an input event; we call this from handleKeydown
158 handleInput: {
159 enumerable: false,
160 value: function() {
161 this._setEventFlags("change", false);
162 Object.getPropertyDescriptor(this, "value").set.call(this, this.inputFunction(this.element.value), true);
163 }
164 },
165
166
167 _valueFromPageOffset: {
168 value: function(offset, pageY, isShiftKeyPressed, wasSetByCode) {
169 if(!this._isMouseDown)
170 {
171 this._handleMoveEnd(); // If the user has moused up, check if we should go into input mode
172 return;
173 }
174
175 var clickPoint = webkitConvertPointFromPageToNode(this.element, new WebKitPoint(offset,pageY));
176
177 var dX = clickPoint.x - this._xStart;
178 var dY = clickPoint.y - this._yStart;
179
180 var dXAbs = Math.abs(dX);
181 var dYAbs = Math.abs(dY);
182
183 if( (dXAbs < 5) && (dYAbs < 5) )
184 {
185 return; // Don't process unless the user moves at least 5 pixels
186 }
187
188 var incrementVal = dXAbs-4; // otherwise, the first value change will be 5 pixels
189 var multFactor = 1;
190
191 if(dXAbs > dYAbs)
192 {
193 if(dX < 0)
194 {
195 multFactor = -1;
196 }
197 }
198 else
199 {
200 if(dY > 0)
201 {
202 multFactor = -1;
203 }
204 incrementVal = dYAbs-4;
205 }
206
207 if(isShiftKeyPressed)
208 {
209 if(!this._wasShiftKeyPressed)
210 {
211 this._xStart = clickPoint.x;
212 this._yStart = clickPoint.y;
213 this._previousValue = this._numValue;
214 incrementVal = 1;
215 }
216 this.numValue = this._previousValue + multFactor * incrementVal * this._stepSizeShift;
217 this._wasShiftKeyPressed = true;
218 }
219 else
220 {
221 if(this._wasShiftKeyPressed)
222 {
223 this._xStart = clickPoint.x;
224 this._yStart = clickPoint.y;