aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js24
-rwxr-xr-xjs/controllers/elements/element-controller.js3
-rwxr-xr-xjs/controllers/selection-controller.js37
3 files changed, 46 insertions, 18 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index e0402219..7491ef9f 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -66,19 +66,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
66 66
67 67
68 68
69 69
70 70
71 71
72 72
73 //////////////////////////////////////////////////////////////////// 73 ////////////////////////////////////////////////////////////////////
74 // 74 //
75 handleWebRequest: { 75 handleWebRequest: {
76 value: function (request) { 76 value: function (request) {
77 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { 77 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) {
78 //TODO: Optimize creating string 78 //TODO: Optimize creating string
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]}; 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]};
80 }
80 } 81 }
81 }
82 }, 82 },
83 //////////////////////////////////////////////////////////////////// 83 ////////////////////////////////////////////////////////////////////
84 // 84 //
@@ -89,7 +89,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
89 } 89 }
90 }, 90 },
91 //////////////////////////////////////////////////////////////////// 91 ////////////////////////////////////////////////////////////////////
92 92
93 93
94 94
95 95
@@ -121,9 +121,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
121 handleExecuteSave: { 121 handleExecuteSave: {
122 value: function(event) { 122 value: function(event) {
123 if(!!this.activeDocument){ 123 if(!!this.activeDocument){
124 //Text and HTML document classes should return the same save object for fileSave 124 //Text and HTML document classes should return the same save object for fileSave
125 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); 125 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
126 } 126 }
127 } 127 }
128 }, 128 },
129 //////////////////////////////////////////////////////////////////// 129 ////////////////////////////////////////////////////////////////////
@@ -135,7 +135,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
135 } 135 }
136 } 136 }
137 }, 137 },
138 138
139 createNewFile:{ 139 createNewFile:{
140 value:function(newFileObj){ 140 value:function(newFileObj){
141 //console.log(newFileObj);//contains the template uri and the new file uri 141 //console.log(newFileObj);//contains the template uri and the new file uri
@@ -456,5 +456,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
456 value: function() { 456 value: function() {
457 return "userDocument_" + (this._iframeCounter++); 457 return "userDocument_" + (this._iframeCounter++);
458 } 458 }
459 } 459 }
460}); 460});
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..fed9affd 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,6 +20,27 @@ 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 console.log("setting container in the selection tool");
37 this.executeSelectElement();
38 }
39
40 this._selectionContainer = value;
41 }
42 },
43
23 deserializedFromTemplate: { 44 deserializedFromTemplate: {
24 value: function() { 45 value: function() {
25 this.eventManager.addEventListener("openDocument", this, false); 46 this.eventManager.addEventListener("openDocument", this, false);
@@ -53,7 +74,9 @@ exports.SelectionController = Montage.create(Component, {
53 } 74 }
54 } 75 }
55 76
56 this.dispatchEvent(selectionEvent.event); 77 //
78 this._selectionContainer = this.application.ninja.currentSelectedContainer;
79
57 } 80 }
58 }, 81 },
59 82
@@ -66,13 +89,10 @@ exports.SelectionController = Montage.create(Component, {
66 handleElementDeleted: { 89 handleElementDeleted: {
67 value: function(event) { 90 value: function(event) {
68 if(!this._isDocument) { 91 if(!this._isDocument) {
69
70 if(this.findSelectedElement(event.detail) !== -1) { 92 if(this.findSelectedElement(event.detail) !== -1) {
71 this.executeSelectElement(); 93 this.executeSelectElement();
72 } 94 }
73
74 } 95 }
75
76 } 96 }
77 }, 97 },
78 98
@@ -130,12 +150,17 @@ exports.SelectionController = Montage.create(Component, {
130 this.executeSelectElement(); // Else execute selection with no item 150 this.executeSelectElement(); // Else execute selection with no item
131 } else { 151 } else {
132 152
133 if(item.parentNode.id == "UserContent") { 153// if(item.parentNode.id === "UserContent") {
154 if(item.parentNode.uuid === this.selectionContainer.uuid) {
134 this.executeSelectElement(item); 155 this.executeSelectElement(item);
135 } else { 156 } else {
136 var outerElement = item.parentNode; 157 var outerElement = item.parentNode;
137 158
138 while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { 159 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) {
160 //while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") {
161 // If element is higher up than current container then return
162 if(outerElement.id === "UserContent") return;
163 // else keep going up the chain
139 outerElement = outerElement.parentNode; 164 outerElement = outerElement.parentNode;
140 } 165 }
141 166