aboutsummaryrefslogtreecommitdiff
path: root/js/panels/properties/sections/custom.reel/custom.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-02 12:36:34 -0800
committerPushkar Joshi2012-03-02 12:36:34 -0800
commitdc3c813320c8d3fb837d5d18e70ab35a53b116c1 (patch)
treeda417684de5e302d302ea617854015bd9a8ca17a /js/panels/properties/sections/custom.reel/custom.js
parentd7d78d4a4e8cf82c56379d25efbe679b3b823abc (diff)
parent4419209a1fd850ab468209b562b66b0242b42a9c (diff)
downloadninja-dc3c813320c8d3fb837d5d18e70ab35a53b116c1.tar.gz
Merge branch 'brushtool' into pentool
Diffstat (limited to 'js/panels/properties/sections/custom.reel/custom.js')
-rwxr-xr-xjs/panels/properties/sections/custom.reel/custom.js351
1 files changed, 0 insertions, 351 deletions
diff --git a/js/panels/properties/sections/custom.reel/custom.js b/js/panels/properties/sections/custom.reel/custom.js
deleted file mode 100755
index a2b9b9fa..00000000
--- a/js/panels/properties/sections/custom.reel/custom.js
+++ /dev/null
@@ -1,351 +0,0 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
7var Montage = require("montage/core/core").Montage;
8var Component = require("montage/ui/component").Component;
9var ElementsMediator = require("js/mediators/element-mediator").ElementMediator;
10
11//Custom Rows
12var SingleRow = require("js/panels/properties/sections/custom-rows/single-row.reel").SingleRow;
13var DualRow = require("js/panels/properties/sections/custom-rows/dual-row.reel").DualRow;
14var ColorSelect = require("js/panels/properties/sections/custom-rows/color-select.reel").ColorSelect;
15
16// Components Needed to make this work
17var Hottext = require("js/components/hottextunit.reel").HotTextUnit;
18var Dropdown = require("js/components/combobox.reel").Combobox;
19var TextField = require("js/components/textfield.reel").TextField;
20var FileInput = require("js/components/ui/file-input.reel").FileInput;
21var Checkbox = require("js/components/checkbox.reel").Checkbox;
22var ColorChip = require("js/components/ui/color-chip.reel").ColorChip;
23
24exports.CustomSection = Montage.create(Component, {
25
26 repeat: {
27 value: null
28 },
29
30 _fields: {
31
32 },
33
34 fields: {
35 get: function() {
36 return this._fields;
37 },
38 set: function(val) {
39 this.controls = {};
40 this.rows = [];
41 this._fields = val;
42 for(var i=0; i < this._fields.length; i++) {
43 var tmpRow, fields;
44 if(this._fields[i].length === 1) {
45 fields = this._fields[i][0];
46 tmpRow = SingleRow.create();
47 tmpRow.content = this.generateObject(fields);
48 if (fields.label) tmpRow.label = fields.label;
49 if (fields.divider) tmpRow.divider = fields.divider;
50 this.rows.push(tmpRow);
51 } else if(this._fields[i].length === 2) {
52
53 var obj1 = this._fields[i][0];
54 var obj2 = this._fields[i][1];
55
56
57 if (obj1.type == "color" && obj2.type == "color") {
58 tmpRow = Montage.create(ColorSelect);
59 if(obj1.visible === false) tmpRow.colorVisible = obj1.visible;
60 if(obj2.visible === false) tmpRow.color2Visible = obj2.visible;
61
62 }
63 else
64 {
65 tmpRow = DualRow.create();
66 if (obj1.label) tmpRow.label = obj1.label;
67 if (obj2.label) tmpRow.label2 = obj2.label;
68 tmpRow.content = this.generateObject(obj1);
69 tmpRow.content2 = this.generateObject(obj2);
70 }
71
72 if (obj1.divider === true || obj2.divider === true) tmpRow.divider = true;
73 this.rows.push(tmpRow);
74
75 } else if(this._fields[i].length === 3) {
76
77 }
78
79 }
80 }
81
82 },
83
84 rows: {
85 value: []
86 },
87
88 controls: {
89 value:{}
90 },
91
92 handleChanging: {
93 value:function(event) {
94 var obj = event.currentTarget;
95 this._dispatchPropEvent({"type": "changing", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj});
96 }
97 },
98
99 handleChange: {
100 value:function(event) {
101 if(event._event.wasSetByCode) return;
102
103 var obj = event.currentTarget;
104 this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj});
105 }
106 },
107
108 /**
109 * Color change handler. Hard coding the stage for now since only the stage PI uses this color chip
110 */
111 handleColorChange: {
112 value: function(event) {
113 // Change the stage color for now
114 //console.log(this, event);
115 ElementsMediator.setProperty([this.application.ninja.currentDocument.documentRoot], this.id, [event._event.color.css], "Change", "pi", '');
116 /*
117 var propEvent = document.createEvent("CustomEvent");
118 propEvent.initEvent("propertyChange", true, true);
119 propEvent.type = "propertyChange";
120
121 propEvent.prop = "background";//event.prop;
122 propEvent.value = event._event.color.css;
123
124 this.dispatchEvent(propEvent);
125 */
126 }
127 },
128
129 _dispatchPropEvent: {
130 value: function(event) {
131// console.log(event);
132 var propEvent = document.createEvent("CustomEvent");
133 if(event.type === "changing")
134 {
135 propEvent.initEvent("propertyChanging", true, true);
136 propEvent.type = "propertyChanging";
137 }
138 else
139 {
140 propEvent.initEvent("propertyChange", true, true);
141 propEvent.type = "propertyChange";
142 }
143
144 propEvent.id = event.id;
145 propEvent.prop = event.prop;
146 propEvent.text = event.text;
147 propEvent.value = event.value;
148
149 event.control.units ? propEvent.units = event.control.units : propEvent.units = "";
150
151 this.dispatchEvent(propEvent);
152 }
153 },
154
155 generateObject: {
156 value: function(fields) {
157 switch(fields.type) {
158 case "hottext" : return this.createHottext(fields);
159 case "dropdown" : return this.createDropdown(fields);
160 case "textbox" : return this.createTextField(fields);
161 case "file" : return this.createFileInput(fields);
162 case "checkbox" : return this.createCheckbox(fields);
163 case "chip" : return this.createColorChip(fields);
164 }
165 }
166 },
167
168 //Breaking Up Switch Case Statement to functions to return a row
169 createHottext: {
170 value: function(aField) {
171
172 // Generate Hottext
173 var obj = Hottext.create();
174
175 // Set Values for HottextRow
176 if (aField.id) obj.id = aField.id;
177 if (aField.value) obj.value = aField.value;
178 if (aField.acceptableUnits) obj.acceptableUnits = aField.acceptableUnits;
179 if (aField.unit) obj.units = aField.unit;
180 if (aField.min) obj._minValue = aField.min;
181 if (aField.max) obj._maxValue = aField.max;
182 if (aField.prop) obj.prop = aField.prop;
183
184 //Initiate onChange Events
185 obj.addEventListener("change", this, false);
186 obj.addEventListener("changing", this, false);
187
188 //Bind object value to controls list so it can be manipulated
189 Object.defineBinding(this.controls, aField.id, {
190 boundObject: obj,
191 boundObjectPropertyPath: "value"
192 });
193
194 return obj;
195 }
196 },
197
198 createDropdown: {
199 value: function(aField) {
200
201 //Generate Dropdown
202 var obj = Dropdown.create();
203
204 // Set Values for Dropdown
205 if (aField.id) obj.id = aField.id;
206 if (aField.prop) obj.prop = aField.prop;
207 if (aField.value) obj.value = aField.value;
208 if (aField.labelField) obj.labelField = aField.labelField;
209 if (aField.labelFunction) obj.labelFunction = aField.labelFunction;
210 if (aField.dataField) obj.dataField = aField.dataField;