Addresses #1021 mostly by adding label tags, generating unique element ids as needed. In the process, moved the label text that gets set in the ___ContentTypeView.js files to the respective handlebar templates; the text was static as far as I could tell. There are additional minor 508 improvements that can be made with the tables (scope tags, header attributes)
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
Handlebars.registerHelper('sanitize', function(html) {
|
|
// Strip the script tags from the html, and return it as a Handlebars.SafeString
|
|
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
|
|
return new Handlebars.SafeString(html);
|
|
});
|
|
|
|
Handlebars.registerHelper('renderTextParam', function(param) {
|
|
var result, type = 'text', idAtt = '';
|
|
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
|
|
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
|
|
|
|
if (typeof defaultValue === 'undefined') {
|
|
defaultValue = '';
|
|
}
|
|
|
|
if(param.format && param.format === 'password') {
|
|
type = 'password';
|
|
}
|
|
|
|
if(param.valueId) {
|
|
idAtt = ' id=\'' + param.valueId + '\'';
|
|
}
|
|
|
|
if(isArray) {
|
|
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt;
|
|
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';
|
|
result += defaultValue + '</textarea>';
|
|
} else {
|
|
var parameterClass = 'parameter';
|
|
if(param.required) {
|
|
parameterClass += ' required';
|
|
}
|
|
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
|
|
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt;
|
|
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
|
|
}
|
|
return new Handlebars.SafeString(result);
|
|
});
|