diff options
Diffstat (limited to 'js/components')
28 files changed, 1349 insertions, 58 deletions
diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js index a68a7d6b..3200b01c 100644 --- a/js/components/combobox.reel/combobox.js +++ b/js/components/combobox.reel/combobox.js | |||
@@ -15,7 +15,7 @@ exports.Combobox = Montage.create(Component, { | |||
15 | }, | 15 | }, |
16 | 16 | ||
17 | _wasSetByCode: { | 17 | _wasSetByCode: { |
18 | enumerable: false, | 18 | enumerable: true, |
19 | value: true | 19 | value: true |
20 | }, | 20 | }, |
21 | 21 | ||
@@ -27,6 +27,14 @@ exports.Combobox = Montage.create(Component, { | |||
27 | value: null | 27 | value: null |
28 | }, | 28 | }, |
29 | 29 | ||
30 | dataField: { | ||
31 | value: null | ||
32 | }, | ||
33 | |||
34 | dataFunction: { | ||
35 | value: null | ||
36 | }, | ||
37 | |||
30 | _items: { | 38 | _items: { |
31 | value: [] | 39 | value: [] |
32 | }, | 40 | }, |
@@ -71,7 +79,27 @@ exports.Combobox = Montage.create(Component, { | |||
71 | e.value = this._value; | 79 | e.value = this._value; |
72 | this.dispatchEvent(e); | 80 | this.dispatchEvent(e); |
73 | 81 | ||
74 | this._wasSetByCode = false; | 82 | this._wasSetByCode = true; |
83 | } | ||
84 | } | ||
85 | }, | ||
86 | |||
87 | _enabled: { | ||
88 | enumerable: false, | ||
89 | value: true | ||
90 | }, | ||
91 | |||
92 | enabled: { | ||
93 | enumerable: true, | ||
94 | serializable: true, | ||
95 | get: function() { | ||
96 | return this._enabled; | ||
97 | }, | ||
98 | set: function(value) { | ||
99 | if(value !== this._enabled) | ||
100 | { | ||
101 | this._enabled = value; | ||
102 | this.needsDraw = true; | ||
75 | } | 103 | } |
76 | } | 104 | } |
77 | }, | 105 | }, |
@@ -102,7 +130,19 @@ exports.Combobox = Montage.create(Component, { | |||
102 | { | 130 | { |
103 | var current = items[i]; | 131 | var current = items[i]; |
104 | optionItem = document.createElement("option"); | 132 | optionItem = document.createElement("option"); |
105 | optionItem.value = current; | 133 | if(this.dataFunction) |
134 | { | ||
135 | optionItem.value = this.dataFunction(current); | ||
136 | } | ||
137 | else if(this.dataField) | ||
138 | { | ||
139 | optionItem.value = current[this.dataField]; | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | optionItem.value = current; | ||
144 | } | ||
145 | |||
106 | if(this.labelFunction) | 146 | if(this.labelFunction) |
107 | { | 147 | { |
108 | optionItem.innerText = this.labelFunction(current); | 148 | optionItem.innerText = this.labelFunction(current); |
@@ -117,6 +157,7 @@ exports.Combobox = Montage.create(Component, { | |||
117 | } | 157 | } |
118 | this.element.appendChild(optionItem); | 158 | this.element.appendChild(optionItem); |
119 | } | 159 | } |
160 | this.element.disabled = !this._enabled; | ||
120 | } | 161 | } |
121 | } | 162 | } |
122 | }, | 163 | }, |
@@ -133,6 +174,22 @@ exports.Combobox = Montage.create(Component, { | |||
133 | 174 | ||
134 | prepareForDraw: { | 175 | prepareForDraw: { |
135 | value: function() { | 176 | value: function() { |
177 | if( (this._value === null) && this._items.length ) | ||
178 | { | ||
179 | var current = this._items[0]; | ||
180 | if(this.dataFunction) | ||
181 | { | ||
182 | this.value = this.dataFunction(current); | ||
183 | } | ||
184 | else if(this.dataField) | ||
185 | { | ||
186 | this.value = current[this.dataField]; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | this.value = current; | ||
191 | } | ||
192 | } | ||
136 | this.element.addEventListener("change", this, false); | 193 | this.element.addEventListener("change", this, false); |
137 | } | 194 | } |
138 | } | 195 | } |
diff --git a/js/components/controllers/tree-controller.js b/js/components/controllers/tree-controller.js new file mode 100644 index 00000000..03ef7b9e --- /dev/null +++ b/js/components/controllers/tree-controller.js | |||
@@ -0,0 +1,185 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 | /** | ||
7 | @module montage/ui/controller/tree-controller | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/controller/object-controller | ||
10 | @requires montage/core/event/mutable-event | ||
11 | */ | ||
12 | var Montage = require("montage").Montage, | ||
13 | ObjectController = require("montage/ui/controller/object-controller").ObjectController, | ||
14 | ArrayController = require("montage/ui/controller/array-controller").ArrayController, | ||
15 | MutableEvent = require("montage/core/event/mutable-event").MutableEvent; | ||
16 | /** | ||
17 | TODO: Write description like the array controllers: The ArrayController helps with organizing a hierarchical | ||
18 | collection of objects, and managing user selection within that collection. | ||
19 | You can assign a TreeController instance as the <code>contentProvider</code> property for a TreeView object. | ||
20 | @class module:montage/ui/controller/tree-controller.TreeController | ||
21 | @classdesc | ||
22 | @extends module:montage/ui/controller/object-controller.ObjectController | ||
23 | */ | ||
24 | var TreeController = exports.TreeController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/tree-controller.TreeController# */ { | ||
25 | |||
26 | rootKey : { | ||
27 | value: null | ||
28 | }, | ||
29 | |||
30 | branchKey : { | ||
31 | value: 'children' | ||
32 | }, | ||
33 | |||
34 | _root : { | ||
35 | value : null | ||
36 | }, | ||
37 | root : { | ||
38 | get: function() { | ||
39 | return this._root; | ||
40 | }, | ||
41 | set: function(value) { | ||
42 | this._root = value; | ||
43 | |||
44 | this.initArrayControllers(); | ||
45 | } | ||
46 | }, | ||
47 | |||
48 | rootController: { | ||
49 | value: null | ||
50 | }, | ||
51 | |||
52 | initArrayControllers : { | ||
53 | value: function() { | ||
54 | var self = this; | ||
55 | |||
56 | ///// Recursive function that finds all branch nodes and initializes | ||
57 | ///// sets the tree node type to "branch" or "leaf" | ||
58 | |||
59 | function walk(node, init, depth) { | ||
60 | var branch = node[self.branchKey]; | ||
61 | |||
62 | if(branch) { |