function cRichTextEditor(){
this.emwindow = new Array;
this.editor = "body_1";
this.table = "";
this.id = "1";
this.saveFlag = 0;
this.signatures = false;
this.replyController = false;
this.newImageId = false;
this.plain = new Array;
this.editorReady = true;
this.hoho = '';
}
// This code was written by Tyler Akins and has been placed in the
// public domain. It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) {
var StringMaker = function () {
this.str = "";
this.length = 0;
this.append = function (s) {
this.str += s;
this.length += s.length;
}
this.prepend = function (s) {
this.str = s + this.str;
this.length += s.length;
}
this.toString = function () {
return this.str;
}
}
} else {
var StringMaker = function () {
this.parts = [];
this.length = 0;
this.append = function (s) {
this.parts.push(s);
this.length += s.length;
}
this.prepend = function (s) {
this.parts.unshift(s);
this.length += s.length;
}
this.toString = function () {
return this.parts.join('');
}
}
}
cRichTextEditor.prototype.fromJSON = function( value )
{
if(!value)
return '';
return (new Function( "return " + this.decode64( value )))();
}
cRichTextEditor.prototype.decode64 = function(input) {
if( typeof input === "undefined" ) return '';
var output = new StringMaker();
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output.append(String.fromCharCode(chr1));
if (enc3 != 64) {
output.append(String.fromCharCode(chr2));
}
if (enc4 != 64) {
output.append(String.fromCharCode(chr3));
}
}
return output.toString();
}
cRichTextEditor.prototype.loadEditor = function(ID) {
var parentDiv = document.getElementById("body_position_" + ID);
var pObj = "body_" + ID;
var textArea = document.createElement("TEXTAREA");
textArea.id = pObj;
textArea.style.width = '100%';
parentDiv.appendChild(textArea);
RichTextEditor.plain[ID] = false;
if(preferences.plain_text_editor == 1)
{
RichTextEditor.plain[ID] = true;
RichTextEditor.editorReady = true;
}
else
RichTextEditor.active(pObj);
}
cRichTextEditor.prototype.loadEditor2 = function(ID) {
var pObj = "body_" + ID;
RichTextEditor.plain[ID] = false;
if(preferences.plain_text_editor == 1)
{
RichTextEditor.plain[ID] = true;
RichTextEditor.editorReady = true;
}
else
RichTextEditor.active(pObj);
}
cRichTextEditor.prototype.getSignaturesOptions = function() {
if(RichTextEditor.signatures !== false)
return RichTextEditor.signatures;
var signatures = this.fromJSON( preferences.signatures );
var signature_types = this.fromJSON( preferences.signature_types );
for( key in signatures )
if( !signature_types[key] )
signatures[key] = signatures[key].replace( /\n/g, "
" );
RichTextEditor.signatures = signatures;
return signatures;
}
cRichTextEditor.prototype.getSignatureDefault = function() {
if(RichTextEditor.signatures === false)
RichTextEditor.signatures = RichTextEditor.getSignaturesOptions();
if(!RichTextEditor.signatures ||
!RichTextEditor.signatures[preferences.signature_default || ""])
{
preferences.use_signature = "0"; //Desabilita o uso da assinatura
return '';
}
return unescape(RichTextEditor.signatures[preferences.signature_default]);
}
cRichTextEditor.prototype.execPosInstance = function(inst) {
if(RichTextEditor.editorReady === false)
{
var editor = CKEDITOR.instances[inst];
var id = inst.replace('body_','');
var content = $("#content_id_"+id)
editor.document.on('keydown', function(event)
{
away = false;
var save_link = content.find(".save");
save_link.unbind("click").click(function(){
openTab.toPreserve[id] = true;save_msg(id);
});
save_link.button({ disabled: false });
});
// IM Module Enabled
if( window.parent.loadscript && loadscript.autoStatusIM )
{
CKEDITOR.instances[inst].document.on('keydown', function(event){
loadscript.autoStatusIM;
});
}
if (preferences.auto_save_draft == 1)
{
autoSaveControl.status[id] = true;
autoSaveControl.timer[id] = window.setInterval( "autoSave("+id+")" ,autosave_time);
CKEDITOR.instances[inst].document.on('keydown', function(event){
autoSaveControl.status[id] = false;
})
}
$(".cke_editor").css("white-space", "normal");
if(typeof(preferences.font_size_editor) !== 'undefined')
$(editor.document.$.body).css("font-size",preferences.font_size_editor);
if(typeof(preferences.font_family_editor) !== 'undefined')
$(editor.document.$.body).css("font-family",preferences.font_family_editor);
RichTextEditor.editorReady = true;
}
}
cRichTextEditor.prototype.setPlain = function (active,id){
RichTextEditor.plain[id] = active;
var content = $("#content_id_"+id);
var div = $("
((.\n*)*)'),'$1'); if($('#'+id) !== undefined){ $('#'+id).val(data); if (reply === undefined){ $('#to_'+id).focus(); } } else{ setTimeout(function() {RichTextEditor.setInitData(id,data,reply,recursion); }, 500); } } else{ if( RichTextEditor.editorReady === true && CKEDITOR.instances['body_'+id] !== undefined ){ var editor = CKEDITOR.instances['body_'+id]; var selection = editor.getSelection(); var fontSize = ''; var fontFamily = ''; if(typeof(preferences.font_size_editor) !== 'undefined') fontSize = 'font-size:' + preferences.font_size_editor; if(fontSize != '') fontFamily = ';' if(typeof(preferences.font_family_editor) !== 'undefined') fontFamily += 'font-family:' + preferences.font_family_editor + ';'; var divBr = '