-
Notifications
You must be signed in to change notification settings - Fork 0
/
mobile-table.jsx
78 lines (67 loc) · 1.82 KB
/
mobile-table.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* =================================
Convert Table to Mobile that is housing a custom component
================================= */
class mobileTable extends React.Component {
constructor(props) {
super(props);
this.state = {
test: "Hello World",
};
}
foo = () => {
// document.getDocumentById(${param});
// var classSelector = document.querySelectorAll('.table');
// return param
};
componentDidMount() {
console.log($(".table"));
$(".table")
.not(".customTable")
.each(function () {
var table = $(this);
var row = table.find("tr");
var thText;
table.find("td").each(function () {
var tdIndex = $(this).index();
if ($(row).find("th").eq(tdIndex).attr("data-label")) {
thText = $(row).find("th").eq(tdIndex).data("label");
} else {
thText = $(row).find("th").eq(tdIndex).text();
}
$(this).attr("data-label", thText + ":");
});
});
}
render() {
return null;
}
}
manywho.component.register("js-pattern", mobileTable);
(function (manywho) {
class MobileTable extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
$(".table")
.not(".customTable")
.each(function () {
var table = $(this);
var row = table.find("tr");
var thText;
table.find("td").each(function () {
var tdIndex = $(this).index();
if ($(row).find("th").eq(tdIndex).attr("data-label")) {
thText = $(row).find("th").eq(tdIndex).data("label");
} else {
thText = $(row).find("th").eq(tdIndex).text();
}
$(this).attr("data-label", thText + ":");
});
});
}
render() {
return null;
}
}
}(manywho));