diff options
author | Valerio Virgillito | 2012-07-31 15:18:51 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-31 15:18:51 -0700 |
commit | 4343e1f92547df9f7d42eecdf7e4feb47ad960e8 (patch) | |
tree | 27913b22fc5a899ae679013427d3cfe4b497837a /js/controllers | |
parent | d68ad5c4aa404f66303833367700983b8d7f5303 (diff) | |
parent | b391dde5f319bf4c534e9fce523c22be3bb16ace (diff) | |
download | ninja-4343e1f92547df9f7d42eecdf7e4feb47ad960e8.tar.gz |
Merge pull request #422 from joseeight/Document
Document Code View
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 26 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 34 |
2 files changed, 56 insertions, 4 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 588481bb..83c1f58c 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -68,7 +68,7 @@ exports.DocumentController = Montage.create(Component, { | |||
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | 70 | ||
71 | if(this._currentDocument) { | 71 | if(this._currentDocument && this._currentDocument.model.currentView) { |
72 | this._currentDocument.model.currentView.hide(); | 72 | this._currentDocument.model.currentView.hide(); |
73 | } | 73 | } |
74 | 74 | ||
@@ -80,17 +80,35 @@ exports.DocumentController = Montage.create(Component, { | |||
80 | } else if(this._currentDocument.currentView === "design") { | 80 | } else if(this._currentDocument.currentView === "design") { |
81 | document.getElementById("codeViewContainer").style.display = "none"; | 81 | document.getElementById("codeViewContainer").style.display = "none"; |
82 | document.getElementById("iframeContainer").style.display = "block"; | 82 | document.getElementById("iframeContainer").style.display = "block"; |
83 | this._currentDocument.model.currentView.show(); | 83 | this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); |
84 | if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); | ||
84 | this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); | 85 | this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); |
85 | } else { | 86 | } else { |
86 | document.getElementById("iframeContainer").style.display = "none"; | 87 | document.getElementById("iframeContainer").style.display = "none"; |
87 | this._currentDocument.model.parentContainer.style["display"] = "block"; | 88 | this._currentDocument.model.parentContainer.style["display"] = "block"; |
88 | this._currentDocument.model.currentView.show(); | 89 | if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); |
89 | } | 90 | } |
90 | 91 | ||
91 | } | 92 | } |
92 | }, | 93 | }, |
93 | 94 | ||
95 | handleChange: { | ||
96 | value: function(notification) { | ||
97 | if(notification.currentPropertyPath === "model.currentViewIdentifier") { | ||
98 | if(this.currentDocument.model.currentView.identifier === "design-code") { | ||
99 | // document.getElementById("iframeContainer").style.display = "none"; | ||
100 | // this._currentDocument.model.parentContainer.style["display"] = "block"; | ||
101 | // if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); | ||
102 | } else { | ||
103 | document.getElementById("codeViewContainer").style.display = "none"; | ||
104 | document.getElementById("iframeContainer").style.display = "block"; | ||
105 | if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); | ||
106 | this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | }, | ||
111 | |||
94 | deserializedFromTemplate: { | 112 | deserializedFromTemplate: { |
95 | value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name]) | 113 | value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name]) |
96 | this.eventManager.addEventListener("appLoaded", this, false); | 114 | this.eventManager.addEventListener("appLoaded", this, false); |
@@ -356,7 +374,7 @@ exports.DocumentController = Montage.create(Component, { | |||
356 | break; | 374 | break; |
357 | default: | 375 | default: |
358 | //Open in code view | 376 | //Open in code view |
359 | Montage.create(TextDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'code'); | 377 | Montage.create(TextDocument).init(file, this.application.ninja, this.application.ninja.openDocument, 'code', document.getElementById("codeViewContainer")); |
360 | break; | 378 | break; |
361 | } | 379 | } |
362 | } | 380 | } |
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 21321f6d..e95c6614 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -99,6 +99,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
99 | ///// setting document via binding | 99 | ///// setting document via binding |
100 | this._currentDocument = document; | 100 | this._currentDocument = document; |
101 | 101 | ||
102 | this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); | ||
103 | |||
102 | ///// Stage stylesheet should always be found | 104 | ///// Stage stylesheet should always be found |
103 | this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); | 105 | this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); |
104 | // Returns null if sheet not found (as in non-ninja projects) | 106 | // Returns null if sheet not found (as in non-ninja projects) |
@@ -126,6 +128,38 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
126 | enumerable : false | 128 | enumerable : false |
127 | }, | 129 | }, |
128 | 130 | ||
131 | handleChange: { | ||
132 | value: function(notification) { | ||
133 | if(notification.currentPropertyPath === "model.currentViewIdentifier") { | ||
134 | if(this.currentDocument && this.currentDocument.model.currentView.identifier === "design") { | ||
135 | ///// Stage stylesheet should always be found | ||
136 | this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); | ||
137 | // Returns null if sheet not found (as in non-ninja projects) | ||
138 | // Setter will handle null case | ||
139 | this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); | ||
140 | |||
141 | this.userStyleSheets = nj.toArray(this.currentDocument.model.views.design.document.styleSheets).filter(function(sheet) { | ||
142 | if(sheet === this._stageStylesheet) { return false; } | ||
143 | |||
144 | var media = sheet.ownerNode.getAttribute('media'); | ||
145 | |||
146 | ///// If the media attribute contains a query, we'll watch for changes in media | ||
147 | if(/\([0-9A-Za-z-: ]+\)/.test(media)) { | ||
148 | this.watchMedia(media); | ||
149 | } | ||
150 | |||
151 | return true; | ||
152 | |||
153 | }, this); | ||
154 | |||
155 | this.initializeRootStyles(); | ||
156 | |||
157 | NJevent('styleSheetsReady', this); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | }, | ||
162 | |||
129 | _mediaList : { | 163 | _mediaList : { |
130 | value: [] | 164 | value: [] |
131 | }, | 165 | }, |