diff options
Diffstat (limited to 'js/controllers')
-rw-r--r-- | js/controllers/code-editor-controller.js | 1 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 22 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 64 |
3 files changed, 60 insertions, 27 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js index d0b1f179..d292f838 100644 --- a/js/controllers/code-editor-controller.js +++ b/js/controllers/code-editor-controller.js | |||
@@ -32,6 +32,7 @@ exports.CodeEditorController = Montage.create(Component, { | |||
32 | if(!value) { | 32 | if(!value) { |
33 | 33 | ||
34 | } else if(this._currentDocument.currentView === "code") { | 34 | } else if(this._currentDocument.currentView === "code") { |
35 | this._currentDocument.model.views.code.editor.focus(); | ||
35 | this.applySettings(); | 36 | this.applySettings(); |
36 | } | 37 | } |
37 | } | 38 | } |
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e059e7e1..f85e2f97 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -54,6 +54,7 @@ exports.DocumentController = Montage.create(Component, { | |||
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 | this._currentDocument.model.currentView.show(); | 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"; |
59 | this._currentDocument.model.currentView.show(); | 60 | this._currentDocument.model.currentView.show(); |
@@ -149,10 +150,10 @@ exports.DocumentController = Montage.create(Component, { | |||
149 | handleExecuteSave: { | 150 | handleExecuteSave: { |
150 | value: function(event) { | 151 | value: function(event) { |
151 | // | 152 | // |
152 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | 153 | if((typeof this.currentDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
153 | //Currently we don't need a callback handler | 154 | //Currently we don't need a callback handler |
154 | //this.activeDocument.model.save(this.saveExecuted.bind(this)); | 155 | //this.activeDocument.model.save(this.saveExecuted.bind(this)); |
155 | this.activeDocument.model.save(); | 156 | this.currentDocument.model.save(); |
156 | } else { | 157 | } else { |
157 | //Error: cloud not available and/or no active document | 158 | //Error: cloud not available and/or no active document |
158 | } | 159 | } |
@@ -193,16 +194,13 @@ exports.DocumentController = Montage.create(Component, { | |||
193 | //////////////////////////////////////////////////////////////////// | 194 | //////////////////////////////////////////////////////////////////// |
194 | handleExecuteFileClose:{ | 195 | handleExecuteFileClose:{ |
195 | value: function(event) { | 196 | value: function(event) { |
196 | if (this.activeDocument) { | 197 | this.closeFile(this.currentDocument); |
197 | this.closeFile(this.activeDocument); | ||
198 | } | ||
199 | } | 198 | } |
200 | }, | 199 | }, |
201 | //////////////////////////////////////////////////////////////////// | 200 | //////////////////////////////////////////////////////////////////// |
202 | //TODO: Is this used, should be cleaned up | 201 | //TODO: Is this used, should be cleaned up |
203 | handleExecuteFileCloseAll:{ | 202 | handleExecuteFileCloseAll:{ |
204 | value: function(event) { | 203 | value: function(event) { |
205 | var i=0;//TODO: who is using this?? | ||
206 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | 204 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ |
207 | while(this._documents.length > 0){ | 205 | while(this._documents.length > 0){ |
208 | this.closeDocument(this._documents[this._documents.length -1].uuid); | 206 | this.closeDocument(this._documents[this._documents.length -1].uuid); |
@@ -355,14 +353,8 @@ exports.DocumentController = Montage.create(Component, { | |||
355 | if(currentDocument) { | 353 | if(currentDocument) { |
356 | if(currentDocument.currentView === "design") { | 354 | if(currentDocument.currentView === "design") { |
357 | currentDocument.serializeDocument(); | 355 | currentDocument.serializeDocument(); |
358 | this.application.ninja._currentSelectedContainer = this.application.ninja.selectionController._selectionContainer = null; | ||
359 | currentDocument.model.views.design.propertiesPanel.clear(); | ||
360 | } | 356 | } |
361 | 357 | ||
362 | currentDocument.model.isActive = false; | ||
363 | |||
364 | currentDocument.model.currentView.hide(); | ||
365 | |||
366 | if(currentDocument.model.parentContainer !== newDocument.model.parentContainer) { | 358 | if(currentDocument.model.parentContainer !== newDocument.model.parentContainer) { |
367 | currentDocument.model.parentContainer.style["display"] = "none"; | 359 | currentDocument.model.parentContainer.style["display"] = "none"; |
368 | newDocument.model.parentContainer.style["display"] = "block"; | 360 | newDocument.model.parentContainer.style["display"] = "block"; |
@@ -383,13 +375,9 @@ exports.DocumentController = Montage.create(Component, { | |||
383 | this.application.ninja.stage.hideRulers(); | 375 | this.application.ninja.stage.hideRulers(); |
384 | } | 376 | } |
385 | 377 | ||
386 | // this.application.ninja.stage.clearAllCanvas(); | ||
387 | |||
388 | if(didCreate) { | 378 | if(didCreate) { |
389 | // newDocument.model.currentView.show(); | ||
390 | |||
391 | if(newDocument.currentView === "design") { | 379 | if(newDocument.currentView === "design") { |
392 | NJevent("onOpenDocument", newDocument); | 380 | |
393 | } else { | 381 | } else { |
394 | newDocument.model.parentContainer.style["display"] = "block"; | 382 | newDocument.model.parentContainer.style["display"] = "block"; |
395 | } | 383 | } |
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 | ||