Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: ui/webui/resources/js/cr/ui/table.js

Issue 2779663002: Compile cr.ui.Table and cr.ui.table.* in gyp v2 (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/js/cr/ui/table.js
diff --git a/ui/webui/resources/js/cr/ui/table.js b/ui/webui/resources/js/cr/ui/table.js
index 9e28e4c752e2361270ae2a7e037db70ffea79ea0..e6763eabf5a5a65fd54bb2ed6d0a0e5d37a1d9ee 100644
--- a/ui/webui/resources/js/cr/ui/table.js
+++ b/ui/webui/resources/js/cr/ui/table.js
@@ -129,7 +129,35 @@ cr.define('cr.ui', function() {
* @return {function(*, cr.ui.Table): HTMLElement} Render function.
*/
getRenderFunction: function() {
- return this.list_.renderFunction_;
+ return this.renderFunction_;
+ },
+
+ /**
+ * @private
+ */
+ renderFunction_: function(dataItem, table) {
+ // `This` must not be accessed here, since it may be anything, especially
+ // not a pointer to this object.
+
+ var cm = table.columnModel;
+ var listItem = cr.ui.List.prototype.createItem.call(table.list, '');
+ listItem.className = 'table-row';
+
+ for (var i = 0; i < cm.size; i++) {
+ var cell = table.ownerDocument.createElement('div');
+ cell.style.width = cm.getWidth(i) + 'px';
+ cell.className = 'table-row-cell';
+ if (cm.isEndAlign(i))
+ cell.style.textAlign = 'end';
+ cell.hidden = !cm.isVisible(i);
+ cell.appendChild(
+ cm.getRenderFunction(i).call(null, dataItem, cm.getId(i), table));
+
+ listItem.appendChild(cell);
+ }
+ listItem.style.width = cm.totalWidth + 'px';
+
+ return listItem;
},
/**
@@ -138,10 +166,10 @@ cr.define('cr.ui', function() {
* function.
*/
setRenderFunction: function(renderFunction) {
- if (renderFunction === this.list_.renderFunction_)
+ if (renderFunction === this.renderFunction_)
return;
- this.list_.renderFunction_ = renderFunction;
+ this.renderFunction_ = renderFunction;
cr.dispatchSimpleEvent(this, 'change');
},
« no previous file with comments | « ui/webui/resources/js/cr/ui/compiled_resources2.gyp ('k') | ui/webui/resources/js/cr/ui/table/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698