Changeset 4366 for trunk/expressoMail1_2/js/rich_text_editor.js
- Timestamp:
- 05/12/11 15:40:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/rich_text_editor.js
r3865 r4366 25 25 parentDiv.appendChild(this.table); 26 26 27 var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id ); 28 this.table.style.visibility = ( mail_as_plain && mail_as_plain.checked ) ? 'hidden' : 'visible'; 29 27 30 if(!Element(this.editor)) 28 31 { … … 31 34 else 32 35 { 33 Element( "viewsource_rt_checkbox").checked=false;36 Element( 'viewsource_rt_checkbox_' + this.id ).checked=false; 34 37 } 35 38 … … 50 53 config_events( iframe, 'onload', function( ) 51 54 { 52 iframe.contentWindow.document.designMode = "on"; 55 if ( iframe.contentWindow.document.body && iframe.contentWindow.document.body.contentEditable ) 56 iframe.contentWindow.document.body.contentEditable = true; 57 53 58 if ( iframe.contentWindow.document.documentElement ){ 54 59 iframe.contentWindow.document.documentElement.style.background = '#fff'; … … 57 62 }); 58 63 59 var checkbox = document.createElement("INPUT");60 checkbox.id = 'viewsource_rt_checkbox';61 checkbox.type = "checkbox";62 checkbox.setAttribute("tabIndex","-1");63 checkbox.onclick = function () {RichTextEditor.viewsource(this.checked)};64 var text = document.createTextNode(get_lang('View HTML source') + '.');65 64 parentDiv.appendChild(iframe); 66 parentDiv.appendChild(checkbox); 67 parentDiv.appendChild(text); 65 66 var source = document.createElement( 'input' ); 67 source.id = 'viewsource_rt_checkbox_' + this.id; 68 source.type = "checkbox"; 69 source.setAttribute("tabIndex","-1"); 70 source.onclick = function( ) 71 { 72 RichTextEditor.viewsource(this.checked); 73 }; 74 source = parentDiv.appendChild( 75 document.createElement( 'span' ).appendChild( source ).parentNode 76 ).appendChild( 77 document.createTextNode( get_lang( 'View HTML source' ) + '.' ) 78 ).parentNode; 68 79 } 69 80 … … 138 149 document.getElementById(this.editor).contentWindow.document.body.innerHTML = html.toString(); 139 150 document.getElementById("table_richtext_toolbar").style.visibility="visible"; 151 } 152 } 153 } 154 155 cRichTextEditor.prototype.plain = function(source) { 156 var html; 157 var editor = document.getElementById( this.editor ); 158 159 if (source) { 160 if (is_ie){ 161 connector.loadScript('html2xhtml'); 162 html = frames[this.editor].document.body; 163 var xhtml = get_xhtml(html, 'en', 'iso-8859-1'); 164 frames[this.editor].document.body.innerText = xhtml; 165 document.getElementById("table_richtext_toolbar").style.visibility="hidden"; 166 } 167 else{ 168 html = document.createTextNode( editor.contentWindow.document.body.innerHTML ); 169 this.table.style.visibility="hidden"; 170 editor.contentWindow.document.body.innerHTML = ''; 171 172 var textarea = document.createElement( 'textarea' ); 173 textarea.style.width = '99%'; 174 textarea.style.height = '300px'; 175 textarea.style.fontSize = '12pt'; 176 textarea.innerHTML = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' ); 177 178 editor.style.width = '0px'; 179 editor.style.height = '0px'; 180 editor.style.visibility = 'hidden'; 181 182 editor.parentNode.insertBefore( textarea, editor ); 183 textarea.focus( ); 184 } 185 } else { 186 if (is_ie){ 187 var output = escape(frames[this.editor].document.body.innerText); 188 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); 189 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); 190 frames[this.editor].document.body.innerHTML = unescape(output); 191 document.getElementById("table_richtext_toolbar").style.visibility="visible"; 192 } 193 else{ 194 editor.contentWindow.document.body.innerHTML = editor.previousSibling.value.replace( /\n/g, '<br/>' ); 195 editor.parentNode.removeChild( editor.previousSibling ); 196 197 editor.style.width = '99%'; 198 editor.style.height = '300px'; 199 editor.style.visibility = 'visible'; 200 201 this.loadEditor( this.id ); 140 202 } 141 203 }
Note: See TracChangeset
for help on using the changeset viewer.