diff options
Diffstat (limited to 'js/panels/Components/ComponentsPanelBase.reel')
-rw-r--r-- | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html | 11 | ||||
-rw-r--r-- | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | 211 |
2 files changed, 186 insertions, 36 deletions
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html index df104ecc..1e040e35 100644 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html | |||
@@ -11,6 +11,17 @@ | |||
11 | 11 | ||
12 | <script type="text/montage-serialization"> | 12 | <script type="text/montage-serialization"> |
13 | { | 13 | { |
14 | "componentController": { | ||
15 | "module": "montage/ui/controller/array-controller", | ||
16 | "name": "ArrayController", | ||
17 | "bindings": { | ||
18 | "content": { | ||
19 | "boundObject": {"@": "owner"}, | ||
20 | "boundObjectPropertyPath": "components" | ||
21 | } | ||
22 | } | ||
23 | }, | ||
24 | |||
14 | "owner": { | 25 | "owner": { |
15 | "module": "js/panels/Components/ComponentsPanelBase.reel", | 26 | "module": "js/panels/Components/ComponentsPanelBase.reel", |
16 | "name": "ComponentsPanelBase", | 27 | "name": "ComponentsPanelBase", |
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js index 41afefa5..d9decd2c 100644 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | |||
@@ -4,17 +4,96 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component, |
9 | NJUtils = require("js/lib/NJUtils").NJUtils; | 9 | NJUtils = require("js/lib/NJUtils").NJUtils; |
10 | 10 | ||
11 | var treeControlModule = require("js/components/tree.reel"); | 11 | var treeControlModule = require("js/components/tree.reel"); |
12 | var PIData = require("js/data/pi/pi-data").PiData; | ||
12 | 13 | ||
13 | var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, { | 14 | var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, { |
14 | _hasFocus: { | 15 | |
15 | enumerable: false, | 16 | components: { |
16 | value: false | 17 | value: null |
18 | }, | ||
19 | |||
20 | _testButtonJson: { | ||
21 | value: { | ||
22 | "component": "button", | ||
23 | |||
24 | "module": "montage/ui/button.reel", | ||
25 | |||
26 | "name": "Button", | ||
27 | |||
28 | "properties": [ | ||
29 | { | ||
30 | "name": "label", | ||
31 | "type": "string", | ||
32 | "default": "Button" | ||
33 | }, | ||
34 | { | ||
35 | "name": "enabled", | ||
36 | "type": "boolean", | ||
37 | "default": "true" | ||
38 | } | ||
39 | ] | ||
40 | } | ||
41 | }, | ||
42 | |||
43 | didCreate: { | ||
44 | value: function() { | ||
45 | this._loadComponents(); | ||
46 | } | ||
47 | }, | ||
48 | |||
49 | _loadComponents: { | ||
50 | value: function() { | ||
51 | this.components = [ | ||
52 | {name: "Button", data: "montage/ui/button.reel/button.json"} | ||
53 | ]; | ||
54 | |||
55 | // Build the PI objects for each component | ||
56 | for(var i = 0, component; component = this.components[i]; i++) { | ||
57 | var piIdentifier = component.name + "Pi"; | ||
58 | var piObj = []; | ||
59 | var section = {}; | ||
60 | |||
61 | |||
62 | section.label = component.name + " Properties"; | ||
63 | section.Section = []; | ||
64 | |||
65 | for(var j = 0, props; props = this._testButtonJson.properties[j]; j++) { | ||
66 | var row = {}; | ||
67 | row.type = this.getControlType(props.type); | ||
68 | row.id = props.name; | ||
69 | row.prop = props.name; | ||
70 | row.defaultValue = props["default"]; | ||
71 | row.label = props.name; | ||
72 | |||
73 | section.Section.push([row]); | ||
74 | } | ||
75 | |||
76 | PIData[piIdentifier] = []; | ||
77 | PIData[piIdentifier].push(section); | ||
78 | |||
79 | } | ||
80 | |||
81 | } | ||
82 | }, | ||
83 | |||
84 | getControlType: { | ||
85 | value: function(type) { | ||
86 | switch(type) { | ||
87 | case "string": | ||
88 | return "textbox"; | ||
89 | case "boolean": | ||
90 | return "checkbox"; | ||
91 | default: | ||
92 | alert("Conversion not implemented for ", type); | ||
93 | } | ||
94 | } | ||
17 | }, | 95 | }, |
96 | |||
18 | prepareForDraw: { | 97 | prepareForDraw: { |
19 | enumerable: false, | 98 | enumerable: false, |
20 | value: function() { | 99 | value: function() { |
@@ -27,18 +106,6 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component | |||
27 | this.eventManager.addEventListener( "executeAddComponent", this, false); | 106 | this.eventManager.addEventListener( "executeAddComponent", this, false); |
28 | } | 107 | } |
29 | }, | 108 | }, |
30 | willDraw: { | ||
31 | enumerable: false, | ||
32 | value: function() { | ||
33 | |||
34 | } | ||
35 | }, | ||
36 | draw: { | ||
37 | enumerable: false, | ||
38 | value: function() { | ||
39 | |||
40 | } | ||
41 | }, | ||
42 | 109 | ||
43 | _loadXMLDoc: { | 110 | _loadXMLDoc: { |
44 | value:function(dname) { | 111 | value:function(dname) { |
@@ -51,23 +118,88 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component | |||
51 | } | 118 | } |
52 | }, | 119 | }, |
53 | 120 | ||
121 | _stash: { | ||
122 | value: {} | ||
123 | }, | ||
124 | |||
54 | handleExecuteAddComponent: { | 125 | handleExecuteAddComponent: { |
55 | value: function(evt) { | 126 | value: function(evt) { |
56 | this.addComponentToStage(evt.detail.component, evt.detail.dropX, evt.detail.dropY) | 127 | //var component = evt.detail.component; |
128 | // Get the data from the event detail component | ||
129 | var component = this._testButtonJson; | ||
130 | this._stash.dropx = evt.detail.dropX; | ||
131 | this._stash.dropy = evt.detail.dropY; | ||
132 | this.addComponentToStage(component);// evt.detail.dropX, evt.detail.dropY); | ||
133 | } | ||
134 | }, | ||
135 | |||
136 | /** | ||
137 | * Send a request to add a component to the user document and waits for a callback to continue | ||
138 | */ | ||
139 | addComponentToStage: { | ||
140 | value: function(component) { | ||
141 | var that = this; | ||
142 | var element = this.makeComponent(component.component); | ||
143 | this.application.ninja.currentDocument._window.addComponent(element, {type: "Button", path: component.module, name: "Button"}, function(instance, element) { | ||
144 | |||
145 | var styles = { | ||
146 | 'position': 'absolute', | ||
147 | 'top' : that._stash.dropy + 'px', | ||
148 | 'left' : that._stash.dropx + 'px', | ||
149 | '-webkit-transform-style' : 'preserve-3d', | ||
150 | '-webkit-transform' : 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' | ||
151 | }; | ||
152 | |||
153 | |||
154 | that.application.ninja.currentDocument.setComponentInstance(instance, element); | ||
155 | |||
156 | NJevent("elementAdding", {"el": element, "data":styles}); | ||
157 | }); | ||
57 | } | 158 | } |
58 | }, | 159 | }, |
59 | 160 | ||
60 | addComponentToStage:{ | 161 | callback: { |