aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js26
-rwxr-xr-xjs/controllers/elements/component-controller.js4
-rwxr-xr-xjs/controllers/elements/element-controller.js94
-rwxr-xr-xjs/controllers/elements/shapes-controller.js101
4 files changed, 168 insertions, 57 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index a90375af..a3ebac24 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -174,9 +174,9 @@ exports.DocumentController = Montage.create(Component, {
174 handleExecuteSaveAll: { 174 handleExecuteSaveAll: {
175 value: function(event) { 175 value: function(event) {
176 // 176 //
177 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 177 if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
178 // 178 //
179 this.activeDocument.model.saveAll(); 179 this.currentDocument.model.saveAll();
180 } else { 180 } else {
181 //TODO: Add error handling 181 //TODO: Add error handling
182 } 182 }
@@ -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/component-controller.js b/js/controllers/elements/component-controller.js
index 5b0aaeac..dd0766df 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 14 var component = el.controller;
15 15
16 switch(prop) { 16 switch(prop) {
17 case "id": 17 case "id":
@@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, {
34 34
35 setProperty: { 35 setProperty: {
36 value: function(el, p, value) { 36 value: function(el, p, value) {
37 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 37 var component = el.controller;
38 38
39 switch(p) { 39 switch(p) {
40 case "id": 40 case "id":
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 53588f68..308e598b 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
7var Montage = require("montage/core/core").Montage, 7var 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
10exports.ElementController = Montage.create(Component, { 11exports.ElementController = Montage.create(Component, {
11 12
@@ -182,28 +183,12 @@ exports.ElementController = Montage.create(Component, {
182 el.elementModel.stroke = null; 183 el.elementModel.stroke = null;
183 return; 184 return;
184 case 'gradient': 185 case 'gradient':
185 if(color.borderInfo) {
186 if(color.borderInfo.borderWidth) {
187 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
188 }
189 if(color.borderInfo.borderStyle) {
190 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
191 }
192 }
193 this.setGradientBorder(el, color.color.gradientMode, color.color.css); 186 this.setGradientBorder(el, color.color.gradientMode, color.color.css);
194 break; 187 break;
195 default: 188 default:
196 this.setProperty(el, "border-image", "none"); 189 this.setProperty(el, "border-image", "none");
197 this.setProperty(el, "border-image-slice", ""); 190 this.setProperty(el, "border-image-slice", "");
198 this.setProperty(el, "border-color", color.color.css); 191 this.setProperty(el, "border-color", color.color.css);
199 if(color.borderInfo) {
200 if(color.borderInfo.borderWidth) {
201 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
202 }
203 if(color.borderInfo.borderStyle) {
204 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
205 }
206 }
207 } 192 }
208 } 193 }
209 el.elementModel.stroke = color; 194 el.elementModel.stroke = color;
@@ -231,20 +216,83 @@ exports.ElementController = Montage.create(Component, {
231 }, 216 },
232 217
233 getStroke: { 218 getStroke: {
234 value: function(el) { 219 value: function(el, stroke) {
235 // TODO - Need to figure out which border side user wants 220 var strokeInfo = {},
236 return this.application.ninja.stylesController.getElementStyle(el, "border"); 221 color,
222 borderWidth,
223 border;
224 if(stroke.colorInfo) {
225 strokeInfo.colorInfo = {};
226 color = this.getColor(el, false);
227 if(color && color.color) {
228 strokeInfo.colorInfo.mode = color.mode;
229 strokeInfo.colorInfo.color = color.color;
230 } else {
231 strokeInfo.colorInfo.mode = "nocolor";
232 strokeInfo.colorInfo.color = null;
233 }
234 }
235 if(stroke.borderInfo) {
236 // TODO - Need to figure out which border side user wants
237 strokeInfo.borderInfo = {};
238 if(stroke.borderInfo.borderWidth) {
239 borderWidth = this.getProperty(el, "border-width");
240 if(borderWidth) {
241 border = njModule.NJUtils.getValueAndUnits(borderWidth);
242 strokeInfo.borderInfo.borderWidth = border[0];
243 strokeInfo.borderInfo.borderUnits = border[1];
244 }
245 }
246 if(stroke.borderInfo.borderStyle) {
247 strokeInfo.borderInfo.borderStyle = this.getProperty(el, "border-style");
248 }
249 }
250 return strokeInfo;
237 } 251 }
238 }, 252 },
239 253
240 setStroke: { 254 setStroke: {
241 value: function(el, stroke) { 255 value: function(el, stroke) {
242 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits); 256 if(stroke.borderInfo) {
243 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle); 257 if(stroke.borderInfo.borderWidth) {
244 this.setColor(el, stroke.color, false); 258 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderInfo.borderWidth + stroke.borderInfo.borderUnits);
259 }
260 if(stroke.borderInfo.borderStyle) {
261 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderInfo.borderStyle);
262 }
263 }
264 if(stroke.colorInfo) {