aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/style.reel/style.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/css-panel/style.reel/style.js')
-rw-r--r--js/panels/css-panel/style.reel/style.js87
1 files changed, 82 insertions, 5 deletions
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
124 this.editingNewStyle = false;
125 }
71 } 126 }
72 }, 127 },
73 prepareForDraw : { 128 prepareForDraw : {
@@ -75,12 +130,22 @@ exports.Style = Montage.create(TreeNode, {
75 console.log("style's prepare for draw"); 130 console.log("style's prepare for draw");
76 this.element.addEventListener('dragstart', this, false); 131 this.element.addEventListener('dragstart', this, false);
77 this.element.addEventListener('drag', this, false); 132 this.element.addEventListener('drag', this, false);
78// this.element.addEventListener('dragenter', this, false);
79// this.element.addEventListener('dragleave', this, false);
80 this.element.addEventListener('dragend', this, false); 133 this.element.addEventListener('dragend', this, false);
81 this.element.addEventListener('drop', this, false); 134 this.element.addEventListener('drop', this, false);
135 this.element.addEventListener('webkitTransitionEnd', this, false);
136
137 if(this.sourceObject.isEmpty) {
138 this.element.draggable = false;
139 this.addStyleButton.addEventListener('click', this, false);
140 this.propertyField.addEventListener('stop', this, false);
141 this.valueField.addEventListener('stop', this, false);
142 } else {
143 this.element.removeChild(this.addStyleButton);
144 delete this.addStyleButton;
145 }
82 } 146 }
83 }, 147 },
148
84 draw : { 149 draw : {
85 value : function() { 150 value : function() {
86 //debugger; 151 //debugger;
@@ -90,12 +155,24 @@ exports.Style = Montage.create(TreeNode, {
90 console.log("Label key unknown"); 155 console.log("Label key unknown");
91 } 156 }
92 157
158 if(this.sourceObject.isEmpty) {
159 this.element.classList.add('empty-css-style');
160 } else {
161 this.element.classList.remove('empty-css-style');
162 }
163
93 if(this._enabled) { 164 if(this._enabled) {
94 this.element.classList.remove(this.disabledClass); 165 this.element.classList.remove(this.disabledClass);
95 } else { 166 } else {
96 this.element.classList.add(this.disabledClass); 167 this.element.classList.add(this.disabledClass);
97 } 168 }
98 169
170 if(this._editingNewStyle) {
171 this.propertyField.start();
172 this.element.classList.add(this.editNewEmptyClass);
173 } else {
174 this.element.classList.remove(this.editNewEmptyClass);
175 }
99 } 176 }
100 } 177 }
101}); \ No newline at end of file 178}); \ No newline at end of file