diff options
author | Eric Guzman | 2012-05-16 16:04:00 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-16 16:04:00 -0700 |
commit | b5439f436cac405c4bbf7e01ead9cee5dbc71a73 (patch) | |
tree | d4d6b96738ed13347d01a1c0a3ef00a718bdeaf0 /js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | |
parent | 62a47c22cf5fb76289a50be8e73de1ae8c55c78f (diff) | |
download | ninja-b5439f436cac405c4bbf7e01ead9cee5dbc71a73.tar.gz |
CSS Panel - Style sheets dirty flag added
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 | 41 |
1 files changed, 40 insertions, 1 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 b2d2c0fb..8131a619 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 | |||
@@ -17,6 +17,8 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
17 | documentNameLabel : { value: null }, | 17 | documentNameLabel : { value: null }, |
18 | noDocumentLabelClass : { value: "no-document" }, | 18 | noDocumentLabelClass : { value: "no-document" }, |
19 | 19 | ||
20 | dirtyStyleSheets: { value: null }, | ||
21 | |||
20 | _documentName : { value: null }, | 22 | _documentName : { value: null }, |
21 | documentName : { | 23 | documentName : { |
22 | get: function() { | 24 | get: function() { |
@@ -52,7 +54,21 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
52 | this.needsDraw = true; | 54 | this.needsDraw = true; |
53 | } | 55 | } |
54 | }, | 56 | }, |
55 | 57 | ||
58 | _dirtyStyleSheets : { value: null }, | ||
59 | dirtyStyleSheets : { | ||
60 | get: function() { | ||
61 | return this._dirtyStyleSheets; | ||
62 | }, | ||
63 | set: function(value) { | ||
64 | if(value === this._dirtyStyleSheets) { return false; } | ||
65 | |||
66 | this._dirtyStyleSheets = value; | ||
67 | |||
68 | this.needsDraw = true; | ||
69 | } | ||
70 | }, | ||
71 | |||
56 | /// Toolbar Button Actions | 72 | /// Toolbar Button Actions |
57 | /// -------------------------------- | 73 | /// -------------------------------- |
58 | 74 | ||
@@ -79,10 +95,22 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
79 | 'oneway': false | 95 | 'oneway': false |
80 | }); | 96 | }); |
81 | 97 | ||
98 | Object.defineBinding(this, 'dirtyStyleSheets', { | ||
99 | 'boundObject': this.stylesController, | ||
100 | 'boundObjectPropertyPath': 'dirtyStyleSheets', | ||
101 | 'oneway': true | ||
102 | }); | ||
103 | |||
82 | this._initView = this.needsDraw = true; | 104 | this._initView = this.needsDraw = true; |
83 | } | 105 | } |
84 | }, | 106 | }, |
85 | 107 | ||
108 | handleStyleSheetModified : { | ||
109 | value: function(e) { | ||
110 | this.needsDraw = true; | ||
111 | } | ||
112 | }, | ||
113 | |||
86 | /// Draw cycle | 114 | /// Draw cycle |
87 | /// -------------------------------- | 115 | /// -------------------------------- |
88 | 116 | ||
@@ -94,6 +122,7 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
94 | prepareForDraw : { | 122 | prepareForDraw : { |
95 | value: function() { | 123 | value: function() { |
96 | this.eventManager.addEventListener("styleSheetsReady", this, false); | 124 | this.eventManager.addEventListener("styleSheetsReady", this, false); |
125 | this.eventManager.addEventListener("styleSheetModified", this, false); | ||
97 | } | 126 | } |
98 | }, | 127 | }, |
99 | draw : { | 128 | draw : { |
@@ -115,6 +144,16 @@ exports.StyleSheetsView = Montage.create(Component, { | |||
115 | this.documentNameLabel.classList.add(this.noDocumentLabelClass); | 144 | this.documentNameLabel.classList.add(this.noDocumentLabelClass); |
116 | } | 145 | } |
117 | 146 | ||
147 | if(this.dirtyStyleSheets) { | ||
148 | var dirtySheets = this.dirtyStyleSheets.map(function(sheetDescriptor) { | ||
149 | return sheetDescriptor.stylesheet; | ||
150 | }); | ||
151 | |||
152 | this.styleSheetList.childComponents.forEach(function(sheetComponent) { | ||
153 | sheetComponent.dirty = dirtySheets.indexOf(sheetComponent.source) !== -1; | ||
154 | }, this); | ||
155 | } | ||
156 | |||
118 | if(this._needsScroll) { | 157 | if(this._needsScroll) { |
119 | 158 | ||
120 | setTimeout(function() { | 159 | setTimeout(function() { |