From 8bea1e0807f36595d762592c030d4810396ada85 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 2 May 2012 15:30:27 -0700 Subject: CSS Panel - Add focus management to styles view delegate --- .../css-panel/declaration.reel/declaration.js | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'js/panels/css-panel/declaration.reel/declaration.js') diff --git a/js/panels/css-panel/declaration.reel/declaration.js b/js/panels/css-panel/declaration.reel/declaration.js index 873d2ce4..8ab19ad6 100644 --- a/js/panels/css-panel/declaration.reel/declaration.js +++ b/js/panels/css-panel/declaration.reel/declaration.js @@ -9,6 +9,9 @@ var Montage = require("montage/core/core").Montage, ShorthandProps = require("js/panels/CSSPanel/css-shorthand-map"); exports.Declaration = Montage.create(Component, { + cssText : { + value: null + }, focusDelegate : { value: null }, @@ -42,6 +45,8 @@ exports.Declaration = Montage.create(Component, { set: function(dec) { this._declaration = dec; + this.cssText = dec.cssText; + ///// creates data structure to use with tree component this.buildStyleTree(); @@ -52,11 +57,34 @@ exports.Declaration = Montage.create(Component, { "isEmpty": true }); } -//debugger; + this.needsDraw = true; } }, + update : { + value: function() { + if(this.declaration.cssText !== this.cssText) { + ///// Needs update + this.treeController.branchControllers[0].content.forEach(function(obj) { + this.treeController.branchControllers[0].removeObjects(obj); + }, this ); + + this.buildStyleTree(); + + if(this.includeEmptyStyle) { + this.styleTree.properties.push({ + "name": "property", + "value" : "value", + "isEmpty": true + }); + } +//debugger; + this.needsDraw = true; + } + } + }, + buildStyleTree : { value: function() { var styles = Array.prototype.slice.call(this._declaration).sort(); @@ -124,8 +152,6 @@ exports.Declaration = Montage.create(Component, { addNewStyleAfter : { value: function(style) { - //this.treeController.branchControllers[0].addObjects({ - foo1 = style.parentComponent.parentComponent; style.parentComponent.parentComponent.contentController.addObjects({ name: 'property', value: 'value', -- cgit v1.2.3