diff options
Diffstat (limited to 'node_modules/montage/ui/token-field/token.reel')
-rw-r--r-- | node_modules/montage/ui/token-field/token.reel/token.html | 6 | ||||
-rw-r--r-- | node_modules/montage/ui/token-field/token.reel/token.js | 65 |
2 files changed, 48 insertions, 23 deletions
diff --git a/node_modules/montage/ui/token-field/token.reel/token.html b/node_modules/montage/ui/token-field/token.reel/token.html index 54ba266e..c478ef0c 100644 --- a/node_modules/montage/ui/token-field/token.reel/token.html +++ b/node_modules/montage/ui/token-field/token.reel/token.html | |||
@@ -9,7 +9,7 @@ | |||
9 | { | 9 | { |
10 | 10 | ||
11 | "tokenText": { | 11 | "tokenText": { |
12 | "prototype": "montage/ui/dynamic-text.reel", | 12 | "prototype": "ui/dynamic-text.reel", |
13 | "properties": { | 13 | "properties": { |
14 | "element": {"#": "token-text"} | 14 | "element": {"#": "token-text"} |
15 | }, | 15 | }, |
@@ -18,7 +18,7 @@ | |||
18 | } | 18 | } |
19 | }, | 19 | }, |
20 | "tokenDelete": { | 20 | "tokenDelete": { |
21 | "prototype": "montage/ui/dynamic-text.reel", | 21 | "prototype": "ui/dynamic-text.reel", |
22 | "properties": { | 22 | "properties": { |
23 | "element": {"#": "token-delete"}, | 23 | "element": {"#": "token-delete"}, |
24 | "value": "✕" | 24 | "value": "✕" |
@@ -26,7 +26,7 @@ | |||
26 | }, | 26 | }, |
27 | 27 | ||
28 | "owner": { | 28 | "owner": { |
29 | "prototype": "montage/ui/token-field/token.reel", | 29 | "prototype": "ui/token-field/token.reel", |
30 | "properties": { | 30 | "properties": { |
31 | "element": {"#": "token"}, | 31 | "element": {"#": "token"}, |
32 | "_deleteEl": {"#": "token-delete"} | 32 | "_deleteEl": {"#": "token-delete"} |
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 | ||