aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/styles-view-mediator.js
diff options
context:
space:
mode:
authorEric Guzman2012-04-26 03:15:49 -0700
committerEric Guzman2012-04-26 03:15:49 -0700
commit143105a0b9c7765898b22d53489b4bd8df3dff2e (patch)
tree05c6cd14d6400dc2393ebc4465ac3c31c42feb47 /js/panels/css-panel/styles-view-mediator.js
parentf1d4c48cd12d4c1a4a8b8d7ce648ea510607cb88 (diff)
downloadninja-143105a0b9c7765898b22d53489b4bd8df3dff2e.tar.gz
CSS Panel - add handlers for css panel actions
Diffstat (limited to 'js/panels/css-panel/styles-view-mediator.js')
-rw-r--r--js/panels/css-panel/styles-view-mediator.js77
1 files changed, 75 insertions, 2 deletions
diff --git a/js/panels/css-panel/styles-view-mediator.js b/js/panels/css-panel/styles-view-mediator.js
index 38b61220..c93a5e73 100644
--- a/js/panels/css-panel/styles-view-mediator.js
+++ b/js/panels/css-panel/styles-view-mediator.js
@@ -5,7 +5,8 @@
5 </copyright> */ 5 </copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component,
9 Keyboard = require("js/mediators/keyboard-mediator").Keyboard;
9 10
10exports.StylesViewMediator = Montage.create(Component, { 11exports.StylesViewMediator = Montage.create(Component, {
11 stylesController : { 12 stylesController : {
@@ -29,10 +30,82 @@ exports.StylesViewMediator = Montage.create(Component, {
29 selector = this.stylesController.generateClassName(this.ruleListContainer.displayedList.selection[0].nodeName); 30 selector = this.stylesController.generateClassName(this.ruleListContainer.displayedList.selection[0].nodeName);
30 } 31 }
31 32
32 newRule = this.application.ninja.stylesController.addRule("."+selector, ' { }'); 33 newRule = this.application.ninja.stylesController.addRule('.'+selector, ' { }');
33 34
34 this.ruleListContainer.displayedList.component.addRule(newRule); 35 this.ruleListContainer.displayedList.component.addRule(newRule);
35 36
36 } 37 }
38 },
39 handleStyleStop: {
40 value: function(e) {
41 console.log("Handle Style Stop");
42 //debugger;
43 if(e._event.detail.type === 'keydown') {
44
45 }
46 }
47 },
48 handlePropertyChange : {
49 value: function(rule, property, value, oldProperty, style) {
50 var browserValue;
51
52 if(style.editingNewStyle) {
53 return false;
54 }
55
56 ///// Remove old property and add new one
57 this.stylesController.deleteStyle(rule, oldProperty);
58 browserValue = this.stylesController.setStyle(rule, property, value);
59
60 ///// Mark style as invalid if the browser doesn't accept it
61 style.invalid = (browserValue === null);
62
63 console.log("BrowserValue: ", browserValue, rule);
64
65 this._dispatchChange(property, browserValue);
66 }
67 },
68 handleValueChange : {
69 value: function(rule, property, value, style) {
70 var browserValue, units;
71
72 ///// Auto-fill units if not provided and units
73 ///// not previously stored
74 units = style.getUnits(value);
75 if(style.units && units === null && parseInt(value)) {
76 value += style.units;
77 style.valueField.value = value;
78 } else if (value !== '0') {
79 style.units = units;
80 }
81
82 ///// update value
83 browserValue = this.stylesController.setStyle(rule, property, value);
84
85 ///// Mark style as invalid if the browser doesn't accept it
86 style.invalid = (browserValue === null);
87
88 console.log("BrowserValue: ", browserValue, rule);
89
90 this._dispatchChange(property, browserValue);
91
92 if(style.editingNewStyle) {
93 style.treeView.parentComponent.addNewStyle();
94 }
95 }
96 },
97
98 _dispatchChange : {
99 value: function(property, value) {
100 this.application.ninja.stage.updatedStage = true;
101 NJevent('elementChange', {
102 type : 'cssChange',
103 data: {
104 "prop": property,
105 "value": value
106 },
107 redraw: null
108 });
109 }
37 } 110 }
38}); \ No newline at end of file 111}); \ No newline at end of file