aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/component-controller.js53
-rwxr-xr-xjs/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js99
2 files changed, 125 insertions, 27 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 33b9b79a..83450d0f 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -12,20 +12,19 @@ exports.ComponentController = Montage.create(ElementController, {
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 switch(prop) { 14 switch(prop) {
15 case "label": 15 case "id":
16 return this.application.ninja.currentDocument.getComponentFromElement(el).label; 16 case "class":
17 break; 17 case "left":
18 case "enabled": 18 case "top":
19 return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; 19 case "width":
20 break; 20 case "height":
21 case "disabled": 21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el).disabled; 22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
23 break; 23 } else {
24 case "value": 24 return ElementController.getProperty(el, prop, true);
25 return this.application.ninja.currentDocument.getComponentFromElement(el).value; 25 }
26 break;
27 default: 26 default:
28 return ElementController.getProperty(el, prop, true); 27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
29 } 28 }
30 } 29 }
31 }, 30 },
@@ -33,20 +32,24 @@ exports.ComponentController = Montage.create(ElementController, {
33 setProperty: { 32 setProperty: {
34 value: function(el, p, value) { 33 value: function(el, p, value) {
35 switch(p) { 34 switch(p) {
36 case "label": 35 case "id":
37 this.application.ninja.currentDocument.getComponentFromElement(el).label = value; 36 case "class":
38 break; 37 case "left":
39 case "enabled": 38 case "top":
40 this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; 39 case "width":
41 break; 40 case "height":
42 case "disabled": 41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
43 this.application.ninja.currentDocument.getComponentFromElement(el).disabled = value; 42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
44 break; 43 } else {
45 case "value": 44 ElementController.setProperty(el, p, value);
46 this.application.ninja.currentDocument.getComponentFromElement(el).value = value; 45 }
47 break; 46 break;
48 default: 47 default:
49 ElementController.setProperty(el, p, value); 48 if(p === "min" || p === "max") value = parseFloat(value);
49
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break;
52
50 } 53 }
51 } 54 }
52 } 55 }
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index 7e5a76ee..b4eec771 100755
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -26,14 +26,59 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
26 "text": "Montage Components", 26 "text": "Montage Components",
27 "children": [ 27 "children": [
28 { 28 {
29 "text": "Anchor",
30 "dataFile" : "node_modules/components-data/anchor.json",
31 "component": "anchor"
32 },
33 {
29 "text": "Button", 34 "text": "Button",
30 "dataFile" : "node_modules/components-data/button.json", 35 "dataFile" : "node_modules/components-data/button.json",
31 "component": "button" 36 "component": "button"
32 }, 37 },
33 { 38 {
39 "text": "Checkbox",
40 "dataFile" : "node_modules/components-data/checkbox.json",
41 "component": "checkbox"
42 },
43 {
44 "text": "Image Component",
45 "dataFile" : "node_modules/components-data/image.json",
46 "component": "imageComponent"
47 },
48 {
49 "text": "NumberInput",
50 "dataFile" : "node_modules/components-data/number-input.json",
51 "component": "numberInput"
52 },
53 {
54 "text": "Select Input",
55 "dataFile" : "node_modules/components-data/select.json",
56 "component": "select"
57 },
58 {
59 "text": "Radio Button",
60 "dataFile" : "node_modules/components-data/radio-button.json",
61 "component": "radioButton"
62 },
63 {
64 "text": "Range Input",
65 "dataFile" : "node_modules/components-data/range-input.json",
66 "component": "rangeInput"
67 },
68 {
69 "text": "TextArea",
70 "dataFile" : "node_modules/components-data/textarea.json",
71 "component": "textarea"
72 },
73 {
34 "text": "Textfield", 74 "text": "Textfield",
35 "dataFile" : "node_modules/components-data/textfield.json", 75 "dataFile" : "node_modules/components-data/textfield.json",
36 "component": "textfield" 76 "component": "textfield"
77 },
78 {
79 "text": "Toogle Button",
80 "dataFile" : "node_modules/components-data/toggle-button.json",
81 "component": "toggleButton"
37 } 82 }
38 ] 83 ]
39 } 84 }
@@ -119,6 +164,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
119 row.prop = props.name; 164 row.prop = props.name;
120 row.defaultValue = props["default"]; 165 row.defaultValue = props["default"];
121 row.label = props.name; 166 row.label = props.name;
167 row.items = props.possibleValues;
122 168
123 section.Section.push([row]); 169 section.Section.push([row]);
124 } 170 }
@@ -147,6 +193,10 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
147 return "textbox"; 193 return "textbox";
148 case "boolean": 194 case "boolean":
149 return "checkbox"; 195 return "checkbox";
196 case "select":
197 return "dropdown";
198 case "number":
199 return "hottext";
150 default: 200 default:
151 alert("Conversion not implemented for ", type); 201 alert("Conversion not implemented for ", type);
152 } 202 }
@@ -211,6 +261,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
211 261
212 NJevent("elementAdding", {"el": element, "data":styles}); 262 NJevent("elementAdding", {"el": element, "data":styles});
213 }); 263 });
264
214 } 265 }
215 }, 266 },
216 267
@@ -219,18 +270,62 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
219 var el; 270 var el;
220 271
221 switch(name) { 272 switch(name) {
273 case "anchor":
274 el = NJUtils.makeNJElement("a", "Anchor", "component");
275 el.elementModel.pi = "AnchorPi";
276 el.setAttribute("href", "http://www.motorola.com");
277 el.innerHTML = "link";
278 break;
222 case "button": 279 case "button":
223 el = NJUtils.makeNJElement(name, "Button", "component"); 280 el = NJUtils.makeNJElement(name, "Button", "component");
224 el.elementModel.pi = "ButtonPi"; 281 el.elementModel.pi = "ButtonPi";
225 el.setAttribute("type", "button"); 282 el.setAttribute("type", "button");
226 el.innerHTML = "Button"; 283 el.innerHTML = "Button";
227 break; 284 break;
228 case "textfield": { 285 case "checkbox":
286 el = NJUtils.makeNJElement("input", "Checkbox", "component");