aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorAnanya Sen2012-02-22 12:18:25 -0800
committerAnanya Sen2012-02-22 12:18:25 -0800
commitdbf0ca5637a3bca87c21c65ada47f8a4d794f78c (patch)
treeace2a2415ef14662c27cdb2528914bef0a7f9208 /js/controllers
parent9aa442da1ac9fd3212b37fa63a36090af47b6808 (diff)
parent27589634d3e8ea52abe8623f8f2cc48ce0aa04c9 (diff)
downloadninja-dbf0ca5637a3bca87c21c65ada47f8a4d794f78c.tar.gz
Merge branch 'refs/heads/FileIO-jose' into FileIO
Conflicts: js/controllers/document-controller.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js29
-rwxr-xr-xjs/controllers/elements/element-controller.js3
-rwxr-xr-xjs/controllers/selection-controller.js36
3 files changed, 43 insertions, 25 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 7470bae2..48e33267 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -67,19 +67,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
67 67
68 68
69 69
70 70
71 71
72 72
73 73
74 //////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////
75 // 75 //
76 handleWebRequest: { 76 handleWebRequest: {
77 value: function (request) { 77 value: function (request) {
78 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { 78 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) {
79 //TODO: Optimize creating string 79 //TODO: Optimize creating string
80 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]}; 80 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]};
81 }
81 } 82 }
82 }
83 }, 83 },
84 //////////////////////////////////////////////////////////////////// 84 ////////////////////////////////////////////////////////////////////
85 // 85 //
@@ -90,7 +90,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
90 } 90 }
91 }, 91 },
92 //////////////////////////////////////////////////////////////////// 92 ////////////////////////////////////////////////////////////////////
93 93
94 94
95 95
96 96
@@ -146,19 +146,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
146 fileSaveResult: { 146 fileSaveResult: {
147 value: function (result) { 147 value: function (result) {
148 if(result.status === 204){ 148 if(result.status === 204){
149 this.clearDocumentDirtyFlag(); 149 this.activeDocument.needsSave = false;
150 } 150 }
151 } 151 }
152 }, 152 },
153 ////////////////////////////////////////////////////////////////////
154
155
156 clearDocumentDirtyFlag:{
157 value: function(){
158 this.activeDocument.dirtyFlag = false;
159 }
160 },
161
162 153
163 createNewFile:{ 154 createNewFile:{
164 value:function(newFileObj){ 155 value:function(newFileObj){
@@ -297,7 +288,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
297 288
298 closeDocument: { 289 closeDocument: {
299 value: function(id) { 290 value: function(id) {
300 if(this.activeDocument.dirtyFlag === true){ 291 if(this.activeDocument.needsSave === true){
301 //if file dirty then alert user to save 292 //if file dirty then alert user to save
302 } 293 }
303 294
@@ -480,5 +471,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
480 value: function() { 471 value: function() {
481 return "userDocument_" + (this._iframeCounter++); 472 return "userDocument_" + (this._iframeCounter++);
482 } 473 }
483 } 474 }
484}); 475});
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
161 if(outerElement.id === "UserContent") return;
162 // else keep going up the chain
139 outerElement = outerElement.parentNode; 163 outerElement = outerElement.parentNode;
140 } 164 }
141 165