Changeset 2546
- Timestamp:
- 04/15/10 11:15:13 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js
r2543 r2546 50 50 51 51 function beginSpellCheck(){ 52 if(!blockSpellCheck){ 53 position = "body_position_" + currentTab; 54 area = "body_" + currentTab; 55 aba = currentTab; 56 57 //var cp = new cpaint(); 58 // alert("Seta globals"); 59 //cp = new cpaint(); 60 //cp.set_transfer_mode('post'); 61 //cp.set_response_type('text'); 62 //cp.set_debug(1); 63 64 //var currObj; //the current spell checker being used 65 //var spellingSuggestionsDiv = null; // Auto-generated suggestions div 66 67 spellingSuggestionsDiv = null; 68 positionEditor = position; 69 areaEditor = area; 70 abaEditor = aba; 71 72 73 //alert("Seta globals"); 74 75 76 // If there are already any onclick handlers loaded in the page, we'll add 77 // our onclick handler first and then call the old one, rather than completely 78 // overriding it. The checkClickLocation is used to hide the suggestions div 79 // when the user clicks outside it. 80 /*if(document.onclick) 81 { 82 old_onclick = document.onclick; 83 84 document.onclick = function(e) 85 { 86 checkClickLocation(e); 87 old_onclick(e); 88 } 89 } 90 else 91 { 92 //document.onclick = checkClickLocation; 93 }*/ 94 95 //alert("Inicio"); 96 // If there are already any onload handlers loaded in the page, we'll add our onload 97 // handler first and then call the old one, rather than completely overriding it. 98 if(window.onload) 99 { 100 window.onload = new setupSpellCheckers(); 101 102 /*var old_onload = window.onload; 103 window.onload = function(e) 104 { 105 var test = new setupSpellCheckers(e); 106 old_onload(e); 107 }*/ 52 if(!blockSpellCheck){ 53 position = "body_position_" + currentTab; 54 area = "body_" + currentTab; 55 aba = currentTab; 56 spellingSuggestionsDiv = null; 57 positionEditor = position; 58 areaEditor = area; 59 abaEditor = aba; 60 61 if(window.onload) 62 { 63 window.onload = new setupSpellCheckers(); 64 65 } 66 else 67 { 68 window.onload = new setupSpellCheckers(); 69 } 70 71 } else { 72 alert("O corretor esta executando") 108 73 } 109 else 110 { 111 window.onload = new setupSpellCheckers(); 112 } 113 114 //window.onload =new setupSpellCheckers(); 115 //alert("Fim"); 116 } else { 117 alert("O corretor ja esta rodando.") 118 } 119 } // fecha funᅵᅵo 120 74 } // close BeginSpellCheck 121 75 122 76 … … 126 80 * function setupSpellCheckers() 127 81 * 128 * This function goes through the page and finds all the 129 * textareas. It then checks the title attribute for either 130 * spellcheck or spellcheck_icons to determine whether or not 131 * it should add a spellchecker to that textarea. 82 * This function obtain the iframe of the page (that is the area editor) 83 * and then adds a spellchecker to the iframe. 132 84 *************************************************************/ 133 85 function setupSpellCheckers() 134 86 { 135 87 var ifr = document.getElementsByTagName('iframe')[0]; 88 //alert(area); 89 //var ifr = document.getElementById(area); 136 90 var numSpellCheckers = abaEditor; 137 91 … … 140 94 else 141 95 ifr=ifr.contentDocument; 96 97 if (document.addEventListener) { 98 ifr.addEventListener("click", checkClickLocation , true); //add the click event 99 } 100 else { 101 ifr.attachEvent("onclick", checkClickLocation); //add the click event 102 103 } 104 105 142 106 var texto = ifr.body.innerHTML; 143 107 … … 342 306 343 307 344 345 346 308 347 309 … … 369 331 * 370 332 * This function is associated with the click event 371 * of all the tags spanwith correctd_word class.333 * of all the span tags with correctd_word class. 372 334 * 373 335 *************************************************************/ … … 382 344 var browser = checkBrowser(); 383 345 if (browser == "ie"){ 384 //iframe.body.contentEditable="false" ;346 385 347 iframe.body.contentEditable="true" ; 348 var ifr= currObj.objToCheck; 349 if(!e){var e = ifr.contentWindow.event;} 350 if(!e.target){e.target = e.srcElement;} 351 var evento = e.target.onclick.toString(); 352 386 353 } 387 354 else { 388 355 iframe.designMode = "off"; 389 356 iframe.designMode = "on"; 390 }391 392 var browser = checkBrowser();393 if (browser == "ie"){394 var ifr= currObj.objToCheck;395 if(!e){var e = ifr.contentWindow.event;}396 if(!e.target){e.target = e.srcElement;}397 398 if(ifr.contentWindow)399 ifr=ifr.contentWindow.document;400 else401 ifr=ifr.contentDocument;402 var evento = ifr.getElementById(e.target.id).onclick.toString();403 }404 else {405 357 var evento = this.onclick.toString(); 406 } 407 358 } 408 359 evento = evento.replace("function onclick(event) {", ""); 409 360 evento = evento.replace("}", ""); 410 361 var array_func = evento.split(";"); 411 362 eval(array_func[0]); 412 eval(array_func[1]);363 eval(array_func[1]); 413 364 return false; 414 415 416 365 417 366 418 367 // … … 420 369 421 370 /************************************************************* 422 * showMenu371 * replaceMenu 423 372 * 424 373 * This function is associated with the click event 425 * of all the tags div with suggestion class. 426 * 427 *************************************************************/ 428 function replaceMenu(){ 429 //adicionado nathalie 430 374 * of all the div tags with suggestion class. 375 * 376 *************************************************************/ 377 function replaceMenu(){ 431 378 var iframe= currObj.objToCheck; 432 379 if(iframe.contentWindow) … … 434 381 else 435 382 iframe=iframe.contentDocument; 436 437 383 var browser = checkBrowser(); 438 384 if (browser == "ie"){ 439 385 iframe.body.contentEditable="false" ; 440 //iframe.body.contentEditable="true" ; 386 var ifr= currObj.objToCheck; 387 if(!e){var e = ifr.contentWindow.event;} 388 if(!e.target){e.target = e.srcElement;} 389 var evento = e.target.onclick.toString(); 441 390 } 442 391 else { 443 392 iframe.designMode = "off"; 444 393 iframe.designMode = "on"; 445 }446 447 448 449 var browser = checkBrowser();450 if (browser == "ie"){451 var ifr= currObj.objToCheck;452 if(!e){var e = ifr.contentWindow.event;}453 if(!e.target){e.target = e.srcElement;}454 var evento = e.target.onclick.toString();455 }456 else {457 394 var evento = this.onclick.toString(); 458 395 } 459 460 396 evento = evento.replace("function onclick(event) {", ""); 461 397 evento = evento.replace("}", ""); … … 482 418 function spellCheck_cb(new_data) 483 419 { 484 //adicionado nathalie420 485 421 var ifr= currObj.objToCheck; 486 422 if(ifr.contentWindow) … … 503 439 } 504 440 505 506 /*currObj.spellingResultsDiv = document.createElement('DIV'); 507 currObj.spellingResultsDiv.className = 'edit_box'; 508 currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie 509 currObj.spellingResultsDiv.style.width = "99%";//the width of the textarea 510 currObj.spellingResultsDiv.style.height = 300; // = height; //currObj.objToCheck.style.height; 511 currObj.spellingResultsDiv.innerHTML = new_data; 512 currObj.objToCheck.style.display = "none"; 513 currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck); 514 currObj.statusSpan.innerHTML = ""; */ 515 516 517 518 519 // Teste de iFrame - Nathalie 441 520 442 var ifr= currObj.objToCheck; 521 443 if(ifr.contentWindow) … … 568 490 569 491 570 //adicionado Paula 571 // currObj.objToCheck.style.display = "none"; //Paula 572 //currObj.objToCheck.parentNode. 573 //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck); 574 // currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); //Paula 575 currObj.statusSpan.innerHTML = ""; 492 currObj.statusSpan.innerHTML = ""; 576 493 577 494 … … 694 611 }*/ 695 612 613 696 614 // Obtain the HTML content from iframe (edit area) 697 615 var ifr= currObj.objToCheck; … … 783 701 function checkClickLocation(e) 784 702 { 785 703 704 var browser = checkBrowser(); 786 705 if(spellingSuggestionsDiv) 787 706 { … … 789 708 // on a word to get suggestions starts up a race condition between 790 709 // showing and hiding the suggestion box, so we'll ignore the first 791 // click. 792 if(spellingSuggestionsDiv.ignoreNextClick ){710 // click. Problem with IE browser 711 if(spellingSuggestionsDiv.ignoreNextClick && browser == "ie"){ 793 712 spellingSuggestionsDiv.ignoreNextClick = false; 794 713 } … … 801 720 spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv); 802 721 spellingSuggestionsDiv = null; 803 } 804 } 722 723 if (browser == "ie"){ 724 var iframe= currObj.objToCheck; 725 if(iframe.contentWindow) 726 iframe=iframe.contentWindow.document; 727 else 728 iframe=iframe.contentDocument; 729 iframe.body.contentEditable="false" ; 730 } 731 } 732 } 805 733 } 806 734 … … 826 754 if(checkBrowser() == "ie") 827 755 { 828 value = window.event.srcElement; 756 if(!e){var e = ifr.contentWindow.event;} 757 if(!e.target){value = e.srcElement;} 758 829 759 } 830 760 else 831 761 { 832 762 value = e.target; 833 763 } 834 764 return value; … … 899 829 * php's showSuggestions function returns to. It sets the 900 830 * suggestions table to contain the new data and then displays 901 * the suggestions div. It also clears the status message. 831 * the suggestions div. It also adds the event listener - click - 832 * for all the suggestions tags and sets te property to be not editable. 902 833 * 903 834 * @param new_data The suggestions table returned from php. … … 911 842 currObj.statusSpan.innerHTML = ""; 912 843 913 //adicionado os listener - nathalie 914 var ifr= currObj.objToCheck; 915 if(ifr.contentWindow) 916 ifr=ifr.contentWindow.document; 917 else 918 ifr=ifr.contentDocument; 844 var ifr= currObj.objToCheck; 845 if(ifr.contentWindow) 846 ifr=ifr.contentWindow.document; 847 else 848 ifr=ifr.contentDocument; 919 849 920 850 var nodeArray = ifr.getElementsByTagName("div"); … … 927 857 ifr.getElementsByTagName("div")[i].contentEditable="false" ; 928 858 } 929 else {859 else { 930 860 ifr.getElementsByTagName("div")[i].attachEvent("onclick", replaceMenu); 931 861 ifr.getElementsByTagName("div")[i].contentEditable="false" ; 932 } 933 934 935 936 937 862 } 863 938 864 939 865 } … … 955 881 * calls the showSuggestions php function with the misspelled word 956 882 * and the id of the span containing it. 883 * This function is only executed when the word is in red (the word id misspelled). 957 884 * 958 885 * @param word The misspelled word that the user clicked on … … 961 888 function showSuggestions(word, id) 962 889 { 963 964 //adicionado nathalie 890 965 891 var ifr= currObj.objToCheck; 966 892 if(ifr.contentWindow) … … 969 895 ifr=ifr.contentDocument; 970 896 971 if (ifr.getElementById(id).className == "highlight"){ //show the suggestion box only when the words are in red972 973 //alterado - colocar ifr897 if (ifr.getElementById(id).className == "highlight"){ //show the suggestion box only if the words are in red 898 899 974 900 languageId = document.getElementById("selectLanguage"); 975 901 languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value; … … 1009 935 spellingSuggestionsDiv.style.left = x + 'px'; 1010 936 spellingSuggestionsDiv.style.top = (y+16-scrollPos) + 'px'; 1011 spellingSuggestionsDiv.id = 'suggestion_box'; //Adicionado Nathalie937 spellingSuggestionsDiv.id = 'suggestion_box'; 1012 938 spellingSuggestionsDiv.contentEditable="false" ; 1013 1014 1015 1016 1017 1018 1019 939 1020 940 … … 1023 943 // showing and hiding the suggestion box, so we'll ignore the first 1024 944 // click. 1025 //spellingSuggestionsDiv.ignoreNextClick = true; // comentado Nathalie945 spellingSuggestionsDiv.ignoreNextClick = true; 1026 946 1027 947 1028 948 //document.body.appendChild(spellingSuggestionsDiv); 1029 ifr.body.appendChild(spellingSuggestionsDiv); //alterado nathalie 1030 1031 1032 949 ifr.body.appendChild(spellingSuggestionsDiv); 1033 950 1034 951 1035 952 cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, languageId); 1036 } 953 } // end if - show the suggestion box only if the words are in red 1037 954 1038 955 }; // end showSuggestions … … 1161 1078 1162 1079 with(currObj); 1163 //By Nathalie - The Element means that this div belongs to the current tab1164 //var parentElement = Element(currObj.spellingResultsDiv.id); //alterado nathalie1165 1080 var ifr= currObj.objToCheck; 1166 1081 if(ifr.contentWindow) … … 1168 1083 else 1169 1084 ifr=ifr.contentDocument; 1170 1171 //var parentElement =ifr.getElementById(currObj.spellingResultsDiv.id); //alterado nathalie 1172 // 1085 1173 1086 // Obtain all span tags which have highlight className or corrected_word className 1174 1087 var nodeArray = ifr.getElementsByTagName("div"); … … 1195 1108 } 1196 1109 1197 var text = ifr.body.innerHTML; //alterado result div1110 var text = ifr.body.innerHTML; 1198 1111 1199 1112 text = text.replace(/ /gi, " %u2026 "); // Replace with the code %u2026 … … 1220 1133 1221 1134 1222 //adicionado Paula1223 1135 with(currObj); 1224 1136 1225 new_string = new_string.replace(/ %u2026/gi, " "); // Replace the code %u2026 with 1226 1227 new_string = new_string.replace(/~~~/gi, "\n"); 1228 1229 // Remove the prefixed asterisk that was added in switchText(). 1230 new_string = new_string.substr(1); 1231 1232 1233 currObj.objToCheck.style.display = "none"; 1234 var ifr= currObj.objToCheck; 1235 if(ifr.contentWindow) 1236 ifr=ifr.contentWindow.document; 1237 else 1238 ifr=ifr.contentDocument; 1239 var texto = ifr.body.innerHTML; 1240 1241 ifr.body.innerHTM = ""; //adicionado nathalie 1242 ifr.body.innerHTML = new_string; 1243 currObj.spellingResultsDiv = null; //adicionado nathalie 1244 1245 1246 1247 currObj.objToCheck.disabled = false; 1248 1249 //Removido Nathalie 1250 /*if(currObj.spellingResultsDiv) 1251 { 1252 ifr.removeChild(currObj.spellingResultsDiv); //Alterado nathalie 1253 currObj.spellingResultsDiv = null; 1254 }*/ 1255 currObj.objToCheck.style.display = "block"; 1256 currObj.resetAction(); 1137 new_string = new_string.replace(/ %u2026/gi, " "); // Replace the code %u2026 with 1138 1139 new_string = new_string.replace(/~~~/gi, "\n"); 1140 1141 // Remove the prefixed asterisk that was added in switchText(). 1142 new_string = new_string.substr(1); 1143 1144 1145 currObj.objToCheck.style.display = "none"; 1146 var ifr= currObj.objToCheck; 1147 if(ifr.contentWindow) 1148 ifr=ifr.contentWindow.document; 1149 else 1150 ifr=ifr.contentDocument; 1151 var texto = ifr.body.innerHTML; 1152 1153 ifr.body.innerHTM = ""; 1154 ifr.body.innerHTML = new_string; 1155 currObj.spellingResultsDiv = null; 1156 1157 currObj.objToCheck.disabled = false; 1158 1159 1160 currObj.objToCheck.style.display = "block"; 1161 currObj.resetAction(); 1257 1162 }; // end switchText_cb 1258 1163 … … 1324 1229 { 1325 1230 1326 //adicionado Paula 1231 1327 1232 with(currObj); 1328 1233 /*if(currObj.config['useIcons']) … … 1351 1256 { 1352 1257 1353 //adicionado nathalie1258 1354 1259 var ifr= currObj.objToCheck; 1355 1260 if(ifr.contentWindow) 1356 1261 ifr=ifr.contentWindow.document; 1357 1262 else 1358 1263 ifr=ifr.contentDocument; 1359 1264 … … 1368 1273 if(currObj.spellingResultsDiv) 1369 1274 { 1370 ifr.removeChild(currObj.spellingResultsDiv); //alterado nathalie1275 ifr.removeChild(currObj.spellingResultsDiv); 1371 1276 currObj.spellingResultsDiv = null; 1372 1277 } … … 1393 1298 function findPosXById(object) 1394 1299 { 1395 1396 //adicionado Nathalie 1300 1397 1301 var ifr= currObj.objToCheck; 1398 1302 if(ifr.contentWindow) 1399 1303 ifr=ifr.contentWindow.document; 1400 1304 else 1401 1305 ifr=ifr.contentDocument; 1402 1306 var obj = ifr.getElementById(object); … … 1404 1308 1405 1309 var curleft = 0; 1406 //var obj = document.getElementById(object); //removido nathalie 1407 1408 1310 1409 1311 if(obj.offsetParent) 1410 1312 { … … 1434 1336 *************************************************************/ 1435 1337 function findPosYById(object) 1436 { 1437 1438 //adicionado Nathalie 1338 { 1439 1339 var ifr= currObj.objToCheck; 1440 1340 if(ifr.contentWindow) 1441 1341 ifr=ifr.contentWindow.document; 1442 1342 else 1443 1343 ifr=ifr.contentDocument; 1444 var obj = ifr.getElementById(object); //removido Nathalie 1445 1344 var obj = ifr.getElementById(object); 1446 1345 1447 1346 var curtop = 0;var curtop = 0; 1448 //var obj = document.getElementById(object); //removido Nathalie1449 1347 if(obj.offsetParent) 1450 1348 {
Note: See TracChangeset
for help on using the changeset viewer.