aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/color-controller.js1
-rwxr-xr-xjs/controllers/document-controller.js92
-rwxr-xr-xjs/controllers/elements/component-controller.js13
-rwxr-xr-xjs/controllers/elements/element-controller.js65
-rwxr-xr-xjs/controllers/elements/shapes-controller.js262
-rwxr-xr-xjs/controllers/elements/stage-controller.js41
-rw-r--r--js/controllers/presets-controller.js108
-rwxr-xr-xjs/controllers/selection-controller.js25
-rwxr-xr-xjs/controllers/styles-controller.js10
9 files changed, 527 insertions, 90 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js
index 53573baf..c6d664cf 100755
--- a/js/controllers/color-controller.js
+++ b/js/controllers/color-controller.js
@@ -198,7 +198,6 @@ exports.ColorController = Montage.create(Component, {
198 handleChange: { 198 handleChange: {
199 enumerable: true, 199 enumerable: true,
200 value: function (e) { 200 value: function (e) {
201
202 // 201 //
203 var actionEvent, color, input = e._event.input, panelMode, mode = e._event.mode; 202 var actionEvent, color, input = e._event.input, panelMode, mode = e._event.mode;
204 if (this.colorView) { 203 if (this.colorView) {
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index a8056519..a308f191 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -32,22 +32,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
32 _iframeHolder: { value: null, enumerable: false }, 32 _iframeHolder: { value: null, enumerable: false },
33 _textHolder: { value: null, enumerable: false }, 33 _textHolder: { value: null, enumerable: false },
34 _codeMirrorCounter: {value: 1, enumerable: false}, 34 _codeMirrorCounter: {value: 1, enumerable: false},
35
36 canSave:{value: false},//for Save menu state update
37 canSaveAll:{value: false},//for Save All menu state update
35 38
36 activeDocument: { 39 activeDocument: {
37 get: function() { 40 get: function() {
38 return this._activeDocument; 41 return this._activeDocument;
39 }, 42 },
40 set: function(doc) { 43 set: function(doc) {
41 if(!!this._activeDocument) this._activeDocument.isActive = false; 44 if(!!this._activeDocument){ this._activeDocument.isActive = false;}
42
43 this._activeDocument = doc; 45 this._activeDocument = doc;
44 if(!!this._activeDocument){ 46 if(!!this._activeDocument){
45
46 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 47 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
47 this._activeDocument.isActive = true; 48 this._activeDocument.isActive = true;
49
48 if(!!this._activeDocument.editor){ 50 if(!!this._activeDocument.editor){
49 this._activeDocument.editor.focus(); 51 this._activeDocument.editor.focus();
50 } 52 }
53
54 this.canSave = doc.needsSave;
55 this.canSaveAll = doc.needsSave;
56 }else{
57 this.canSave = false;
58 this.canSaveAll = false;
51 } 59 }
52 } 60 }
53 }, 61 },
@@ -60,25 +68,34 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
60 this.eventManager.addEventListener("executeSave", this, false); 68 this.eventManager.addEventListener("executeSave", this, false);
61 this.eventManager.addEventListener("executeSaveAs", this, false); 69 this.eventManager.addEventListener("executeSaveAs", this, false);
62 this.eventManager.addEventListener("executeSaveAll", this, false); 70 this.eventManager.addEventListener("executeSaveAll", this, false);
71 this.eventManager.addEventListener("executeFileClose", this, false);
72 this.eventManager.addEventListener("executeFileCloseAll", this, false);
63 73
64 this.eventManager.addEventListener("recordStyleChanged", this, false); 74 this.eventManager.addEventListener("styleSheetDirty", this, false);
65 75
76 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
66 } 77 }
67 }, 78 },
68 79
69 80 handleAddComponentFirstDraw: {
81 value: function (e) {
82 //TODO: Add logic to reparse the document for dynamically added styles
83 console.log(e);
84 }
85 },
70 86
71 87
72 88
73 89
74 90
75 //////////////////////////////////////////////////////////////////// 91////////////////////////////////////////////////////////////////////
76 // 92 //
77 handleWebRequest: { 93 handleWebRequest: {
78 value: function (request) { 94 value: function (request) {
79 //TODO: Check if frameId is proper 95 //TODO: Check if frameId is proper
80 if (this._hackRootFlag && request.parentFrameId !== -1) { 96 if (this._hackRootFlag && request.parentFrameId !== -1) {
81 //TODO: Optimize creating string 97 //TODO: Optimize creating string
98 //console.log(request);
82 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); 99 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
83 //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; 100 //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]};
84 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; 101 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]};
@@ -102,6 +119,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
102 }, 119 },
103 //////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////
104 121
122
105 123
106 124
107 125
@@ -157,17 +175,40 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
157 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 175 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
158 saveAsSettings.fileName = this.activeDocument.name; 176 saveAsSettings.fileName = this.activeDocument.name;
159 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); 177 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/"));
160 //add callback 178 saveAsSettings.callback = this.saveAsCallback.bind(this);
161 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); 179 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
162 } 180 }
163 } 181 }
164 }, 182 },
165 183 ////////////////////////////////////////////////////////////////////
184 handleExecuteFileClose:{
185 value: function(event) {
186 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
187 this.closeDocument(this.activeDocument.uuid);
188 }
189 }
190 },
191 ////////////////////////////////////////////////////////////////////
192 handleExecuteFileCloseAll:{
193 value: function(event) {
194 var i=0;
195 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
196 while(this._documents.length > 0){
197 this.closeDocument(this._documents[this._documents.length -1].uuid);
198 }
199 }
200 }
201 },
202 ////////////////////////////////////////////////////////////////////
166 // 203 //
167 fileSaveResult: { 204 fileSaveResult: {
168 value: function (result) { 205 value: function (result) {
169 if(result.status === 204){ 206 if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved
170 this.activeDocument.needsSave = false; 207 this.activeDocument.needsSave = false;
208 if(this.application.ninja.currentDocument !== null){
209 //clear Dirty StyleSheets for the saved document
210 this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument);
211 }
171 } 212 }
172 } 213 }
173 }, 214 },
@@ -249,6 +290,29 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
249 }, 290 },
250 //////////////////////////////////////////////////////////////////// 291 ////////////////////////////////////////////////////////////////////
251 // 292 //
293 saveAsCallback:{
294 value:function(saveAsDetails){
295 var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination;
296 //update document metadata
297 this.activeDocument.name = ""+filename;
298 //prepare new file uri
299 if(destination && (destination.charAt(destination.length -1) !== "/")){
300 destination = destination + "/";
301 }
302 fileUri = destination+filename;
303
304 this.activeDocument.uri = fileUri;
305 //save a new file
306 //use the ioMediator.fileSaveAll when implemented
307 this.activeDocument._userDocument.name=filename;
308 this.activeDocument._userDocument.root=destination;
309 this.activeDocument._userDocument.uri=fileUri;
310 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
311 //
312 }
313 },
314
315 ////////////////////////////////////////////////////////////////////
252 openDocument: { 316 openDocument: {
253 value: function(doc) { 317 value: function(doc) {
254 318
@@ -336,7 +400,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
336 nextDocumentIndex = closeDocumentIndex - 1; 400 nextDocumentIndex = closeDocumentIndex - 1;
337 } 401 }
338 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 402 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
339 if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} 403 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
340 this._removeDocumentView(doc.container);