//http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
// This CSS will reduce the space between (lines) paragraphs to zero. It will look more like the default line spacing in popular Word processors.
// p {margin: 0px; padding: 0px;}
// force BR elements on newlines instead of inserting paragraphs
//force_br_newlines : true,
//forced_root_block : '' // Needed for 3.x
// disable/enable the creation of paragraphs on return/enter in Mozilla/Firefox. The default value of this option is true.
//force_p_newlines : true
// preserve white space
//preformatted : true
// all element cleanup will be skipped but other cleanup functionality such as URL conversion will still be executed.
//verify_html : false
var resetValues = {};
function resetValue(editor,option) {
var text = resetValues[editor.id];
if (option=="Reset") {
text = "\n" + text;
editor.setContent(text);
} else if (option=="Convert") {
text = "\n" + text.replace(/\n/g, "
");
editor.setContent(text);
} else if (option=="Revert") {
tinyMCE.execCommand('mceRemoveControl', true, editor.id);
var obj = document.getElementById(editor.id);
obj.value = text;
}
}
function ensureRtfPrefix(id, html, body) {
// make sure the user did not delete the FIT_TINY comment
if (html.indexOf("")<0) {
//alert("putting back prefix");
html = "" + html;
}
return html;
}
var TINYINIT = false;
function tinyInit(id) {
// This is where the compressor will load all components, include all components used on the page here
// tinyMCE_GZ.init({
// plugins : "emotions,inlinepopups,preview,searchreplace,fullscreen",
// themes : 'advanced',
// languages : 'en',
// disk_cache : true,
// debug : false
// });
tinymce.create('tinymce.plugins.FitPlugin', {
createControl: function(n, cm) {
switch (n) {
case 'fit':
var c = cm.createMenuButton('fit', {
title : '',
image : 'com/other/fit20.gif',
icons : false
});
c.onRenderMenu.add(function(c, m) {
var sub;
m.add({title : '', onclick : function() {
resetValue(tinyMCE.activeEditor,"Reset");
}});
m.add({title : '', onclick : function() {
resetValue(tinyMCE.activeEditor,"Convert");
}});
m.add({title : '', onclick : function() {
resetValue(tinyMCE.activeEditor,"Revert");
}});
});
return c;
}
return null;
}
});
// Register plugin with a short name
tinymce.PluginManager.add('fit', tinymce.plugins.FitPlugin);
if(typeof (window.customTinyInit) == 'function') {
customTinyInit();
} else {
tinyMCE.init({
save_callback : "ensureRtfPrefix",
//mode : "textareas",
//convert_urls : false, // otherwise emotions get a "../" added to them when you switch between rtf and normal modes
//relative_urls : false,
content_css : "stylesheets/TinyMce.css",
theme_advanced_font_sizes: "10pt,12pt,13pt,14pt,16pt,18pt,20pt",
font_size_style_values : "10pt,12pt,13pt,14pt,16pt,18pt,20pt",
//force_br_newlines : true, // they warn against this but it works better with old format, as does forced_root_block
//forced_root_block : '', // otherwise, converting back to regular textarea shows all the stuff
// problem with
when going back and forth
//convert_newlines_to_brs : true, // otherwise, if a user from old system with newlines uses this, all newlines are lost
gecko_spellcheck : true, // this keeps firefox spellcheck working
theme : "advanced",
mode : "none",
language : "",
height:"200",
width:"100%",
theme_advanced_layout_manager : "SimpleLayout",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
plugins : "-fit",//advlist,advlink,emotions,inlinepopups,preview,searchreplace,fullscreen",
theme_advanced_buttons1 : "fit,bold,italic,underline,strikethrough,fontsizeselect,forecolor,hr,charmap,|,bullist,numlist,outdent,indent",//backcolor,hr,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,|,link,unlink,anchor,image,charmap,emotions,|,search,replace,|,help,code,preview,fullscreen",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : ""
});
}
}
// This is the function that moves the cursor to the end of content
function moveCursorToEnd(editor_id) {
inst = tinyMCE.getInstanceById(editor_id);
tinyMCE.execInstanceCommand(editor_id,"selectall", false, null);
if (tinyMCE.isMSIE) {
rng = inst.getRng();
rng.collapse(false);
rng.select();
}
else {
sel = inst.getSel();
sel.collapseToEnd();
}
}
function setCaretTo(obj, pos) {
if(obj.createTextRange) {
/* Create a TextRange, set the internal pointer to
a specified position and show the cursor at this
position
*/
var range = obj.createTextRange();
range.move("character", pos);
range.select();
} else if(obj.selectionStart) {
/* Gecko is a little bit shorter on that. Simply
focus the element and set the selection to a
specified position
*/
alert(obj.selectionStart);
obj.focus();
obj.setSelectionRange(pos, pos);
}
}
function toggleEditor(id) {
if (typeof tinyMCE !== 'undefined') {
if (TINYINIT==false) {
tinyInit();
TINYINIT=true;
}
var obj = document.getElementById(id);
if (!tinyMCE.getInstanceById(id)) {
resetValues[id] = obj.value;
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. All newlines will be removed by this editor.\n\nIf you do not like the result, use the custom ATS 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
}
tinyMCE.execCommand('mceAddControl', true, id);
//window.setTimeout("tinyMCE.execCommand('mceFocus', false, id)", 1);
tinyMCE.execInstanceCommand(id,'JustifyLeft',false); // get rid of missing cursor
} else {
tinyMCE.execCommand('mceRemoveControl', true, id);
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) {
obj.value = "" + obj.value;
}
}
}
}
}
// initialize any that need it
function initTiny() {
for(i=0; i=0) {
// defaults to rtf through settings
toggleEditor(element.id);
} else if (element.id.length>0) { // mNotifyList id is blank
// defaults to rtf cause data was from it before
var obj = document.getElementById(element.id);
if (obj && obj.value.indexOf("")>=0) {
toggleEditor(element.id);
}
}
}
}
}