diff options
Diffstat (limited to 'js/panels/properties/sections/custom.reel')
-rw-r--r-- | js/panels/properties/sections/custom.reel/custom.html | 61 | ||||
-rw-r--r-- | js/panels/properties/sections/custom.reel/custom.js | 296 |
2 files changed, 357 insertions, 0 deletions
diff --git a/js/panels/properties/sections/custom.reel/custom.html b/js/panels/properties/sections/custom.reel/custom.html new file mode 100644 index 00000000..6d4cf0cd --- /dev/null +++ b/js/panels/properties/sections/custom.reel/custom.html | |||
@@ -0,0 +1,61 @@ | |||
1 | <!DOCTYPE HTML> | ||
2 | <!-- <copyright> | ||
3 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
4 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
5 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
6 | </copyright> --> | ||
7 | <html> | ||
8 | <head> | ||
9 | <title></title> | ||
10 | <script type="text/montage-serialization"> | ||
11 | { | ||
12 | "owner": { | ||
13 | "module" : "js/panels/properties/sections/custom.reel", | ||
14 | "name" : "CustomSection", | ||
15 | "properties" : { | ||
16 | "element" : {"#": "section"}, | ||
17 | "repeat" : {"@": "repeat"} | ||
18 | } | ||
19 | }, | ||
20 | |||
21 | "repeat": { | ||
22 | "module": "montage/ui/repetition.reel", | ||
23 | "name": "Repetition", | ||
24 | "properties": { | ||
25 | "element" : {"#": "repetitionContainer"} | ||
26 | }, | ||
27 | "bindings": { | ||
28 | "objects": { | ||
29 | "boundObject": {"@": "owner"}, | ||
30 | "boundObjectPropertyPath": "rows", | ||
31 | "oneway": true | ||
32 | } | ||
33 | } | ||
34 | }, | ||
35 | |||
36 | "slot": { | ||
37 | "module": "montage/ui/slot.reel", | ||
38 | "name": "Slot", | ||
39 | "properties": { | ||
40 | "element": { "#": "repeitionContent" } | ||
41 | }, | ||
42 | "bindings": { | ||
43 | "content": { | ||
44 | "boundObject": {"@": "repeat"}, | ||
45 | "boundObjectPropertyPath": "objectAtCurrentIteration", | ||
46 | "oneway": true | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
51 | } | ||
52 | </script> | ||
53 | </head> | ||
54 | <body> | ||
55 | <div id="section" class="sectional"> | ||
56 | <div id="repetitionContainer"> | ||
57 | <div id="repeitionContent"></div> | ||
58 | </div> | ||
59 | </div> | ||
60 | </body> | ||
61 | </html> \ No newline at end of file | ||
diff --git a/js/panels/properties/sections/custom.reel/custom.js b/js/panels/properties/sections/custom.reel/custom.js new file mode 100644 index 00000000..2b5b522a --- /dev/null +++ b/js/panels/properties/sections/custom.reel/custom.js | |||
@@ -0,0 +1,296 @@ | |||
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 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | |||
10 | //Custom Rows | ||
11 | var SingleRow = require("js/panels/properties/sections/custom-rows/single-row.reel").SingleRow; | ||
12 | var DualRow = require("js/panels/properties/sections/custom-rows/dual-row.reel").DualRow; | ||
13 | var ColorSelect = require("js/panels/properties/sections/custom-rows/color-select.reel").ColorSelect; | ||
14 | |||
15 | // Components Needed to make this work | ||
16 | var Hottext = require("js/components/hottextunit.reel").HotTextUnit; | ||
17 | var Dropdown = require("js/components/combobox.reel").Combobox; | ||
18 | var TextField = require("js/components/textfield.reel").TextField; | ||
19 | var FileInput = require("js/components/ui/file-input.reel").FileInput; | ||
20 | var Checkbox = require("js/components/checkbox.reel").Checkbox; | ||
21 | |||
22 | |||
23 | exports.CustomSection = Montage.create(Component, { | ||
24 | |||
25 | repeat: { | ||
26 | value: null | ||
27 | }, | ||
28 | |||
29 | _fields: { | ||
30 | |||
31 | }, | ||
32 | |||
33 | fields: { | ||
34 | get: function() { | ||
35 | return this._fields; | ||
36 | }, | ||
37 | set: function(val) { | ||
38 | this.controls = {}; | ||
39 | this.rows = []; | ||
40 | this._fields = val; | ||
41 | for(var i=0; i < this._fields.length; i++) { | ||
42 | var tmpRow, fields; | ||
43 | if(this._fields[i].length === 1) { | ||
44 | fields = this._fields[i][0]; | ||
45 | tmpRow = SingleRow.create(); | ||
46 | tmpRow.content = this.generateObject(fields); | ||
47 | if (fields.label) tmpRow.label = fields.label; | ||
48 | if (fields.divider) tmpRow.divider = fields.divider; | ||
49 | this.rows.push(tmpRow); | ||
50 | } else if(this._fields[i].length === 2) { | ||
51 | |||
52 | var obj1 = this._fields[i][0]; | ||
53 | var obj2 = this._fields[i][1]; | ||
54 | |||
55 | |||
56 | if (obj1.type == "color" && obj2.type == "color") { | ||
57 | tmpRow = Montage.create(ColorSelect); | ||
58 | if(obj1.visible === false) tmpRow.colorVisible = obj1.visible; | ||
59 | if(obj2.visible === false) tmpRow.color2Visible = obj2.visible; | ||
60 | |||
61 | } | ||
62 | else | ||
63 | { | ||
64 | tmpRow = DualRow.create(); | ||
65 | if (obj1.label) tmpRow.label = obj1.label; | ||
66 | if (obj2.label) tmpRow.label2 = obj2.label; | ||
67 | tmpRow.content = this.generateObject(obj1); | ||
68 | tmpRow.content2 = this.generateObject(obj2); | ||
69 | } | ||
70 | |||
71 | if (obj1.divider === true || obj2.divider === true) tmpRow.divider = true; | ||
72 | this.rows.push(tmpRow); | ||
73 | |||
74 | } else if(this._fields[i].length === 3) { | ||
75 | |||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
80 | |||
81 | }, | ||
82 | |||
83 | rows: { | ||
84 | value: [] | ||
85 | }, | ||
86 | |||
87 | controls: { | ||
88 | value:{} | ||
89 | }, | ||
90 | |||
91 | handleChanging: | ||
92 | { | ||
93 | value:function(event) | ||
94 | { | ||
95 | var obj = event.currentTarget; | ||
96 | this._dispatchPropEvent({"type": "changing", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj}); | ||
97 | } | ||
98 | }, | ||
99 | |||
100 | handleChange: { | ||
101 | value:function(event) { | ||
102 | if(event._event.wasSetByCode) return; | ||
103 | |||
104 | var obj = event.currentTarget; | ||
105 | this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj}); | ||
106 | } | ||
107 | }, | ||
108 | |||
109 | _dispatchPropEvent: { | ||
110 | value: function(event) { | ||
111 | // console.log(event); | ||
112 | var propEvent = document.createEvent("CustomEvent"); | ||
113 | if(event.type === "changing") | ||
114 | { | ||
115 | propEvent.initEvent("propertyChanging", true, true); | ||
116 | propEvent.type = "propertyChanging"; | ||
117 | } | ||
118 | else | ||
119 | { | ||
120 | propEvent.initEvent("propertyChange", true, true); | ||
121 | propEvent.type = "propertyChange"; | ||
122 | } | ||
123 | |||
124 | propEvent.id = event.id; | ||
125 | propEvent.prop = event.prop; | ||
126 | propEvent.text = event.text; | ||
127 | propEvent.value = event.value; | ||
128 | |||
129 | event.control.units ? propEvent.units = event.control.units : propEvent.units = ""; | ||
130 | |||
131 | this.dispatchEvent(propEvent); | ||
132 | } | ||
133 | }, | ||
134 | |||
135 | generateObject: { | ||
136 | value: function(fields) { | ||
137 | switch(fields.type) { | ||
138 | case "hottext" : return this.createHottext(fields); | ||
139 | case "dropdown" : return this.createDropdown(fields); | ||
140 | case "textbox" : return this.createTextField(fields); | ||
141 | case "file" : return this.createFileInput(fields); | ||
142 | case "checkbox" : return this.createCheckbox(fields); | ||
143 | } | ||
144 | } | ||
145 | }, | ||
146 | |||
147 | //Breaking Up Switch Case Statement to functions to return a row | ||
148 | createHottext: { | ||
149 | value: function(aField) { | ||
150 | |||
151 | // Generate Hottext | ||
152 | var obj = Hottext.create(); | ||
153 | |||
154 | // Set Values for HottextRow | ||
155 | if (aField.id) obj.id = aField.id; | ||