diff options
Diffstat (limited to 'js/panels/css-panel/style.reel')
-rw-r--r-- | js/panels/css-panel/style.reel/style.css | 2 | ||||
-rw-r--r-- | js/panels/css-panel/style.reel/style.html | 8 | ||||
-rw-r--r-- | js/panels/css-panel/style.reel/style.js | 83 |
3 files changed, 69 insertions, 24 deletions
diff --git a/js/panels/css-panel/style.reel/style.css b/js/panels/css-panel/style.reel/style.css index c6bb070c..6864e245 100644 --- a/js/panels/css-panel/style.reel/style.css +++ b/js/panels/css-panel/style.reel/style.css | |||
@@ -111,7 +111,7 @@ | |||
111 | right: -1px; | 111 | right: -1px; |
112 | } | 112 | } |
113 | .style-item .hintable-hint { | 113 | .style-item .hintable-hint { |
114 | color: #CCC; | 114 | color: #bdbdbd; |
115 | } | 115 | } |
116 | 116 | ||
117 | /* ------------------------ | 117 | /* ------------------------ |
diff --git a/js/panels/css-panel/style.reel/style.html b/js/panels/css-panel/style.reel/style.html index acc169be..9830a21e 100644 --- a/js/panels/css-panel/style.reel/style.html +++ b/js/panels/css-panel/style.reel/style.html | |||
@@ -58,6 +58,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
58 | { | 58 | { |
59 | "type": "change", | 59 | "type": "change", |
60 | "listener": {"@": "owner"} | 60 | "listener": {"@": "owner"} |
61 | }, | ||
62 | { | ||
63 | "type": "stop", | ||
64 | "listener": {"@": "owner"} | ||
61 | } | 65 | } |
62 | ] | 66 | ] |
63 | }, | 67 | }, |
@@ -80,6 +84,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
80 | { | 84 | { |
81 | "type": "change", | 85 | "type": "change", |
82 | "listener": {"@": "owner"} | 86 | "listener": {"@": "owner"} |
87 | }, | ||
88 | { | ||
89 | "type": "stop", | ||
90 | "listener": {"@": "owner"} | ||
83 | } | 91 | } |
84 | ] | 92 | ] |
85 | } | 93 | } |
diff --git a/js/panels/css-panel/style.reel/style.js b/js/panels/css-panel/style.reel/style.js index c73da6e5..1d5a11a5 100644 --- a/js/panels/css-panel/style.reel/style.js +++ b/js/panels/css-panel/style.reel/style.js | |||
@@ -8,27 +8,14 @@ var Montage = require("montage/core/core").Montage, | |||
8 | TreeNode = require("js/components/treeview/tree-node").TreeNode; | 8 | TreeNode = require("js/components/treeview/tree-node").TreeNode; |
9 | 9 | ||
10 | exports.Style = Montage.create(TreeNode, { | 10 | exports.Style = Montage.create(TreeNode, { |
11 | delegate : { | 11 | delegate : { value: null }, |
12 | value: null | 12 | disabledClass : { value: 'style-item-disabled' }, |
13 | }, | 13 | editingStyleClass : { value: 'edit-style-item' }, |
14 | disabledClass : { | 14 | editNewEmptyClass : { value: 'edit-empty-style' }, |
15 | value: 'style-item-disabled' | 15 | invalidStyleClass : { value: "style-item-invalid" }, |
16 | }, | 16 | |
17 | editingStyleClass : { | 17 | propertyText : { value: "property" }, |
18 | value: 'edit-style-item' | 18 | _valueText : { value: "value" }, |
19 | }, | ||
20 | editNewEmptyClass : { | ||
21 | value: 'edit-empty-style' | ||
22 | }, | ||
23 | invalidStyleClass : { | ||
24 | value: "style-item-invalid" | ||
25 | }, | ||
26 | propertyText : { | ||
27 | value: "property" | ||
28 | }, | ||
29 | _valueText : { | ||
30 | value: "value" | ||
31 | }, | ||
32 | valueText : { | 19 | valueText : { |
33 | get: function() { | 20 | get: function() { |
34 | return this._valueText; | 21 | return this._valueText; |
@@ -158,6 +145,27 @@ exports.Style = Montage.create(TreeNode, { | |||
158 | } | 145 | } |
159 | }, | 146 | }, |
160 | 147 | ||
148 | getSiblingStyle : { | ||
149 | value: function(which) { | ||
150 | var styles = this.parentComponent.parentComponent.childComponents.map(function(sub){ | ||
151 | return sub.childComponents[0]; | ||
152 | }), | ||
153 | index = styles.indexOf(this); | ||
154 | |||
155 | switch (which) { | ||
156 | case "first": | ||
157 | return styles[0]; | ||
158 | case "last": | ||
159 | return styles[styles.length-1]; | ||
160 | case "next": | ||
161 | return (index+1 < styles.length) ? styles[index+1] : null; | ||
162 | case "prev": | ||
163 | return (index-1 >= 0) ? styles[index-1] : null; | ||
164 | } | ||
165 | } | ||
166 | }, | ||
167 | |||
168 | |||
161 | handleEvent : { | 169 | handleEvent : { |
162 | value: function(e) { | 170 | value: function(e) { |
163 | console.log(e); | 171 | console.log(e); |
@@ -206,11 +214,40 @@ exports.Style = Montage.create(TreeNode, { | |||
206 | handleStart : { | 214 | handleStart : { |
207 | value: function(e) { | 215 | value: function(e) { |
208 | this.editing = true; | 216 | this.editing = true; |
217 | |||
218 | if(this.empty) { | ||
219 | this.editingNewStyle = true; | ||
220 | } | ||
209 | } | 221 | } |
210 | }, | 222 | }, |
211 | 223 | ||
212 | //// Handler for both hintable components | 224 | //// Handler for both hintable components |
213 | handleStop : { | 225 | handlePropertyStop : { |
226 | value: function(e) { | ||
227 | var event = e; | ||
228 | ///// Function to determine if an empty (new) style should return | ||
229 | ///// to showing the add button, i.e. the fields were not clicked | ||
230 | function fieldsClicked() { | ||
231 | var clicked; | ||
232 | if(e._event.detail.originalEventType === 'mousedown') { | ||
233 | clicked = e._event.detail.originalEvent.target; | ||
234 | return clicked === this.propertyField.element || clicked === this.valueField.element; | ||
235 | } | ||
236 | return false; | ||
237 | } | ||
238 | |||
239 | this.editing = false; | ||
240 | |||
241 | if(this.sourceObject.isEmpty && !this.dirty && !fieldsClicked.bind(this)()) { | ||
242 | ///// Show add button | ||
243 | this.editingNewStyle = false; | ||
244 | } | ||
245 | |||
246 | this.delegate.handlePropertyStop(e, this); | ||
247 | } | ||
248 | }, | ||
249 | //// Handler for both hintable components | ||
250 | handleValueStop : { | ||
214 | value: function(e) { | 251 | value: function(e) { |
215 | var event = e; | 252 | var event = e; |
216 | ///// Function to determine if an empty (new) style should return | 253 | ///// Function to determine if an empty (new) style should return |
@@ -231,7 +268,7 @@ exports.Style = Montage.create(TreeNode, { | |||
231 | this.editingNewStyle = false; | 268 | this.editingNewStyle = false; |
232 | } | 269 | } |
233 | 270 | ||
234 | this.delegate.handleStyleStop(e); | 271 | this.delegate.handleValueStop(e, this); |
235 | } | 272 | } |
236 | }, | 273 | }, |
237 | 274 | ||