OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This implements a table header. | 6 * @fileoverview This implements a table header. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('cr.ui.table', function() { | 9 cr.define('cr.ui.table', function() { |
10 const TableSplitter = cr.ui.TableSplitter; | 10 const TableSplitter = cr.ui.TableSplitter; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 var splitters = this.querySelectorAll('.table-header-splitter'); | 61 var splitters = this.querySelectorAll('.table-header-splitter'); |
62 var rtl = this.ownerDocument.defaultView.getComputedStyle(this) | 62 var rtl = this.ownerDocument.defaultView.getComputedStyle(this) |
63 .direction == 'rtl'; | 63 .direction == 'rtl'; |
64 for (var i = 0; i < cm.size - 1; i++) { | 64 for (var i = 0; i < cm.size - 1; i++) { |
65 leftPercent += cm.getWidth(i); | 65 leftPercent += cm.getWidth(i); |
66 splitters[i].style.left = rtl ? | 66 splitters[i].style.left = rtl ? |
67 100 - leftPercent + '%' : leftPercent + '%'; | 67 100 - leftPercent + '%' : leftPercent + '%'; |
68 } | 68 } |
69 }, | 69 }, |
70 | 70 |
71 batchCount_: 0, | |
72 | |
73 startBatchUpdates: function() { | |
74 this.batchCount_++; | |
75 }, | |
76 | |
77 endBatchUpdates: function() { | |
78 this.batchCount_--; | |
79 if (this.batchCount_ == 0) | |
80 this.redraw(); | |
81 }, | |
82 | |
83 /** | 71 /** |
84 * Redraws table header. | 72 * Redraws table header. |
85 */ | 73 */ |
86 redraw: function() { | 74 redraw: function() { |
87 if (this.batchCount_ != 0) | |
88 return; | |
89 | |
90 var cm = this.table_.columnModel; | 75 var cm = this.table_.columnModel; |
91 var dm = this.table_.dataModel; | 76 var dm = this.table_.dataModel; |
92 | 77 |
93 this.updateWidth(); | 78 this.updateWidth(); |
94 this.headerInner_.textContent = ''; | 79 this.headerInner_.textContent = ''; |
95 | 80 |
96 if (!cm || ! dm) { | 81 if (!cm || ! dm) { |
97 return; | 82 return; |
98 } | 83 } |
99 | 84 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 /** | 161 /** |
177 * The table associated with the header. | 162 * The table associated with the header. |
178 * @type {cr.ui.Table} | 163 * @type {cr.ui.Table} |
179 */ | 164 */ |
180 cr.defineProperty(TableHeader, 'table'); | 165 cr.defineProperty(TableHeader, 'table'); |
181 | 166 |
182 return { | 167 return { |
183 TableHeader: TableHeader | 168 TableHeader: TableHeader |
184 }; | 169 }; |
185 }); | 170 }); |
OLD | NEW |