diff options
-rw-r--r-- | js/panels/css-panel/declaration.reel/declaration.js | 15 | ||||
-rw-r--r-- | js/panels/css-panel/style.reel/style.css | 56 | ||||
-rw-r--r-- | js/panels/css-panel/style.reel/style.html | 6 | ||||
-rw-r--r-- | js/panels/css-panel/style.reel/style.js | 87 |
4 files changed, 155 insertions, 9 deletions
diff --git a/js/panels/css-panel/declaration.reel/declaration.js b/js/panels/css-panel/declaration.reel/declaration.js index 0cc98951..55fe0e18 100644 --- a/js/panels/css-panel/declaration.reel/declaration.js +++ b/js/panels/css-panel/declaration.reel/declaration.js | |||
@@ -9,6 +9,9 @@ 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.Declaration = Montage.create(Component, { | 11 | exports.Declaration = Montage.create(Component, { |
12 | includeEmptyStyle : { | ||
13 | value: true | ||
14 | }, | ||
12 | templateDidLoad : { | 15 | templateDidLoad : { |
13 | value: function() { | 16 | value: function() { |
14 | console.log("declaration - template did load"); | 17 | console.log("declaration - template did load"); |
@@ -31,10 +34,18 @@ exports.Declaration = Montage.create(Component, { | |||
31 | }, | 34 | }, |
32 | set: function(dec) { | 35 | set: function(dec) { |
33 | this._declaration = dec; | 36 | this._declaration = dec; |
34 | console.log('here'); | 37 | |
35 | ///// creates data structure to use with tree component | 38 | ///// creates data structure to use with tree component |
36 | this.buildStyleTree(); | 39 | this.buildStyleTree(); |
37 | console.log('there'); | 40 | |
41 | if(this.includeEmptyStyle) { | ||
42 | this.styleTree.properties.push({ | ||
43 | "name": "property", | ||
44 | "value" : "value", | ||
45 | "isEmpty": true | ||
46 | }); | ||
47 | } | ||
48 | //debugger; | ||
38 | this.needsDraw = true; | 49 | this.needsDraw = true; |
39 | } | 50 | } |
40 | }, | 51 | }, |
diff --git a/js/panels/css-panel/style.reel/style.css b/js/panels/css-panel/style.reel/style.css index 66c25fe0..f8750eea 100644 --- a/js/panels/css-panel/style.reel/style.css +++ b/js/panels/css-panel/style.reel/style.css | |||
@@ -11,7 +11,7 @@ | |||
11 | border-bottom: 1px solid rgba(0,0,0,0); | 11 | border-bottom: 1px solid rgba(0,0,0,0); |
12 | cursor: url(/js/../images/tools/hand_down.png), default; | 12 | cursor: url(/js/../images/tools/hand_down.png), default; |
13 | display: block; | 13 | display: block; |
14 | overflow: hidden; | 14 | /*overflow: hidden;*/ |
15 | white-space: nowrap; | 15 | white-space: nowrap; |
16 | text-overflow: ellipsis; | 16 | text-overflow: ellipsis; |
17 | } | 17 | } |
@@ -93,6 +93,60 @@ | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* ------------------------ | 95 | /* ------------------------ |
96 | Empty Style (Add Style) | ||
97 | ------------------------ */ | ||
98 | .add-style-button { | ||
99 | display: none; | ||
100 | } | ||
101 | .empty-css-style { | ||
102 | cursor: default; | ||
103 | -webkit-transition: -webkit-transform .2s cubic-bezier(0.44, 0.19, 0, 0.99); | ||
104 | -webkit-transform: translate3d(-120px, 0, 0); | ||
105 | } | ||
106 | .empty-css-style:hover { | ||
107 | border-right-style: none; | ||
108 | } | ||
109 | .empty-css-style .add-style-button { | ||
110 | cursor: pointer; | ||
111 | color: #333; | ||
112 | display: inline-block; | ||
113 | font-family: "Droid Sans", sans-serif; | ||
114 | background: -webkit-linear-gradient(top, rgba(242,242,242,1) 1%,rgba(221,221,221,1) 100%); | ||
115 | border-radius: 5px; | ||
116 | border: 1px solid #CCC; | ||
117 | padding: 1px 10px 0; | ||
118 | position: absolute; | ||
119 | left: 140px; | ||
120 | text-shadow: 1px 1px 0 #FFF; | ||
121 | -webkit-transition: opacity .2s cubic-bezier(0.44, 0.19, 0, 0.99); | ||
122 | } | ||
123 | .empty-css-style .add-style-button:hover { | ||
124 | background: -webkit-linear-gradient(top, rgba(252,252,252,1) 1%,rgba(234,234,234,1) 100%); | ||
125 | } | ||
126 | .empty-css-style .add-style-button:active { | ||
127 | background: -webkit-linear-gradient(top, rgba(234,234,234,1) 0%,rgba(252,252,252,1) 99%); | ||
128 | } | ||
129 | .empty-css-style .css-property, .empty-css-style .css-value { | ||
130 | -webkit-transition: opacity .2s cubic-bezier(0.44, 0.19, 0, 0.99); | ||
131 | opacity: 0; | ||
132 | } | ||
133 | .empty-css-style.edit-empty-style .css-property, .empty-css-style.edit-empty-style .css-value { | ||
134 | opacity: 1; | ||
135 | } | ||
136 | .empty-css-style.edit-empty-style { | ||
137 | border-right-style: none; | ||
138 | -webkit-transform: translate3d(0, 0, 0); | ||
139 | } | ||
140 | .empty-css-style.edit-empty-style .css-property, .empty-css-style.edit-empty-style .css-value { | ||
141 | color: #adadad; | ||
142 | } | ||
143 | .empty-css-style.edit-empty-style .add-style-button { | ||
144 | opacity: 0; | ||
145 | } | ||
146 | .empty-css-style input[type="checkbox"] { | ||
147 | visibility: hidden; | ||
148 | } | ||
149 | /* ------------------------ | ||
96 | Drag/Drop Styles | 150 | Drag/Drop Styles |
97 | ------------------------ */ | 151 | ------------------------ */ |
98 | 152 | ||
diff --git a/js/panels/css-panel/style.reel/style.html b/js/panels/css-panel/style.reel/style.html index 587dedb5..0d438ead 100644 --- a/js/panels/css-panel/style.reel/style.html +++ b/js/panels/css-panel/style.reel/style.html | |||
@@ -14,7 +14,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
14 | "module" : "js/panels/css-panel/style.reel", | 14 | "module" : "js/panels/css-panel/style.reel", |
15 | "name" : "Style", | 15 | "name" : "Style", |
16 | "properties" : { | 16 | "properties" : { |
17 | "element" : {"#" : "container"} | 17 | "element" : {"#" : "container"}, |
18 | "addStyleButton": {"#": "add-style-button"}, | ||
19 | "propertyField": {"@": "property"}, | ||
20 | "valueField": {"@": "value"} | ||
18 | } | 21 | } |
19 | }, | 22 | }, |
20 | "checkbox": { | 23 | "checkbox": { |
@@ -68,6 +71,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
68 | <body> | 71 | <body> |
69 | <div id="container" class="style-item" spellcheck="false" draggable="true"> | 72 | <div id="container" class="style-item" spellcheck="false" draggable="true"> |
70 | <input type="checkbox" data-montage-id="disable-checkbox"><dt data-montage-id="property" class="css-property"></dt><dd data-montage-id="value" class="css-value"></dd> | 73 | <input type="checkbox" data-montage-id="disable-checkbox"><dt data-montage-id="property" class="css-property"></dt><dd data-montage-id="value" class="css-value"></dd> |
74 | <button data-montage-id="add-style-button" class="add-style-button">Add</button> | ||
71 | </div> | 75 | </div> |
72 | </body> | 76 | </body> |
73 | </html> \ No newline at end of file | 77 | </html> \ No newline at end of file |
diff --git a/js/panels/css-panel/style.reel/style.js b/js/panels/css-panel/style.reel/style.js index c3e9efdf..adf17a84 100644 --- a/js/panels/css-panel/style.reel/style.js +++ b/js/panels/css-panel/style.reel/style.js | |||
@@ -11,6 +11,9 @@ exports.Style = Montage.create(TreeNode, { | |||
11 | disabledClass : { | 11 | disabledClass : { |
12 | value: 'style-item-disabled' | 12 | value: 'style-item-disabled' |
13 | }, | 13 | }, |
14 | editNewEmptyClass : { | ||
15 | value: 'edit-empty-style' | ||
16 | }, | ||
14 | propertyText : { | 17 | propertyText : { |
15 | value: "property" | 18 | value: "property" |
16 | }, | 19 | }, |
@@ -28,6 +31,30 @@ exports.Style = Montage.create(TreeNode, { | |||
28 | this.needsDraw = true; | 31 | this.needsDraw = true; |
29 | } | 32 | } |
30 | }, | 33 | }, |
34 | |||
35 | |||
36 | dirty : { | ||
37 | get: function() { | ||
38 | return this.propertyField.isDirty || this.valueField.isDirty; | ||
39 | }, | ||
40 | set: function(value) { | ||
41 | |||
42 | } | ||
43 | }, | ||
44 | |||
45 | _editingNewStyle : { | ||
46 | value: null | ||
47 | }, | ||
48 | editingNewStyle : { | ||
49 | get: function() { | ||
50 | return this._editingNewStyle; | ||
51 | }, | ||
52 | set: function(value) { | ||
53 | this._editingNewStyle = value; | ||
54 | this.needsDraw = true; | ||
55 | } | ||
56 | }, | ||
57 | |||
31 | handleEvent : { | 58 | handleEvent : { |
32 | value: function(e) { | 59 | value: function(e) { |
33 | console.log(e); | 60 | console.log(e); |
@@ -65,9 +92,37 @@ exports.Style = Montage.create(TreeNode, { | |||
65 | this.valueText = this.sourceObject.value; | 92 | this.valueText = this.sourceObject.value; |
66 | } | 93 | } |
67 | }, | 94 | }, |
68 | templateDidLoad : { | 95 | handleWebkitTransitionEnd : { |
69 | value: function() { | 96 | value: function(e) { |
70 | console.log("style - template did load"); | 97 | console.log("trans end"); |
98 | } | ||
99 | }, | ||
100 | handleClick : { | ||
101 | value: function(e) { | ||
102 | console.log("handleAction"); | ||
103 | this.editingNewStyle = true; | ||
104 | } | ||
105 | }, | ||
106 | |||
107 | //// Handler for both hintable components | ||
108 | handleStop : { | ||
109 | value: function(e) { | ||
110 | var event = e; | ||
111 | ///// Function to determine if an empty (new) style should return | ||
112 | ///// to showing the add button, i.e. the fields were not clicked | ||
113 | function shouldStopEditing() { | ||
114 | var clicked; | ||
115 | if(e._event.detail.originalEventType === 'mousedown') { | ||
116 | clicked = e._event.detail.originalEvent.target; | ||
117 | return clicked !== this.propertyField.element && clicked !== this.valueField.element; | ||
118 | } | ||
119 | return | ||
120 | } | ||
121 | |||
122 | if(this.sourceObject.isEmpty && !this.dirty && shouldStopEditing.bind(this)()) { | ||
123 |