Ignore:
Timestamp:
04/12/10 10:27:29 (14 years ago)
Author:
paula.franceschini
Message:

Ticket #891 - modificações referentes ao corretor ortografico.

Location:
sandbox/expressoMail1_2/corretor_ortografico/spell_checker
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js

    r2430 r2477  
    4343var positionEditor; 
    4444var areaEditor; 
    45 var abaEditor;  
     45var abaEditor; 
     46var blockSpellCheck = false; 
    4647cp = new cpaint(); 
    4748cp.set_transfer_mode('post'); 
    4849cp.set_response_type('text'); 
    49 function beginSpellCheck(position, area, aba){ 
    50  
    51      
     50function beginSpellCheck(){ 
     51if(!blockSpellCheck){ 
     52    position = "body_position_" + currentTab; 
     53    area = "body_" + currentTab; 
     54    aba = currentTab; 
    5255    //var cp = new cpaint(); 
    5356    // alert("Seta globals"); 
     
    109112//window.onload =new setupSpellCheckers(); 
    110113//alert("Fim"); 
     114} else { 
     115    alert("O corretor ja esta rodando.") 
     116} 
    111117} // fecha funᅵᅵo 
    112118 
     
    140146         
    141147}; // end setInit 
     148 
     149function setupSpellChecker(){ 
     150 
     151 
     152        currObj = this; 
     153 
     154        currObj.config               = new Array(); 
     155         
     156        currObj.config['divId'] = "body_position_" + currentTab; 
     157        currObj.config['width'] = "99%"; 
     158        currObj.config['id'] = "body_" + currentTab; 
     159 
     160        spellContainer = document.createElement('DIV'); 
     161        spellContainer.id = currObj.config['divId']; 
     162        spellContainer.className = 'spell_container'; 
     163        spellContainer.style.width = currObj.config['width']; 
     164 
     165        oldElement = document.getElementById(currObj.config['id']); 
     166 
     167        //oldElement.parentNode.replaceChild(spellContainer, oldElement); 
     168 
     169        //generate the div to hold the spell checker controls 
     170        currObj.controlPanelDiv = document.createElement('DIV'); 
     171        currObj.controlPanelDiv.className = 'control_panel'; 
     172        currObj.controlPanelDiv.id = 'control_panel_' + currentTab; 
     173        document.getElementById(currObj.config['divId']).appendChild(currObj.controlPanelDiv); 
     174 
     175        //the span that toggles between spell checking and editing 
     176        currObj.actionSpan = document.createElement('SPAN'); 
     177        currObj.actionSpan.className = "action"; 
     178        currObj.actionSpan.id = "action";         
     179        /*if(currObj.config['useIcons']) 
     180        { 
     181                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>"; 
     182        } 
     183        else 
     184        { 
     185                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 
     186        }*/ 
     187        currObj.controlPanelDiv.appendChild(currObj.actionSpan); 
     188 
     189        //the span that lets the user know of the status of the spell checker 
     190        currObj.statusSpan = document.createElement('SPAN'); 
     191        currObj.statusSpan.className = "status"; 
     192        currObj.statusSpan.id = "status"; 
     193        currObj.statusSpan.innerHTML = ""; 
     194        currObj.controlPanelDiv.style.display = "none"; 
     195        currObj.controlPanelDiv.appendChild(currObj.statusSpan); 
     196 
     197        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox")); 
     198        //the textarea to be spell checked 
     199        //oldElement.value = currObj.config['value']; 
     200        //document.getElementById(currObj.config['divId']).appendChild(oldElement); 
     201        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 
     202 
     203 } 
    142204 
    143205 
     
    161223function ajaxSpell(varName, width, height, spellUrl, divId, name, id, title, value) 
    162224{ 
    163          
    164         currObj = this; 
     225         
     226       currObj = this; 
    165227 
    166228        currObj.config               = new Array();         //the array of configuration options 
     
    185247        } 
    186248         
    187         spellContainer = document.createElement('DIV'); 
     249        /*spellContainer = document.createElement('DIV'); 
    188250        spellContainer.id = currObj.config['divId']; 
    189251        spellContainer.className = 'spell_container'; 
     
    192254        oldElement = document.getElementById(currObj.config['id']); 
    193255 
    194         oldElement.parentNode.replaceChild(spellContainer, oldElement); 
     256        //oldElement.parentNode.replaceChild(spellContainer, oldElement); 
    195257         
    196258        //generate the div to hold the spell checker controls 
     
    203265        currObj.actionSpan.className = "action"; 
    204266        currObj.actionSpan.id = "action"; 
    205         if(currObj.config['useIcons']) 
     267        /*if(currObj.config['useIcons']) 
    206268        { 
    207269                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia \" border=\"0\" /></a>"; 
     
    210272        { 
    211273                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 
    212         } 
    213         currObj.controlPanelDiv.appendChild(currObj.actionSpan); 
     274        }*/ 
     275        /*currObj.controlPanelDiv.appendChild(currObj.actionSpan); 
    214276         
    215277        //the span that lets the user know of the status of the spell checker 
     
    219281        currObj.statusSpan.innerHTML = ""; 
    220282        currObj.controlPanelDiv.appendChild(currObj.statusSpan); 
    221          
     283 
     284        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox")); 
    222285        //the textarea to be spell checked 
    223286        oldElement.value = currObj.config['value']; 
    224         document.getElementById(currObj.config['divId']).appendChild(oldElement); 
    225  
    226          
     287        //document.getElementById(currObj.config['divId']).appendChild(oldElement); 
     288        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 
     289        */ 
     290 
     291        currObj.controlPanelDiv = document.getElementById('control_panel_' + currentTab); 
     292        currObj.statusSpan = currObj.controlPanelDiv.childNodes[1]; 
     293        currObj.actionSpan = currObj.controlPanelDiv.childNodes[0] ; 
     294 
    227295        currObj.objToCheck              = document.getElementById(currObj.config['id']);      //the actual object we're spell checking 
    228296        currObj.spellingResultsDiv      = null;                                               // Auto-generated results div 
     
    276344function spellCheck_cb(new_data) 
    277345{ 
    278         with(currObj); 
     346 
     347        with(currObj); 
    279348        new_data = new_data.toString(); 
    280349        var isThereAMisspelling = new_data.charAt(0); 
     
    295364 
    296365        currObj.objToCheck.style.display = "none"; 
    297         currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck); 
     366        //currObj.objToCheck.parentNode. 
     367        //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck); 
     368        currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); 
    298369        currObj.statusSpan.innerHTML = "";     
    299370         
     
    320391                currObj.objToCheck.disabled = false; 
    321392        } 
     393 
     394       currObj.controlPanelDiv.style.display = "block"; 
     395 
    322396}; // end spellCheck_cb 
    323397 
     
    332406 *************************************************************/ 
    333407function spellCheck() { 
    334         with(currObj); 
    335         var query; 
    336  
    337         if(currObj.spellingResultsDiv) 
    338         { 
    339                 currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv); 
    340                 currObj.spellingResultsDiv = null; 
    341         } 
    342          
    343         if(currObj.config['useIcons']) 
    344         { 
    345                 currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />"; 
    346         } 
    347         else 
    348         { 
    349                 currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>"; 
    350         } 
    351          
    352         if(currObj.config['useIcons']) 
    353         { 
    354                 currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />"; 
    355         } 
    356         else 
    357         { 
    358                 currObj.statusSpan.innerHTML = "Verificando Ortografia..."; 
    359         } 
    360          
    361          
    362         // Obtain the HTML content from iframe (edit area) 
    363          var ifr= currObj.objToCheck; 
    364          if(ifr.contentWindow) 
    365             ifr=ifr.contentWindow.document; 
    366          else 
    367             ifr=ifr.contentDocument; 
    368          var texto = ifr.body.innerHTML; 
    369          
    370          
    371         query = texto; 
    372         //query = currObj.objToCheck.value;         
    373          
    374         //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie 
    375         query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie 
    376         
    377          
    378         cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']); 
     408 
     409        if(!blockSpellCheck) { 
     410            blockSpellCheck = true; 
     411 
     412         language =  document.getElementById("selectLanguage"); 
     413            language = language[document.getElementById("selectLanguage").selectedIndex].value; 
     414 
     415            with(currObj); 
     416            var query; 
     417 
     418            currObj.controlPanelDiv.style.display = "block"; 
     419 
     420            if(currObj.spellingResultsDiv) 
     421            { 
     422                    currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv); 
     423                    currObj.spellingResultsDiv = null; 
     424            } 
     425 
     426            /*if(currObj.config['useIcons']) 
     427            { 
     428                    currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />"; 
     429            } 
     430            else 
     431            { 
     432                    currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>"; 
     433            }*/ 
     434 
     435            /*if(currObj.config['useIcons']) 
     436            { 
     437                    currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />"; 
     438            } 
     439            else 
     440            { 
     441                    currObj.statusSpan.innerHTML = "Verificando Ortografia..."; 
     442            }*/ 
     443 
     444            // Obtain the HTML content from iframe (edit area) 
     445             var ifr= currObj.objToCheck; 
     446             if(ifr.contentWindow) 
     447                ifr=ifr.contentWindow.document; 
     448             else 
     449                ifr=ifr.contentDocument; 
     450             var texto = ifr.body.innerHTML; 
     451 
     452            query = texto; 
     453            //query = currObj.objToCheck.value; 
     454 
     455            //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie 
     456            query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie 
     457 
     458            cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], language); 
     459        } 
    379460}; // end spellcheck 
    380461 
     
    400481                spellingSuggestionsDiv = null; 
    401482        } 
    402          
     483 
     484        currObj.controlPanelDiv.style.display = "block"; 
     485 
    403486        if(currObj.config['useIcons']) 
    404487        { 
     
    595678function showSuggestions(word, id) 
    596679{ 
    597  
     680        language =  document.getElementById("selectLanguage"); 
     681        language = language[document.getElementById("selectLanguage").selectedIndex].value; 
     682         
    598683        with(currObj); 
    599684        if(currObj.config['useIcons']) 
     
    633718        document.body.appendChild(spellingSuggestionsDiv); 
    634719         
    635         cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id); 
     720        cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, language); 
    636721}; // end showSuggestions 
    637722 
     
    682767 
    683768        with(currObj); 
    684  
    685769        //By Nathalie - The Element means that this div belongs to the current tab 
    686770        var parentElement = Element(currObj.spellingResultsDiv.id);  
    687  
    688771        // Obtain all span tags which have highlight className or corrected_word className 
    689772        var nodeArray = parentElement.getElementsByTagName("span"); 
     
    691774        var nodeRemove = new Array(totArray); 
    692775        var j = -1; 
     776 
    693777        for (var i = 0 ; i < totArray ; i++) { 
    694778            var node = nodeArray[i]; 
     
    708792            parent.replaceChild(fake, document.getElementById(nodeRemove[i]));             
    709793        } 
    710         var text = currObj.spellingResultsDiv.innerHTML; 
     794 
     795       var text = currObj.spellingResultsDiv.innerHTML; 
    711796 
    712797        text = text.replace(/&nbsp;/gi, " %u2026 "); // Replace &nbsp; with the code %u2026 
    713798        text = '*' + text; 
     799 
    714800        cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text); 
    715801         
     
    730816function switchText_cb(new_string) 
    731817{ 
    732  
     818     
    733819        with(currObj); 
    734820 
     
    775861         
    776862        with(currObj); 
     863 
     864        currObj.controlPanelDiv.style.display = "block"; 
    777865        if(currObj.config['useIcons']) 
    778866        { 
     
    812900function resetAction() 
    813901{ 
    814         
    815902        with(currObj); 
    816         if(currObj.config['useIcons']) 
     903        /*if(currObj.config['useIcons']) 
    817904        { 
    818905                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\"><img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" /></a>"; 
     
    821908        { 
    822909                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>"; 
    823         } 
    824  
     910        }*/ 
     911 
     912        currObj.actionSpan.innerHTML = ""; 
    825913        currObj.statusSpan.innerHTML = ""; 
     914        currObj.controlPanelDiv.style.display = "none"; 
     915        blockSpellCheck = false; 
    826916}; // end resetAction 
    827917 
  • sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php

    r2430 r2477  
    7575 
    7676//$pspell_link = pspell_new_config($pspell_config); 
    77 $pspell_link = pspell_new("pt_BR"); 
     77 
    7878 
    7979require_once("cpaint/cpaint2.inc.php"); //AJAX library file 
     
    9898 * 
    9999 *************************************************************/ 
    100 function showSuggestions($word, $id) 
     100function showSuggestions($word, $id, $language) 
    101101{ 
    102102        global $editablePersonalDict; //bool to set editability of personal dictionary 
    103         global $pspell_link; //the global link to the pspell module 
     103        //global $pspell_link; //the global link to the pspell module 
     104        $pspell_link = pspell_new($language); 
    104105        global $cp; //the CPAINT object 
    105106         
     
    160161 * 
    161162 *************************************************************/ 
    162 function spellCheck($string, $varName) 
    163 { 
    164         global $pspell_link; //the global link to the pspell module 
     163function spellCheck($string, $varName, $language) 
     164{ 
     165        //global $pspell_link; //the global link to the pspell module 
     166        $pspell_link = pspell_new($language); 
    165167        global $cp; //the CPAINT object 
    166168        $retVal = ""; 
     
    287289{ 
    288290        global $editablePersonalDict; 
    289         global $pspell_link; //the global link to the pspell module 
     291        //global $pspell_link; //the global link to the pspell module 
     292        $pspell_link = pspell_new("pt_BR"); 
    290293        global $cp; //the CPAINT object 
    291294        $retVal = ""; 
Note: See TracChangeset for help on using the changeset viewer.