<h2>IT WORK !! YEAHHHHH ; truely this one WORK !!!!! dynamicly !!! with multiple TinyMceEditor !!!!</h2>
Hello for the 2nd time TinyMCE forum reader,
-(RAW TEXT length + (converted HTML iso char; exemple ö === ö) + HTML code length) === Happy function
-paste[Ctrl+V]
-word past
-text insert
-etc
-no try with image content (but this is finally html code ;-) )
... and don't forget:
ö = 1 char
ö = 6 char
after my First POST :
max length for 1 TinyEditor
here my second POST:
max length for multiple TinyEditor Instance
NOTE:
Be carefull by debug with turn on the javascript alert(''); box because if you turn on the alert('') by the onKeyDown then the "onKeyUp" don't will run but this last one is essential!
Scincerly Stéphane
{thx for feedback}
#############################
###
### The javascript_code.js file
###
#############################
/*
trunk text if the length of the 'limitField' > 'limitNum')
How to use:
onKeyUp=limitText(this,1048)
*/
function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
}
}
function verifyEditorMaxLength(EditorMaxLength) {
tinyMCE.triggerSave();
alert(EditorMaxLength);
alert(EditorMaxLength.value);
/*if (EditorMaxLength.content.value.length > 2) {
alert("HEY to much content!!");
return false;
}
*/
return true;
}
function myMaxLength_1024(){
// variable declaration; You must change this value for your use.
/*
!! ATTENTION !!
in purpose to not lose the HTML balise in the 'TinyMCE Editor' (like: <p></p>)
this value will be used to save the visible char AND the HTML balise
that mean :
var mytext = '<p>123</p>';
alert(mytext.length);
//10
*/
return 1000; //Maxlength
/*
Post Scriptum:
You can use the 'replace' function (thanks to lorenzocampanis at users.sourceforge.net)if you want to count ONLY visible char
that mean :
var mytext = '<p>123</p>';
alert(mytext.length.replace(/<\/?[^>]+(>|$)/g, ""));
//3
*/
};
function the_HTML_id_Of_My_TextArea(){
//variable declaration; You must change this value for your use
return 'myTinyEditor';
};
#############################
###
### The main HTML file
###
#############################
<html>
<head>
<!--
* Firm : http://www.fiveinfo.ch
* Author : Stéphane Lauper
* Email : slauper at fiveinfo dot ch
* Date : 10.October.2008
*
* Objective : with InternetExplorer (endUser wish)
* MaxLength solution for the TinyMCE Editor with target to write in Database
* without HTML formatting loss and without Database field size Overflow.
* NOTE:
* Be carefull by debug with turn on the javascript alert(''); box because if you turn on the alert('') by the onKeyDown then the "onKeyUp" don't will run but this last one is essential!
-->
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="javascript_code.js"></script>
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({ // Start declare one of the TinyEditor instance
// General options
mode : "textareas",
theme : "advanced",
editor_selector : "myTinyEditorDE",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,hr,|,print,|,fullscreen",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "",
theme_advanced_resizing : true,
setup : function(ed) {
ed.onKeyDown.add(
function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorDE" ID="myTinyEditorDE" CLASS="myTinyEditorDE" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorDE";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyDown Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnKeyDown Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnKeyDown Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('OnKeyDown Event document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
//alert('10');
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('1a');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('1b');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
//alert('OnKeyDown Event NEW document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
}//endif
}//end function(ed,e)
);//end ed.onKeyDown.add
ed.onChange.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorDE" ID="myTinyEditorDE" CLASS="myTinyEditorDE" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorDE";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnChange Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnChange Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnChange Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('20');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('2a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('2b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onChange.add
ed.onKeyUp.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorDE" ID="myTinyEditorDE" CLASS="myTinyEditorDE" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorDE";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyUp Event : CantWriteMoreThan'+ CantWriteMoreThan);
//alert('OnKeyUp Event : theTextAreaContent'+ theTextAreaContent);
//alert('OnKeyUp Event : theTextAreaContentLength'+ theTextAreaContentLength);
//alert('30');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('3a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('3b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onKeyUp.add
},//end setup : function(ed)
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});// end declare one of the TinyEditor instance
tinyMCE.init({ // Start declare one of the TinyEditor instance
// General options
mode : "textareas",
theme : "advanced",
editor_selector : "myTinyEditorFR",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,hr,|,print,|,fullscreen",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "",
theme_advanced_resizing : true,
setup : function(ed) {
ed.onKeyDown.add(
function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorFR" ID="myTinyEditorFR" CLASS="myTinyEditorFR" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorFR";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyDown Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnKeyDown Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnKeyDown Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('OnKeyDown Event document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
//alert('10');
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('1a');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('1b');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
//alert('OnKeyDown Event NEW document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
}//endif
}//end function(ed,e)
);//end ed.onKeyDown.add
ed.onChange.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorFR" ID="myTinyEditorFR" CLASS="myTinyEditorFR" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorFR";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnChange Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnChange Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnChange Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('20');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('2a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('2b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onChange.add
ed.onKeyUp.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorFR" ID="myTinyEditorFR" CLASS="myTinyEditorFR" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorFR";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyUp Event : CantWriteMoreThan'+ CantWriteMoreThan);
//alert('OnKeyUp Event : theTextAreaContent'+ theTextAreaContent);
//alert('OnKeyUp Event : theTextAreaContentLength'+ theTextAreaContentLength);
//alert('30');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('3a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('3b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onKeyUp.add
},//end setup : function(ed)
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});// end declare one of the TinyEditor instance
tinyMCE.init({ // Start declare one of the TinyEditor instance
// General options
mode : "textareas",
theme : "advanced",
editor_selector : "myTinyEditorIT",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,hr,|,print,|,fullscreen",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "",
theme_advanced_resizing : true,
setup : function(ed) {
ed.onKeyDown.add(
function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorIT" ID="myTinyEditorIT" CLASS="myTinyEditorIT" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorIT";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyDown Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnKeyDown Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnKeyDown Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('OnKeyDown Event document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
//alert('10');
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('1a');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('1b');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
//alert('OnKeyDown Event NEW document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
}//endif
}//end function(ed,e)
);//end ed.onKeyDown.add
ed.onChange.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorIT" ID="myTinyEditorIT" CLASS="myTinyEditorIT" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorIT";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnChange Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnChange Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnChange Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('20');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('2a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('2b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onChange.add
ed.onKeyUp.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorIT" ID="myTinyEditorIT" CLASS="myTinyEditorIT" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorIT";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyUp Event : CantWriteMoreThan'+ CantWriteMoreThan);
//alert('OnKeyUp Event : theTextAreaContent'+ theTextAreaContent);
//alert('OnKeyUp Event : theTextAreaContentLength'+ theTextAreaContentLength);
//alert('30');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('3a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('3b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onKeyUp.add
},//end setup : function(ed)
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});// end declare one of the TinyEditor instance
tinyMCE.init({ // Start declare one of the TinyEditor instance
// General options
mode : "textareas",
theme : "advanced",
editor_selector : "myTinyEditorEN",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
// Theme options
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,hr,|,print,|,fullscreen",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "",
theme_advanced_resizing : true,
setup : function(ed) {
ed.onKeyDown.add(
function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorEN" ID="myTinyEditorEN" CLASS="myTinyEditorEN" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorEN";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyDown Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnKeyDown Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnKeyDown Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('OnKeyDown Event document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
//alert('10');
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('1a');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('1b');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
//alert('OnKeyDown Event NEW document.getElementById(UndoText).value: '+ document.getElementById('UndoText').value);
}//endif
}//end function(ed,e)
);//end ed.onKeyDown.add
ed.onChange.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorEN" ID="myTinyEditorEN" CLASS="myTinyEditorEN" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorEN";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnChange Event CantWriteMoreThan: '+ CantWriteMoreThan);
//alert('OnChange Event theTextAreaContent: '+ theTextAreaContent);
//alert('OnChange Event theTextAreaContentLength: '+ theTextAreaContentLength);
//alert('20');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('2a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('2b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onChange.add
ed.onKeyUp.add(function(ed, e) {
//change this var it must be the same name as the above "editor_selector" property
//AND in the HTML <text area> following properties must be equal set as the above "editor_selector" property:
// <TEXTAREA NAME="myTinyEditorEN" ID="myTinyEditorEN" CLASS="myTinyEditorEN" ></TEXTAREA>
var the_HTML_id_Of_My_TextArea = "myTinyEditorEN";
//variable declaration; No change needed.
var CantWriteMoreThan = myMaxLength_1024();/* if you want to change the 'Max number of char allowed' you can change this value in a unique location. See the above myMaxLength() function. */
var Authorized_theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //is the 'undo-text'
var theTextAreaContent = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent(); //Content of the TextArea
var theTextAreaContentLength = tinyMCE.get(the_HTML_id_Of_My_TextArea).getContent().length; //Length of the Content of the TextArea
//alert('OnKeyUp Event : CantWriteMoreThan'+ CantWriteMoreThan);
//alert('OnKeyUp Event : theTextAreaContent'+ theTextAreaContent);
//alert('OnKeyUp Event : theTextAreaContentLength'+ theTextAreaContentLength);
//alert('30');
if (theTextAreaContentLength <= CantWriteMoreThan){
//alert('3a');
//Set 'HTML hidden input' with the value got from the 'TinyMCE Editor'.
document.getElementById('UndoText').value = Authorized_theTextAreaContent;
}//endif
if(theTextAreaContentLength > CantWriteMoreThan){
//alert('3b');
//Set the 'TinyMCE Editor' Editor with the value got from the 'HTML hidden input'.
tinyMCE.get(the_HTML_id_Of_My_TextArea).setContent(document.getElementById('UndoText').value);
}//end if
}//end function(ed,e)
);//end ed.onKeyUp.add
},//end setup : function(ed)
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});// end declare one of the TinyEditor instance
</script>
<!-- /TinyMCE -->
</head>
<BODY>
<FORM name="form1" method="post" action="">
<!-- Do not delete this hidden input element. It is the 'undo' of the MaxLength -->
<input type="hidden" name="UndoText"/>
<!-- Do not delete this hidden input element. It is the 'undo' of the MaxLength -->
<!-- Do not delete this element. This is My_TextArea for DE language(German)-->
<textarea rows="15" id="myTinyEditorDE" name="myTinyEditorDE" class="myTinyEditorDE" tabindex="30" style="width: 600px" >DE</textarea>
<!-- Do not delete this element. This is My_TextArea for DE language(German)-->
<!-- Do not delete this element. This is My_TextArea for FR language(French)-->
<textarea rows="15" id="myTinyEditorFR" name="myTinyEditorFR" class="myTinyEditorFR" tabindex="30" style="width: 600px" >FR</textarea>
<!-- Do not delete this element. This is My_TextArea for FR language(French)-->
<!-- Do not delete this element. This is My_TextArea for IT language(Italian)-->
<textarea rows="15" id="myTinyEditorIT" name="myTinyEditorIT" class="myTinyEditorIT" tabindex="30" style="width: 600px" >IT</textarea>
<!-- Do not delete this element. This is My_TextArea for IT language(Italian)-->
<!-- Do not delete this element. This is My_TextArea for EN language(English)-->
<textarea rows="15" id="myTinyEditorEN" name="myTinyEditorEN" class="myTinyEditorEN" tabindex="30" style="width: 600px" >EN</textarea>
<!-- Do not delete this element. This is My_TextArea for EN language(English)-->
</FORM>
</BODY>
</html>
Last edited by slauper (2009-05-05 16:49:46)