Link helper class

This commit is contained in:
Zlatin Balevsky
2019-12-12 22:31:42 +00:00
parent 3747f9a5d5
commit a0fb07cf99

View File

@ -1,3 +1,15 @@
class Link {
constructor(text, call, params) {
this.text = text
this.call = call
this.params = params
}
render() {
return "<a href='#' onclick='window." + this.call +"(\"" + this.params.join("\",\"") + "\");return false;'>" + this.text + "</a>"
}
}
class Column {
constructor(key) {
this.key = key
@ -6,8 +18,8 @@ class Column {
render(descending, callback) {
var html = "<th>"
var linkText = _t(this.key)
var link = "<a href='#' onclick='" + callback + "(\"" + this.key + "\",\"" + descending + "\");return false;'>" + linkText + "</a>"
html += link + "</th>"
var link = new Link(linkText, callback, [this.key, descending])
html += link.render() + "</th>"
return html
}
}