From af4dac82d2e76fe90191d6c085740d855bf961f3 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 8 May 2012 09:43:57 -0700 Subject: Style sheets - Added default stylesheet selection --- .../style-sheets-view.reel/style-sheets-view.css | 10 +++-- .../style-sheets-view.reel/style-sheets-view.js | 44 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.css b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.css index a3e13c77..a6e83a2c 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.css +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.css @@ -12,7 +12,10 @@ .style-sheets-view-container .sheet-list { margin: 0; padding: 0; - min-height: 55px; + min-height: 35px; + -webkit-box-flex: 1; + overflow-y: auto; + overflow-x: hidden; } .style-sheets-view-container .sheet-list li { list-style-type: none; @@ -30,10 +33,11 @@ ------------------- */ .style-sheets-toolbar-container { - bottom: 0; + /*bottom: 0;*/ height: 24px; - position: absolute; + /*position: absolute;*/ width: 100%; + -webkit-box-flex: 0; } /* ------------------ 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 2d6e18ed..b2d2c0fb 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 @@ -13,6 +13,7 @@ exports.StyleSheetsView = Montage.create(Component, { stylesController : { value: null }, styleSheets : { value: [] }, _initView : { value: false }, + _needsScroll : { value: false }, documentNameLabel : { value: null }, noDocumentLabelClass : { value: "no-document" }, @@ -28,6 +29,29 @@ exports.StyleSheetsView = Montage.create(Component, { this.needsDraw = true; } }, + _defaultStyleSheet: { value: null }, + defaultStyleSheet: { + get: function() { + return this._defaultStyleSheet; + }, + set: function(sheet) { + if(sheet === this._defaultStyleSheet) { return false; } + + var sheetComponent, oldDefaultSheet; + + if(this.styleSheetList) { + sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)]; + sheetComponent.default = true; + if(this._defaultStyleSheet) { + oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; + oldDefaultSheet.default = false; + } + } + + this._defaultStyleSheet = sheet; + this.needsDraw = true; + } + }, /// Toolbar Button Actions /// -------------------------------- @@ -36,6 +60,8 @@ exports.StyleSheetsView = Montage.create(Component, { handleAddAction : { value: function(e) { this.stylesController.createStylesheet(); + this.needsDraw = this._needsScroll = true; + } }, @@ -46,6 +72,13 @@ exports.StyleSheetsView = Montage.create(Component, { value: function(e) { this.documentName = this.stylesController.activeDocument.name; this.styleSheets = this.stylesController.userStyleSheets; + + Object.defineBinding(this, 'defaultStyleSheet', { + 'boundObject': this.stylesController, + 'boundObjectPropertyPath': 'defaultStylesheet', + 'oneway': false + }); + this._initView = this.needsDraw = true; } }, @@ -81,6 +114,17 @@ exports.StyleSheetsView = Montage.create(Component, { } else { this.documentNameLabel.classList.add(this.noDocumentLabelClass); } + + if(this._needsScroll) { + + setTimeout(function() { + console.log('setting scroll top to:', this.styleSheetList.element.scrollHeight); + //debugger; + this.styleSheetList.element.scrollTop = this.styleSheetList.element.scrollHeight; + }.bind(this), 50); + + this._needsScroll = false; + } } }, didDraw: { -- cgit v1.2.3