diff options
author | Eric Guzman | 2012-05-08 09:43:57 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-08 09:43:57 -0700 |
commit | af4dac82d2e76fe90191d6c085740d855bf961f3 (patch) | |
tree | be1eb3c1cab11bc8711f92c6a47a3fa6c46c07e7 /js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | |
parent | a62f57cf6beee332ff60a48f5e26d0084b4a5432 (diff) | |
download | ninja-af4dac82d2e76fe90191d6c085740d855bf961f3.tar.gz |
Style sheets - Added default stylesheet selection
Diffstat (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js')
-rw-r--r-- | js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | 44 |
1 files changed, 44 insertions, 0 deletions
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, { | |||
13 | stylesController : { value: null }, | 13 | stylesController : { value: null }, |
14 | styleSheets : { value: [] }, | 14 | styleSheets : { value: [] }, |
15 | _initView : { value: false }, | 15 | _initView : { value: false }, |
16 | _needsScroll : { value: false }, | ||
16 | documentNameLabel : { value: null }, | 17 | documentNameLabel : { value: null }, |
17 | noDocumentLabelClass : { value: "no-document" }, | 18 | noDocumentLabelClass : { value: "no-document" }, |
18 | 19 | ||
@@ -28,6 +29,29 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
28 | this.needsDraw = true; | 29 | this.needsDraw = true; |
29 | } | 30 | } |
30 | }, | 31 | }, |
32 | _defaultStyleSheet: { value: null }, | ||
33 | defaultStyleSheet: { | ||
34 | get: function() { | ||
35 | return this._defaultStyleSheet; | ||
36 | }, | ||
37 | set: function(sheet) { | ||
38 | if(sheet === this._defaultStyleSheet) { return false; } | ||
39 | |||
40 | var sheetComponent, oldDefaultSheet; | ||
41 | |||
42 | if(this.styleSheetList) { | ||
43 | sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)]; | ||
44 | sheetComponent.default = true; | ||
45 | if(this._defaultStyleSheet) { | ||
46 | oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; | ||
47 | oldDefaultSheet.default = false; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | this._defaultStyleSheet = sheet; | ||
52 | this.needsDraw = true; | ||
53 | } | ||
54 | }, | ||
31 | 55 | ||
32 | /// Toolbar Button Actions | 56 | /// Toolbar Button Actions |
33 | /// -------------------------------- | 57 | /// -------------------------------- |
@@ -36,6 +60,8 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
36 | handleAddAction : { | 60 | handleAddAction : { |
37 | value: function(e) { | 61 | value: function(e) { |
38 | this.stylesController.createStylesheet(); | 62 | this.stylesController.createStylesheet(); |
63 | this.needsDraw = this._needsScroll = true; | ||
64 | |||
39 | } | 65 | } |
40 | }, | 66 | }, |
41 | 67 | ||
@@ -46,6 +72,13 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
46 | value: function(e) { | 72 | value: function(e) { |
47 | this.documentName = this.stylesController.activeDocument.name; | 73 | this.documentName = this.stylesController.activeDocument.name; |
48 | this.styleSheets = this.stylesController.userStyleSheets; | 74 | this.styleSheets = this.stylesController.userStyleSheets; |
75 | |||
76 | Object.defineBinding(this, 'defaultStyleSheet', { | ||
77 | 'boundObject': this.stylesController, | ||
78 | 'boundObjectPropertyPath': 'defaultStylesheet', | ||
79 | 'oneway': false | ||
80 | }); | ||
81 | |||
49 | this._initView = this.needsDraw = true; | 82 | this._initView = this.needsDraw = true; |
50 | } | 83 | } |
51 | }, | 84 | }, |
@@ -81,6 +114,17 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
81 | } else { | 114 | } else { |
82 | this.documentNameLabel.classList.add(this.noDocumentLabelClass); | 115 | this.documentNameLabel.classList.add(this.noDocumentLabelClass); |
83 | } | 116 | } |
117 | |||
118 | if(this._needsScroll) { | ||
119 | |||
120 | setTimeout(function() { | ||
121 | console.log('setting scroll top to:', this.styleSheetList.element.scrollHeight); | ||
122 | //debugger; | ||
123 | this.styleSheetList.element.scrollTop = this.styleSheetList.element.scrollHeight; | ||
124 | }.bind(this), 50); | ||
125 | |||
126 | this._needsScroll = false; | ||
127 | } | ||
84 | } | 128 | } |
85 | }, | 129 | }, |
86 | didDraw: { | 130 | didDraw: { |