aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-31 10:27:46 -0700
committerValerio Virgillito2012-05-31 10:27:46 -0700
commite1fe603a7c002073f8ac13623f8cc8dc43efb59d (patch)
tree38d9f7e00cc4a7b181ebe0029eaadcb46c70afb8
parent5b982abcfe51278062c06fde5fa7e5371f6aef54 (diff)
downloadninja-e1fe603a7c002073f8ac13623f8cc8dc43efb59d.tar.gz
fixing selection when switching documents
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
-rwxr-xr-xjs/controllers/document-controller.js16
-rwxr-xr-xjs/controllers/selection-controller.js64
-rwxr-xr-xjs/document/models/base.js5
-rwxr-xr-xjs/document/models/html.js5
-rwxr-xr-xjs/ninja.reel/ninja.html4
-rwxr-xr-xjs/ninja.reel/ninja.js22
-rwxr-xr-xjs/panels/properties.reel/properties.js26
7 files changed, 88 insertions, 54 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 13ab33cc..c9557a57 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -53,9 +53,11 @@ exports.DocumentController = Montage.create(Component, {
53 document.getElementById("iframeContainer").style.display = "block"; 53 document.getElementById("iframeContainer").style.display = "block";
54 document.getElementById("codeViewContainer").style.display = "block"; 54 document.getElementById("codeViewContainer").style.display = "block";
55 } else if(this._currentDocument.currentView === "design") { 55 } else if(this._currentDocument.currentView === "design") {
56 56 this._currentDocument.model.currentView.show();
57 this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*');
57 } else { 58 } else {
58 document.getElementById("iframeContainer").style.display = "none"; 59 document.getElementById("iframeContainer").style.display = "none";
60 this._currentDocument.model.currentView.show();
59 } 61 }
60 62
61 } 63 }
@@ -354,14 +356,8 @@ exports.DocumentController = Montage.create(Component, {
354 if(currentDocument) { 356 if(currentDocument) {
355 if(currentDocument.currentView === "design") { 357 if(currentDocument.currentView === "design") {
356 currentDocument.serializeDocument(); 358 currentDocument.serializeDocument();
357 this.application.ninja._currentSelectedContainer = this.application.ninja.selectionController._selectionContainer = null;
358 currentDocument.model.views.design.propertiesPanel.clear();
359 } 359 }
360 360
361 currentDocument.model.isActive = false;
362
363 currentDocument.model.currentView.hide();
364
365 if(currentDocument.model.parentContainer !== newDocument.model.parentContainer) { 361 if(currentDocument.model.parentContainer !== newDocument.model.parentContainer) {
366 currentDocument.model.parentContainer.style["display"] = "none"; 362 currentDocument.model.parentContainer.style["display"] = "none";
367 newDocument.model.parentContainer.style["display"] = "block"; 363 newDocument.model.parentContainer.style["display"] = "block";
@@ -382,13 +378,9 @@ exports.DocumentController = Montage.create(Component, {
382 this.application.ninja.stage.hideRulers(); 378 this.application.ninja.stage.hideRulers();
383 } 379 }
384 380
385// this.application.ninja.stage.clearAllCanvas();
386
387 if(didCreate) { 381 if(didCreate) {
388// newDocument.model.currentView.show();
389
390 if(newDocument.currentView === "design") { 382 if(newDocument.currentView === "design") {
391 NJevent("onOpenDocument", newDocument); 383
392 } else { 384 } else {
393 newDocument.model.parentContainer.style["display"] = "block"; 385 newDocument.model.parentContainer.style["display"] = "block";
394 } 386 }
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 848355da..a219c597 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,6 +20,60 @@ exports.SelectionController = Montage.create(Component, {
20 } 20 }
21 }, 21 },
22 22
23 _currentDocument: {
24 value : null
25 },
26
27 currentDocument : {
28 get : function() {
29 return this._currentDocument;
30 },
31 set : function(value) {
32 if (value === this._currentDocument) {
33 return;
34 }
35
36 if(this._currentDocument) {
37 this._currentDocument.model.selection = this.application.ninja.selectedElements;
38 this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer;
39 }
40
41 this._currentDocument = value;
42
43 if(!value) {
44 } else if(this._currentDocument.currentView === "design") {
45 } else {
46 }
47
48 }
49 },
50
51 _selectedElements: {
52 value: null
53 },
54
55 selectedElements: {
56 get: function() {
57 return this._selectedElements;
58 },
59 set: function(value) {
60 if(value) {
61 this._selectedElements = value;
62
63 this.application.ninja.selectedElements = this._selectedElements;
64 this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot;
65
66 if(this._selectedElements.length === 0) {
67 this.executeSelectElement();
68 } else {
69 this.executeSelectElement(this._selectedElements);
70 }
71
72
73 }
74 }
75 },
76
23 // Bound property to the ninja currentSelectedContainer 77 // Bound property to the ninja currentSelectedContainer
24 _selectionContainer: { 78 _selectionContainer: {
25 value: null 79 value: null
@@ -44,16 +98,6 @@ exports.SelectionController = Montage.create(Component, {
44 this.eventManager.addEventListener("elementsRemoved", this, false); 98 this.eventManager.addEventListener("elementsRemoved", this, false);
45 this.eventManager.addEventListener("elementReplaced", this, false); 99 this.eventManager.addEventListener("elementReplaced", this, false);
46 this.eventManager.addEventListener("selectAll", this, false); 100 this.eventManager.addEventListener("selectAll", this, false);
47 this.eventManager.addEventListener("switchDocument", this, false);
48 }
49 },
50
51 handleSwitchDocument: {
52 value: function() {
53// if(this.application.ninja.documentController.activeDocument.currentView === "design"){
54 this._isDocument = this.application.ninja.selectedElements.length === 0;
55 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
56// }
57 } 101 }
58 }, 102 },
59 103
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 6d9d2e89..886a4ef0 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -62,6 +62,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
62 }, 62 },
63 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
64 // 64 //
65 selection: {
66 value: []
67 },
68 ////////////////////////////////////////////////////////////////////
69 //
65 fileTemplate: { 70 fileTemplate: {
66 value: null 71 value: null
67 }, 72 },
diff --git a/js/document/models/html.js b/js/document/models/html.js
index fd42d4de..9f5599a2 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -19,11 +19,6 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
19 }, 19 },
20 //////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////
21 // 21 //
22 selection: {
23 value: []
24 },
25 ////////////////////////////////////////////////////////////////////
26 //
27 selectionContainer: { 22 selectionContainer: {
28 value: [] 23 value: []
29 }, 24 },
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html
index d9bebc36..031d68e9 100755
--- a/js/ninja.reel/ninja.html
+++ b/js/ninja.reel/ninja.html
@@ -278,7 +278,9 @@
278 "selectionController": { 278 "selectionController": {
279 "prototype": "js/controllers/selection-controller", 279 "prototype": "js/controllers/selection-controller",
280 "bindings" : { 280 "bindings" : {
281 "selectionContainer": {"<-": "@owner.currentSelectedContainer"} 281 "selectionContainer": {"<-": "@owner.currentSelectedContainer"},
282 "currentDocument": {"<-": "@documentList.selectedObjects.0"},
283 "selectedElements": {"<-": "@documentList.selectedObjects.0.model.selection"}
282 } 284 }
283 }, 285 },
284 286
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index 3c60bb41..4c1efff4 100755
--- a/js/ninja.reel/ninja.js
+++ b/js/ninja.reel/ninja.js
@@ -151,7 +151,6 @@ exports.Ninja = Montage.create(Component, {
151 } 151 }
152 }, 152 },
153 153
154
155 selectedElements: { 154 selectedElements: {
156 value: [] 155 value: []
157 }, 156 },
@@ -196,7 +195,6 @@ exports.Ninja = Montage.create(Component, {
196 195
197 this.eventManager.addEventListener("selectTool", this, false); 196 this.eventManager.addEventListener("selectTool", this, false);
198 this.eventManager.addEventListener("selectSubTool", this, false); 197 this.eventManager.addEventListener("selectSubTool", this, false);
199 this.eventManager.addEventListener("onSwitchDocument", this, false);
200 198
201 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false); 199 this.addPropertyChangeListener("appModel.livePreview", this.executeLivePreview, false);
202 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false); 200 this.addPropertyChangeListener("appModel.chromePreview", this.executeChromePreview, false);
@@ -311,15 +309,9 @@ exports.Ninja = Montage.create(Component, {
311 this.currentSelectedContainer = doc.model.documentRoot; 309 this.currentSelectedContainer = doc.model.documentRoot;
312 } 310 }
313 311
314// if(this.currentDocument.model.documentRoot) {
315// this.currentSelectedContainer = this.currentDocument.model.documentRoot;
316// } else {
317// alert("The current document has not loaded yet");
318// return;
319// }
320 312