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/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 + 7 files changed, 46 insertions(+), 57 deletions(-) (limited to 'js/panels/css-panel') 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; + var declarationComponent = this.parentComponent.parentComponent.parentComponent + return declarationComponent.rule; } }, diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.html b/js/panels/css-panel/style-sheet.reel/style-sheet.html index ca24487d..788cafcc 100644 --- a/js/panels/css-panel/style-sheet.reel/style-sheet.html +++ b/js/panels/css-panel/style-sheet.reel/style-sheet.html @@ -20,7 +20,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "editButton": {"@": "editButton"}, "editView": {"#": "style-sheet-edit"}, "disableButton": {"@": "disableButton"}, - "importButton": {"@": "importButton"}, "deleteButton": {"@": "deleteButton"} } }, @@ -74,20 +73,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot "listener": {"@": "owner"} }] - }, - "importButton": { - "module": "montage/ui/button.reel", - "name": "Button", - "properties": { - "element": {"#": "import-button"}, - "identifier": "importButton", - "label": "Import" - }, - "listeners": [{ - "type": "action", - "listener": {"@": "owner"} - }] - }, "deleteButton": { "module": "montage/ui/button.reel", @@ -118,7 +103,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot - diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.js b/js/panels/css-panel/style-sheet.reel/style-sheet.js index 0ff195d5..a3326275 100644 --- a/js/panels/css-panel/style-sheet.reel/style-sheet.js +++ b/js/panels/css-panel/style-sheet.reel/style-sheet.js @@ -11,6 +11,10 @@ exports.StyleSheet = Montage.create(Component, { _translateDistance: { value: null }, + viewContainer : { + value: null, + serializable: true + }, prepareForDraw : { value: function() { @@ -43,14 +47,6 @@ exports.StyleSheet = Montage.create(Component, { this.editView.style.removeProperty(transStr); } - if(this._readOnly) { - this._element.classList.add('ss-locked'); - this.importButton.element.classList.remove('ss-invisible'); - } else { - this._element.classList.remove('ss-locked'); - this.importButton.element.classList.add('ss-invisible'); - } - if(this.default) { this._element.classList.add('default-style-sheet'); } else { @@ -73,10 +69,7 @@ exports.StyleSheet = Montage.create(Component, { var nonBlurringElements = [ this.editView, this.deleteButton.element, - this.disableButton.element, - this.importButton.element]; - - console.log("handle mousedown"); + this.disableButton.element]; if(nonBlurringElements.indexOf(e.target) === -1) { this.editing = false; @@ -112,7 +105,7 @@ exports.StyleSheet = Montage.create(Component, { handleDeleteButtonAction : { value: function(e) { e.stopPropagation(); - debugger; + this.parentComponent.parentComponent.handleDeleteAction(this); } }, @@ -208,6 +201,8 @@ exports.StyleSheet = Montage.create(Component, { return this._source; }, set: function(sheet) { + if(!sheet || sheet === this._source) { return; } + console.log('sheet being set: ', this); this._extractData(sheet.ownerNode); diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.html b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.html index 6e1638a6..bbefc69b 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.html +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.html @@ -11,16 +11,14 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot