META-INF.resources.webjars.skeleton.js.generic-renderers.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of skeleton Show documentation
Show all versions of skeleton Show documentation
Common components for webapps
var tooltipRenderer = function (data, cell, record, rowIndex, columnIndex, store) {
if (!!data) {
cell.tdAttr += ' data-qtip="' + Ext.String.htmlEncode(data) + '"';
}
return data;
}
var tooltipWrapperRenderer = function (rendererFunction) {
return function () {
var toDisplay = rendererFunction.apply(this, arguments);
return tooltipRenderer.apply(this, [toDisplay].concat(Array.prototype.slice.call(arguments, 1)));
}
}
var nullableRenderer = function (rendererFunction) {
return function (data) {
if (!data) {
return "N/A";
}
return rendererFunction.apply(this, arguments);
}
}
var twoDigitsNumberRenderer = function (data, cell, record, rowIndex, columnIndex, store) {
return Ext.util.Format.number(data, "0.00");
};
var percentRenderer = function (data, cell, record, rowIndex, columnIndex, store) {
return (data >= 0 ? "+" : "") + Ext.util.Format.number(data, "0.00%")
};
var renderListAsTable = function (list) {
var header = ''
var body = '';
for (var i = 0; i != list.length; ++i) {
body += '' + list[i] + ' ';
}
var footer = '
';
return header + body + footer;
}
var renderObjectDetailsAsTable = function (obj) {
var header = ''
var body = '';
for (var propt in obj) {
body += '' + propt + ' ' + obj[propt] + ' ';
}
var footer = '
';
return header + body + footer;
}
var errorsToText = function (errors) {
return "" + (errors || []).map(function (e) {
return Ext.String.format("- {0}{1}{2}
", e.context && (Ext.htmlEncode(e.context) + ":"), Ext.htmlEncode(e.reason), e.details && (" - " + Ext.htmlEncode(e.details)));
}).join("\n") + "
";
}