aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/selection-controller.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-04 10:20:57 -0700
committerValerio Virgillito2012-06-04 10:20:57 -0700
commitc1ec69879028220b0c3f11ad6e24035bf527802c (patch)
tree043bfe4ec9e08f4f598a4845ae5fbcddacc7c8fb /js/controllers/selection-controller.js
parent3abba04025dbc0daadb08184833a2558c442b8e1 (diff)
parent266460e52831c5b3a3473be420756fd88bb8aced (diff)
downloadninja-c1ec69879028220b0c3f11ad6e24035bf527802c.tar.gz
Merge pull request #264 from mencio/document-bindings-fix
Document bindings fix - Changing the documents architecture to use bindings instead of events
Diffstat (limited to 'js/controllers/selection-controller.js')
-rwxr-xr-xjs/controllers/selection-controller.js100
1 files changed, 59 insertions, 41 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 75bffc5c..4bca0755 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,9 +20,65 @@ exports.SelectionController = Montage.create(Component, {
20 } 20 }
21 }, 21 },
22 22
23 /* 23 _currentDocument: {
24 * Bound property to the ninja currentSelectedContainer 24 value : null
25 */ 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 && this._currentDocument.currentView === "design") {
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 /*
44 if(!value) {
45 } else if(this._currentDocument.currentView === "design") {
46 } else {
47 }
48 */
49
50 }
51 },
52
53 _selectedElements: {
54 value: null
55 },
56
57 selectedElements: {
58 get: function() {
59 return this._selectedElements;
60 },
61 set: function(value) {
62 if(this.currentDocument && this.currentDocument.currentView === "code") return;
63
64 if(value) {
65 this._selectedElements = value;
66
67 this.application.ninja.selectedElements = this._selectedElements;
68 this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot;
69
70 if(this._selectedElements.length === 0) {
71 this.executeSelectElement();
72 } else {
73 this.executeSelectElement(this._selectedElements);
74 }
75
76
77 }
78 }
79 },
80
81 // Bound property to the ninja currentSelectedContainer
26 _selectionContainer: { 82 _selectionContainer: {
27 value: null 83 value: null
28 }, 84 },
@@ -42,48 +98,10 @@ exports.SelectionController = Montage.create(Component, {
42 98
43 deserializedFromTemplate: { 99 deserializedFromTemplate: {
44 value: function() { 100 value: function() {
45 this.eventManager.addEventListener("openDocument", this, false);
46 this.eventManager.addEventListener("elementAdded", this, false); 101 this.eventManager.addEventListener("elementAdded", this, false);
47 this.eventManager.addEventListener("elementsRemoved", this, false); 102 this.eventManager.addEventListener("elementsRemoved", this, false);
48 this.eventManager.addEventListener("elementReplaced", this, false); 103 this.eventManager.addEventListener("elementReplaced", this, false);
49 this.eventManager.addEventListener("selectAll", this, false); 104 this.eventManager.addEventListener("selectAll", this, false);
50 this.eventManager.addEventListener("switchDocument", this, false);
51 this.eventManager.addEventListener("closeDocument", this, false);
52 }
53 },
54
55 /**
56 * Get the current document selection array. If nothing is selected the currentSelectionArray should be null
57 */
58 handleOpenDocument: {
59 value: function() {
60 // Handle initializing the selection array here.
61 this.initWithDocument([]);
62 }
63 },
64
65 initWithDocument: {
66 value: function(currentSelectionArray) {
67 this._isDocument = true;
68
69 if(currentSelectionArray) {
70 this.application.ninja.selectedElements = currentSelectionArray;
71 if(currentSelectionArray.length) {
72 this._isDocument = false;
73 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument});
74 }
75 }
76
77 this._selectionContainer = this.application.ninja.currentSelectedContainer;
78 }
79 },
80
81 handleSwitchDocument: {
82 value: function() {
83// if(this.application.ninja.documentController.activeDocument.currentView === "design"){
84 this._isDocument = this.application.ninja.selectedElements.length === 0;
85 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
86// }
87 } 105 }
88 }, 106 },
89 107