From 197a7646e472fcea616764685c8d03c6063e66f5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 18 May 2012 14:05:06 -0700 Subject: CSS Panel - Add support for deleting style sheets --- js/controllers/styles-controller.js | 23 +++++++++++++++++++- js/panels/css-panel/css-panel.reel/css-panel.html | 3 ++- js/panels/css-panel/css-style.reel/css-style.js | 13 ++--------- .../css-panel/style-sheet.reel/style-sheet.html | 16 -------------- .../css-panel/style-sheet.reel/style-sheet.js | 21 +++++++----------- .../style-sheets-view.reel/style-sheets-view.html | 24 +++++++-------------- .../style-sheets-view.reel/style-sheets-view.js | 25 ++++++++++++++++++++++ .../styles-view-container.html | 1 + 8 files changed, 68 insertions(+), 58 deletions(-) diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index f6977a00..c5076771 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -821,7 +821,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// method to apply/test the new value dec.setProperty(property, value, priority); - if(rule.parentStyleSheet) { + if(rule.type !== 'inline' && rule.parentStyleSheet) { this.styleSheetModified(rule.parentStyleSheet); } @@ -1289,6 +1289,27 @@ var stylesController = exports.StylesController = Montage.create(Component, { return sheet; } }, + + ///// Remove Style sheet + ///// Removes style sheet from document + + removeStyleSheet : { + value: function(sheet) { + var sheetEl = sheet.ownerNode; + + if(sheetEl) { + sheetEl.disabled = true; + this.userStyleSheets.splice(this.userStyleSheets.indexOf(sheet), 1); + + ///// Mark for removal for i/o + sheetEl.setAttribute('data-ninja-remove', 'true'); + + NJevent('removeStyleSheet', sheet); + } + + + } + }, ///// Gets the stylesheet object associated with passed-in ///// element or element id, with option context (document) diff --git a/js/panels/css-panel/css-panel.reel/css-panel.html b/js/panels/css-panel/css-panel.reel/css-panel.html index 5bc5c87d..54bb1fae 100644 --- a/js/panels/css-panel/css-panel.reel/css-panel.html +++ b/js/panels/css-panel/css-panel.reel/css-panel.html @@ -15,7 +15,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "name" : "CSSPanelNew", "properties" : { "element" : {"#" : "container"}, - "styleSheetsView": {"@": "styleSheetsView"} + "styleSheetsView": {"@": "styleSheetsView"}, + "stylesViewContainer": {"@": "stylesViewContainer"} } }, diff --git a/js/panels/css-panel/css-style.reel/css-style.js b/js/panels/css-panel/css-style.reel/css-style.js index 3a07f8f1..1787665f 100644 --- a/js/panels/css-panel/css-style.reel/css-style.js +++ b/js/panels/css-panel/css-style.reel/css-style.js @@ -143,17 +143,8 @@ exports.CssStyle = Montage.create(Component, { getRule : { value: function() { - //var declarationComponent = this.treeView.parentComponent, - var declarationComponent = this.parentComponent.parentComponent.parentComponent, - rule; - - if(declarationComponent.type === 'inline') { - rule = { style : declarationComponent.declaration } - } else { - rule = this.parentComponent.parentComponent.parentComponent.declaration.parentRule; - } - - return rule; +