aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js53
-rwxr-xr-xjs/controllers/elements/element-controller.js3
-rwxr-xr-xjs/controllers/selection-controller.js36
-rwxr-xr-xjs/controllers/styles-controller.js7
4 files changed, 65 insertions, 34 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 1f339fe7..fa611de4 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -66,35 +66,39 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
66 66
67 67
68 68
69 handleWebRequest: {
70 value: function (request) {
71 if (request.url.indexOf('js/document/templates/montage-html') !== -1) {
72 69
73 console.log(request);
74 70
75 //TODO: Figure out why active document is not available here
76 71
77 if (this._hackRootFlag) {
78
79 //console.log(request.url.split('/')[request.url.split('/').length-1]);
80 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]);
81 72
73 ////////////////////////////////////////////////////////////////////
74 //
75 handleWebRequest: {
76 value: function (request) {
77 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) {
78 //TODO: Optimize creating string
82 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]}; 79 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]};
83 } 80 }
84 } 81 }
85 }
86 }, 82 },
87 83 ////////////////////////////////////////////////////////////////////
88 84 //
89 handleAppLoaded: { 85 handleAppLoaded: {
90 value: function() { 86 value: function() {
91 // 87 //Adding an intercept to resources loaded to ensure user assets load from cloud simulator
92 88 if (window.chrome.app.isInstalled) {
93 chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); 89 chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]);
94 90 }
95 } 91 }
96 }, 92 },
93 ////////////////////////////////////////////////////////////////////
97 94
95
96
97
98
99
100
101
98 handleExecuteFileOpen: { 102 handleExecuteFileOpen: {
99 value: function(event) { 103 value: function(event) {
100 var pickerSettings = event._event.settings || {}; 104 var pickerSettings = event._event.settings || {};
@@ -118,28 +122,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
118 //TODO: Check for appropiate structures 122 //TODO: Check for appropiate structures
119 handleExecuteSave: { 123 handleExecuteSave: {
120 value: function(event) { 124 value: function(event) {
125 if(!!this.activeDocument){
121 //Text and HTML document classes should return the same save object for fileSave 126 //Text and HTML document classes should return the same save object for fileSave
122 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); 127 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
123 } 128 }
129 }
124 }, 130 },
125 //////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////
126 // 132 //
127 fileSaveResult: { 133 fileSaveResult: {
128 value: function (result) { 134 value: function (result) {
129 if(result.status === 204){ 135 if(result.status === 204){
130 this.clearDocumentDirtyFlag(); 136 this.activeDocument.needsSave = false;
131 } 137 }
132 } 138 }
133 }, 139 },
134 ////////////////////////////////////////////////////////////////////
135
136
137 clearDocumentDirtyFlag:{
138 value: function(){
139 this.activeDocument.dirtyFlag = false;
140 }
141 },
142
143 140
144 createNewFile:{ 141 createNewFile:{
145 value:function(newFileObj){ 142 value:function(newFileObj){
@@ -278,7 +275,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
278 275
279 closeDocument: { 276 closeDocument: {
280 value: function(id) { 277 value: function(id) {
281 if(this.activeDocument.dirtyFlag === true){ 278 if(this.activeDocument.needsSave === true){
282 //if file dirty then alert user to save 279 //if file dirty then alert user to save
283 } 280 }
284 281
@@ -301,6 +298,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
301 this._removeDocumentView(doc.container); 298 this._removeDocumentView(doc.container);
302 this.application.ninja.stage.stageView.hideRulers(); 299 this.application.ninja.stage.stageView.hideRulers();
303 document.getElementById("iframeContainer").style.display="block"; 300 document.getElementById("iframeContainer").style.display="block";
301
302 this.application.ninja.stage.hideCanvas(true);
304 } 303 }
305 } 304 }
306 }, 305 },
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 65d26bdd..ac14def4 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -12,6 +12,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
12 addElement: { 12 addElement: {
13 value: function(el, styles) { 13 value: function(el, styles) {
14 this.application.ninja.currentDocument.documentRoot.appendChild(el); 14 this.application.ninja.currentDocument.documentRoot.appendChild(el);
15 // Nested elements -
16 // TODO make sure the CSS is correct before nesting elements
17 // this.application.ninja.currentSelectedContainer.appendChild(el);
15 this.application.ninja.stylesController.setElementStyles(el, styles); 18 this.application.ninja.stylesController.setElementStyles(el, styles);
16 } 19 }
17 }, 20 },
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 833e6f04..d69b53e0 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,6 +20,26 @@ exports.SelectionController = Montage.create(Component, {
20 } 20 }
21 }, 21 },
22 22
23 /*
24 * Bound property to the ninja currentSelectedContainer
25 */
26 _selectionContainer: {
27 value: null
28 },
29
30 selectionContainer: {
31 get: function() {
32 return this._selectionContainer
33 },
34 set: function(value) {
35 if(this._selectionContainer && this._selectionContainer !== value) {
36 this.executeSelectElement();
37 }
38
39 this._selectionContainer = value;
40 }
41 },
42
23 deserializedFromTemplate: { 43 deserializedFromTemplate: {
24 value: function() { 44 value: function() {
25 this.eventManager.addEventListener("openDocument", this, false); 45 this.eventManager.addEventListener("openDocument", this, false);
@@ -53,7 +73,9 @@ exports.SelectionController = Montage.create(Component, {
53 } 73 }
54 } 74 }
55 75
56 this.dispatchEvent(selectionEvent.event); 76 //
77 this._selectionContainer = this.application.ninja.currentSelectedContainer;
78
57 } 79 }
58 }, 80 },
59 81
@@ -66,13 +88,10 @@ exports.SelectionController = Montage.create(Component, {
66 handleElementDeleted: { 88 handleElementDeleted: {
67 value: function(event) { 89 value: function(event) {
68 if(!this._isDocument) { 90 if(!this._isDocument) {
69
70 if(this.findSelectedElement(event.detail) !== -1) { 91 if(this.findSelectedElement(event.detail) !== -1) {
71 this.executeSelectElement(); 92 this.executeSelectElement();
72 } 93 }
73
74 } 94 }
75
76 } 95 }
77 }, 96 },
78 97
@@ -130,12 +149,17 @@ exports.SelectionController = Montage.create(Component, {
130 this.executeSelectElement(); // Else execute selection with no item 149 this.executeSelectElement(); // Else execute selection with no item
131 } else { 150 } else {
132 151
133 if(item.parentNode.id == "UserContent") { 152// if(item.parentNode.id === "UserContent") {
153 if(item.parentNode.uuid === this.selectionContainer.uuid) {
134 this.executeSelectElement(item); 154 this.executeSelectElement(item);
135 } else { 155 } else {
136 var outerElement = item.parentNode; 156 var outerElement = item.parentNode;
137 157
138 while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { 158 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) {
159 //while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") {
160 // If element is higher up than current container then return