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.js40
-rwxr-xr-xjs/controllers/elements/component-controller.js13
-rwxr-xr-xjs/controllers/elements/shapes-controller.js47
-rw-r--r--js/controllers/presets-controller.js108
-rwxr-xr-xjs/controllers/selection-controller.js12
6 files changed, 204 insertions, 17 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 7d982a62..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 },
@@ -61,25 +69,33 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
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);
63 this.eventManager.addEventListener("executeFileClose", this, false); 71 this.eventManager.addEventListener("executeFileClose", this, false);
72 this.eventManager.addEventListener("executeFileCloseAll", this, false);
64 73
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 74 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 75
76 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
67 } 77 }
68 }, 78 },
69 79
70 80 handleAddComponentFirstDraw: {
81 value: function (e) {
82 //TODO: Add logic to reparse the document for dynamically added styles
83 console.log(e);
84 }
85 },
71 86
72 87
73 88
74 89
75 90
76 //////////////////////////////////////////////////////////////////// 91////////////////////////////////////////////////////////////////////
77 // 92 //
78 handleWebRequest: { 93 handleWebRequest: {
79 value: function (request) { 94 value: function (request) {
80 //TODO: Check if frameId is proper 95 //TODO: Check if frameId is proper
81 if (this._hackRootFlag && request.parentFrameId !== -1) { 96 if (this._hackRootFlag && request.parentFrameId !== -1) {
82 //TODO: Optimize creating string 97 //TODO: Optimize creating string
98 //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); 99 //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]}; 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]};
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]}; 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]};
@@ -103,6 +119,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
103 }, 119 },
104 //////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////
105 121
122
106 123
107 124
108 125
@@ -172,6 +189,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
172 } 189 }
173 }, 190 },
174 //////////////////////////////////////////////////////////////////// 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 ////////////////////////////////////////////////////////////////////
175 // 203 //
176 fileSaveResult: { 204 fileSaveResult: {
177 value: function (result) { 205 value: function (result) {
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 83450d0f..260ee8a0 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,6 +11,8 @@ 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,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, {
19 case "width": 21 case "width":
20 case "height": 22 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { 23 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 24 return component[prop];
23 } else { 25 } else {
24 return ElementController.getProperty(el, prop, true); 26 return ElementController.getProperty(el, prop, true);
25 } 27 }
26 default: 28 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 29 return component[prop];
28 } 30 }
29 } 31 }
30 }, 32 },
31 33
32 setProperty: { 34 setProperty: {
33 value: function(el, p, value) { 35 value: function(el, p, value) {
36 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
37
34 switch(p) { 38 switch(p) {
35 case "id": 39 case "id":
36 case "class": 40 case "class":
@@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, {
39 case "width": 43 case "width":
40 case "height": 44 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) { 45 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; 46 component[p] = value;
43 } else { 47 } else {
44 ElementController.setProperty(el, p, value); 48 ElementController.setProperty(el, p, value);
45 } 49 }
46 break; 50 break;
47 default: 51 default:
48 if(p === "min" || p === "max") value = parseFloat(value); 52 if(p === "min" || p === "max") value = parseFloat(value);
49 53 component[p] = value;
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break; 54 break;
52 55
53 } 56 }
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b3ac9ddb..f0e9458b 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -105,6 +105,20 @@ exports.ShapesController = Montage.create(CanvasController, {
105 case "editFillMaterial": 105 case "editFillMaterial":
106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); 106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()});