- Timestamp:
- 09/09/11 15:26:36 (13 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r5079 r5083 4235 4235 } 4236 4236 4237 function show_decript($params ,$dec=0){4237 function show_decript($params){ 4238 4238 $source = $params['source']; 4239 //error_log("source: $source\nversao: " . PHP_VERSION); 4240 4241 if ($dec == 0) 4242 { 4243 $source = str_replace(" ", "+", $source,$i); 4244 if (version_compare(PHP_VERSION, '5.2.0', '>=')){ 4245 if(!$source = base64_decode($source,true)) 4246 return "error ".$source."Espaï¿œos ".$i; 4247 4248 } 4249 else { 4250 if(!$source = base64_decode($source)) 4251 return "error ".$source."Espaï¿œos ".$i; 4252 } 4239 //error_log("source: $source\nversao: " . PHP_VERSION, 3, '/tmp/teste.log'); 4240 $source = str_replace(" ", "+", $source,$i); 4241 4242 if (version_compare(PHP_VERSION, '5.2.0', '>=')){ 4243 if(!$source = base64_decode($source,true)) 4244 return "error ".$source."Espaços ".$i; 4245 4246 } 4247 else { 4248 if(!$source = base64_decode($source)) 4249 return "error ".$source."Espaços ".$i; 4253 4250 4254 4251 } -
trunk/expressoMail1_2/inc/hook_settings.inc.php
r5075 r5083 75 75 var edit = !!document.getElementById( "edit_signature" + i ).checked; 76 76 77 var value = edit ? tinyMCE.get( "user_signature" + i ).getContent() :77 var value = edit ? CKEDITOR.instances["user_signature" + i ].getData() : 78 78 document.getElementById( "user_signature" + i ).value; 79 79 … … 410 410 411 411 create_select_box('What is the maximum size of embedded images?','image_size',$default,'When user send an email with image in body message, it changes the size'); 412 create_check_box('Use plain text editor with standard ?','plain_text_editor',''); 412 413 413 414 $default = array( … … 449 450 $vars = $GLOBALS['phpgw']->preferences->user['expressoMail']; 450 451 451 create_html_code("signature","<script src='../library/jquery/jquery.js' language='javascript'></script><script src='../library/tiny_mce/jquery.tinymce.js' language='javascript'></script><script src='../library/tiny_mce/tiny_mce.js' language='javascript'></script> 452 create_html_code("signature","<script src='../library/jquery/jquery.js' language='javascript'></script> 453 <script src='../library/ckeditor/ckeditor.js' language='javascript'></script> 454 <script src='../library/ckeditor/adapters/jquery.js' language='javascript'></script> 452 455 <input type='hidden' id='counter' value='0'> 453 456 <input type='hidden' id='signatures' name='user[signatures]' value='". $vars['signatures']."'> … … 459 462 <div id='_signature' name='signature' style='display: none;'> 460 463 <div id='options_signature'> 461 <input id='edit_signature' type='checkbox' name='isEditor' onclick='changeType( \"\", this.id.replace( /[^0-9]*/gi, \"\" ) );' checked='checked'><label for='isEditor'>Editor de texto</label> titulo da assinatura <input type='text' id='title_signature'> <input type='radio' id='default_signature' name='signature_default'><label>Usar como padrao</label><a href='#' onclick='javascript: return removeSignature( this );' id='remove_signature'> remover</a>464 <input id='edit_signature' type='checkbox' name='isEditor' onclick='changeType( this, this.id.replace( /[^0-9]*/gi, \"\" ) );' checked='checked'><label for='isEditor'>Editor de texto</label> | Titulo da assinatura <input type='text' id='title_signature'> | <input type='radio' id='default_signature' name='signature_default'><label>Usar como padrao</label> | <a href='#' onclick='javascript: return removeSignature( this );' id='remove_signature'> Remover</a> 462 465 </div><br/> 463 466 <div id='text_signature'> 464 <textarea rows=' 5' cols='50' id='user_signature' class='editor'></textarea></div>467 <textarea rows='10' cols='65' id='user_signature' class='editor'></textarea></div> 465 468 </div> 466 469 … … 473 476 }); 474 477 475 function changeType(value, target){ 476 477 tinyMCE.execCommand( 'mceToggleEditor', false, 'user_signature' + target ); 478 function changeType(obj, target){ 479 if(obj.checked === true) 480 $('#user_signature' + target).ckeditor( { toolbar:'signature' }); 481 else 482 CKEDITOR.instances['user_signature' + target ].destroy(); 478 483 } 479 484 … … 493 498 494 499 if( !simple ) 495 $( '#user_signature' + counter ).tinymce({ 496 plugins : 'paste', 497 theme_advanced_toolbar_location : 'top', 498 theme_advanced_toolbar_align : 'center', 499 entities: '', 500 entity_encoding: 'raw', 501 theme: 'advanced', 502 add_form_submit_trigger : false 503 }); 500 $('#user_signature' + counter).ckeditor( { toolbar:'signature' }); 504 501 else 505 502 document.getElementById('edit_signature' + counter ).checked = ''; -
trunk/expressoMail1_2/index.php
r5075 r5083 16 16 echo "<script type='text/javascript'>var template = '".$_SESSION['phpgw_info']['expressoMail1_2']['user']['preferences']['common']['template_set']."';</script>"; 17 17 echo "<script src='js/modal/modal.js'></script>"; 18 //jquery and Editor 19 echo " <script src='../library/jquery/jquery.js' language='javascript'></script> 20 <script src='../library/ckeditor/ckeditor.js' language='javascript'></script> 21 <script src='../library/ckeditor/adapters/jquery.js' language='javascript'></script> 22 <script src='js/rich_text_editor.js' type='text/javascript'></script>"; 23 //---------------------------// 18 24 echo '<link href="js/lert/lert.css" rel="stylesheet" type="text/css"/>'; 19 25 echo '<script src="js/lert/lert.js" type="text/javascript"></script>'; -
trunk/expressoMail1_2/js/abas.js
r4889 r5083 1 1 var BordersArray = new Array(); 2 2 BordersArray[0] = new setBorderAttributes(0); 3 var countBorders = 0; 3 4 4 5 function setBorderAttributes(ID) … … 56 57 if(Element("font_border_id_"+BordersArray[i].sequence)) 57 58 Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu'; 58 var body = Element('body_'+BordersArray[i].sequence); 59 if (body) 60 { 61 try 62 { 63 if (Element('viewsource_rt_checkbox_' + ID).checked) 64 { 65 connector.loadScript("rich_text_editor"); 66 RichTextEditor.viewsource(false); 67 } 68 } 69 catch(e) 70 { 71 //alert(e.message) 72 } 73 } 59 74 60 } 75 61 } … … 84 70 c.style.display = ''; 85 71 86 body = document.getElementById('body_'+ ID);87 if (body){88 try{89 if(ID){90 connector.loadScript("rich_text_editor");91 if(typeof(RichTextEditor) == 'undefined'){92 setTimeout('alternate_border(\''+ID+'\');',500);93 return false;94 }95 RichTextEditor.loadEditor(ID);96 }97 body.contentWindow.document.designMode="on";98 }99 catch(e){100 //alert(e.message);101 }102 }103 72 104 73 // hide the DropDrowContact, if necessary … … 131 100 document.getElementById('to_'+ID).focus(); 132 101 } 133 102 103 RichTextEditor.setEditable(ID); 134 104 return ID; 135 105 } … … 397 367 content.parentNode.removeChild(content); 398 368 resizeWindow(); 369 RichTextEditor.destroy( 'body_'+ID ); 399 370 return true; 400 371 } -
trunk/expressoMail1_2/js/draw_api.js
r4996 r5083 2381 2381 var td = document.createElement("TD"); 2382 2382 td.colSpan = '2'; 2383 td.style.fontSize = '10pt'; 2384 td.style.fontFamily = 'Arial,Verdana'; 2385 td.style.verticalAlign = 'top'; 2386 td.style.height = '100%'; 2383 2387 div.appendChild(table_message_others_options); 2384 2388 var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi); … … 3130 3134 input_subject.style.width = "100%"; 3131 3135 input_subject.setAttribute("autocomplete","off"); 3136 input_subject.onkeydown = function(event){ 3137 var k; 3138 if(window.event) k = window.event.keyCode; 3139 else k = event.keyCode; 3140 3141 if (k == 9) 3142 { 3143 RichTextEditor.focus(ID); 3144 return false; 3145 } 3146 } 3132 3147 td_subject.appendChild(input_subject); 3133 3148 tr4.appendChild(td4); … … 3252 3267 text_plain.onclick = function () 3253 3268 { 3254 RichTextEditor.plain( this.checked ); 3255 document.getElementById( 'viewsource_rt_checkbox_' + ID ).parentNode.style.display = ( this.checked ) ? 'none' : ''; 3269 RichTextEditor.setPlain( this.checked, ID ); 3256 3270 }; 3257 //text_plain = text_plain.parentNode.appendChild(input_checkbox);3271 3258 3272 } 3259 3273 -
trunk/expressoMail1_2/js/main.js
r4997 r5083 222 222 save_link.className = 'message_options'; 223 223 }; 224 225 var obj = document.getElementById('body_'+border_id).contentWindow.document;226 if ( obj.addEventListener )227 obj.addEventListener('keypress', keypress_handler, false);228 else if ( obj.attachEvent )229 obj.attachEvent('onkeypress', keypress_handler);230 224 231 225 var subject_obj = document.getElementById('subject_'+border_id); … … 956 950 957 951 function new_message(type, border_ID){ 952 if(RichTextEditor.editorReady === false) return false; 953 954 RichTextEditor.editorReady = false; 955 956 958 957 if (Element('show_img_link_'+border_ID)) 959 958 { … … 986 985 if (new_border_ID == false) 987 986 { 988 setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500); 987 RichTextEditor.editorReady = true; 988 setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500); 989 989 return false; 990 990 } … … 1052 1052 data.date_hour = Element('date_hour_' + border_ID).value; 1053 1053 } 1054 if(typeof(preferences.signature) == 'undefined') 1055 preferences.signature = ""; 1056 var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 1054 var signature = RichTextEditor.getSignatureDefault(); 1057 1055 if(type!="new" && type!="edit") 1058 1056 data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; 1059 1057 switch(type){ 1060 1058 case "reply_without_history": 1059 RichTextEditor.replyController = true; //Seta o editor como modo reply 1061 1060 Element("to_" + new_border_ID).value = data.to; 1062 1061 title = "Re: " + data.subject; 1063 1062 Element("subject_" + new_border_ID).value = "Re: " + data.subject; 1064 1063 useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); 1065 var body = Element("body_" + new_border_ID);1066 body.contentWindow.document.open();1067 1064 // Insert the signature automaticaly at message body if use_signature preference is set 1068 if (preferences.use_signature == "1"){ 1069 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); 1070 } 1071 else{ 1072 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 1073 } 1074 body.contentWindow.document.close(); 1075 body.contentWindow.document.designMode = "on"; 1076 //Focus 1077 if (is_ie) 1078 window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); 1079 else 1080 body.contentWindow.focus(); 1081 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1082 { 1083 if ( e.keyCode == 13 ) 1084 { 1085 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1086 for ( p = 0; p < paragraphs.length; p++ ) 1087 paragraphs.item( p ).style.margin = '0px'; 1088 } 1089 }); 1065 if (preferences.use_signature == "1"){ 1066 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature ,true) ; 1067 } 1090 1068 msg_reply_from = document.createElement('input'); 1091 1069 msg_reply_from.id = "msg_reply_from_" + new_border_ID; … … 1095 1073 break; 1096 1074 case "reply_with_history": 1075 RichTextEditor.replyController = true; //Seta o editor como modo reply 1097 1076 title = "Re: " + data.subject; 1098 1077 Element("subject_" + new_border_ID).value = "Re: " + data.subject; … … 1100 1079 useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); 1101 1080 block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); 1102 var body = Element("body_" + new_border_ID);1103 body.contentWindow.document.open();1104 1081 // Insert the signature automaticaly at message body if use_signature preference is set 1105 if (preferences.use_signature == "1") { 1106 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + block_quoted_body + "</body></html>"); 1107 } 1108 else { 1109 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); 1110 } 1111 body.contentWindow.document.close(); 1112 body.contentWindow.document.designMode = "on"; 1113 //Focus 1114 if (is_ie) 1115 window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); 1082 if (preferences.use_signature == "1") 1083 RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body,true); 1116 1084 else 1117 body.contentWindow.focus(); 1118 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1119 { 1120 if ( e.keyCode == 13 ) 1121 { 1122 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1123 for ( p = 0; p < paragraphs.length; p++ ) 1124 paragraphs.item( p ).style.margin = '0px'; 1125 } 1126 }); 1085 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+ block_quoted_body,true); 1127 1086 msg_reply_from = document.createElement('input'); 1128 1087 msg_reply_from.id = "msg_reply_from_" + new_border_ID; … … 1132 1091 break; 1133 1092 case "reply_to_all_without_history": 1093 RichTextEditor.replyController = true; //Seta o editor como modo reply 1134 1094 // delete user email from to_all array. 1135 1095 data.to_all = new Array(); … … 1153 1113 } 1154 1114 useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); 1155 var body = Element("body_" + new_border_ID);1156 body.contentWindow.document.open();1157 1115 // Insert the signature automaticaly at message body if use_signature preference is set 1158 if (preferences.use_signature == "1") { 1159 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); 1160 } 1161 else { 1162 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 1163 } 1164 body.contentWindow.document.close(); 1165 body.contentWindow.document.designMode = "on"; 1166 //Focus 1167 if (is_ie) 1168 window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); 1169 else 1170 body.contentWindow.focus(); 1171 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1172 { 1173 if ( e.keyCode == 13 ) 1174 { 1175 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1176 for ( p = 0; p < paragraphs.length; p++ ) 1177 paragraphs.item( p ).style.margin = '0px'; 1178 } 1179 }); 1116 if (preferences.use_signature == "1") 1117 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature,true); 1180 1118 msg_reply_from = document.createElement('input'); 1181 1119 msg_reply_from.id = "msg_reply_from_" + new_border_ID; … … 1185 1123 break; 1186 1124 case "reply_to_all_with_history": 1125 RichTextEditor.replyController = true; //Seta o editor como modo reply 1187 1126 // delete user email from to_all array. 1188 1127 data.to_all = new Array(); … … 1209 1148 useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); 1210 1149 block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); 1211 var body = document.getElementById("body_" + new_border_ID);1212 body.contentWindow.document.open();1213 1150 // Insert the signature automaticaly at message body if use_signature preference is set 1214 if (preferences.use_signature == "1") { 1215 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + block_quoted_body + "</body></html>"); 1216 } 1217 else { 1218 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); 1219 } 1220 body.contentWindow.document.close(); 1221 body.contentWindow.document.designMode = "on"; 1222 //Focus 1223 if (is_ie) 1224 window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); 1225 else 1226 body.contentWindow.focus(); 1227 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1228 { 1229 if ( e.keyCode == 13 ) 1230 { 1231 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1232 for ( p = 0; p < paragraphs.length; p++ ) 1233 paragraphs.item( p ).style.margin = '0px'; 1234 } 1235 }); 1151 if (preferences.use_signature == "1") 1152 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body,true); 1153 else 1154 RichTextEditor.setInitData(new_border_ID,block_quoted_body,true); 1236 1155 msg_reply_from = document.createElement('input'); 1237 1156 msg_reply_from.id = "msg_reply_from_" + new_border_ID; … … 1299 1218 } 1300 1219 } 1301 var body = Element("body_" + new_border_ID);1302 body.contentWindow.document.open();1303 1220 // Insert the signature automaticaly at message body if use_signature preference is set 1304 if (preferences.use_signature == "1") { 1305 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) + "</body></html>"); 1306 } 1307 else { 1308 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+"</body></html>"); 1309 } 1310 body.contentWindow.document.close(); 1311 body.contentWindow.document.designMode = "on"; 1312 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1313 { 1314 if ( e.keyCode == 13 ) 1315 { 1316 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1317 for ( p = 0; p < paragraphs.length; p++ ) 1318 paragraphs.item( p ).style.margin = '0px'; 1319 } 1320 }); 1221 if (preferences.use_signature == "1") 1222 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); 1223 else 1224 RichTextEditor.setInitData(new_border_ID,make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); 1321 1225 Element("to_" + new_border_ID).focus(); 1322 1226 break; … … 1339 1243 Element('msg_number').value = ''; 1340 1244 } 1341 var body = document.getElementById("body_" + new_border_ID); 1342 body.contentWindow.document.open(); 1245 1343 1246 // Insert the signature automaticaly at message body if use_signature preference is set 1344 if (preferences.use_signature == "1") { 1345 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); 1346 } 1347 else { 1348 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); 1349 } 1350 body.contentWindow.document.close(); 1351 body.contentWindow.document.designMode = "on"; 1352 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1353 { 1354 if ( e.keyCode == 13 ) 1355 { 1356 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1357 for ( p = 0; p < paragraphs.length; p++ ) 1358 paragraphs.item( p ).style.margin = '0px'; 1359 } 1360 }); 1247 if (preferences.use_signature == "1") 1248 RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature); 1361 1249 Element("to_" + new_border_ID).focus(); 1362 1250 break; … … 1418 1306 } 1419 1307 } 1420 var body = Element("body_" + new_border_ID); 1421 body.contentWindow.document.open(); 1422 body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+data.body+"</body></html>"); 1423 body.contentWindow.document.close(); 1424 body.contentWindow.document.designMode = "on"; 1425 //Focus 1426 if (is_ie) 1427 window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); 1428 else 1429 body.contentWindow.focus(); 1430 config_events( body.contentWindow.document, 'onkeyup', function( e ) 1431 { 1432 if ( e.keyCode == 13 ) 1433 { 1434 var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); 1435 for ( p = 0; p < paragraphs.length; p++ ) 1436 paragraphs.item( p ).style.margin = '0px'; 1437 } 1438 }); 1308 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + data.body); 1439 1309 break; 1440 1310 default: 1441 1311 } 1442 1312 1443 // IM Module Enabled 1444 if( window.parent.loadscript && loadscript.autoStatusIM ) 1445 { 1446 config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM ); 1447 } 1448 1449 if ( ! expresso_offline ) 1450 { 1451 if ( mobile_device ) 1452 { 1453 var text_plain = document.getElementById( 'textplain_rt_checkbox_' + new_border_ID ); 1454 text_plain.click( ); 1455 text_plain.parentNode.style.display = 'none'; 1456 } 1457 } 1458 1459 if (preferences.auto_save_draft == 1) 1460 { 1461 openTab.autosave_timer[new_border_ID] = false; 1462 var save_link = document.getElementById("save_message_options"+new_border_ID); 1463 1464 function auto_sav() 1465 { 1466 if (openTab.autosave_timer[new_border_ID]) 1467 clearTimeout(openTab.autosave_timer[new_border_ID]); 1468 1469 openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time); 1470 } 1471 config_events(body.contentWindow.document,'keypress', auto_sav); 1472 } 1473 1474 //BEGIN Tab event 1475 if (preferences.use_shortcuts == '1') 1476 { 1477 if (is_ie) 1478 { 1479 body.contentWindow.document.attachEvent('onkeydown', function(event) {if(event.keyCode==27){delete_border(new_border_ID,'false');}if(event.keyCode==9) {Element('to_'+new_border_ID).focus();Element('send_button_'+new_border_ID).focus();return false;}}, false); 1480 } 1481 else 1482 { 1483 body.contentWindow.document.addEventListener('keypress', function(event) {if(event.keyCode==27){delete_border(new_border_ID,'false');}if(event.keyCode==9) {Element('send_button_'+new_border_ID).focus();event.preventDefault();}}, false); 1484 } 1485 } 1486 // END Tab event 1487 1488 // Load default style for <PRE> tag, inside RichTextEditor. 1489 RichTextEditor.loadStyle("pre","main.css"); 1490 RichTextEditor.Select( 'fontname' ); 1491 RichTextEditor.Select( 'fontsize' ); 1492 1313 1493 1314 Element("border_id_" + new_border_ID).title = title; 1494 1315 set_border_caption("border_id_" + new_border_ID, title); 1495 1316 1496 if(!expresso_offline && preferences.use_SpellChecker != '0')1497 setupSpellChecker();1498 1317 1499 1318 return new_border_ID; //Preciso retornar o ID da nova mensagem. … … 1730 1549 } 1731 1550 1732 if ( document.getElementById('viewsource_rt_checkbox_' + ID).checked == true )1733 document.getElementById('viewsource_rt_checkbox_' + ID).click();1734 1551 1735 1552 var save_link = Element("save_message_options_"+ID); … … 1750 1567 textArea.style.display='none'; 1751 1568 textArea.name = "body"; 1752 body = document.getElementById("body_"+ID); 1753 textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) ); 1569 textArea.value = RichTextEditor.getData('body_'+ID); 1754 1570 var input_folder = document.createElement("INPUT"); 1755 1571 input_folder.style.display='none'; … … 1868 1684 else 1869 1685 { 1686 var newImage = false; 1870 1687 openTab.imapUid[border_id] = data.msg_no; 1871 1688 openTab.imapBox[border_id] = data.folder_id; … … 1877 1694 1878 1695 // Replace the embedded images for new uids 1879 var mainField = document.getElementById('body_'+border_id).contentWindow; 1880 var bodyChildNodes = mainField.document.body.childNodes; 1696 var content_body = RichTextEditor.getData('body_'+border_id); 1881 1697 1882 1698 if (is_ie) … … 1911 1727 //content_body = content_body.replace(/msg_part=-/g,'msg_part='); 1912 1728 } 1913 mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body;1729 1914 1730 } 1915 1731 } … … 2001 1817 divFiles.appendChild(document.createElement("br")); 2002 1818 } 1819 } 1820 1821 if(RichTextEditor.newImageId !== false) 1822 { 1823 var rex = new RegExp('<img id="'+RichTextEditor.newImageId+'" src="" [^\/>]*\/>', 'i'); 1824 var newImg = '<img src="./inc/get_archive.php?msgFolder=INBOX'+cyrus_delimiter+draftsfolder+'&msgNumber='+openTab.imapUid[border_id]+'&indexPart=0.'+(openTab.countFile[border_id])+'" />'; 1825 content_body = content_body.replace(rex,newImg); 1826 1827 RichTextEditor.newImageID = false; 1828 newImage = true; 1829 } 1830 1831 if(body_images != null || newImage === true) 1832 { 1833 RichTextEditor.setData('body_'+border_id,content_body); 2003 1834 } 2004 1835 … … 2029 1860 withImage = false; 2030 1861 2031 var rt_checkbox = Element('viewsource_rt_checkbox_' + border_id);2032 if (rt_checkbox == null)2033 return false;2034 if (rt_checkbox.checked == true)2035 rt_checkbox.click();2036 2037 1862 var sendButton = Element("send_button_"+border_id); 2038 1863 if (sendButton) … … 2062 1887 textArea.style.display='none'; 2063 1888 textArea.name = "body"; 2064 body = document.getElementById("body_"+border_id); 2065 if (! body) 2066 return; 2067 textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) ); 1889 textArea.value = RichTextEditor.getData("body_"+border_id); 2068 1890 var input_folder = document.createElement("INPUT"); 2069 1891 input_folder.style.display='none'; … … 2138 1960 textArea.style.display='none'; 2139 1961 textArea.name = "body"; 2140 body = document.getElementById("body_"+border_id); 2141 textArea.value += '<body>\r\n'; 2142 textArea.value += body.contentWindow.document.body.innerHTML; 2143 textArea.value += '\r\n</body>'; 1962 textArea.value = RichTextEditor.getData("body_"+border_id); 2144 1963 2145 1964 var input_folder = document.createElement("INPUT"); -
trunk/expressoMail1_2/js/rich_text_editor.js
r4828 r5083 1 1 function cRichTextEditor(){ 2 this.emwindow = new Array; 3 this.editor = "body_1"; 4 this.table = ""; 5 this.id = "1"; 6 this.buildEditor(); 7 this.saveFlag = 0; 8 } 9 10 // This code was written by Tyler Akins and has been placed in the 11 // public domain. It would be nice if you left this header intact. 12 // Base64 code from Tyler Akins -- http://rumkin.com 13 14 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 15 16 var ua = navigator.userAgent.toLowerCase(); 17 if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) { 18 var StringMaker = function () { 19 this.str = ""; 20 this.length = 0; 21 this.append = function (s) { 22 this.str += s; 23 this.length += s.length; 24 } 25 this.prepend = function (s) { 26 this.str = s + this.str; 27 this.length += s.length; 28 } 29 this.toString = function () { 30 return this.str; 31 } 32 } 33 } else { 34 var StringMaker = function () { 35 this.parts = []; 36 this.length = 0; 37 this.append = function (s) { 38 this.parts.push(s); 39 this.length += s.length; 40 } 41 this.prepend = function (s) { 42 this.parts.unshift(s); 43 this.length += s.length; 44 } 45 this.toString = function () { 46 return this.parts.join(''); 47 } 48 } 49 } 50 51 function fromJSON( value ) 52 { 53 return (new Function( "return " + decode64( value )))(); 54 } 55 2 this.emwindow = new Array; 3 this.editor = "body_1"; 4 this.table = ""; 5 this.id = "1"; 6 this.saveFlag = 0; 7 this.signatures = false; 8 this.replyController = false; 9 this.newImageId = false; 10 this.plain = new Array; 11 this.editorReady = true; 12 } 13 14 // This code was written by Tyler Akins and has been placed in the 15 // public domain. It would be nice if you left this header intact. 16 // Base64 code from Tyler Akins -- http://rumkin.com 17 18 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 19 20 var ua = navigator.userAgent.toLowerCase(); 21 if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) { 22 var StringMaker = function () { 23 this.str = ""; 24 this.length = 0; 25 this.append = function (s) { 26 this.str += s; 27 this.length += s.length; 28 } 29 this.prepend = function (s) { 30 this.str = s + this.str; 31 this.length += s.length; 32 } 33 this.toString = function () { 34 return this.str; 35 } 36 } 37 } else { 38 var StringMaker = function () { 39 this.parts = []; 40 this.length = 0; 41 this.append = function (s) { 42 this.parts.push(s); 43 this.length += s.length; 44 } 45 this.prepend = function (s) { 46 this.parts.unshift(s); 47 this.length += s.length; 48 } 49 this.toString = function () { 50 return this.parts.join(''); 51 } 52 } 53 } 54 55 cRichTextEditor.prototype.fromJSON = function( value ) 56 { 57 return (new Function( "return " + this.decode64( value )))(); 58 } 59 60 cRichTextEditor.prototype.decode64 = function(input) { 61 if( typeof input === "undefined" ) return ''; 62 63 var output = new StringMaker(); 64 var chr1, chr2, chr3; 65 var enc1, enc2, enc3, enc4; 66 var i = 0; 67 68 // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 69 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 70 71 while (i < input.length) { 72 enc1 = keyStr.indexOf(input.charAt(i++)); 73 enc2 = keyStr.indexOf(input.charAt(i++)); 74 enc3 = keyStr.indexOf(input.charAt(i++)); 75 enc4 = keyStr.indexOf(input.charAt(i++)); 76 77 chr1 = (enc1 << 2) | (enc2 >> 4); 78 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 79 chr3 = ((enc3 & 3) << 6) | enc4; 80 81 output.append(String.fromCharCode(chr1)); 82 83 if (enc3 != 64) { 84 output.append(String.fromCharCode(chr2)); 85 } 86 if (enc4 != 64) { 87 output.append(String.fromCharCode(chr3)); 88 } 89 } 90 91 return output.toString(); 92 } 93 94 95 cRichTextEditor.prototype.loadEditor = function(ID) { 96 97 var parentDiv = document.getElementById("body_position_" + ID); 98 var pObj = "body_" + ID; 99 var textArea = document.createElement("TEXTAREA"); 100 textArea.id = pObj; 101 textArea.style.height = '500'; 102 textArea.style.width = '100%'; 103 parentDiv.appendChild(textArea); 104 RichTextEditor.plain[ID] = false; 105 106 if(preferences.plain_text_editor == 1) 107 RichTextEditor.plain[ID] = true; 108 else 109 RichTextEditor.active(pObj); 110 } 111 112 cRichTextEditor.prototype.getSignaturesOptions = function() { 113 114 if(RichTextEditor.signatures !== false) 115 return RichTextEditor.signatures; 116 117 var signatures = this.fromJSON( preferences.signatures ); 118 var signature_types = this.fromJSON( preferences.signature_types ); 119 120 for( key in signatures ) 121 if( !signature_types[key] ) 122 signatures[key] = signatures[key].replace( /\n/g, "<br>" ); 123 124 RichTextEditor.signatures = signatures; 125 return signatures; 126 127 } 128 129 cRichTextEditor.prototype.getSignatureDefault = function() { 130 131 if(RichTextEditor.signatures === false) 132 RichTextEditor.signatures = RichTextEditor.getSignaturesOptions(); 133 134 if(!RichTextEditor.signatures || 135 !RichTextEditor.signatures[preferences.signature_default || ""]) 136 { 137 preferences.use_signature = "0"; //Desabilita o uso da assinatura 138 return ''; 139 } 140 141 return unescape(RichTextEditor.signatures[preferences.signature_default]); 142 143 } 144 145 cRichTextEditor.prototype.createImage = function(){ 146 if (preferences.auto_save_draft == 1) 147 { 148 autosave_time = 200000; 149 clearTimeout(openTab.autosave_timer[currentTab]); 150 } 151 152 var form = document.getElementById("attachment_window"); 153 154 if (form == null){ 155 form = document.createElement("DIV"); 156 form.id = "attachment_window"; 157 form.style.visibility = "hidden"; 158 form.style.position = "absolute"; 159 form.style.background = "#eeeeee"; 160 form.style.left = "0px"; 161 form.style.top = "0px"; 162 form.style.width = "0px"; 163 form.style.height = "0px"; 164 document.body.appendChild(form); 165 } 166 var form_upload = Element('form_upload'); 167 if (form_upload == null) 168 form_upload = document.createElement("DIV"); 169 form_upload.id = "form_upload"; 170 form_upload.style.position = "absolute"; 171 form_upload.style.top = "5px"; 172 form_upload.style.left = "5px"; 173 form_upload.name = get_lang("Upload File"); 174 form_upload.style.width = "450px"; 175 form_upload.style.height = "75px"; 176 form_upload.innerHTML = get_lang('Select the desired image file')+':<br>'+ 177 '<input name="image_at" maxlength="255" size="40" id="inputFile_img" type="file"><br>' + 178 '<input title="' + get_lang('Include') + '" value="' + get_lang('Include') + '"' + 179 'type="button" onclick="RichTextEditor.addInputFile();"> ' + 180 '<input title="' + get_lang('Close') + '" value="' + get_lang('Close') + '"' + 181 ' type="button" onclick="win.close()">'; 182 form.appendChild(form_upload); 56 183 57 function decode64(input) { 58 59 if( typeof input === "undefined" ) return; 60 61 var output = new StringMaker(); 62 var chr1, chr2, chr3; 63 var enc1, enc2, enc3, enc4; 64 var i = 0; 65 66 // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 67 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 68 69 while (i < input.length) { 70 enc1 = keyStr.indexOf(input.charAt(i++)); 71 enc2 = keyStr.indexOf(input.charAt(i++)); 72 enc3 = keyStr.indexOf(input.charAt(i++)); 73 enc4 = keyStr.indexOf(input.charAt(i++)); 74 75 chr1 = (enc1 << 2) | (enc2 >> 4); 76 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 77 chr3 = ((enc3 & 3) << 6) | enc4; 78 79 output.append(String.fromCharCode(chr1)); 80 81 if (enc3 != 64) { 82 output.append(String.fromCharCode(chr2)); 83 } 84 if (enc4 != 64) { 85 output.append(String.fromCharCode(chr3)); 86 } 87 } 88 89 return output.toString(); 90 91 92 } 93 94 cRichTextEditor.prototype.loadEditor = function(ID) { 95 var _this = this; 96 _this.id = ID; 97 parentDiv = document.getElementById("body_position_"+this.id); 98 this.editor = "body_"+this.id; 99 100 if(this.table.parentNode) 101 this.table.parentNode.removeChild(this.table); 102 103 if( parentDiv.firstChild ) 104 { 105 if (!parentDiv.firstChild.hasChildNodes()) 106 parentDiv.insertBefore(this.table,parentDiv.firstChild); 107 } 108 else 109 parentDiv.appendChild(this.table); 110 111 var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id ); 112 this.table.style.visibility = ( mail_as_plain && mail_as_plain.checked ) ? 'hidden' : 'visible'; 113 if(!Element(this.editor)) 114 { 115 this.createElementEditor(this.editor); 116 } 117 else 118 { 119 Element("viewsource_rt_checkbox_" + this.id).checked=false; 120 } 121 122 document.getElementById('fontname').selectedIndex = 1; 123 document.getElementById('fontsize').selectedIndex = 2; 124 } 125 126 cRichTextEditor.prototype.createElementEditor = function(pObj) 127 { 128 iframe = document.createElement("IFRAME"); 129 iframe.id = pObj; 130 iframe.name = pObj; 131 iframe.width = "99%"; 132 iframe.height = 300; 133 iframe.setAttribute("unselectable","on"); 134 iframe.setAttribute("tabIndex","1"); 135 136 config_events( iframe, 'onload', function( ) 137 { 138 if ( iframe.contentWindow.document.body && iframe.contentWindow.document.body.contentEditable ) { 139 140 if(mobile_device) 141 iframe.contentWindow.document.body.contentEditable = true; 142 else 143 iframe.contentWindow.document.designMode = "on"; 144 } 145 146 if ( iframe.contentWindow.document.documentElement ){ 147 iframe.contentWindow.document.documentElement.style.background = '#fff'; 148 iframe.contentWindow.document.documentElement.style.fontSize = '16px'; 149 } 150 }); 151 152 153 parentDiv.appendChild(iframe); 154 155 var source = document.createElement( 'input' ); 156 source.id = 'viewsource_rt_checkbox_' + this.id; 157 source.type = "checkbox"; 158 source.setAttribute("tabIndex","-1"); 159 source.onclick = function( ) 160 { 161 RichTextEditor.viewsource(this.checked); 162 }; 163 source = parentDiv.appendChild( 164 document.createElement( 'span' ).appendChild( source ).parentNode 165 ).appendChild( 166 document.createTextNode( get_lang( 'View HTML source' ) + '.' ) 167 ).parentNode; 168 169 } 170 171 cRichTextEditor.prototype.loadStyle = function(tag, css_file) { 172 var theRules = new Array(); 173 var stylePRE = ""; 174 for(var s = 0; s < document.styleSheets.length; s++) { 175 if(document.styleSheets[s].href != null && 176 document.styleSheets[s].href.match("templates/"+template+"/"+css_file)){ 177 if (document.styleSheets[s].cssRules) 178 theRules = document.styleSheets[s].cssRules; 179 else if (document.styleSheets[s].rules) 180 theRules = document.styleSheets[s].rules; 181 break; 182 } 183 } 184 for(var s = 0;s < theRules.length; s++){ 185 if(theRules[s].selectorText.toLowerCase() == tag.toLowerCase()){ 186 stylePRE = theRules[s].style; 187 break; 188 } 189 } 190 var _body = Element(this.editor); 191 var i_doc = (document.all) ? _body.contentWindow.document: _body.contentDocument; 192 var hh1 = i_doc.getElementsByTagName('head')[0]; 193 // For IE 194 if(typeof(hh1) == 'undefined'){ 195 hh1 = i_doc.createElement("head"); 196 i_doc.appendChild(hh1); 197 } 198 var ss1 = i_doc.createElement('style'); 199 ss1.setAttribute("type", "text/css"); 200 var def = tag.toLowerCase()+' {'+stylePRE.cssText+'}'; 201 if (ss1.styleSheet) { 202 ss1.styleSheet.cssText = def; 203 } else { 204 var tt1 = i_doc.createTextNode(def); 205 ss1.appendChild(tt1); 206 } 207 hh1.appendChild(ss1); 208 } 209 210 cRichTextEditor.prototype.viewsource = function(source) { 211 var html; 212 var mainField = document.getElementById(this.editor).contentWindow; 213 if (source) { 214 if (is_ie){ 215 connector.loadScript('html2xhtml'); 216 html = frames[this.editor].document.body; 217 var xhtml = get_xhtml(html, 'en', 'iso-8859-1'); 218 frames[this.editor].document.body.innerText = xhtml; 219 document.getElementById("table_richtext_toolbar").style.visibility="hidden"; 220 } 221 else{ 222 html = document.createTextNode(document.getElementById(this.editor).contentWindow.document.body.innerHTML); 223 document.getElementById(this.editor).contentWindow.document.body.innerHTML = ""; 224 html = document.getElementById(this.editor).contentWindow.document.importNode(html,false); 225 document.getElementById(this.editor).contentWindow.document.body.appendChild(html); 226 document.getElementById("table_richtext_toolbar").style.visibility="hidden"; 227 } 228 } else { 229 if (is_ie){ 230 var output = escape(frames[this.editor].document.body.innerText); 231 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); 232 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); 233 frames[this.editor].document.body.innerHTML = unescape(output); 234 document.getElementById("table_richtext_toolbar").style.visibility="visible"; 235 } 236 else{ 237 html = document.getElementById(this.editor).contentWindow.document.body.ownerDocument.createRange(); 238 html.selectNodeContents(document.getElementById(this.editor).contentWindow.document.body); 239 document.getElementById(this.editor).contentWindow.document.body.innerHTML = html.toString(); 240 document.getElementById("table_richtext_toolbar").style.visibility="visible"; 241 } 242 } 243 } 244 245 246 cRichTextEditor.prototype.plain = function(source) { 247 var html; 248 var editor = document.getElementById( this.editor ); 249 250 if (source) { 251 if (is_ie){ 252 connector.loadScript('html2xhtml'); 253 html = frames[this.editor].document.body; 254 var xhtml = get_xhtml(html, 'en', 'iso-8859-1'); 255 frames[this.editor].document.body.innerText = xhtml; 256 document.getElementById("table_richtext_toolbar").style.visibility="hidden"; 257 } 258 else{ 259 var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id ); 260 html = document.createTextNode( editor.contentWindow.document.body.innerHTML ); 261 262 html = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' ).replace( /^[\n ]+|[\n ]+$/g, '' ); 263 264 if ( ! mobile_device && html != '' && ! ( mail_as_plain.checked = confirm( get_lang( 'The text format will be lost' ) + '.' ) ) ) 265 return false; 266 267 this.table.style.visibility="hidden"; 268 editor.contentWindow.document.body.innerHTML = ''; 269 270 var textarea = document.createElement( 'textarea' ); 271 textarea.style.width = '99%'; 272 textarea.style.height = '300px'; 273 textarea.style.fontSize = '12pt'; 274 textarea.innerHTML = html; 275 276 editor.style.width = '0px'; 277 editor.style.height = '0px'; 278 editor.style.visibility = 'hidden'; 279 280 editor.parentNode.insertBefore( textarea, editor ); 281 textarea.focus( ); 282 } 283 } else { 284 if (is_ie){ 285 var output = escape(frames[this.editor].document.body.innerText); 286 output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); 287 output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); 288 frames[this.editor].document.body.innerHTML = unescape(output); 289 document.getElementById("table_richtext_toolbar").style.visibility="visible"; 290 } 291 else{ 292 editor.contentWindow.document.body.innerHTML = editor.previousSibling.value.replace( /\n/g, '<br/>' ); 293 editor.parentNode.removeChild( editor.previousSibling ); 294 295 editor.style.width = '99%'; 296 editor.style.height = '300px'; 297 editor.style.visibility = 'visible'; 298 this.loadEditor( this.id ); 299 300 setTimeout( function( ) { editor.contentWindow.focus( ); }, 100 ); 301 } 302 } 303 } 304 305 306 cRichTextEditor.prototype.buildSelect = function( selectId, label, options, decode ) { 307 308 var selectBox = document.createElement("SELECT"); 309 selectBox.id = selectId; 310 selectBox.setAttribute("tabIndex","-1"); 311 selectBox.onchange = function () {RichTextEditor.Select( selectId );}; 312 selectBox.className = 'select_richtext'; 313 selectBox.length = 0; 314 315 selectBox.options[0] = new Option( get_lang(label), label ); 316 317 for( var key in options ) 318 selectBox.options[ selectBox.length ] = new Option( key, unescape( options[key] ) ); 319 320 return selectBox; 321 } 322 323 cRichTextEditor.prototype.buildEditor = function() { 324 this.table = document.createElement("TABLE"); 325 this.table.id = "table_richtext_toolbar"; 326 this.table.className = "richtext_toolbar"; 327 this.table.width = "100%"; 328 var tbody = document.createElement("TBODY"); 329 var tr = document.createElement("TR"); 330 var td = document.createElement("TD"); 331 var div_button_rt = document.createElement("DIV"); 332 333 334 selectBox = this.buildSelect( "fontname", 'Font', { 'Arial' : 'Arial', 335 'Courier' : 'Courier', 336 'Times New Roman' : 'Times' }); 337 338 div_button_rt.appendChild( selectBox ); 339 340 selectBox = this.buildSelect( "fontsize", 'Size', { '1 (8 pt)': '1', 341 '2 (10 pt)': '2', 342 '3 (12 pt)': '3', 343 '4 (14 pt)': '4', 344 '5 (18 pt)': '5', 345 '6 (24 pt)': '6', 346 '7 (36 pt)': '7' }); 347 348 div_button_rt.appendChild( selectBox ); 349 350 var buttons = ['bold', 'italic', 'underline', 'forecolor', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 351 'undo', 'redo', 'insertorderedlist', 'insertunorderedlist', 'outdent', 'indent', 'link', 'image', 'table', 'signature']; 352 353 for (var i=0; i<buttons.length; i++){ 354 var img = document.createElement("IMG"); 355 img.id = buttons[i]; 356 img.className = 'imagebutton'; 357 img.align = 'center'; 358 img.src = './templates/'+template+'/images/'+buttons[i]+'.gif'; 359 img.title = get_lang(buttons[i]); 360 img.style.cursor = 'pointer'; 361 362 if (buttons[i] == 'forecolor') 363 img.onclick = function () {RichTextEditor.show_pc('forecolor')}; 364 else if (buttons[i] == 'link') 365 img.onclick = function () {RichTextEditor.createLink();}; 366 else if (buttons[i] == 'image') 367 img.onclick = function () {RichTextEditor.createImage();}; 368 else if (buttons[i] == 'table') 369 img.onclick = function () {RichTextEditor.createTable();}; 370 else 371 img.onclick = function () {RichTextEditor.editorCommand(this.id,'');}; 372 373 img.onmouseover = function () {this.style.border="outset 2px";}; 374 img.onmouseout = function () {this.style.border="solid 2px #C0C0C0";}; 375 div_button_rt.appendChild(img); 376 } 377 if(preferences.use_SpellChecker != '0'){ 378 selectBox=document.createElement("SELECT"); 379 selectBox.id="selectLanguage"; 380 selectBox.setAttribute("tabIndex","-1"); 381 selectBox.setAttribute("unselectable","on"); 382 selectBox.className = 'select_richtext'; 383 selectBox.onchange = function () {RichTextEditor.Select("selectLanguage");}; 384 var option1 = new Option(get_lang("Portuguese"),"pt_BR" ); 385 option1.selected = true; 386 var option2 = new Option(get_lang("English"),'en'); 387 var option3 = new Option(get_lang("Spanish"),'es'); 388 if (is_ie){ 389 selectBox.add(option1); 390 selectBox.add(option2); 391 selectBox.add(option3); 392 } 393 else{ 394 selectBox.add(option1, null); 395 selectBox.add(option2, null); 396 selectBox.add(option3, null); 397 } 398 div_button_rt.appendChild(selectBox); 399 400 // spellCheck button 401 var img = document.createElement("IMG"); 402 img.id = "spellCheck"; 403 img.className = 'imagebutton'; 404 img.align = 'center'; 405 img.src = './templates/'+template+'/images/'+img.id+'.gif'; 406 img.title = get_lang(img.id); 407 img.style.cursor = 'pointer'; 408 img.onclick = function () {RichTextEditor.editorCommand(this.id,'');}; 409 img.onmouseover = function () {this.style.border="outset 2px";}; 410 img.onmouseout = function () {this.style.border="solid 2px #C0C0C0";}; 411 div_button_rt.appendChild(img); 412 } 413 414 preferences.signatures = fromJSON( preferences.signatures ); 415 preferences.signature_types = fromJSON( preferences.signature_types ); 416 417 for( key in preferences.signatures ) 418 if( !preferences.signature_types[key] ) 419 preferences.signatures[key] = preferences.signatures[key].replace( /\n/g, "<br>" ); 420 421 selectBox = this.buildSelect( "inserthtml", 'Signature', preferences.signatures ); 422 div_button_rt.appendChild( selectBox ); 423 424 td.appendChild(div_button_rt); 425 tr.appendChild(td); 426 tbody.appendChild(tr); 427 this.table.appendChild(tbody); 428 } 429 430 cRichTextEditor.prototype.editorCommand = function(command, option) { 431 try { 432 var mainField = document.getElementById(this.editor).contentWindow; 433 mainField.focus(); 434 var signature = preferences.signature; 435 if( !preferences.signatures ) 436 signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 437 if (command == 'signature'){ 438 if (is_ie){ 439 var sel = document.selection; 440 if (sel!=null) 441 { 442 var rng = sel.createRange(); 443 if (rng!=null) 444 rng.pasteHTML(signature); 445 } 446 } 447 else{ 448 mainField.document.execCommand('inserthtml', false, signature); 449 } 450 } 451 else if (command == 'CreateLink') 452 mainField.document.execCommand('CreateLink', false, option); 453 else if (command == 'Table'){ 454 if (is_ie){ 455 var sel = document.selection; 456 if (sel!=null) 457 { 458 var rng = sel.createRange(); 459 if (rng!=null) 460 rng.pasteHTML(option); 461 } 462 } 463 else 464 mainField.document.execCommand('inserthtml', false, option); 465 } 466 else if (command == 'Image') 467 mainField.document.execCommand('InsertImage', false, option); 468 else if (command == 'spellCheck' && preferences.use_SpellChecker != '0'){ 469 beginSpellCheck(); // configure 470 spellCheck(); // run spellChecker 471 } 472 else 473 mainField.document.execCommand(command, false, option); 474 //mainField.focus(); 475 } catch (e) {/* alert(e);*/ } 476 } 477 478 cRichTextEditor.prototype.createLink = function(){ 479 var mainField = document.getElementById(this.editor).contentWindow; 480 if (is_ie){ 481 if ((mainField.document.selection.createRange().text) == ''){ 482 alert(get_lang('Chose the text you want transform in link before.')); 184 this.showWindow(form); 185 } 186 cRichTextEditor.prototype.showWindow = function (div){ 187 188 if(! div) { 483 189 return; 484 190 } 485 } 486 else{ 487 if (mainField.window.getSelection() == ''){ 488 alert(get_lang('Chose the text you want transform in link before.')); 489 return; 191 192 if(! this.emwindow[div.id]) { 193 div.style.width = div.firstChild.style.width; 194 div.style.height = div.firstChild.style.height; 195 div.style.zIndex = "10000"; 196 var title = div.firstChild.name; 197 var wHeight = div.offsetHeight + "px"; 198 var wWidth = div.offsetWidth + "px"; 199 div.style.width = div.offsetWidth - 5; 200 201 win = new dJSWin({ 202 id: 'win_'+div.id, 203 content_id: div.id, 204 width: wWidth, 205 height: wHeight, 206 title_color: '#3978d6', 207 bg_color: '#eee', 208 title: title, 209 title_text_color: 'white', 210 button_x_img: '../phpgwapi/images/winclose.gif', 211 border: true}); 212 213 this.emwindow[div.id] = win; 214 win.draw(); 490 215 } 491 } 492 var szURL = prompt(get_lang('Enter with link URL:'), 'http://'); 493 if ((szURL != null) && (szURL != "")){ 494 this.editorCommand("CreateLink", szURL); 495 } 496 } 497 498 // It include the image file in emails body 499 // It saves and attach in drafts folder and open it 216 else 217 win = this.emwindow[div.id]; 218 win.open(); 219 } 500 220 cRichTextEditor.prototype.addInputFile = function() 501 221 { … … 518 238 } 519 239 // End: Verify image extension. 520 var id = this.editor.substr(5); // border_id 240 var id = currentTab; 521 241 divFiles = document.getElementById("divFiles_"+id); 522 242 var countDivFiles = divFiles.childNodes.length + 1; … … 535 255 RichTextEditor.saveFlag = 0; // See if save function finished 536 256 var save_link = document.getElementById("save_message_options_"+id); 257 save_link.onclick = function () {}; 258 this.newImageId = new Date().getTime(); 259 CKEDITOR.instances['body_'+id].insertHtml('<img id="'+this.newImageId+'" src=""/>'); 537 260 save_msg(id,true); 538 RichTextEditor.insertImgHtml(id); 261 } 262 263 cRichTextEditor.prototype.execPosInstance = function(inst) { 264 265 var editor = CKEDITOR.instances[inst]; 266 267 268 var id = inst.replace('body_',''); 269 270 editor.document.on('keydown', function(event) 271 { 272 away = false; 273 var save_link = Element("save_message_options_"+id); 274 save_link.onclick = function onclick() {openTab.toPreserve[id] = true;save_msg(id);} ; 275 save_link.className = 'message_options'; 276 }); 277 278 //Adicionando atalhos de preferencias 279 //TODO: Não esta pegando o numero (keycode) 280 // if (preferences.use_shortcuts == '1') 281 // { 282 // CKEDITOR.instances[inst].document.on('keyup', function(event){ 283 // if(event.keyCode == 27){ 284 // delete_border(id,'false');} //Tecla delete fechar aba 285 // }); 286 // } 287 288 // IM Module Enabled 289 if( window.parent.loadscript && loadscript.autoStatusIM ) 290 { 291 CKEDITOR.instances[inst].document.on('keydown', function(event){ 292 loadscript.autoStatusIM; 293 }); 294 } 295 296 if (preferences.auto_save_draft == 1) 297 { 298 openTab.autosave_timer[id] = false; 299 var save_link = document.getElementById("save_message_options"+id); 300 CKEDITOR.instances[inst].document.on('keydown', function(event){ 301 if (openTab.autosave_timer[id]) 302 clearTimeout(openTab.autosave_timer[id]); 303 openTab.autosave_timer[id] = setTimeout("save_msg("+id+")", autosave_time); 304 305 }); 306 } 307 ///////////////////////////////////////////////////////////////////////////////////// 308 309 310 311 RichTextEditor.editorReady = true; 312 } 313 cRichTextEditor.prototype.setPlain = function (active,id){ 314 RichTextEditor.plain[id] = active; 315 if(active === true) 316 { 317 CKEDITOR.instances['body_'+id].destroy(); 318 var height = document.body.scrollHeight; 319 height -= 330; 320 $('#body_'+id).height(height); 321 $('#body_'+id).keydown(function(event) { 322 away = false; 323 var save_link = Element("save_message_options_"+id); 324 save_link.onclick = function onclick() {openTab.toPreserve[id] = true;save_msg(id);} ; 325 save_link.className = 'message_options'; 326 }); 327 328 } 329 else 330 RichTextEditor.active('body_'+id); 331 } 332 333 cRichTextEditor.prototype.getData = function (inst){ 334 var id = inst.replace('body_',''); 335 336 if(RichTextEditor.plain[id] === true) 337 return $('#'+inst).val(); 338 else 339 return CKEDITOR.instances[inst].getData(); 340 } 341 cRichTextEditor.prototype.setData = function (id,data){ 342 343 if(this.plain[id] === true) 344 $('#'+id).val(data); 345 else 346 CKEDITOR.instances[id].setData(data) 347 } 348 cRichTextEditor.prototype.setInitData = function (id,data,reply,recursion){ 349 350 if(recursion === undefined) recursion = 1; 351 else recursion++; 352 353 if(this.plain[id] === true) 354 { 355 if($('#'+id) !== undefined) 356 $('#'+id).val(data); 357 else 358 setTimeout(function() {RichTextEditor.setInitData(id,data,reply,recursion); }, 500); 359 } 360 else 361 { 362 if( RichTextEditor.editorReady === true && CKEDITOR.instances['body_'+id] !== undefined ) 363 { 364 var editor = CKEDITOR.instances['body_'+id]; 365 editor.insertHtml(''); 366 var selection = editor.getSelection(); 367 if(selection !== undefined && selection !== null) var selectionRanges = selection.getRanges(); 368 369 editor.insertHtml('<div><br type="_moz"></div>'+data); 370 371 if(selection !== null) selection.selectRanges(selectionRanges); 372 373 editor.execCommand("autogrow"); //Atualiza tamanho do editor 374 375 //Caso não for uma resposta votla o foco para o input to 376 if(reply === undefined) 377 setTimeout("$('#to_"+id+"').focus()",100); 378 379 } 380 else if(recursion < 20) 381 setTimeout(function() {RichTextEditor.setInitData(id,data,reply,recursion); }, 500); 382 } 383 } 384 385 cRichTextEditor.prototype.destroy = function(id) 386 { 387 //Remove Instancia do editor 388 if( CKEDITOR.instances[id] !== undefined ) 389 CKEDITOR.remove(CKEDITOR.instances[id]); 390 } 391 cRichTextEditor.prototype.active = function(id) 392 { 393 394 //Remove Instancia do editor caso ela exista 395 if( CKEDITOR.instances[id] !== undefined ) 396 CKEDITOR.remove(CKEDITOR.instances[id]); 397 398 $('#'+id).ckeditor( 399 function() {RichTextEditor.execPosInstance(id)}, 400 { 401 toolbar:'mail' 402 }); 403 404 } 405 cRichTextEditor.prototype.focus = function(id) 406 { 407 if(RichTextEditor.plain[id] === true) 408 $('#body_'+id).focus(); 409 else 410 CKEDITOR.instances['body_'+id].focus(); 411 412 } 413 //Função reseta o atributo contentEditable para resolver bug de cursor ao trocar abas 414 cRichTextEditor.prototype.setEditable = function(id) { 415 if( CKEDITOR.instances['body_'+ id] === undefined ) return; 416 var element = CKEDITOR.instances['body_'+ id].document.getBody(); 417 element.removeAttribute('contentEditable'); 418 element.setAttribute('contentEditable','true'); 539 419 } 540 541 cRichTextEditor.prototype.insertImgHtml = function (id)542 {543 if ( RichTextEditor.saveFlag == 0 )544 {545 setTimeout( function(){ RichTextEditor.insertImgHtml(id); },1000 );546 }547 else548 {549 if ( RichTextEditor.saveFlag == 1 )550 {551 var folderNameDraft = "INBOX" + cyrus_delimiter + draftsfolder;552 this.editorCommand('Image', './inc/show_embedded_attach.php?msg_folder=' + folderNameDraft + '&msg_num='+openTab.imapUid[id]+'&msg_part='+(openTab.countFile[id]+1));553 openTab.toPreserve[id] = true;554 save_msg(id,true);555 }556 }557 }558 559 560 cRichTextEditor.prototype.insertTableHtml = function (){561 var id = this.editor.substr(5); // border_id562 var rows = document.getElementById('rows').value;563 var cols = document.getElementById('cols').value;564 var border = document.getElementById('border').value;565 var insertTable = '<table border="'+border+'px"><tbody>';566 for (var i = 0; i < rows; i++){567 insertTable += "<tr>";568 for (var j = 0; j < cols; j++)569 insertTable += "<td> </td>";570 insertTable += "</tr>";571 }572 insertTable += "</tbody></table>";573 this.editorCommand('Table', insertTable);574 }575 576 cRichTextEditor.prototype.createTable = function(){577 var form = document.getElementById("table_window");578 if (form == null){579 form = document.createElement("DIV");580 form.id = "table_window";581 form.style.visibility = "hidden";582 form.style.position = "absolute";583 form.style.background = "#eeeeee";584 form.style.left = "0px";585 form.style.top = "0px";586 form.style.width = "0px";587 form.style.height = "0px";588 document.body.appendChild(form);589 }590 591 var form_table = document.createElement("DIV");592 form_table.id = "form_table";593 form_table.style.position = "absolute";594 form_table.style.top = "5px";595 form_table.style.left = "5px";596 form_table.style.width = "190px";597 form_table.style.height = "90px";598 form_table.name = get_lang("Insert Table");599 form_table.innerHTML = get_lang('Select the table size')+':<br><br><table cellspacing="0"><tbody><tr><td align="center">'+600 get_lang('Rows')+':</td><td></td><td align="center">'+get_lang('Cols')+':</td><td></td><td align="center">'+get_lang('Border')+':</td></tr>'+601 '<tr><td align="right"><input type="text" readonly="true" id="rows" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'rows\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'rows\');"></img></td>'+602 '<td align="right"><input type="text" readonly="true" id="cols" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'cols\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'cols\');"></img></td>'+603 '<td align="right"><input type="text" readonly="true" id="border" size="2" maxlength="2" value="1"></input></td><td align="left"><img src="templates/'+template+'/images/plus.png" onclick="javascript:RichTextEditor.incrementField(\'border\');"></img><br><img src="templates/'+template+'/images/minus.png" onclick="javascript:RichTextEditor.decrementField(\'border\');"></img></td>'+604 '</tr></tbody></table>'+605 ' <input title="'+get_lang('Close')+'" value="' + get_lang('Close') + '" type="button" onclick="win.close()"> '+606 '<input title="' + get_lang('Include') + '" value="' + get_lang('Include') + '" type="button" onclick="RichTextEditor.insertTableHtml();win.close();">';607 form.appendChild(form_table);608 609 this.showWindow(form);610 }611 612 cRichTextEditor.prototype.incrementField = function(id_val){613 var field_text = document.getElementById(id_val);614 field_text.value = parseInt(field_text.value)+1;615 }616 617 cRichTextEditor.prototype.decrementField = function(id_val){618 var field_text = document.getElementById(id_val);619 if (parseInt(field_text.value) > 0)620 field_text.value = parseInt(field_text.value)-1;621 }622 623 cRichTextEditor.prototype.createImage = function(){624 if (preferences.auto_save_draft == 1){625 autosave_time = 200000;626 clearTimeout(openTab.autosave_timer[currentTab]);627 }628 var form = document.getElementById("attachment_window");629 if (form == null){630 form = document.createElement("DIV");631 form.id = "attachment_window";632 form.style.visibility = "hidden";633 form.style.position = "absolute";634 form.style.background = "#eeeeee";635 form.style.left = "0px";636 form.style.top = "0px";637 form.style.width = "0px";638 form.style.height = "0px";639 document.body.appendChild(form);640 }641 var form_upload = Element('form_upload');642 if (form_upload == null)643 form_upload = document.createElement("DIV");644 form_upload.id = "form_upload";645 form_upload.style.position = "absolute";646 form_upload.style.top = "5px";647 form_upload.style.left = "5px";648 form_upload.name = get_lang("Upload File");649 form_upload.style.width = "550px";650 form_upload.style.height = "100px";651 form_upload.innerHTML = get_lang('Select the desired image file')+':<br>'+652 '<input name="image_at" maxlength="255" size="40" id="inputFile_img" type="file"><br/><br/>' +653 '<input title="' + get_lang('Include') + '" value="' + get_lang('Include') + '"' + 'type="button" onclick="RichTextEditor.addInputFile();"> ' +654 '<input title="' + get_lang('Close') + '" value="' + get_lang('Close') + '"' +655 ' type="button" onclick="win.close()">';656 form.appendChild(form_upload);657 658 this.showWindow(form);659 }660 cRichTextEditor.prototype.showWindow = function (div){661 662 if(! div) {663 return;664 }665 666 if(! this.emwindow[div.id]) {667 div.style.width = div.firstChild.style.width;668 div.style.height = div.firstChild.style.height;669 div.style.zIndex = "10000";670 var title = div.firstChild.name;671 var wHeight = div.offsetHeight + "px";672 var wWidth = div.offsetWidth + "px";673 div.style.width = div.offsetWidth - 5;674 675 win = new dJSWin({676 id: 'win_'+div.id,677 content_id: div.id,678 width: wWidth,679 height: wHeight,680 title_color: '#3978d6',681 bg_color: '#eee',682 title: title,683 title_text_color: 'white',684 button_x_img: '../phpgwapi/images/winclose.gif',685 border: true });686 687 this.emwindow[div.id] = win;688 win.draw();689 }690 else691 win = this.emwindow[div.id];692 win.open();693 }694 695 cRichTextEditor.prototype.Select = function(selectname)696 {697 var mainField = Element(this.editor).contentWindow;698 var cursel = document.getElementById(selectname).selectedIndex;699 700 if (cursel != 0) {701 var selected = document.getElementById(selectname).options[cursel].value;702 mainField.document.execCommand(selectname, false, selected);703 document.getElementById(selectname).selectedIndex = "Size"; //cursel;704 }705 mainField.focus();706 }707 708 cRichTextEditor.prototype.show_pc = function(command)709 {710 connector.loadScript("color_palette");711 ColorPalette.loadPalette(this.id);712 if (ColorPalette.div.style.visibility != "visible")713 ColorPalette.div.style.visibility="visible";714 else715 this.hide_pc();716 }717 718 cRichTextEditor.prototype.hide_pc = function()719 {720 document.getElementById("palettecolor").style.visibility="hidden";721 }722 723 cRichTextEditor.prototype.getOffsetTop = function(elm) {724 var mOffsetTop = elm.offsetTop;1725 var mOffsetParent = elm.offsetParent;726 while(mOffsetParent){727 mOffsetTop += mOffsetParent.offsetTop;728 mOffsetParent = mOffsetParent.offsetParent;729 }730 return mOffsetTop;731 }732 733 cRichTextEditor.prototype.getOffsetLeft = function(elm) {734 var mOffsetLeft = elm.offsetLeft;735 var mOffsetParent = elm.offsetParent;736 while(mOffsetParent){737 mOffsetLeft += mOffsetParent.offsetLeft;738 mOffsetParent = mOffsetParent.offsetParent;739 }740 return mOffsetLeft;741 }742 743 420 //Build the Object 744 421 RichTextEditor = new cRichTextEditor(); -
trunk/expressoMail1_2/setup/phpgw_pt-br.lang
r5075 r5083 685 685 Quick Search Contacts expressoMail1_2 pt-br Busca rápida de contatos 686 686 All Catalogs expressoMail1_2 pt-br Todos catálogos 687 Use plain text editor with standard ? expressoMail1_2 pt-br Usar editor de texto simples como padrão ? 687 688 -
trunk/expressoMail1_2/templates/default/index.tpl
r5075 r5083 132 132 </div> 133 133 <link href="../library/jquery/css/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css"> 134 <script src='../library/jquery/jquery.js' language='javascript'></script>135 134 <script type="text/javascript" src="../library/jquery/jquery-ui.min.js"></script> 136 135 <link href="templates/default/quick_search.css" rel="stylesheet" type="text/css"> -
trunk/preferences/templates/default/index.tpl
r1155 r5083 1 1 <!-- BEGIN list --> 2 <table border="0" width=" 75%" cellspacing="0" cellpadding="0">2 <table border="0" width="100%" cellspacing="0" cellpadding="0"> 3 3 <tr> 4 4 <td align="left">{tabs}</td> -
trunk/preferences/templates/default/preferences.tpl
r4828 r5083 2 2 <!-- BEGIN form --> 3 3 <form method="POST" action="{action_url}" {validateForm}> 4 <table width=" 75%" cellpadding=0 cellspacing=0 class="prefTable">4 <table width="100%" cellpadding=0 cellspacing=0 class="prefTable"> 5 5 <tr><td colspan="3">{tabs}</td></tr> 6 6 <!-- BEGIN list --> … … 30 30 <!-- BEGIN row --> 31 31 <tr id="{row_id}" bgcolor="{tr_color}" {row_visibility}> 32 <td >{row_name}</td>33 <td >{row_value}</td>32 <td style="width:35%">{row_name}</td> 33 <td style="width:65%">{row_value}</td> 34 34 </tr> 35 35 <!-- END row -->
Note: See TracChangeset
for help on using the changeset viewer.