diff options
Diffstat (limited to 'js/panels/properties.reel/sections/custom.reel')
-rwxr-xr-x | js/panels/properties.reel/sections/custom.reel/custom.html | 61 | ||||
-rwxr-xr-x | js/panels/properties.reel/sections/custom.reel/custom.js | 356 |
2 files changed, 417 insertions, 0 deletions
diff --git a/js/panels/properties.reel/sections/custom.reel/custom.html b/js/panels/properties.reel/sections/custom.reel/custom.html new file mode 100755 index 00000000..99a68264 --- /dev/null +++ b/js/panels/properties.reel/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.reel/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.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js new file mode 100755 index 00000000..3c595980 --- /dev/null +++ b/js/panels/properties.reel/sections/custom.reel/custom.js | |||
@@ -0,0 +1,356 @@ | |||
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 | var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | ||
10 | |||
11 | //Custom Rows | ||
12 | var SingleRow = require("js/panels/properties.reel/sections/custom-rows/single-row.reel").SingleRow; | ||
13 | var DualRow = require("js/panels/properties.reel/sections/custom-rows/dual-row.reel").DualRow; | ||
14 | var ColorSelect = require("js/panels/properties.reel/sections/custom-rows/color-select.reel").ColorSelect; | ||
15 | |||
16 | // Components Needed to make this work | ||
17 | var Hottext = require("js/components/hottextunit.reel").HotTextUnit; | ||
18 | var Dropdown = require("js/components/combobox.reel").Combobox; | ||
19 | var TextField = require("js/components/textfield.reel").TextField; | ||
20 | var FileInput = require("js/components/ui/file-input.reel").FileInput; | ||
21 | var Checkbox = require("js/components/checkbox.reel").Checkbox; | ||
22 | var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; | ||
23 | |||
24 | exports.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 | // TODO - Hack for now to reference the color select object to unregister color chips | ||
63 | this.controls["colorSelect"] = tmpRow; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | tmpRow = DualRow.create(); | ||
68 | if (obj1.label) tmpRow.label = obj1.label; | ||
69 | if (obj2.label) tmpRow.label2 = obj2.label; | ||
70 | tmpRow.content = this.generateObject(obj1); | ||
71 | tmpRow.content2 = this.generateObject(obj2); | ||
72 | } | ||
73 | |||
74 | if (obj1.divider === true || obj2.divider === true) tmpRow.divider = true; | ||
75 | this.rows.push(tmpRow); | ||
76 | |||
77 | } else if(this._fields[i].length === 3) { | ||
78 | |||
79 | } | ||
80 | |||
81 | } | ||
82 | } | ||
83 | |||
84 | }, | ||
85 | |||
86 | rows: { | ||
87 | value: [] | ||
88 | }, | ||
89 | |||
90 | controls: { | ||
91 | value:{} | ||
92 | }, | ||
93 | |||
94 | handleChanging: { | ||
95 | value:function(event) { | ||
96 | var obj = event.currentTarget; | ||
97 | this._dispatchPropEvent({"type": "changing", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj}); | ||
98 | } | ||
99 | }, | ||
100 | |||
101 | handleChange: { | ||
102 | value:function(event) { | ||
103 | if(event._event.wasSetByCode) return; | ||
104 | |||
105 | var obj = event.currentTarget; | ||
106 | this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj}); | ||
107 | } | ||
108 | }, | ||
109 | |||
110 | /** | ||
111 | * Color change handler. Hard coding the stage for now since only the stage PI uses this color chip | ||
112 | */ | ||
113 | handleColorChange: { | ||
114 | value: function(event) { | ||
115 | // Change the stage color for now | ||
116 | //console.log(this, event); | ||
117 | ElementsMediator.setProperty([this.application.ninja.currentDocument.documentRoot], this.id, [event._event.color.css], "Change", "pi", ''); | ||
118 | /* | ||
119 | var propEvent = document.createEvent("CustomEvent"); | ||
120 | propEvent.initEvent("propertyChange", true, true); | ||
121 | propEvent.type = "propertyChange"; | ||
122 | |||
123 | propEvent.prop = "background";//event.prop; | ||
124 | propEvent.value = event._event.color.css; | ||
125 | |||
126 | this.dispatchEvent(propEvent); | ||
127 | */ | ||
128 | } | ||
129 | }, | ||
130 | |||
131 | _dispatchPropEvent: { | ||
132 | value: function(event) { | ||
133 | // console.log(event); | ||
134 | var propEvent = document.createEvent("CustomEvent"); | ||
135 | if(event.type === "changing") | ||
136 | { | ||
137 | propEvent.initEvent("propertyChanging", true, true); | ||
138 | propEvent.type = "propertyChanging"; | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | propEvent.initEvent("propertyChange", true, true); | ||
143 | propEvent.type = "propertyChange"; | ||
144 | } | ||
145 | |||
146 | propEvent.id = event.id; | ||
147 | propEvent.prop = event.prop; | ||
148 | propEvent.text = event.text; | ||
149 | propEvent.value = event.value; | ||
150 | |||