X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman%2FWebContent%2Frtef%2Frichtext.js;h=2b09b060b9bdb7861e0004bb986ea2a15efd5807;hb=f7efb7f2f9424e3abb294955697a8bd7654e02a5;hp=1acd7a9fab570613095b7e22995a407b21b53adf;hpb=6eed5be54ffc262c46c112c5218649d37431de63;p=tools%2Fsiman.git diff --git a/Workspace/Siman/WebContent/rtef/richtext.js b/Workspace/Siman/WebContent/rtef/richtext.js index 1acd7a9..2b09b06 100644 --- a/Workspace/Siman/WebContent/rtef/richtext.js +++ b/Workspace/Siman/WebContent/rtef/richtext.js @@ -34,7 +34,8 @@ //////////////////////////////////////////////////////////////////////////////// // Constants -var minWidth = 450; // minumum width +var ctxpath = "/siman/"; +var minWidth = 400; // minumum width var wrapWidth = 1245; //width at which all icons will appear on one bar var maxchar = 64000; // maximum number of characters per save var lang = "en"; //xhtml language @@ -135,7 +136,7 @@ function initTextInput() { wrapWidth = 14 * 24; defaultFont = "Arial, Helvetica, sans-serif"; - initRTE("../rtef/images/", "../rtef/", "", true); + initRTE(ctxpath + "rtef/images/", ctxpath + "rtef/", "", true); } function initTextEditor() { @@ -158,7 +159,7 @@ function initTextEditor() { wrapWidth = 15 * 24; defaultFont = "Arial, Helvetica, sans-serif"; - initRTE("../rtef/images/", "../rtef/", "", true); + initRTE(ctxpath + "rtef/images/", ctxpath + "rtef/", "", true); } function addCommand(name, action) { @@ -268,7 +269,7 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr document.writeln(''); insertBar(); if(fullscreen || activeCommand.get("save") != null){ - document.writeln(''); + document.writeln(''); nbcommand += 1; } if(!isSafari && !isKonqueror) { @@ -281,13 +282,11 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr // insertImg(lblUnformat,"unformat.gif","rteCommand('"+rte+"','removeformat')"); insertSep(); } - if(isIE || isSafari || isKonqueror) { + if(false) { addCommand("cut","rteCommand('"+rte+"','cut')"); // insertImg(lblCut,"cut.gif","rteCommand('"+rte+"','cut')"); addCommand("copy","rteCommand('"+rte+"','copy')"); // insertImg(lblCopy,"copy.gif","rteCommand('"+rte+"','copy')"); - } - if(isSafari || isKonqueror) { addCommand("paste","rteCommand('"+rte+"','InsertText')"); // insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','InsertText')"); } @@ -347,16 +346,15 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr // insertImg(lblAlgnRight,"right_just.gif","rteCommand('"+rte+"','justifyright')"); addCommand("justifyfull","rteCommand('"+rte+"','justifyfull')"); // insertImg(lblJustifyFull,"justifyfull.gif","rteCommand('"+rte+"','justifyfull')"); - if(!isSafari && !isKonqueror) { + insertSep(); + addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')"); +// insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')"); + addCommand("list","rteCommand('"+rte+"','insertunorderedlist')"); +// insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')"); + addCommand("hyperlink","dlgLaunch('"+rte+"','link')"); +// insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')"); + if(false) { insertSep(); - addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')"); -// insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')"); - addCommand("list","rteCommand('"+rte+"','insertunorderedlist')"); -// insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')"); - addCommand("outdent","rteCommand('"+rte+"','outdent')"); -// insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')"); - addCommand("indent","rteCommand('"+rte+"','indent')"); -// insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')"); insertSep(); addCommand("textcolor","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte); // insertImg(lblTextColor,"textcolor.gif","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte); @@ -368,15 +366,17 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr insertSep(); addCommand("special_char","dlgLaunch('"+rte+"','char')"); // insertImg(lblInsertChar,"special_char.gif","dlgLaunch('"+rte+"','char')"); - addCommand("hyperlink","dlgLaunch('"+rte+"','link')"); -// insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')"); addCommand("image","dlgLaunch('"+rte+"','image')"); // insertImg(lblAddImage,"image.gif","dlgLaunch('"+rte+"','image')"); addCommand("insert_table","dlgLaunch('"+rte+"','table')"); // insertImg(lblInsertTable,"insert_table.gif","dlgLaunch('"+rte+"','table')"); } + addCommand("outdent","rteCommand('"+rte+"','outdent')"); +// insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')"); + addCommand("indent","rteCommand('"+rte+"','indent')"); +// insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')"); insertSep(); - if(!isSafari && !isKonqueror) { + if(false) { addCommand("replace","dlgLaunch('"+rte+"','replace')"); // insertImg(lblSearch,"replace.gif","dlgLaunch('"+rte+"','replace')"); } @@ -437,7 +437,7 @@ function insertImg(name, image, command, id){ if(id!=null){ td = ""; } - document.writeln(td+''+name+''); + document.writeln(td+''+name+''); } function enableDesignMode(rte, html, css, readOnly) { @@ -481,7 +481,6 @@ function enableDesignMode(rte, html, css, readOnly) { if(isGecko && !readOnly) { //attach a keyboard handler for gecko browsers to make keyboard shortcuts work oRTE.addEventListener("keypress", geckoKeyPress, true); - oRTE.addEventListener("focus", function (){dlgCleanUp();}, false); } } catch(e) { alert(lblErrorPreload); @@ -490,7 +489,12 @@ function enableDesignMode(rte, html, css, readOnly) { //gecko may take some time to enable design mode. //Keep looping until able to set. if(isGecko){ - setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+");", 200); + if(!timeLeft) { + timeLeft = 5000; + } + if(timeLeft > 0) { + setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+ "','"+(timeLeft-200)+"');", 200); + } }else{ return false; } @@ -817,7 +821,7 @@ function getText(rte) { return rtn; } -function setFormText(popup, content){ +function setFormText(popup, content, timeLeft){ //set link text value in dialog windows if(content != "undefined") { @@ -829,8 +833,13 @@ function setFormText(popup, content){ }catch(e){ //may take some time to create dialog window. //Keep looping until able to set. - setTimeout("setFormText('"+popup+"','" + content + "');", 10); - } + if(!timeLeft) { + timeLeft = 5000; + } + if(timeLeft > 0) { + setTimeout("setFormText('"+popup+"','" + content + "','"+(timeLeft-200)+"');", 200); + } + } } } @@ -1037,14 +1046,18 @@ function setRange(rte){ //function to store range of current selection var oRTE = returnRTE(rte); var selection; - if(document.all){ + if(document.all){ //IE selection = oRTE.document.selection; if(selection != null){ rng = selection.createRange(); } }else{ selection = oRTE.getSelection(); - rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange(); + if(selection.rangeCount > 0) { + rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange(); + } else { + rng = oRTE.document.createRange(); + } } return rng; } @@ -1318,3 +1331,17 @@ function checkspell() { } } } + +//***************** +//Validation +//***************** +function enableRTEvalidation(rteName) { + document.getElementById(rteName+'SaveButton').addEventListener("click", function(event){ + updateRTEs(); + field = document.getElementById('hdn'+rteName); + if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) { + event.preventDefault(); + } + }); +} + \ No newline at end of file