aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/selection-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/selection-controller.js')
-rwxr-xr-xjs/controllers/selection-controller.js96
1 files changed, 55 insertions, 41 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 75bffc5c..a219c597 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,9 +20,61 @@ 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) {
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
77 // Bound property to the ninja currentSelectedContainer
26 _selectionContainer: { 78 _selectionContainer: {
27 value: null 79 value: null
28 }, 80 },
@@ -42,48 +94,10 @@ exports.SelectionController = Montage.create(Component, {
42 94
43 deserializedFromTemplate: { 95 deserializedFromTemplate: {
44 value: function() { 96 value: function() {
45 this.eventManager.addEventListener("openDocument", this, false);
46 this.eventManager.addEventListener("elementAdded", this, false); 97 this.eventManager.addEventListener("elementAdded", this, false);
47 this.eventManager.addEventListener("elementsRemoved", this, false); 98 this.eventManager.addEventListener("elementsRemoved", this, false);
48 this.eventManager.addEventListener("elementReplaced", this, false); 99 this.eventManager.addEventListener("elementReplaced", this, false);
49 this.eventManager.addEventListener("selectAll", this, false); 100 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 } 101 }
88 }, 102 },
89 103