diff options
author | Valerio Virgillito | 2012-02-16 10:54:48 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-16 10:54:48 -0800 |
commit | d52aca45e0357b5597e13d9b74998abb75fabea5 (patch) | |
tree | ffd4a0c060b00611953b7e3ed0b3955bf02ac6e7 /node_modules/montage/ui/text-input.js | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-d52aca45e0357b5597e13d9b74998abb75fabea5.tar.gz |
integrating the latest montage fixes for v0.6 into master
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/text-input.js')
-rw-r--r-- | node_modules/montage/ui/text-input.js | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/node_modules/montage/ui/text-input.js b/node_modules/montage/ui/text-input.js index 5b8025a2..403c342d 100644 --- a/node_modules/montage/ui/text-input.js +++ b/node_modules/montage/ui/text-input.js | |||
@@ -8,39 +8,6 @@ var Montage = require("montage").Montage, | |||
8 | Component = require("ui/component").Component, | 8 | Component = require("ui/component").Component, |
9 | NativeControl = require("ui/native-control").NativeControl; | 9 | NativeControl = require("ui/native-control").NativeControl; |
10 | 10 | ||
11 | // Standard <input> tag attributes - http://www.w3.org/TR/html5/the-input-element.html#the-input-element | ||
12 | |||
13 | exports.StandardInputAttributes = { | ||
14 | accept: null, | ||
15 | alt: null, | ||
16 | autocomplete: null, | ||
17 | autofocus: {dataType: "boolean"}, | ||
18 | checked: {dataType: "boolean"}, | ||
19 | dirname: null, | ||
20 | disabled: {dataType: 'boolean'}, | ||
21 | form: null, | ||
22 | formaction: null, | ||
23 | formenctype: null, | ||
24 | formmethod: null, | ||
25 | formnovalidate: null, | ||
26 | formtarget: null, | ||
27 | height: null, | ||
28 | list: null, | ||
29 | max: null, | ||
30 | maxlength: null, | ||
31 | min: null, | ||
32 | multiple: {dataType: 'boolean'}, | ||
33 | name: null, | ||
34 | pattern: null, | ||
35 | placeholder: null, | ||
36 | readonly: {dataType: 'boolean'}, | ||
37 | required: {dataType: 'boolean'}, | ||
38 | size: null, | ||
39 | src: null, | ||
40 | step: null, | ||
41 | width: null | ||
42 | // "type" is not bindable and "value" is handled as a special attribute | ||
43 | }; | ||
44 | 11 | ||
45 | var TextInput = exports.TextInput = Montage.create(NativeControl, { | 12 | var TextInput = exports.TextInput = Montage.create(NativeControl, { |
46 | 13 | ||
@@ -81,29 +48,33 @@ var TextInput = exports.TextInput = Montage.create(NativeControl, { | |||
81 | }, | 48 | }, |
82 | set: function(value, fromInput) { | 49 | set: function(value, fromInput) { |
83 | 50 | ||
84 | if (value && value.length > 0 && this.converter) { | 51 | if(value !== this._value) { |
85 | var convertedValue; | 52 | if(this.converter) { |
86 | try { | 53 | var convertedValue; |
87 | convertedValue = this.converter.revert(value); | 54 | try { |
88 | if (this.error) { | 55 | convertedValue = this.converter.revert(value); |
89 | this.error = null; | 56 | if (this.error) { |
57 | this.error = null; | ||
58 | } | ||
59 | this._value = convertedValue; | ||
60 | |||
61 | } catch(e) { | ||
62 | // unable to convert - maybe error | ||
63 | this.error = e; | ||
64 | this._valueSyncedWithInputField = false; | ||
90 | } | 65 | } |
91 | this._value = convertedValue; | ||
92 | 66 | ||
93 | } catch(e) { | 67 | } else { |
94 | // unable to convert - maybe error | 68 | this._value = value; |
95 | this.error = e; | 69 | } |
70 | |||
71 | if(fromInput) { | ||
72 | this._valueSyncedWithInputField = true; | ||
73 | //this.needsDraw = true; | ||
74 | } else { | ||
96 | this._valueSyncedWithInputField = false; | 75 | this._valueSyncedWithInputField = false; |
76 | this.needsDraw = true; | ||
97 | } | 77 | } |
98 | } else { | ||
99 | this._value = value; | ||
100 | } | ||
101 | if(fromInput) { | ||
102 | this._valueSyncedWithInputField = true; | ||
103 | //this.needsDraw = true; | ||
104 | } else { | ||
105 | this._valueSyncedWithInputField = false; | ||
106 | this.needsDraw = true; | ||
107 | } | 78 | } |
108 | } | 79 | } |
109 | }, | 80 | }, |
@@ -202,8 +173,8 @@ var TextInput = exports.TextInput = Montage.create(NativeControl, { | |||
202 | @private | 173 | @private |
203 | */ | 174 | */ |
204 | _setElementValue: { | 175 | _setElementValue: { |
205 | value: function(v) { | 176 | value: function(value) { |
206 | this.element.value = v; | 177 | this.element.value = (value == null ? '' : value); |
207 | } | 178 | } |
208 | }, | 179 | }, |
209 | /** | 180 | /** |
@@ -302,3 +273,33 @@ var TextInput = exports.TextInput = Montage.create(NativeControl, { | |||
302 | 273 | ||
303 | }); | 274 | }); |
304 | 275 | ||
276 | // Standard <input> tag attributes - http://www.w3.org/TR/html5/the-input-element.html#the-input-element | ||
277 | |||
278 | TextInput.addAttributes({ | ||
279 | accept: null, | ||
280 | alt: null, | ||
281 | autocomplete: null, | ||
282 | autofocus: {dataType: "boolean"}, | ||
283 | checked: {dataType: "boolean"}, | ||
284 | dirname: null, | ||
285 | disabled: {dataType: 'boolean'}, | ||
286 | form: null, | ||
287 | formaction: null, | ||
288 | formenctype: null, | ||
289 | formmethod: null, | ||
290 | formnovalidate: null, | ||
291 | formtarget: null, | ||
292 | height: null, | ||
293 | list: null, | ||
294 | maxlength: null, | ||
295 | multiple: {dataType: 'boolean'}, | ||
296 | name: null, | ||
297 | pattern: null, | ||
298 | placeholder: null, | ||
299 | readonly: {dataType: 'boolean'}, | ||
300 | required: {dataType: 'boolean'}, | ||
301 | size: null, | ||
302 | src: null, | ||
303 | width: null | ||
304 | // "type" is not bindable and "value" is handled as a special attribute | ||
305 | }); | ||