diff options
author | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
commit | c59eb371559a3061ce53223e249ca97daace5968 (patch) | |
tree | f9540e26c0f273d35f92010605da65dd85bbe70c /node_modules/montage/ui/token-field/token.reel/token.js | |
parent | 0f040acabfb7a4bf3138debec5aff869487ceb11 (diff) | |
parent | 918a4f5870e972b6e4e301c3237e065a1ffd26f5 (diff) | |
download | ninja-c59eb371559a3061ce53223e249ca97daace5968.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'node_modules/montage/ui/token-field/token.reel/token.js')
-rw-r--r-- | node_modules/montage/ui/token-field/token.reel/token.js | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/node_modules/montage/ui/token-field/token.reel/token.js b/node_modules/montage/ui/token-field/token.reel/token.js index 15216c3f..18112625 100644 --- a/node_modules/montage/ui/token-field/token.reel/token.js +++ b/node_modules/montage/ui/token-field/token.reel/token.js | |||
@@ -8,35 +8,58 @@ var Montage = require("montage").Montage, | |||
8 | 8 | ||
9 | exports.Token = Montage.create(Component, { | 9 | exports.Token = Montage.create(Component, { |
10 | 10 | ||
11 | text: {value: null}, | 11 | _text: { |
12 | value: null | ||
13 | }, | ||
14 | |||
15 | text: { | ||
16 | dependencies: ["value", "textPropertyPath"], | ||
17 | get: function() { | ||
18 | var textPropertyPath, | ||
19 | value, | ||
20 | text; | ||
21 | |||
22 | if (this._text == null) { | ||
23 | this._adHoc = false; | ||
24 | textPropertyPath = this.textPropertyPath; | ||
25 | value = this.value; | ||
26 | |||
27 | if (textPropertyPath != null && value != null) { | ||
28 | if (typeof value[textPropertyPath] === 'undefined' && this.allowAdHocValues) { | ||
29 | this._adHoc = true; | ||
30 | this._text = value; | ||
31 | } else { | ||
32 | this._text = value[textPropertyPath]; | ||
33 | } | ||
34 | } else { | ||
35 | this._text = value; | ||
36 | } | ||
37 | } | ||
12 | 38 | ||
13 | allowAdHocValues: {value: null}, | 39 | return this._text; |
40 | } | ||
41 | }, | ||
42 | |||
43 | allowAdHocValues: {value: null, serializable: true}, | ||
44 | |||
45 | _value: { | ||
46 | value: null | ||
47 | }, | ||
14 | 48 | ||
15 | value: { | 49 | value: { |
50 | serializable: true, | ||
16 | get: function() { | 51 | get: function() { |
17 | return this._value; | 52 | return this._value; |
18 | }, | 53 | }, |
19 | set: function(aValue) { | 54 | set: function(aValue) { |
20 | this._adHoc = false; | 55 | this._value = aValue; |
21 | if(aValue) { | 56 | this._text = null; |
22 | this._value = aValue; | ||
23 | if(this.textPropertyPath) { | ||
24 | if(typeof aValue[this.textPropertyPath] == 'undefined' && this.allowAdHocValues) { | ||
25 | this.text = aValue; | ||
26 | this._adHoc = true; | ||
27 | } else { | ||
28 | this.text = this.value[this.textPropertyPath]; | ||
29 | } | ||
30 | } else { | ||
31 | this.text = this.value; | ||
32 | } | ||
33 | } | ||
34 | } | 57 | } |
35 | }, | 58 | }, |
36 | 59 | ||
37 | textPropertyPath: {value: null}, | 60 | textPropertyPath: {value: null, serializable: true}, |
38 | 61 | ||
39 | tokensController: {value: null}, | 62 | tokensController: {value: null, serializable: true}, |
40 | 63 | ||
41 | // private | 64 | // private |
42 | 65 | ||
@@ -51,7 +74,7 @@ exports.Token = Montage.create(Component, { | |||
51 | } | 74 | } |
52 | }, | 75 | }, |
53 | 76 | ||
54 | _deleteEl: {value: null}, | 77 | _deleteEl: {value: null, serializable: true}, |
55 | 78 | ||
56 | prepareForDraw: { | 79 | prepareForDraw: { |
57 | value: function() { | 80 | value: function() { |
@@ -73,7 +96,9 @@ exports.Token = Montage.create(Component, { | |||
73 | 96 | ||
74 | removeSelf: { | 97 | removeSelf: { |
75 | value: function() { | 98 | value: function() { |
76 | this.tokensController.removeObjects(this.value); | 99 | this.tokensController.selectedObjects = [this.value]; |
100 | this.tokensController.removeObjectsAtSelectedIndexes(); | ||
101 | this.tokensController.selectedIndexes = []; | ||
77 | } | 102 | } |
78 | }, | 103 | }, |
79 | 104 | ||