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.js33
-rwxr-xr-xjs/controllers/elements/component-controller.js15
-rwxr-xr-xjs/controllers/elements/element-controller.js115
-rwxr-xr-xjs/controllers/elements/shapes-controller.js502
-rwxr-xr-xjs/controllers/elements/stage-controller.js69
-rw-r--r--js/controllers/presets-controller.js130
-rwxr-xr-xjs/controllers/selection-controller.js148
-rwxr-xr-xjs/controllers/styles-controller.js69
9 files changed, 733 insertions, 349 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 87e93465..ddaeb061 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -38,13 +38,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
38 return this._activeDocument; 38 return this._activeDocument;
39 }, 39 },
40 set: function(doc) { 40 set: function(doc) {
41 if(!!this._activeDocument) this._activeDocument.isActive = false; 41 if(!!this._activeDocument){ this._activeDocument.isActive = false;}
42
43 this._activeDocument = doc; 42 this._activeDocument = doc;
44 if(!!this._activeDocument){ 43 if(!!this._activeDocument){
45
46 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 44 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
47 this._activeDocument.isActive = true; 45 this._activeDocument.isActive = true;
46
48 if(!!this._activeDocument.editor){ 47 if(!!this._activeDocument.editor){
49 this._activeDocument.editor.focus(); 48 this._activeDocument.editor.focus();
50 } 49 }
@@ -61,25 +60,33 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
61 this.eventManager.addEventListener("executeSaveAs", this, false); 60 this.eventManager.addEventListener("executeSaveAs", this, false);
62 this.eventManager.addEventListener("executeSaveAll", this, false); 61 this.eventManager.addEventListener("executeSaveAll", this, false);
63 this.eventManager.addEventListener("executeFileClose", this, false); 62 this.eventManager.addEventListener("executeFileClose", this, false);
63 this.eventManager.addEventListener("executeFileCloseAll", this, false);
64 64
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 65 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 66
67 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
67 } 68 }
68 }, 69 },
69 70
70 71 handleAddComponentFirstDraw: {
72 value: function (e) {
73 //TODO: Add logic to reparse the document for dynamically added styles
74 //console.log(e);
75 }
76 },
71 77
72 78
73 79
74 80
75 81
76 //////////////////////////////////////////////////////////////////// 82////////////////////////////////////////////////////////////////////
77 // 83 //
78 handleWebRequest: { 84 handleWebRequest: {
79 value: function (request) { 85 value: function (request) {
80 //TODO: Check if frameId is proper 86 //TODO: Check if frameId is proper
81 if (this._hackRootFlag && request.parentFrameId !== -1) { 87 if (this._hackRootFlag && request.parentFrameId !== -1) {
82 //TODO: Optimize creating string 88 //TODO: Optimize creating string
89 //console.log(request);
83 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); 90 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
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('/')[request.url.split('/').length-1]}; 91 //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]};
85 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]}; 92 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]};
@@ -103,6 +110,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
103 }, 110 },
104 //////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////
105 112
113
106 114
107 115
108 116
@@ -172,6 +180,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
172 } 180 }
173 }, 181 },
174 //////////////////////////////////////////////////////////////////// 182 ////////////////////////////////////////////////////////////////////
183 handleExecuteFileCloseAll:{
184 value: function(event) {
185 var i=0;
186 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
187 while(this._documents.length > 0){
188 this.closeDocument(this._documents[this._documents.length -1].uuid);
189 }
190 }
191 }
192 },
193 ////////////////////////////////////////////////////////////////////
175 // 194 //
176 fileSaveResult: { 195 fileSaveResult: {
177 value: function (result) { 196 value: function (result) {
@@ -372,7 +391,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
372 nextDocumentIndex = closeDocumentIndex - 1; 391 nextDocumentIndex = closeDocumentIndex - 1;
373 } 392 }
374 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); 393 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
375 if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} 394 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
376 this._removeDocumentView(doc.container); 395 this._removeDocumentView(doc.container);
377 }else if(this._documents.length === 0){ 396 }else if(this._documents.length === 0){
378 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ 397 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 83450d0f..d902e4a1 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,43 +11,48 @@ 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.getComponentFromElement(el);
15
14 switch(prop) { 16 switch(prop) {
15 case "id": 17 case "id":
16 case "class": 18 case "class":
19 case "-webkit-transform-style":
17 case "left": 20 case "left":
18 case "top": 21 case "top":
19 case "width": 22 case "width":
20 case "height": 23 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { 24 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 25 return component[prop];
23 } else { 26 } else {
24 return ElementController.getProperty(el, prop, true); 27 return ElementController.getProperty(el, prop, true);
25 } 28 }
26 default: 29 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 30 return component[prop];
28 } 31 }
29 } 32 }
30 }, 33 },
31 34
32 setProperty: { 35 setProperty: {
33 value: function(el, p, value) { 36 value: function(el, p, value) {
37 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
38
34 switch(p) { 39 switch(p) {
35 case "id": 40 case "id":
36 case "class": 41 case "class":
42 case "-webkit-transform-style":
37 case "left": 43 case "left":
38 case "top": 44 case "top":
39 case "width": 45 case "width":
40 case "height": 46 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) { 47 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; 48 component[p] = value;
43 } else { 49 } else {
44 ElementController.setProperty(el, p, value); 50 ElementController.setProperty(el, p, value);
45 } 51 }
46 break; 52 break;
47 default: 53 default:
48 if(p === "min" || p === "max") value = parseFloat(value); 54 if(p === "min" || p === "max") value = parseFloat(value);
49 55 component[p] = value;
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break; 56 break;
52 57
53 } 58 }
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 9f00604f..2ac84452 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js