aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/controllers/elements/component-controller.js12
-rw-r--r--js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js65
-rw-r--r--node_modules/components-data/textfield.json4
-rw-r--r--user-document-templates/montage-application-cloud/main.reel/main.js141
4 files changed, 34 insertions, 188 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 1b0591be..33b9b79a 100644
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -18,6 +18,12 @@ exports.ComponentController = Montage.create(ElementController, {
18 case "enabled": 18 case "enabled":
19 return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; 19 return this.application.ninja.currentDocument.getComponentFromElement(el).enabled;
20 break; 20 break;
21 case "disabled":
22 return this.application.ninja.currentDocument.getComponentFromElement(el).disabled;
23 break;
24 case "value":
25 return this.application.ninja.currentDocument.getComponentFromElement(el).value;
26 break;
21 default: 27 default:
22 return ElementController.getProperty(el, prop, true); 28 return ElementController.getProperty(el, prop, true);
23 } 29 }
@@ -33,6 +39,12 @@ exports.ComponentController = Montage.create(ElementController, {
33 case "enabled": 39 case "enabled":
34 this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; 40 this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value;
35 break; 41 break;
42 case "disabled":
43 this.application.ninja.currentDocument.getComponentFromElement(el).disabled = value;
44 break;
45 case "value":
46 this.application.ninja.currentDocument.getComponentFromElement(el).value = value;
47 break;
36 default: 48 default:
37 ElementController.setProperty(el, p, value); 49 ElementController.setProperty(el, p, value);
38 } 50 }
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index 33241d42..953c0484 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -160,7 +160,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
160 var that = this; 160 var that = this;
161 var element = this.makeComponent(component.component); 161 var element = this.makeComponent(component.component);
162 162
163 this.application.ninja.currentDocument._window.addComponent(element, {type: component.name, path: component.module, name: "Button"}, function(instance, element) { 163 this.application.ninja.currentDocument._window.addComponent(element, {name: component.name, path: component.module}, function(instance, element) {
164 164
165 var pos = that.getStageCenter(); 165 var pos = that.getStageCenter();
166 166
@@ -181,73 +181,24 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
181 181
182 makeComponent: { 182 makeComponent: {
183 value: function(name) { 183 value: function(name) {
184 var el;
185
184 switch(name) { 186 switch(name) {
185 case "button": 187 case "button":
186 var el;
187 el = NJUtils.makeNJElement(name, "Button", "component"); 188 el = NJUtils.makeNJElement(name, "Button", "component");
188 el.elementModel.pi = "ButtonPi"; 189 el.elementModel.pi = "ButtonPi";
189 el.setAttribute("type", "button"); 190 el.setAttribute("type", "button");
190 return el; 191 el.innerHTML = "Button";
192 break;
191 case "textfield": { 193 case "textfield": {
192 var el; 194 el = NJUtils.makeNJElement("input", "Textfield", "component");
193 el = NJUtils.makeNJElement("input", "Text Field", "component");
194 el.elementModel.pi = "TextfieldPi"; 195 el.elementModel.pi = "TextfieldPi";
195 el.setAttribute("type", "text"); 196 el.setAttribute("type", "text");
196 return el; 197 break;
197 } 198 }
198 } 199 }
199 200
200 } 201 return el;
201 },
202
203 ___addComponentToStage:{
204 value:function(component, dropX, dropY){
205// var compW = 100,
206// compH = 100,
207//
208 var componentEl, componentInstance;
209
210 if(componentType == "Button"){
211 componentEl = NJUtils.makeNJElement("button", componentType, "component");//, {"type": "button"});
212 componentEl.setAttribute("type", "button");
213
214 componentInstance = this.application.ninja.currentDocument._window.addComponent(componentEl, {type: componentType, path: "montage/ui/button.reel", name: "Button"}, this.callback);
215
216 }else if(componentType == "Checkbox"){
217 compW = 53;
218 compH = 53;
219// elementType = "input";
220 }
221
222 /*
223 componentContainer = NJUtils.makeNJElement("div", componentType, "component");
224 componentContainer.elementModel.isComponent = true;
225 */
226 var styles = {
227 'position': 'absolute',
228 'top' : dropY + 'px',
229 'left' : dropX + 'px',
230// 'width' : compW + 'px',
231// 'height' : compH + 'px',
232 '-webkit-transform-style' : 'preserve-3d',
233 '-webkit-transform' : 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
234 };
235
236
237 //componentElement = NJUtils.makeNJElement(elementType, "ComponentDiv", "block");
238
239 //componentContainer.appendChild(componentElement);
240
241 this.application.ninja.currentDocument.setComponentInstance(componentInstance, componentEl);
242
243 NJevent("elementAdding", {"el": componentEl, "data":styles});
244 /*
245 var componentRef = this.application.ninja.currentDocument._window.addComponent(componentElement, componentType);
246
247 */
248
249
250
251 } 202 }
252 }, 203 },
253 204
diff --git a/node_modules/components-data/textfield.json b/node_modules/components-data/textfield.json
index 2a21394a..4f8a1499 100644
--- a/node_modules/components-data/textfield.json
+++ b/node_modules/components-data/textfield.json
@@ -13,9 +13,9 @@
13 "default": "Button" 13 "default": "Button"
14 }, 14 },
15 { 15 {
16 "name": "enabled", 16 "name": "disabled",
17 "type": "boolean", 17 "type": "boolean",
18 "default": "true" 18 "default": "false"
19 } 19 }
20 ] 20 ]
21} \ No newline at end of file 21} \ No newline at end of file
diff --git a/user-document-templates/montage-application-cloud/main.reel/main.js b/user-document-templates/montage-application-cloud/main.reel/main.js
index 2e331cdc..86871fd3 100644
--- a/user-document-templates/montage-application-cloud/main.reel/main.js
+++ b/user-document-templates/montage-application-cloud/main.reel/main.js
@@ -32,140 +32,23 @@ exports.Main = Montage.create(Component, {
32 }, 32 },
33 33
34 addComponentToUserDocument:{ 34 addComponentToUserDocument:{
35 value:function(containerElement, componentType, callback){ 35 value:function(element, data, callback){
36 var component = null;
37 switch(componentType.type){
38 case "Button":
39 36
40 var button = require.async(componentType.path) 37 var component;
41 .then(function (button) {
42 var buttonObj = button["Button"];
43 var btIns = buttonObj.create();
44 38
45 btIns.element = containerElement; 39 component = require.async(data.path)
46 btIns.deserializedFromTemplate(); 40 .then(function(component) {
41 var componentRequire = component[data.name];
42 var componentInstance = componentRequire.create();
47 43
48 btIns.needsDraw = true; 44 componentInstance.element = element;
49 btIns.label = "Button"; 45 componentInstance.deserializedFromTemplate();
50 callback(btIns, containerElement); 46 componentInstance.needsDraw = true;
51 })
52 .end();
53 47
54 break; 48 callback(componentInstance, element);
55 case "Textfield": 49 })
56 var tf = require.async(componentType.path) 50 .end();
57 .then(function (tf) {
58 var buttonObj = tf["Textfield"];
59 var btIns = buttonObj.create();
60 51
61 btIns.element = containerElement;
62 btIns.deserializedFromTemplate();
63
64 btIns.needsDraw = true;
65 btIns.value = "Button";
66