diff options
author | Jose Antonio Marquez Russo | 2012-07-24 17:15:30 -0700 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-07-24 17:15:30 -0700 |
commit | 98b098942d0f0c46d645879972e1cd47a09436d5 (patch) | |
tree | c350756f9295835bdf39e8d3afc2178ed67ec649 /js/controllers/styles-controller.js | |
parent | 3ec902504a7188b6468d93e9ec194bb97af6222f (diff) | |
parent | 80ff3adb07eff80e30a073d578b6273bd515bb4e (diff) | |
download | ninja-98b098942d0f0c46d645879972e1cd47a09436d5.tar.gz |
Merge pull request #45 from mencio/document-switch
Document switch fixes
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-x | js/controllers/styles-controller.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 21321f6d..0e1df1e9 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.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 | }, |