aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Resizer.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Resizer.js')
-rwxr-xr-xjs/panels/Resizer.js83
1 files changed, 53 insertions, 30 deletions
diff --git a/js/panels/Resizer.js b/js/panels/Resizer.js
index 3afe5d5b..ca6ed062 100755
--- a/js/panels/Resizer.js
+++ b/js/panels/Resizer.js
@@ -8,11 +8,42 @@ var Montage = require("montage/core/core").Montage;
8var Component = require("montage/ui/component").Component; 8var Component = require("montage/ui/component").Component;
9 9
10exports.Resizer = Montage.create(Component, { 10exports.Resizer = Montage.create(Component, {
11 11
12 version: {
13 value: "1.0"
14 },
15
12 hasTemplate: { 16 hasTemplate: {
13 value: false 17 value: false
14 }, 18 },
15 19
20 // This property might not be needed anymore.
21 // TODO - Review this once we the the new panels in place
22 ownerId: {
23 value: ""
24 },
25
26 willSave: {
27 value: true
28 },
29
30 _value: {
31 value: null
32 },
33
34 value: {
35 get: function() {
36 return this._value;
37 },
38 set: function(val) {
39 this._value = val;
40 }
41 },
42
43 redrawStage: {
44 value:false
45 },
46
16 _isInversed: { 47 _isInversed: {
17 value: false 48 value: false
18 }, 49 },
@@ -74,7 +105,6 @@ exports.Resizer = Montage.create(Component, {
74 e.preventDefault(); 105 e.preventDefault();
75 this.panel.addEventListener("webkitTransitionEnd", this, true); 106 this.panel.addEventListener("webkitTransitionEnd", this, true);
76 if (this.isVertical) { 107 if (this.isVertical) {
77 //console.log("y: " + e.y + " startPosition: " + this._startPosition + " initDimension: " + this._initDimension);
78 this._startPosition = e.y; 108 this._startPosition = e.y;
79 this._initDimension = this.panel.offsetHeight; 109 this._initDimension = this.panel.offsetHeight;
80 } 110 }
@@ -98,21 +128,34 @@ exports.Resizer = Montage.create(Component, {
98 } else { 128 } else {
99 this.panel.style.width = ""; 129 this.panel.style.width = "";
100 } 130 }
101 this.application.ninja.settings.setSetting(this.element.id,"value", ""); 131
132 this.application.localStorage.setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": ""});
102 } 133 }
103 }, 134 },
104 135
105 handleWebkitTransitionEnd: { 136 handleWebkitTransitionEnd: {
106 value: function() { 137 value: function() {
138
107 if(this.redrawStage) { 139 if(this.redrawStage) {
108 this.application.ninja.stage.resizeCanvases = true; 140 this.application.ninja.stage.resizeCanvases = true;
109 } 141 }
110 this.panel.removeEventListener("webkitTransitionEnd"); 142
143 this.panel.removeEventListener("webkitTransitionEnd", this, false);
144
111 } 145 }
112 }, 146 },
113 147
114 prepareForDraw: { 148 prepareForDraw: {
115 value: function() { 149 value: function() {
150 if(this.willSave) {
151 var storedData = this.application.localStorage.getItem(this.element.getAttribute("data-montage-id"));
152
153 if(storedData && storedData.value) {
154 this.value = storedData.value;
155 }
156
157 }
158
116 if(this.value != null) { 159 if(this.value != null) {
117 if (this.isVertical) { 160 if (this.isVertical) {
118 this.panel.style.height = this.value + "px"; 161 this.panel.style.height = this.value + "px";
@@ -137,15 +180,19 @@ exports.Resizer = Montage.create(Component, {
137 window.removeEventListener("mousemove", this); 180 window.removeEventListener("mousemove", this);
138 window.removeEventListener("mouseup", this); 181 window.removeEventListener("mouseup", this);
139 this.panel.classList.remove("disableTransition"); 182 this.panel.classList.remove("disableTransition");
183
140 if (this.isVertical) { 184 if (this.isVertical) {
141 this.panel.style.height = this.panel.offsetHeight; 185 this.panel.style.height = this.panel.offsetHeight;
142 } else { 186 } else {
143 this.panel.style.width = this.panel.offsetWidth; 187 this.panel.style.width = this.panel.offsetWidth;
144 } 188 }
145 this.application.ninja.settings.setSetting(this.element.id,"value", this.value); 189
190 this.application.localStorage.setItem(this.element.getAttribute("data-montage-id"), {"version": this.version, "value": this.value});
191
146 if(this.redrawStage) { 192 if(this.redrawStage) {
147 this.application.ninja.stage.resizeCanvases = true; 193 this.application.ninja.stage.resizeCanvases = true;
148 } 194 }
195
149 NJevent("panelResizedEnd", this) 196 NJevent("panelResizedEnd", this)
150 } 197 }
151 }, 198 },
@@ -154,7 +201,6 @@ exports.Resizer = Montage.create(Component, {
154 value: function(e) { 201 value: function(e) {
155 if(this.isVertical) { 202 if(this.isVertical) {
156 this.value = this._isInversed ? this._initDimension + (this._startPosition - e.y) : this._initDimension + (e.y - this._startPosition); 203 this.value = this._isInversed ? this._initDimension + (this._startPosition - e.y) : this._initDimension + (e.y - this._startPosition);
157 //console.log("y: " + e.y + " startPosition: " + this._startPosition + " initDimension: " + this._initDimension + " finalPosition: " + pos);
158 this.panel.style.height = this.value + "px"; 204 this.panel.style.height = this.value + "px";
159 } 205 }
160 else { 206 else {
@@ -172,28 +218,5 @@ exports.Resizer = Montage.create(Component, {
172 218
173 NJevent("panelResizing", this); 219 NJevent("panelResizing", this);
174 } 220 }
175 },
176
177 _value: {
178 value: null
179 },
180
181 redrawStage: {
182 value:false
183 },
184
185 value: {
186 get: function() {
187 if(this.application.ninja.settings) {
188 var gottenValue = this.application.ninja.settings.getSetting(this.id, "value");
189 if (this._value == null && gottenValue !=null) {
190 this.value = gottenValue;
191 }
192 }
193 return this._value;
194 },
195 set: function(val) {
196 this._value = val;
197 }
198 } 221 }
199}); \ No newline at end of file 222}); \ No newline at end of file