Skip to content

Instantly share code, notes, and snippets.

@pomack
Created October 11, 2013 14:40
Show Gist options
  • Save pomack/6935837 to your computer and use it in GitHub Desktop.
Save pomack/6935837 to your computer and use it in GitHub Desktop.
var standardSettings = {
'imageGetJson': '/api/v1/json/upload/images/list/@@company_id@@/?t=redactor',
'imageUpload': '/api/v1/json/upload/images/company/@@company_id@@/',
'source': false,
'css': '/static/survey/take/css/survey.css',
'minHeight': 100,
'buttons': [
'html', '|', 'formatting', '|', 'bold', 'italic', 'underline', '|',
'unorderedlist', 'orderedlist', 'outdent', 'indent', '|',
'image', 'table', 'link', '|',
'fontcolor', 'backcolor', '|', 'alignleft', 'aligncenter', 'alignright', 'justify', '|', 'horizontalrule'
// other options: ['deleted', 'alignment', 'video']
],
'allowedTags': [
"code", "span", "div", "label", "a", "br", "p", "b", "i", "del", "strike", "u",
"img", "blockquote",
"mark", "cite", "small", "ul", "ol", "li", "hr", "dl", "dt", "dd", "sup", "sub",
"big", "pre", "code", "figure", "figcaption", "strong", "em", "table", "tr", "td",
"th", "tbody", "thead", "tfoot", "h1", "h2", "h3", "h4", "h5", "h6"
// other options: ["video", "audio", "iframe", "object", "embed", "param"]
]
};
function setup(companyId, redactorClassName) {
if(!jQuery.fn.redactor) {
return;
}
if(companyId) {
standardSettings.imageGetJson = standardSettings.imageGetJson.replace('@@company_id@@', companyId);
standardSettings.imageUpload = standardSettings.imageUpload.replace('@@company_id@@', companyId);
} else {
standardSettings.imageGetJson = standardSettings.imageGetJson.replace('/@@company_id@@', '')
}
redactorClassName = redactorClassName || 'redactor';
jQuery('textarea.' + redactorClassName).redactor(standardSettings);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment