diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/components/ui/color-chip.reel/color-chip.js | 64 | ||||
-rw-r--r-- | js/controllers/elements/stage-controller.js | 4 | ||||
-rw-r--r-- | js/data/pi/pi-data.js | 16 | ||||
-rw-r--r-- | js/io/document/html-document.js | 3 | ||||
-rw-r--r-- | js/panels/properties/content.reel/content.js | 29 | ||||
-rw-r--r-- | js/panels/properties/sections/custom.reel/custom.js | 51 |
6 files changed, 152 insertions, 15 deletions
diff --git a/js/components/ui/color-chip.reel/color-chip.js b/js/components/ui/color-chip.reel/color-chip.js index 5bef7020..e51bdd8a 100644 --- a/js/components/ui/color-chip.reel/color-chip.js +++ b/js/components/ui/color-chip.reel/color-chip.js | |||
@@ -9,32 +9,80 @@ var Montage = require("montage/core/core").Montage, | |||
9 | 9 | ||
10 | var ColorChip = exports.ColorChip = Montage.create(Component, { | 10 | var ColorChip = exports.ColorChip = Montage.create(Component, { |
11 | 11 | ||
12 | chip: { | ||
13 | value: false | ||
14 | }, | ||
15 | |||
12 | hasIcon: { | 16 | hasIcon: { |
13 | value: true | 17 | value: true |
14 | }, | 18 | }, |
15 | 19 | ||
20 | iconType: { | ||
21 | value: null | ||
22 | }, | ||
23 | |||
16 | mode: { | 24 | mode: { |
17 | value: "stroke" | 25 | value: "stroke" |
18 | }, | 26 | }, |
19 | 27 | ||
20 | prepareForDraw: { | 28 | offset: { |
21 | value: function() { | 29 | value: 20 |
22 | // this.colorButton.props = {side: 'right', align: 'bottom', wheel: true, palette: true, gradient: true, image: true, offset: 20}; | 30 | }, |
23 | // this.application.ninja.colorController.addButton('chip', this.colorButton); | ||
24 | 31 | ||
32 | initialColor: { | ||
33 | value: false | ||
34 | }, | ||
25 | 35 | ||
36 | changeDelegate: { | ||
37 | value: null | ||
38 | }, | ||
39 | |||
40 | prepareForDraw: { | ||
41 | value: function() { | ||
26 | this.addEventListener("firstDraw", this, false); | 42 | this.addEventListener("firstDraw", this, false); |
27 | } | 43 | } |
28 | }, | 44 | }, |
29 | 45 | ||
30 | draw: { | 46 | draw: { |
31 | value: function() { | 47 | value: function() { |
48 | if(this.hasIcon) { | ||
49 | var icon = this.iconType || this.mode + "Icon"; | ||
50 | this.application.ninja.colorController.addButton(icon, this.icon); | ||
51 | } | ||
32 | 52 | ||
33 | if(this.hasIcon) this.application.ninja.colorController.addButton(this.mode + 'Icon', this.icon); | 53 | this.chipBtn.props = {side: 'right', align: 'top', wheel: true, palette: true, gradient: true, image: true, offset: this.offset}; |
34 | |||
35 | // this.application.ninja.colorController.addButton(this.mode, this.chipBtn); | ||
36 | this.chipBtn.props = {side: 'right', align: 'top', wheel: true, palette: true, gradient: true, image: true, offset: 20}; | ||
37 | this.application.ninja.colorController.addButton(this.mode, this.chipBtn); | 54 | this.application.ninja.colorController.addButton(this.mode, this.chipBtn); |
55 | |||
56 | } | ||
57 | }, | ||
58 | |||
59 | handleFirstDraw: { | ||
60 | value: function(evt) { | ||
61 | if(this.chip) { | ||
62 | // This is a single chip - Not related to the color panel -- Set the initial color if found | ||
63 | var mode = "rgb", r = 0, g = 0, b = 0, a = 1, css = "rgb(255,0,0)"; | ||
64 | |||
65 | if(this.initialColor) { | ||
66 | var colorObj = this.application.ninja.colorController.getColorObjFromCss(this.initialColor); | ||
67 | mode = colorObj.mode; | ||
68 | r = colorObj.value.r; | ||
69 | g = colorObj.value.g; | ||
70 | b = colorObj.value.b; | ||
71 | a = colorObj.value.a; | ||
72 | css = colorObj.css; | ||
73 | } | ||
74 | |||
75 | this.chipBtn.color(mode, {wasSetByCode: true, type: 'change', color: {r: r, g: g, b: b}, css: css}); | ||
76 | this.chipBtn.addEventListener("change", this, false); | ||
77 | } | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | handleChange: { | ||
82 | value: function(evt) { | ||
83 | if(this.changeDelegate && typeof(this.changeDelegate === "function")) { | ||
84 | this.changeDelegate(evt); | ||
85 | } | ||
38 | } | 86 | } |
39 | } | 87 | } |
40 | 88 | ||
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js index b8170826..af7c4858 100644 --- a/js/controllers/elements/stage-controller.js +++ b/js/controllers/elements/stage-controller.js | |||
@@ -75,6 +75,8 @@ exports.StageController = Montage.create(ElementController, { | |||
75 | getProperty: { | 75 | getProperty: { |
76 | value: function(el, p) { | 76 | value: function(el, p) { |
77 | switch(p) { | 77 | switch(p) { |
78 | case "background" : | ||
79 | return el.elementModel.stageBackground.style.getProperty(p); | ||
78 | case "border": | 80 | case "border": |
79 | return el.elementModel.stageView.style.getProperty(p); | 81 | return el.elementModel.stageView.style.getProperty(p); |
80 | case "height": | 82 | case "height": |
@@ -92,7 +94,7 @@ exports.StageController = Montage.create(ElementController, { | |||
92 | value: function(el, p, value) { | 94 | value: function(el, p, value) { |
93 | switch(p) { | 95 | switch(p) { |
94 | case "background": | 96 | case "background": |
95 | el.elementModel.body.style.setProperty(p, value); | 97 | el.elementModel.stageBackground.style.setProperty(p, value); |
96 | break; | 98 | break; |
97 | case "overflow": | 99 | case "overflow": |
98 | el.elementModel.viewPort.style.setProperty(p, value); | 100 | el.elementModel.viewPort.style.setProperty(p, value); |
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js index 8ffd0ec7..ba03c347 100644 --- a/js/data/pi/pi-data.js +++ b/js/data/pi/pi-data.js | |||
@@ -10,7 +10,21 @@ var Montage = require("montage/core/core").Montage, | |||
10 | exports.PiData = Montage.create( Montage, { | 10 | exports.PiData = Montage.create( Montage, { |
11 | 11 | ||
12 | stagePi: { | 12 | stagePi: { |
13 | value: [] | 13 | value: [ |
14 | { | ||
15 | label: "Style", | ||
16 | |||
17 | Section: [ | ||
18 | [ | ||
19 | { | ||
20 | type : "chip", | ||
21 | id : "background", | ||
22 | prop: "background" | ||
23 | } | ||
24 | ] | ||
25 | ] | ||
26 | } | ||
27 | ] | ||
14 | }, | 28 | }, |
15 | 29 | ||
16 | blockPi: { | 30 | blockPi: { |
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..dd3507c2 100644 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -398,6 +398,9 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
398 | 398 | ||
399 | this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j]; | 399 | this.documentRoot.elementModel.stageView = this.documentRoot.elementModel.defaultRule.cssRules[j]; |
400 | 400 | ||
401 | } else if(this.documentRoot.elementModel.defaultRule.cssRules[j].selectorText === "#stageBG") { | ||
402 | |||
403 | this.documentRoot.elementModel.stageBackground = this.documentRoot.elementModel.defaultRule.cssRules[j]; | ||
401 | } | 404 | } |
402 | } | 405 | } |
403 | 406 | ||
diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 0088447a..1ec6d769 100644 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js | |||
@@ -150,6 +150,35 @@ exports.Content = Montage.create(Component, { | |||
150 | this.customPi = stage.elementModel.pi; | 150 | this.customPi = stage.elementModel.pi; |
151 | this.displayCustomProperties(stage, stage.elementModel.pi); | 151 | this.displayCustomProperties(stage, stage.elementModel.pi); |
152 | } | 152 | } |
153 | |||
154 | // For now hardcode the background since it is the only custom property | ||
155 | // No need to loop through all the properties. | ||
156 | var backgroundChip = this.customSections[0].content.controls["background"]; | ||
157 | backgroundChip.initialColor = ElementsMediator.getProperty(stage, "background"); | ||
158 | |||
159 | /* | ||
160 | var customPI = PiData[this.customPi]; | ||
161 | // Get all the custom section for the custom PI | ||
162 | for(var i = 0, customSec; customSec = customPI[i]; i++) { | ||
163 | |||
164 | // Now set the Fields for the custom PI | ||
165 | for(var j = 0, fields; fields = customSec.Section[j]; j++) { | ||
166 | for(var k = 0, control; control = fields[k]; k++) { | ||
167 | |||
168 | var colorChipEl = this.customSections[i].content.controls[control.id]; | ||
169 | this.foo = colorChipEl; | ||
170 | colorChipEl.addEventListener("firstDraw", this, false); | ||
171 | |||
172 | } | ||
173 | } | ||
174 | } | ||
175 | */ | ||
176 | } | ||
177 | }, | ||
178 | |||
179 | handleFirstDraw: { | ||
180 | value: function() { | ||
181 | this.foo.chipBtn.color('rgb', {wasSetByCode: true, type: 'change', color: {r: 255, g: 0, b: 0}, css: 'rgb(255,0,0)'}); | ||
153 | } | 182 | } |
154 | }, | 183 | }, |
155 | 184 | ||
diff --git a/js/panels/properties/sections/custom.reel/custom.js b/js/panels/properties/sections/custom.reel/custom.js index 992db8e6..a2b9b9fa 100644 --- a/js/panels/properties/sections/custom.reel/custom.js +++ b/js/panels/properties/sections/custom.reel/custom.js | |||
@@ -6,6 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage; | 7 | var Montage = require("montage/core/core").Montage; |
8 | var Component = require("montage/ui/component").Component; | 8 | var Component = require("montage/ui/component").Component; |
9 | var ElementsMediator = require("js/mediators/element-mediator").ElementMediator; | ||
9 | 10 | ||
10 | //Custom Rows | 1 |