diff options
author | Armen Kesablyan | 2012-06-19 01:03:59 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 01:03:59 -0700 |
commit | 2e13a73e4ee980a6f73f6ff48b2a195eb209a7db (patch) | |
tree | d352f5e769eae0e1b7b76ccbeafa9b174b1a9918 /node_modules/montage/ui/token-field/token.reel/token.js | |
parent | 244e608645778746d1a3b5aa0d4c0868f7c5c272 (diff) | |
parent | c59eb371559a3061ce53223e249ca97daace5968 (diff) | |
download | ninja-2e13a73e4ee980a6f73f6ff48b2a195eb209a7db.tar.gz |
Merge branch 'refs/heads/master' into binding
Conflicts:
js/components/layout/tools-list.reel/tools-list.html
js/components/layout/tools-properties.reel/tools-properties.html
js/document/document-html.js
js/document/templates/app/main.js
js/panels/Panel.reel/Panel.js
node_modules/montage/ui/native-control.js
Signed-off-by: Armen Kesablyan <armen@motorola.com>
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 | ||