diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 22 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 94 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 101 |
3 files changed, 164 insertions, 53 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index bb0041eb..a3ebac24 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -186,9 +186,9 @@ exports.DocumentController = Montage.create(Component, { | |||
186 | handleExecuteSaveAs: { | 186 | handleExecuteSaveAs: { |
187 | value: function(event) { | 187 | value: function(event) { |
188 | var saveAsSettings = event._event.settings || {}; | 188 | var saveAsSettings = event._event.settings || {}; |
189 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 189 | if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
190 | saveAsSettings.fileName = this.activeDocument.model.file.name; | 190 | saveAsSettings.fileName = this.currentDocument.model.file.name; |
191 | saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); | 191 | saveAsSettings.folderUri = this.currentDocument.model.file.uri.substring(0, this.currentDocument.model.file.uri.lastIndexOf("/")); |
192 | saveAsSettings.callback = this.saveAsCallback.bind(this); | 192 | saveAsSettings.callback = this.saveAsCallback.bind(this); |
193 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); | 193 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); |
194 | } | 194 | } |
@@ -204,9 +204,9 @@ exports.DocumentController = Montage.create(Component, { | |||
204 | //TODO: Is this used, should be cleaned up | 204 | //TODO: Is this used, should be cleaned up |
205 | handleExecuteFileCloseAll:{ | 205 | handleExecuteFileCloseAll:{ |
206 | value: function(event) { | 206 | value: function(event) { |
207 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | 207 | if(this.currentDocument && this.application.ninja.coreIoApi.cloudAvailable()){ |
208 | while(this._documents.length > 0){ | 208 | while(this.currentDocument.length > 0){ |
209 | this.closeDocument(this._documents[this._documents.length -1].uuid); | 209 | this.closeDocument(this.currentDocument[this.currentDocument.length -1].uuid); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
@@ -291,19 +291,19 @@ exports.DocumentController = Montage.create(Component, { | |||
291 | value:function(saveAsDetails){ | 291 | value:function(saveAsDetails){ |
292 | var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; | 292 | var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; |
293 | //update document metadata | 293 | //update document metadata |
294 | this.activeDocument.name = ""+filename; | 294 | this.currentDocument.model.file.name = ""+filename; |
295 | //prepare new file uri | 295 | //prepare new file uri |
296 | if(destination && (destination.charAt(destination.length -1) !== "/")){ | 296 | if(destination && (destination.charAt(destination.length -1) !== "/")){ |
297 | destination = destination + "/"; | 297 | destination = destination + "/"; |
298 | } | 298 | } |
299 | fileUri = destination+filename; | 299 | fileUri = destination+filename; |
300 | 300 | ||
301 | this.activeDocument.uri = fileUri; | 301 | this.currentDocument.model.file.uri = fileUri; |
302 | //save a new file | 302 | //save a new file |
303 | //use the ioMediator.fileSaveAll when implemented | 303 | //use the ioMediator.fileSaveAll when implemented |
304 | this.activeDocument.model.file.name = filename; | 304 | this.currentDocument.model.file.name = filename; |
305 | this.activeDocument.model.file.uri = fileUri; | 305 | this.currentDocument.model.file.uri = fileUri; |
306 | this.activeDocument.model.save(); | 306 | this.currentDocument.model.save(); |
307 | } | 307 | } |
308 | }, | 308 | }, |
309 | 309 | ||
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 01e132d7..941e05ba 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component, |
9 | njModule = require("js/lib/NJUtils"); | ||
9 | 10 | ||
10 | exports.ElementController = Montage.create(Component, { | 11 | exports.ElementController = Montage.create(Component, { |
11 | 12 | ||
@@ -162,28 +163,12 @@ exports.ElementController = Montage.create(Component, { | |||
162 | el.elementModel.stroke = null; | 163 | el.elementModel.stroke = null; |
163 | return; | 164 | return; |
164 | case 'gradient': | 165 | case 'gradient': |
165 | if(color.borderInfo) { | ||
166 | if(color.borderInfo.borderWidth) { | ||
167 | this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); | ||
168 | } | ||
169 | if(color.borderInfo.borderStyle) { | ||
170 | this.setProperty(el, "border-style", color.borderInfo.borderStyle); | ||
171 | } | ||
172 | } | ||
173 | this.setGradientBorder(el, color.color.gradientMode, color.color.css); | 166 | this.setGradientBorder(el, color.color.gradientMode, color.color.css); |
174 | break; | 167 | break; |
175 | default: | 168 | default: |
176 | this.setProperty(el, "border-image", "none"); | 169 | this.setProperty(el, "border-image", "none"); |
177 | this.setProperty(el, "border-image-slice", ""); | 170 | this.setProperty(el, "border-image-slice", ""); |
178 | this.setProperty(el, "border-color", color.color.css); | 171 | this.setProperty(el, "border-color", color.color.css); |
179 | if(color.borderInfo) { | ||
180 | if(color.borderInfo.borderWidth) { | ||
181 | this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); | ||
182 | } | ||
183 | if(color.borderInfo.borderStyle) { | ||
184 | this.setProperty(el, "border-style", color.borderInfo.borderStyle); | ||
185 | } | ||
186 | } | ||
187 | } | 172 | } |
188 | } | 173 | } |
189 | el.elementModel.stroke = color; | 174 | el.elementModel.stroke = color; |
@@ -211,20 +196,83 @@ exports.ElementController = Montage.create(Component, { | |||
211 | }, | 196 | }, |
212 | 197 | ||
213 | getStroke: { | 198 | getStroke: { |
214 | value: function(el) { | 199 | value: function(el, stroke) { |
215 | // TODO - Need to figure out which border side user wants | 200 | var strokeInfo = {}, |
216 | return this.application.ninja.stylesController.getElementStyle(el, "border"); | 201 | color, |
202 | borderWidth, | ||
203 | border; | ||
204 | if(stroke.colorInfo) { | ||
205 | strokeInfo.colorInfo = {}; | ||
206 | color = this.getColor(el, false); | ||
207 | if(color && color.color) { | ||
208 | strokeInfo.colorInfo.mode = color.mode; | ||
209 | strokeInfo.colorInfo.color = color.color; | ||
210 | } else { | ||
211 | strokeInfo.colorInfo.mode = "nocolor"; | ||
212 | strokeInfo.colorInfo.color = null; | ||
213 | } | ||
214 | } | ||
215 | if(stroke.borderInfo) { | ||
216 | // TODO - Need to figure out which border side user wants | ||
217 | strokeInfo.borderInfo = {}; | ||
218 | if(stroke.borderInfo.borderWidth) { | ||
219 | borderWidth = this.getProperty(el, "border-width"); | ||
220 | if(borderWidth) { | ||
221 | border = njModule.NJUtils.getValueAndUnits(borderWidth); | ||
222 | strokeInfo.borderInfo.borderWidth = border[0]; | ||
223 | strokeInfo.borderInfo.borderUnits = border[1]; | ||
224 | } | ||
225 | } | ||
226 | if(stroke.borderInfo.borderStyle) { | ||
227 | strokeInfo.borderInfo.borderStyle = this.getProperty(el, "border-style"); | ||
228 | } | ||
229 | } | ||
230 | return strokeInfo; | ||
217 | } | 231 | } |
218 | }, | 232 | }, |
219 | 233 | ||
220 | setStroke: { | 234 | setStroke: { |
221 | value: function(el, stroke) { | 235 | value: function(el, stroke) { |
222 | this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits); | 236 | if(stroke.borderInfo) { |
223 | this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle); | 237 | if(stroke.borderInfo.borderWidth) { |
224 | this.setColor(el, stroke.color, false); | 238 | this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderInfo.borderWidth + stroke.borderInfo.borderUnits); |
239 | } | ||
240 | if(stroke.borderInfo.borderStyle) { | ||
241 | this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderInfo.borderStyle); | ||
242 | } | ||
243 | } | ||
244 | if(stroke.colorInfo) { | ||
245 | this.setColor(el, stroke.colorInfo, false); | ||
246 | } | ||
225 | } | 247 | } |
226 | }, | 248 | }, |
227 | 249 | ||
250 | getFill: { | ||
251 | value: function(el, fill) { | ||
252 | var fillInfo = {}, | ||
253 | color; | ||
254 | if(fill.colorInfo) { | ||
255 | fillInfo.colorInfo = {}; | ||
256 | color = this.getColor(el, true); | ||
257 | if(color && color.color) { | ||
258 | fillInfo.colorInfo.mode = color.mode; | ||
259 | fillInfo.colorInfo.color = color.color; | ||
260 | } else { | ||
261 | fillInfo.colorInfo.mode = "nocolor"; | ||
262 | fillInfo.colorInfo.color = null; | ||
263 | } | ||
264 | } | ||
265 | return fillInfo; | ||
266 | } | ||
267 | }, | ||
268 | |||
269 | setFill: { | ||
270 | value: function(el, fill) { | ||
271 | if(fill.colorInfo) { | ||
272 | this.setColor(el, fill.colorInfo, true); | ||
273 | } | ||
274 | } | ||
275 | }, | ||
228 | //-------------------------------------------------------------------------------------------------------- | 276 | //-------------------------------------------------------------------------------------------------------- |
229 | // Routines to get/set 3D properties | 277 | // Routines to get/set 3D properties |
230 | get3DProperty: { | 278 | get3DProperty: { |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 626dedb6..845e7dc2 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -551,12 +551,6 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
551 |