aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorEric Guzman2012-05-18 14:35:09 -0700
committerEric Guzman2012-05-18 14:35:09 -0700
commit4553f48aa17024922569faea1f62e9251a0c0185 (patch)
treee9a45423fd9f0e8ea3e93315402a829224df09e7 /js
parente196cb6fb32eba15156488938c8289568a6e2b88 (diff)
downloadninja-4553f48aa17024922569faea1f62e9251a0c0185.tar.gz
Style sheets - Add support for removing default style sheet
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/styles-controller.js20
-rw-r--r--js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js5
2 files changed, 20 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
diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
index 383fc467..d6ec5349 100644
--- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
+++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js
@@ -37,6 +37,11 @@ exports.StyleSheetsView = Montage.create(Component, {
37 set: function(sheet) { 37 set: function(sheet) {
38 if(sheet === this._defaultStyleSheet) { return false; } 38 if(sheet === this._defaultStyleSheet) { return false; }
39 39
40 if(sheet === null) {
41 this._defaultStyleSheet = null;
42 return;
43 }
44
40 var sheetComponent, oldDefaultSheet; 45 var sheetComponent, oldDefaultSheet;
41 46
42 if(this.styleSheetList) { 47 if(this.styleSheetList) {