From cbd4d317c354137cc3b5f74d1021ea00a3f5b779 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 17 Jul 2012 18:40:55 -0700 Subject: CSS Panel - Handle media attribute changes --- .../css-panel/style-sheet.reel/style-sheet.html | 3 +++ js/panels/css-panel/style-sheet.reel/style-sheet.js | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'js/panels/css-panel') 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 035bc760..01b5f20c 100644 --- a/js/panels/css-panel/style-sheet.reel/style-sheet.html +++ b/js/panels/css-panel/style-sheet.reel/style-sheet.html @@ -62,6 +62,9 @@ POSSIBILITY OF SUCH DAMAGE. "prototype": "js/components/textfield.reel[TextField]", "properties": { "element": {"#": "media-input"} + }, + "bindings": { + "value": {"<->": "@owner.mediaText"} } }, "editButton": { 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 b7df05a7..8a8e7dbf 100644 --- a/js/panels/css-panel/style-sheet.reel/style-sheet.js +++ b/js/panels/css-panel/style-sheet.reel/style-sheet.js @@ -71,6 +71,9 @@ exports.StyleSheet = Montage.create(Component, { prepareForDraw : { value: function() { this.nameText.element.addEventListener('click', this, false); + + //// Set the initial media text value + this.mediaText = this._source.media.mediaText; } }, @@ -89,8 +92,6 @@ exports.StyleSheet = Montage.create(Component, { value: function() { var transStr = '-webkit-transform'; - this.mediaInput.value = this._source.media.mediaText; - if(this.editing) { this.editView.classList.add('expanded'); this.editView.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)'); @@ -194,6 +195,21 @@ exports.StyleSheet = Montage.create(Component, { this._name = text; } }, + + _mediaText : { value: null }, + mediaText : { + get : function() { return this._mediaText; }, + set : function(value) { + if(value === this._mediaText) { return; } + + this._source.ownerNode.setAttribute('media', value); + + this._mediaText = value; + + this.needsDraw = true; + } + }, + _dirty : { value: null }, -- cgit v1.2.3