aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorEric Guzman2012-03-13 13:12:43 -0700
committerEric Guzman2012-03-13 13:12:43 -0700
commit61fd46cad105f0a52afa028e5301b96120f00ab4 (patch)
treed8a7e23e1ea7d9b5c64a288822b7797bb19e50d4 /js/controllers
parent7e3161153b87b891875ac65368a19aed12909fa3 (diff)
parentf56b8cf4d3316d250c0f0045fb78f0dbd5c56e94 (diff)
downloadninja-61fd46cad105f0a52afa028e5301b96120f00ab4.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Conflicts: js/controllers/styles-controller.js
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js50
-rwxr-xr-xjs/controllers/elements/element-controller.js32
-rwxr-xr-xjs/controllers/elements/shapes-controller.js140
-rwxr-xr-xjs/controllers/selection-controller.js19
4 files changed, 207 insertions, 34 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index a8056519..87e93465 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -60,8 +60,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
60 this.eventManager.addEventListener("executeSave", this, false); 60 this.eventManager.addEventListener("executeSave", this, false);
61 this.eventManager.addEventListener("executeSaveAs", this, false); 61 this.eventManager.addEventListener("executeSaveAs", this, false);
62 this.eventManager.addEventListener("executeSaveAll", this, false); 62 this.eventManager.addEventListener("executeSaveAll", this, false);
63 this.eventManager.addEventListener("executeFileClose", this, false);
63 64
64 this.eventManager.addEventListener("recordStyleChanged", this, false); 65 this.eventManager.addEventListener("styleSheetDirty", this, false);
65 66
66 } 67 }
67 }, 68 },
@@ -157,17 +158,29 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
157 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 158 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
158 saveAsSettings.fileName = this.activeDocument.name; 159 saveAsSettings.fileName = this.activeDocument.name;
159 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); 160 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/"));
160 //add callback 161 saveAsSettings.callback = this.saveAsCallback.bind(this);
161 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); 162 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
162 } 163 }
163 } 164 }
164 }, 165 },
165 166 ////////////////////////////////////////////////////////////////////
167 handleExecuteFileClose:{
168 value: function(event) {
169 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
170 this.closeDocument(this.activeDocument.uuid);
171 }
172 }
173 },
174 ////////////////////////////////////////////////////////////////////
166 // 175 //
167 fileSaveResult: { 176 fileSaveResult: {
168 value: function (result) { 177 value: function (result) {
169 if(result.status === 204){ 178 if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved
170 this.activeDocument.needsSave = false; 179 this.activeDocument.needsSave = false;
180 if(this.application.ninja.currentDocument !== null){
181 //clear Dirty StyleSheets for the saved document
182 this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument);
183 }
171 } 184 }
172 } 185 }
173 }, 186 },
@@ -249,6 +262,29 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
249 }, 262 },
250 //////////////////////////////////////////////////////////////////// 263 ////////////////////////////////////////////////////////////////////
251 // 264 //
265 saveAsCallback:{
266 value:function(saveAsDetails){
267 var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination;
268 //update document metadata
269 this.activeDocument.name = ""+filename;
270 //prepare new file uri
271 if(destination && (destination.charAt(destination.length -1) !== "/")){
272 destination = destination + "/";
273 }
274 fileUri = destination+filename;
275
276 this.activeDocument.uri = fileUri;
277 //save a new file
278 //use the ioMediator.fileSaveAll when implemented
279 this.activeDocument._userDocument.name=filename;
280 this.activeDocument._userDocument.root=destination;
281 this.activeDocument._userDocument.uri=fileUri;
282 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
283 //
284 }
285 },
286
287 ////////////////////////////////////////////////////////////////////
252 openDocument: { 288 openDocument: {
253 value: function(doc) { 289 value: function(doc) {
254 290
@@ -515,5 +551,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
515 value: function() { 551 value: function() {
516 return "userDocument_" + (this._iframeCounter++); 552 return "userDocument_" + (this._iframeCounter++);
517 } 553 }
554 },
555
556 handleStyleSheetDirty:{
557 value:function(){
558 this.activeDocument.needsSave = true;
518 } 559 }
560 }
519}); 561});
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index ec0335b4..9f00604f 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -74,8 +74,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
74 74
75 //-------------------------------------------------------------------------------------------------------- 75 //--------------------------------------------------------------------------------------------------------
76 // Routines to get/set color properties 76 // Routines to get/set color properties
77 // borderSide : "top", "right", "bottom", or "left"
77 getColor: { 78 getColor: {
78 value: function(el, isFill) { 79 value: function(el, isFill, borderSide) {
79 var colorObj, 80 var colorObj,
80 color, 81 color,
81 image; 82 image;
@@ -87,22 +88,29 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
87 { 88 {
88 return el.elementModel.fill; 89 return el.elementModel.fill;
89 } 90 }
90// return this.application.ninja.stylesController.getElementStyle(el, "background-color");
91 //TODO: Once logic for color and gradient is established, this needs to be revised 91 //TODO: Once logic for color and gradient is established, this needs to be revised
92 color = this.getProperty(el, "background-color"); 92 color = this.getProperty(el, "background-color");
93 image = this.getProperty(el, "background-image"); 93 image = this.getProperty(el, "background-image");
94 } 94 }
95 else 95 else
96 { 96 {
97 // TODO - Need to figure out which border side user wants 97 // Try getting border color from specific side first
98 if(el.elementModel.stroke) 98 if(borderSide)
99 { 99 {
100 return el.elementModel.stroke; 100 color = this.getProperty(el, "border-" + borderSide + "-color");
101 image = this.getProperty(el, "border-" + borderSide + "-image");
102 }
103
104 // If no color was found, look up the shared border color
105 if(!color && !image)
106 {
107 if(el.elementModel.stroke)
108 {
109 return el.elementModel.stroke;
110 }
111 color = this.getProperty(el, "border-color");
112 image = this.getProperty(el, "border-image");
101 } 113 }
102 // TODO - Need to figure out which border side user wants
103// return this.application.ninja.stylesController.getElementStyle(el, "border-color");
104 color = this.getProperty(el, "border-color");
105 image = this.getProperty(el, "border-image");
106 } 114 }
107 115
108 if(color || image) { 116 if(color || image) {
@@ -120,11 +128,15 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
120 { 128 {
121 el.elementModel.fill = colorObj; 129 el.elementModel.fill = colorObj;
122 } 130 }
123 else 131 else if(!borderSide)
124 { 132 {
125 // TODO - Need to update border style and width also 133 // TODO - Need to update border style and width also
126 el.elementModel.stroke = colorObj; 134 el.elementModel.stroke = colorObj;
127 } 135 }
136 else
137 {
138 // TODO - Should update specific border sides too
139 }
128 140
129 return colorObj; 141 return colorObj;
130 } 142 }
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 3423a5a7..d72d9c14 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -259,24 +259,82 @@ exports.ShapesController = Montage.create(CanvasController, {
259 } 259 }
260 }, 260 },
261 261
262 setColor: { 262 _setGradientMaterial: {
263 value: function(el, color, isFill) { 263 value: function(el, gradientMode, isFill) {
264 var webGl = color.webGlColor || color.color.webGlColor; 264 var m = "LinearGradientMaterial",
265 if(!webGl) 265 fm;
266 if(gradientMode === "radial")
266 { 267 {
267 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); 268 m = "RadialGradientMaterial";
268 } 269 }
270
269 if(isFill) 271 if(isFill)
270 { 272 {
271 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); 273 if(el.elementModel.shapeModel.fillMaterial.getName() !== m)