aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-xjs/controllers/styles-controller.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index c5076771..00d67b89 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -173,13 +173,17 @@ var stylesController = exports.StylesController = Montage.create(Component, {
173 173
174 addRule : { 174 addRule : {
175 value : function(selector, declaration, stylesheet, index) { 175 value : function(selector, declaration, stylesheet, index) {
176 //console.log("Add rule"); 176 stylesheet = stylesheet || this._defaultStylesheet;
177
178 if(stylesheet === null) {
179 stylesheet = this.defaultStylesheet = this.createStylesheet();
180 }
181
177 var rulesLength = this._defaultStylesheet.rules.length, 182 var rulesLength = this._defaultStylesheet.rules.length,
178 argType = (typeof declaration), 183 argType = (typeof declaration),
179 ruleText = selector, 184 ruleText = selector,
180 stylesheet = stylesheet || this._defaultStylesheet, 185 rule;
181 property, rule; 186
182
183 index = index || (argType === 'number') ? declaration : rulesLength; 187 index = index || (argType === 'number') ? declaration : rulesLength;
184 188
185 if(argType === 'string') { 189 if(argType === 'string') {
@@ -1295,12 +1299,18 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1295 1299
1296 removeStyleSheet : { 1300 removeStyleSheet : {
1297 value: function(sheet) { 1301 value: function(sheet) {
1298 var sheetEl = sheet.ownerNode; 1302 var sheetEl = sheet.ownerNode, sheetCount;
1299 1303
1300 if(sheetEl) { 1304 if(sheetEl) {
1301 sheetEl.disabled = true; 1305 sheetEl.disabled = true;
1302 this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1); 1306 this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1);
1303 1307
1308 ///// Check to see if we're removing the default style sheet
1309 if(sheet === this._defaultStylesheet) {
1310 sheetCount = this.userStyleSheets.length;
1311 this.defaultStylesheet = (sheetCount) ? this.userStyleSheets[sheetCount-1] : null;
1312 }
1313
1304 ///// Mark for removal for i/o 1314 ///// Mark for removal for i/o
1305 sheetEl.setAttribute('data-ninja-remove', 'true'); 1315 sheetEl.setAttribute('data-ninja-remove', 'true');
1306 1316