var resetValues = {};
function resetValue(id,option) {
var text = resetValues[id];
if (option=="Reset") {
text = "\n" + text;
CKEDITOR.instances[id].setData(text);
} else if (option=="Convert") {
text = "\n" + text.replace(/\n/g, "
");
CKEDITOR.instances[id].setData(text);
} else if (option=="Revert") {
CKEDITOR.instances[id].destroy();
var obj = document.getElementById(id);
obj.value = text;
}
}
var sURLPREFIX = "/";
var sREVISIONPREFIX = "";
var sREVISIONPREFIXNOHOST = sREVISIONPREFIX.replace(sURLPREFIX,"");
//var revPrefixStr = ""; // separate so it is not replaced by HttpHandler.subst
function fitSaveCallback(id, html, body) {
// make sure the user did not delete the FIT_CK comment
if (html.indexOf("")<0) {
html = "" + html;
}
// get rid of REVISIONPREFIX (ie: smileys) as the revision number will change in future
// tried using revPrefixStr, but it was putting <REVISIONPREFIX> when changing from RTF to console
html = html.replace(sREVISIONPREFIX,"");
html = html.replace(sREVISIONPREFIXNOHOST,"");
return html;
}
var added=0;
function toggleEditor(id) {
if (typeof CKEDITOR !== 'undefined') {
var obj = document.getElementById(id);
if (!CKEDITOR.instances[id]) {
resetValues[id] = obj.value;
//convert any old TINY codes to CK
if (obj.value.indexOf("")>=0) {
obj.value = obj.value.replace("","");
}
if (obj.value.indexOf("")<0) { // make sure field starts with tag
if (obj.value.indexOf('\n') > -1) {
var q2 = confirm("You have existing text which does not appear to be from the RTF editor ("+id+"). All newlines will be removed by this editor.\n\nIf you do not like the result, use the custom FIT options (first icon) to convert your original text!\n\nContinue ?");
if (q2==false) {
return false;
}
}
obj.value = "" + obj.value;
//setCaretTo(obj,16); //does not seem to work on Firefox
}
//https://ckeditor.com/cke4/builder
CKEDITOR.replace(obj, {
//customConfig: '../../ckeditor_custom.js',
// Add the required plugin
//extraPlugins : 'pastebase64,fitops', - taking pastebase64 out since newer version already handles it
extraPlugins : 'fitops',
contentsCss: '/com/other/fit-ckeditor.css',
//enterMode: CKEDITOR.ENTER_BR,
} );
//var editor = CKEDITOR.instances[id];
//editor.on( 'paste', function( evt ) {
// var rtf = evt.data.dataTransfer.getData( 'application/rtf' );
// if ( rtf ) {
// evt.data.dataValue = rtfToHtml( rtf );
// }
//} );
} else {
CKEDITOR.instances[id].destroy();
if (!checkValidRtfContent(obj.value)) {
obj.value=""; // otherwise, nothing there - don't want to see FIT_TINY tag in regular console
}
}
}
}
function checkRtfTags() {
for(i=0; i")<0) {
str = "" + str;
CKEDITOR.instances[element.id].setData(str);
}
}
}
}
}
}
// initialize any that need it
function initTiny() {
//var count;
for(i=0; i0) { // testspec stuff prefixes with tc1, tr2, ..
def = def.substr(index);
}
if (rtfDefaultFields.indexOf(def)>=0) {
// defaults to rtf through settings
//setTimeout("toggleEditor('"+element.id+"');",10*count++);
var obj = document.getElementById(element.id);
if (obj.value.length == 0 || obj.value.indexOf("") >= 0 || obj.value.indexOf("") >= 0) {
//only enable editor if field is blank or contains rich text
toggleEditor(element.id);
}
} else if (element.id.length>0) {
var obj = document.getElementById(element.id);
if (obj && (obj.value.indexOf("")>=0 || obj.value.indexOf("")>=0) ) {
// defaults to rtf cause data was edited there before
toggleEditor(element.id);
}
}
}
}
}