Changeset 2557


Ignore:
Timestamp:
04/16/10 10:55:43 (14 years ago)
Author:
nathalie.silva
Message:

Ticket #891 - alterada a função spell_checker no php - Nathalie

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

    r2554 r2557  
    412412function spellCheck_cb(new_data) 
    413413{ 
    414           
    415         var ifr= currObj.objToCheck; 
     414        var ifr= currObj.objToCheck; 
    416415        if(ifr.contentWindow) 
    417416            ifr=ifr.contentWindow.document; 
     
    419418            ifr=ifr.contentDocument; 
    420419 
    421  
    422420        with(currObj); 
    423421 
     
    426424        new_data = new_data.substring(1); 
    427425 
    428         
    429  
    430         if(currObj.spellingResultsDiv) 
    431         { 
    432              
    433                 ifr.removeChild(currObj.spellingResultsDiv.id); 
    434                  
    435         } 
    436  
    437  
    438          var ifr= currObj.objToCheck; 
    439          if(ifr.contentWindow) 
    440             ifr=ifr.contentWindow.document; 
    441          else 
    442             ifr=ifr.contentDocument; 
    443          ifr.body.innerHTML =  ""; 
    444          var cssLink = ifr.createElement("link"); 
    445          cssLink.href = "spell_checker/css/spell_checker.css"; 
    446          cssLink .rel = "stylesheet"; 
    447          cssLink .type = "text/css";             
    448               //Testes nathalie - substituido 
     426        if(currObj.spellingResultsDiv) 
     427        { 
     428            ifr.removeChild(currObj.spellingResultsDiv.id); 
     429        } 
     430 
     431        var ifr= currObj.objToCheck; 
     432        if(ifr.contentWindow) 
     433           ifr=ifr.contentWindow.document; 
     434        else 
     435           ifr=ifr.contentDocument; 
     436        ifr.body.innerHTML =  ""; 
     437        var cssLink = ifr.createElement("link"); 
     438        cssLink.href = "spell_checker/css/spell_checker.css"; 
     439        cssLink .rel = "stylesheet"; 
     440        cssLink .type = "text/css"; 
     441         
     442        // this is not being used 
    449443        currObj.spellingResultsDiv =  ifr.createElement('span'); 
    450444        currObj.spellingResultsDiv.className = 'edit_box'; 
     
    457451        //currObj.objToCheck.style.display = "none"; 
    458452        currObj.statusSpan.innerHTML = "";   
    459         
    460           //ifr.body.appendChild(currObj.spellingResultsDiv); 
    461          //alert(new_data); 
    462          ifr.body.innerHTML = ""; 
    463          //alert(new_data); 
    464          //new_data = new_data.replace(/ </g ,"&nbsp;<"); 
    465          //alert(new_data); 
    466           
    467          ifr.body.innerHTML = new_data; 
    468          //alert(ifr.body.innerHTML); 
    469          ifr.body.appendChild(cssLink); 
     453 
     454        //add the new_data to iframe and the css style 
     455        ifr.body.innerHTML = ""; 
     456        ifr.body.innerHTML = new_data; 
     457        ifr.body.appendChild(cssLink); 
    470458 
    471459 
     
    623611            query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie 
    624612 
    625             cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], languageId); 
     613            var browser = trim(checkBrowser()); 
     614             
     615            cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], languageId, browser); 
    626616 
    627617}; // end spellcheck 
  • sandbox/expressoMail1_2/corretor_ortografico/spell_checker/spell_checker.php

    r2554 r2557  
    162162 * 
    163163 *************************************************************/ 
    164 function spellCheck($string, $varName, $language) 
     164function spellCheck($string, $varName, $language, $browser) 
    165165{ 
    166166        //global $pspell_link; //the global link to the pspell module 
     
    181181        $numResults = count($words); //the number of elements in the array. 
    182182 
    183         $misspelledCount = 0;    
     183        $misspelledCount = 0; 
     184 
     185 
     186        /* There is a problem with innerHTML of IE browsers - It removes the spaces. 
     187         * If there are two misspelled words side by side, it makes then together (no space 
     188         * between then). This will be checked using this variable. 
     189         * */ 
     190        $difference = 0;  
    184191    
    185192        //this loop looks through the words array and splits any lines of text that aren't html tags on space, preserving the spaces. 
     
    207214                                {                                         
    208215                                        $onClick = "onclick=\"setCurrentObject(" . $varName . "); showSuggestions('" . addslashes($tmpWord) . "', '" . $varName . "_" . $misspelledCount . "_" . addslashes($tmpWord) . "'); return false;\""; 
    209                                         $words[$i][$j] = str_replace($tmpWord, " <span " . $onClick . " id=\"" . $varName . "_" . $misspelledCount . "_" . $tmpWord . "\" class=\"highlight\">" . stripslashes($tmpWord) . " </span> ", $words[$i][$j]); 
     216 
     217                                        $difference =  $misspelledCount + 1; 
     218                                        if (($difference - $misspelledCount) == 1 and $browser == "ie") //if IE, adds a html space before Span tag 
     219                                            $words[$i][$j] = str_replace($tmpWord, "<span " . $onClick . " id=\"" . $varName . "_" . $misspelledCount . "_" . $tmpWord . "\" class=\"highlight\">" . stripslashes($tmpWord) . " </span>&nbsp;", $words[$i][$j]); 
     220                                        else 
     221                                            $words[$i][$j] = str_replace($tmpWord, "<span " . $onClick . " id=\"" . $varName . "_" . $misspelledCount . "_" . $tmpWord . "\" class=\"highlight\">" . stripslashes($tmpWord) . " </span>", $words[$i][$j]); 
     222 
    210223                                        $misspelledCount++; 
    211                                 }  
     224                                         
     225                                }                                 
    212226                                 
    213227                                $words[$i][$j] = str_replace("\n", "<br />", $words[$i][$j]); //replace any breaks with <br />'s, for html display 
Note: See TracChangeset for help on using the changeset viewer.