diff options
author | Eric Guzman | 2012-05-10 13:21:38 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-10 13:21:38 -0700 |
commit | 6056a569caab94bdbdc2c60b58907109ff468dd3 (patch) | |
tree | f48716a7a82ab8d1d70ccefe12e71076d97cf610 /js/panels/css-panel/style-declaration.reel | |
parent | 830b6577ee25a6955bd4e275f216e1cadeff168c (diff) | |
download | ninja-6056a569caab94bdbdc2c60b58907109ff468dd3.tar.gz |
Style Declaration - Improved updating of styles using binding.
Diffstat (limited to 'js/panels/css-panel/style-declaration.reel')
3 files changed, 133 insertions, 133 deletions
diff --git a/js/panels/css-panel/style-declaration.reel/style-declaration.css b/js/panels/css-panel/style-declaration.reel/style-declaration.css index e37d89d2..6be8d33c 100644 --- a/js/panels/css-panel/style-declaration.reel/style-declaration.css +++ b/js/panels/css-panel/style-declaration.reel/style-declaration.css | |||
@@ -4,10 +4,8 @@ | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | .treeRoot > .style-shorthand-branch > div { | 7 | |
8 | display: none; | 8 | .declaration-list { |
9 | } | ||
10 | .treeRoot > .style-shorthand-branch > dl { | ||
11 | margin-top: 4px; | 9 | margin-top: 4px; |
12 | } | 10 | } |
13 | .drag-over { | 11 | .drag-over { |
diff --git a/js/panels/css-panel/style-declaration.reel/style-declaration.html b/js/panels/css-panel/style-declaration.reel/style-declaration.html index 9123e2a0..2fdb11d5 100644 --- a/js/panels/css-panel/style-declaration.reel/style-declaration.html +++ b/js/panels/css-panel/style-declaration.reel/style-declaration.html | |||
@@ -22,6 +22,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
22 | }, | 22 | }, |
23 | "arrayController": { | 23 | "arrayController": { |
24 | "prototype": "montage/ui/controller/array-controller", | 24 | "prototype": "montage/ui/controller/array-controller", |
25 | "properties": { | ||
26 | "automaticallyOrganizeObjects": true | ||
27 | }, | ||
25 | "bindings": { | 28 | "bindings": { |
26 | "content": { | 29 | "content": { |
27 | "boundObject": {"@": "owner"}, | 30 | "boundObject": {"@": "owner"}, |
@@ -44,9 +47,17 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
44 | "declaration": {"@": "owner"} | 47 | "declaration": {"@": "owner"} |
45 | }, | 48 | }, |
46 | "bindings": { | 49 | "bindings": { |
47 | "sourceObject" : { | 50 | "propertyText" : { |
51 | "boundObject": {"@": "repetition"}, | ||
52 | "boundObjectPropertyPath": "objectAtCurrentIteration.name" | ||
53 | }, | ||
54 | "valueText" : { | ||
55 | "boundObject": {"@": "repetition"}, | ||
56 | "boundObjectPropertyPath": "objectAtCurrentIteration.value" | ||
57 | }, | ||
58 | "empty" : { | ||
48 | "boundObject": {"@": "repetition"}, | 59 | "boundObject": {"@": "repetition"}, |
49 | "boundObjectPropertyPath": "objectAtCurrentIteration" | 60 | "boundObjectPropertyPath": "objectAtCurrentIteration.isEmpty" |
50 | }, | 61 | }, |
51 | "delegate": { | 62 | "delegate": { |
52 | "boundObject": {"@": "owner"}, | 63 | "boundObject": {"@": "owner"}, |
diff --git a/js/panels/css-panel/style-declaration.reel/style-declaration.js b/js/panels/css-panel/style-declaration.reel/style-declaration.js index 80d8ff7b..33e77297 100644 --- a/js/panels/css-panel/style-declaration.reel/style-declaration.js +++ b/js/panels/css-panel/style-declaration.reel/style-declaration.js | |||
@@ -9,38 +9,61 @@ var Montage = require("montage/core/core").Montage, | |||
9 | ShorthandProps = require("js/panels/CSSPanel/css-shorthand-map"); | 9 | ShorthandProps = require("js/panels/CSSPanel/css-shorthand-map"); |
10 | 10 | ||
11 | exports.StyleDeclaration = Montage.create(Component, { | 11 | exports.StyleDeclaration = Montage.create(Component, { |
12 | cssText : { | 12 | cssText : { value: null }, |
13 | value: null | 13 | focusDelegate : { value: null }, |
14 | }, | 14 | |
15 | focusDelegate : { | ||
16 | value: null | ||
17 | }, | ||
18 | includeEmptyStyle : { | 15 | includeEmptyStyle : { |
19 | value: true | 16 | value: true, |
17 | distinct: true | ||
20 | }, | 18 | }, |
21 | styles : { | 19 | styles : { |
22 | value: [], | 20 | value: [], |
23 | distinct: true | 21 | distinct: true |
24 | }, | 22 | }, |
25 | 23 | ||
26 | templateDidLoad : { | 24 | _styleSortFunction : { |
27 | value: function() { | 25 | value: function(styleA, styleB) { |
28 | console.log("Style declaration - template did load"); | 26 | ///// If the style is an empty style (with Add button) |
27 | ///// push to end of declaration | ||
28 | if(styleA.isEmpty) { | ||
29 | return 1; | ||
30 | } else if (styleB.isEmpty) { | ||
31 | return -1; | ||
32 | } | ||
29 | 33 | ||
30 | if(this.focusDelegate) { | 34 | ///// Alphabetic sort based on property name |
31 | //this.treeController.delegate = this.focusDelegate; | 35 | if (styleA.name < styleB.name) { |
32 | this.styleComponent.delegate = this.focusDelegate; | 36 | return -1; |
37 | } else if (styleA.name > styleB.name) { | ||
38 | return 1; | ||
39 | } else { | ||
40 | return 0; | ||
33 | } | 41 | } |
34 | } | 42 | } |
35 | }, | 43 | }, |
36 | prepareForDraw : { | 44 | _styleFilterFunction: { |
37 | value: function(e) { | 45 | value: function(style, styleArray) { |
38 | console.log("Style Declaration :: prepare for draw"); | 46 | var shorthands = ShorthandProps.CSS_SHORTHAND_MAP[style.name]; |
39 | this._element.addEventListener('drop', this, false); | 47 | |
40 | this.element.addEventListener('dragenter', this, false); | 48 | ///// No shorthands, return true to include style |
41 | this.element.addEventListener('dragleave', this, false); | 49 | if(!shorthands) { return true; } |
50 | |||
51 | var subProps = ShorthandProps.CSS_SHORTHAND_TO_SUBPROP_MAP[shorthands[0]], | ||
52 | stylesArray = styleArray, | ||
53 | hasAll; | ||
54 | |||
55 | debugger; | ||
56 | hasAll = subProps.every(function(subProp) { | ||
57 | debugger; | ||
58 | return this.declaration[subProp]; | ||
59 | }, this); | ||
60 | |||
61 | if(hasAll) { | ||
62 | return false; | ||
63 | } | ||
42 | } | 64 | } |
43 | }, | 65 | }, |
66 | |||
44 | _declaration: { | 67 | _declaration: { |
45 | value: null | 68 | value: null |
46 | }, | 69 | }, |
@@ -49,21 +72,17 @@ exports.StyleDeclaration = Montage.create(Component, { | |||
49 | return this._declaration; | 72 | return this._declaration; |
50 | }, | 73 | }, |
51 | set: function(dec) { | 74 | set: function(dec) { |
75 | var stylesArray; | ||
76 | |||
52 | if(this._declaration) { | 77 | if(this._declaration) { |
53 | this.arrayController.removeObjects(this.styles); | 78 | this.styles = null; |
79 | this.styles = []; | ||
54 | } | 80 | } |
55 | console.log("dec being set", this); | ||
56 | this._declaration = dec; | ||
57 | 81 | ||
82 | ///// Take snapshot of declaration | ||
58 | this.cssText = dec.cssText; | 83 | this.cssText = dec.cssText; |
59 | 84 | ||
60 | Array.prototype.slice.call(dec).forEach(function(prop, index) { | 85 | stylesArray = Array.prototype.slice.call(dec); |
61 | this.styles.push({ | ||
62 | name: prop, | ||
63 | value: dec.getPropertyValue(prop) | ||
64 | }); | ||
65 | |||
66 | }, this); | ||
67 | 86 | ||
68 | if(this.includeEmptyStyle) { | 87 | if(this.includeEmptyStyle) { |
69 | this.styles.push({ | 88 | this.styles.push({ |
@@ -72,109 +91,85 @@ console.log("dec being set", this); | |||
72 | "isEmpty": true | 91 | "isEmpty": true |
73 | }); | 92 | }); |
74 | } | 93 | } |
75 | ///// creates data structure to use with tree component | ||
76 | //this.buildStyleTree(); | ||
77 | 94 | ||
78 | // if(this.includeEmptyStyle) { | 95 | stylesArray.forEach(function(prop, index) { |
79 | // this.styleTree.properties.push({ | 96 | this.styles.push({ |
80 | // "name": "property", | 97 | name: prop, |
81 | // "value" : "value", | 98 | value: dec.getPropertyValue(prop) |
82 | // "isEmpty": true | 99 | }); |
83 | // }); | 100 | }, this); |
84 | // } | ||
85 | 101 | ||
102 | this._declaration = dec; | ||
86 | this.needsDraw = true; | 103 | this.needsDraw = true; |
87 | } | 104 | } |
88 | }, | 105 | }, |
89 | 106 | ||