aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-12 23:04:07 -0700
committerValerio Virgillito2012-06-12 23:04:07 -0700
commita75947d69f571d723552f926f94d195514a01cbd (patch)
tree978cbf419f481573b977820f57dc4f0dafb2ac58
parent5c976cc4bbaa40315e77e6889b43fc7d7156e26f (diff)
downloadninja-a75947d69f571d723552f926f94d195514a01cbd.tar.gz
fixed document switching issues
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
-rwxr-xr-xjs/components/layout/bread-crumb.reel/bread-crumb.js1
-rwxr-xr-xjs/controllers/selection-controller.js31
-rwxr-xr-xjs/ninja.reel/ninja.html3
-rwxr-xr-xjs/tools/SelectionTool.js1
4 files changed, 7 insertions, 29 deletions
diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js
index 2f493102..a3c743a4 100755
--- a/js/components/layout/bread-crumb.reel/bread-crumb.js
+++ b/js/components/layout/bread-crumb.reel/bread-crumb.js
@@ -105,6 +105,7 @@ exports.Breadcrumb = Montage.create(Component, {
105 105
106 // TODO: This is bound 2 ways, update the internal property 106 // TODO: This is bound 2 ways, update the internal property
107 this.currentDocument.model.domContainer = this.containerElements[i].node; 107 this.currentDocument.model.domContainer = this.containerElements[i].node;
108 this.application.ninja.selectionController.executeSelectElement();
108 } 109 }
109 } 110 }
110}); 111});
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 6d982e69..b327bea4 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -34,13 +34,14 @@ exports.SelectionController = Montage.create(Component, {
34 } 34 }
35 35
36 if(this._currentDocument && this._currentDocument.currentView === "design") { 36 if(this._currentDocument && this._currentDocument.currentView === "design") {
37 this.ignoreFlag = false;
38 this._currentDocument.model._selection = this.application.ninja.selectedElements; 37 this._currentDocument.model._selection = this.application.ninja.selectedElements;
39// this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer;
40 } 38 }
41 39
42 this._currentDocument = value; 40 this._currentDocument = value;
43 41
42 if(this._currentDocument && this._currentDocument.currentView === "design") {
43 this.selectedElements = this._currentDocument.model.selection;
44 }
44 /* 45 /*
45 if(!value) { 46 if(!value) {
46 } else if(this._currentDocument.currentView === "design") { 47 } else if(this._currentDocument.currentView === "design") {
@@ -51,10 +52,6 @@ exports.SelectionController = Montage.create(Component, {
51 } 52 }
52 }, 53 },
53 54
54 ignoreFlag: {
55 value: true
56 },
57
58 _selectedElements: { 55 _selectedElements: {
59 value: null 56 value: null
60 }, 57 },
@@ -64,21 +61,17 @@ exports.SelectionController = Montage.create(Component, {
64 return this._selectedElements; 61 return this._selectedElements;
65 }, 62 },
66 set: function(value) { 63 set: function(value) {
67 if(this.currentDocument && this.currentDocument.currentView === "code") return;
68 64
69 if(value) { 65 if(value) {
70 this._selectedElements = value; 66 this._selectedElements = value;
71 67
72 this.application.ninja.selectedElements = this._selectedElements; 68 this.application.ninja.selectedElements = this._selectedElements;
73// this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot;
74 69
75 if(this._selectedElements.length === 0) { 70 if(this._selectedElements.length === 0) {
76 this.executeSelectElement(); 71 this.executeSelectElement();
77 } else { 72 } else {
78 this.executeSelectElement(this._selectedElements); 73 this.executeSelectElement(this._selectedElements);
79 } 74 }
80
81
82 } 75 }
83 } 76 }
84 }, 77 },
@@ -89,22 +82,6 @@ exports.SelectionController = Montage.create(Component, {
89 this.eventManager.addEventListener("elementsRemoved", this, false); 82 this.eventManager.addEventListener("elementsRemoved", this, false);
90 this.eventManager.addEventListener("elementReplaced", this, false); 83 this.eventManager.addEventListener("elementReplaced", this, false);
91 this.eventManager.addEventListener("selectAll", this, false); 84 this.eventManager.addEventListener("selectAll", this, false);
92
93 this.addPropertyChangeListener("currentDocument.model.domContainer", this);
94 }
95 },
96
97 handleChange: {
98 value: function() {
99 if(this.ignoreFlag) {
100 if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) {
101 if(this.currentDocument.model.getProperty("domContainer") !== null) {
102 this.executeSelectElement();
103 }
104 }
105 } else {
106 this.ignoreFlag = true;
107 }
108 } 85 }
109 }, 86 },
110 87
@@ -134,7 +111,7 @@ exports.SelectionController = Montage.create(Component, {
134 value: function(event) { 111 value: function(event) {
135 var selected = [], childNodes = [], self = this; 112 var selected = [], childNodes = [], self = this;
136 113
137 childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes; 114 childNodes = this.currentDocument.model.domContainer.childNodes;
138 childNodes = Array.prototype.slice.call(childNodes, 0); 115 childNodes = Array.prototype.slice.call(childNodes, 0);
139 childNodes.forEach(function(item) { 116 childNodes.forEach(function(item) {
140 if(self.isNodeTraversable(item)) { 117 if(self.isNodeTraversable(item)) {
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html
index 00740ea9..405f57da 100755
--- a/js/ninja.reel/ninja.html
+++ b/js/ninja.reel/ninja.html
@@ -291,8 +291,7 @@
291 "selectionController": { 291 "selectionController": {
292 "prototype": "js/controllers/selection-controller", 292 "prototype": "js/controllers/selection-controller",
293 "bindings" : { 293 "bindings" : {
294 "currentDocument": {"<-": "@documentList.selectedObjects.0"}, 294 "currentDocument": {"<-": "@documentList.selectedObjects.0"}
295 "selectedElements": {"<-": "@documentList.selectedObjects.0.model.selection"}
296 } 295 }
297 }, 296 },
298 297
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 493f4aa2..8b644d4a 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -228,6 +228,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
228 } else { 228 } else {
229 this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot; 229 this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot;
230 } 230 }
231 this.application.ninja.selectionController.executeSelectElement();
231 } 232 }
232 }, 233 },
233 234