source: sandbox/expressoMail1_2/corretor_ortografico/spell_checker/js/spell_checker.js @ 2510

Revision 2510, 47.8 KB checked in by nathalie.silva, 14 years ago (diff)

Ticket #891 - alteração pro IE - Nathalie

Line 
1/*************************************************************
2 * AJAX Spell Checker - Version 2.8
3 * (C) 2005 - Garrison Locke
4 *
5 * This spell checker is built in the style of the Gmail spell
6 * checker.  It uses AJAX to communicate with the backend without
7 * requiring the page be reloaded.  If you use this code, please
8 * give me credit and a link to my site would be nice.
9 * http://www.broken-notebook.com.
10 *
11 * Copyright (c) 2005, Garrison Locke
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 *
17 *   * Redistributions of source code must retain the above copyright notice,
18 *     this list of conditions and the following disclaimer.
19 *   * Redistributions in binary form must reproduce the above copyright notice,
20 *     this list of conditions and the following disclaimer in the documentation
21 *     and/or other materials provided with the distribution.
22 *   * Neither the name of the http://www.broken-notebook.com nor the names of its
23 *     contributors may be used to endorse or promote products derived from this
24 *     software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 *************************************************************/
38
39var cp;
40var currObj; //the current spell checker being used
41var spellingSuggestionsDiv;
42var old_onclick;
43var positionEditor;
44var areaEditor;
45var abaEditor;
46var blockSpellCheck = false;
47cp = new cpaint();
48cp.set_transfer_mode('post');
49cp.set_response_type('text');
50
51function beginSpellCheck(){
52if(!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}
90else
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            }*/
108    }
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
121
122
123
124
125/*************************************************************
126 * function setupSpellCheckers()
127 *
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.
132 *************************************************************/
133function setupSpellCheckers()
134{
135    var ifr = document.getElementsByTagName('iframe')[0];
136    var numSpellCheckers = abaEditor;
137
138    if(ifr.contentWindow)
139        ifr=ifr.contentWindow.document;
140    else
141        ifr=ifr.contentDocument;
142    var texto = ifr.body.innerHTML;
143
144    var tempWidth = "99%";
145    var tempHeight = "300";
146
147    eval('spellCheckers' + numSpellCheckers + '= new ajaxSpell("spellCheckers' + numSpellCheckers + '", tempWidth, tempHeight, "spell_checker/spell_checker.php", positionEditor, "Nome", areaEditor, "Titulo", texto);');
148       
149}; // end setInit
150
151function setupSpellChecker(){
152
153
154        currObj = this;
155       
156        currObj.config               = new Array();
157       
158        currObj.config['divId'] = "body_position_" + currentTab;
159        currObj.config['width'] = "99%";
160        currObj.config['id'] = "body_" + currentTab;
161
162        spellContainer = document.createElement('DIV');
163        spellContainer.id = currObj.config['divId'];
164        spellContainer.className = 'spell_container';
165        spellContainer.style.width = currObj.config['width'];
166
167        //oldElement = document.getElementById(currObj.config['id']);
168
169        //oldElement.parentNode.replaceChild(spellContainer, oldElement);
170
171        //generate the div to hold the spell checker controls
172        currObj.controlPanelDiv = document.createElement('DIV');
173        currObj.controlPanelDiv.className = 'control_panel';
174        currObj.controlPanelDiv.id = 'control_panel_' + currentTab;
175        document.getElementById(currObj.config['divId']).appendChild(currObj.controlPanelDiv);
176
177        //if (document.getElementById(currObj.config['id']))
178        //    alert("OK");
179
180        //document.getElementById(currObj.config['divId']).insertBefore(currObj.controlPanelDiv, document.getElementById(currObj.config['id']));
181        //currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById(currObj.config["id"]));
182
183     
184       
185       
186
187        //the span that toggles between spell checking and editing
188        currObj.actionSpan = document.createElement('SPAN');
189        currObj.actionSpan.className = "action";
190        currObj.actionSpan.id = "action";       
191        /*if(currObj.config['useIcons'])
192        {
193                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>";
194        }
195        else
196        {
197                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
198        }*/
199        currObj.controlPanelDiv.appendChild(currObj.actionSpan);
200
201        //the span that lets the user know of the status of the spell checker
202        currObj.statusSpan = document.createElement('SPAN');
203        currObj.statusSpan.className = "status";
204        currObj.statusSpan.id = "status";
205        currObj.statusSpan.innerHTML = "";
206        currObj.controlPanelDiv.style.display = "none";
207        currObj.controlPanelDiv.appendChild(currObj.statusSpan);
208
209
210       //document.getElementById(currObj.config['divId']).insertBefore(currObj.controlPanelDiv, document.getElementById(currObj.config['id'])); //test
211
212        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox"));
213        //the textarea to be spell checked
214        //oldElement.value = currObj.config['value'];
215        //document.getElementById(currObj.config['divId']).appendChild(oldElement);
216        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab));
217        //currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById(currObj.config["id"]));
218     
219
220 }
221
222
223/*************************************************************
224 * ajaxSpell(varName, width, height, spellUrl, divId, name, id)
225 *
226 * This is the constructor that creates a new ajaxSpell object.
227 * All of it is dynamically generated so the user doesn't have
228 * to add a bunch of crap to their site.
229 *
230 * @param varName The name of the variable that the object is
231 *                assigned to (must be unique and the same as the variable)
232 * @param width The width of the spell checker
233 * @param height The height of the spell checker
234 * @param spellUrl The url of the spell_checker.php code
235 * @param divId The id of the div that the spell checker is
236 *              contained in (must be unique)
237 * @param name The name of the textarea form element
238 * @param id The id of the spell checker textarea (must be unique)
239 *************************************************************/
240function ajaxSpell(varName, width, height, spellUrl, divId, name, id, title, value)
241{
242
243        currObj = this;
244
245
246        currObj.config               = new Array();         //the array of configuration options
247        currObj.config['varName']    = varName;             //the name of the variable that this instance is stored in
248        currObj.config['width']      = width;               //the width of the textarea
249        currObj.config['height']     = height;              //the height of the textarea
250        currObj.config['spellUrl']   = spellUrl;            //url to spell checker php code (spell_checker.php by default);
251        currObj.config['divId']      = divId;               //the id of the div that the spell checker element is in
252        currObj.config['name']       = name;                //what you want the form element's name to be
253        currObj.config['id']         = id;                  //the unique id of the spell_checker textarea
254        currObj.config['title']      = title;               //the title (specifies whether to use icons or not);
255        currObj.config['value']      = value;               //the value of the text box when the page was loaded
256        currObj.config['aba']      = abaEditor;
257
258        //currObj.config['value']      = currObj.config['value'].replace(/<br *\/?>/gi, "\n"); // Comment from the original by Nathalie
259       
260        currObj.config['useIcons'] = false;
261       
262        if(currObj.config['title'] == "spellcheck_icons")
263        {
264                currObj.config['useIcons'] = true;
265        }
266       
267        /*spellContainer = document.createElement('DIV');
268        spellContainer.id = currObj.config['divId'];
269        spellContainer.className = 'spell_container';
270        spellContainer.style.width = currObj.config['width'];
271
272        oldElement = document.getElementById(currObj.config['id']);
273
274        //oldElement.parentNode.replaceChild(spellContainer, oldElement);
275       
276        //generate the div to hold the spell checker controls
277        currObj.controlPanelDiv = document.createElement('DIV');
278        currObj.controlPanelDiv.className = 'control_panel';
279        document.getElementById(currObj.config['divId']).appendChild(currObj.controlPanelDiv);
280       
281        //the span that toggles between spell checking and editing
282        currObj.actionSpan = document.createElement('SPAN');
283        currObj.actionSpan.className = "action";
284        currObj.actionSpan.id = "action";
285        /*if(currObj.config['useIcons'])
286        {
287                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>";
288        }
289        else
290        {
291                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
292        }*/
293        /*currObj.controlPanelDiv.appendChild(currObj.actionSpan);
294       
295        //the span that lets the user know of the status of the spell checker
296        currObj.statusSpan = document.createElement('SPAN');
297        currObj.statusSpan.className = "status";
298        currObj.statusSpan.id = "status";
299        currObj.statusSpan.innerHTML = "";
300        currObj.controlPanelDiv.appendChild(currObj.statusSpan);
301
302        //document.getElementById("body_position_" + currentTab).insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox"));
303        //the textarea to be spell checked
304        oldElement.value = currObj.config['value'];
305        //document.getElementById(currObj.config['divId']).appendChild(oldElement);
306        currObj.controlPanelDiv.parentNode.insertBefore(currObj.controlPanelDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab));
307        */
308
309        currObj.controlPanelDiv = document.getElementById('control_panel_' + currentTab);
310        currObj.statusSpan = currObj.controlPanelDiv.childNodes[1];
311        currObj.actionSpan = currObj.controlPanelDiv.childNodes[0] ;
312
313        currObj.objToCheck              = document.getElementById(currObj.config['id']);      //the actual object we're spell checking
314        currObj.spellingResultsDiv      = null;                                               // Auto-generated results div
315               
316        //prototypes for the ajaxSpell objects
317        ajaxSpell.prototype.spellCheck           = spellCheck;
318        ajaxSpell.prototype.spellCheck_cb        = spellCheck_cb;
319        ajaxSpell.prototype.showSuggestions      = showSuggestions;
320        ajaxSpell.prototype.showSuggestions_cb   = showSuggestions_cb;
321        ajaxSpell.prototype.replaceWord          = replaceWord;
322        ajaxSpell.prototype.switchText           = switchText;
323        ajaxSpell.prototype.switchText_cb        = switchText_cb;
324        ajaxSpell.prototype.resumeEditing        = resumeEditing;
325        ajaxSpell.prototype.resetSpellChecker    = resetSpellChecker;
326        ajaxSpell.prototype.resetAction          = resetAction;
327       
328
329
330     
331       
332}; // end ajaxSpell
333
334
335/*************************************************************
336 * setCurrentObject
337 *
338 * This sets the current object to be the spell checker that
339 * the user is currently using.
340 *
341 * @param obj The spell checker currently being used
342 *************************************************************/
343function setCurrentObject(obj)
344{
345        currObj  = obj;
346       
347       
348}; // end setCurrentObject
349
350
351
352
353function focusDiv(){
354    alert("focus");
355    var ifr= currObj.objToCheck;
356        if(ifr.contentWindow)
357            ifr=ifr.contentWindow.document;
358        else
359            ifr=ifr.contentDocument;
360
361    ifr.getElementById("suggestion_box").outline = 0;
362    ifr.getElementById(spellingSuggestionsDiv.id).style.display = 'none';
363    ifr.getElementById(spellingSuggestionsDiv.id)._moz_resizing = false;
364
365
366    return false;
367}
368
369
370
371/*************************************************************
372 * showMenu
373 *
374 * This function is associated with the click event
375 *  of all the tags span with correctd_word class.
376 *
377 *************************************************************/
378function showMenu(){
379    var evento = this.onclick.toString();
380    evento = evento.replace("function onclick(event) {", "");
381    evento = evento.replace("}", "");
382    var array_func = evento.split(";");
383    eval(array_func[0]);
384    eval(array_func[1]);
385    return false;   
386}
387
388/*************************************************************
389 * showMenu
390 *
391 * This function is associated with the click event
392 *  of all the tags div with suggestion class.
393 *
394 *************************************************************/
395function replaceMenu(){
396     //adicionado nathalie
397        var ifr= currObj.objToCheck;
398        if(ifr.contentWindow)
399            ifr=ifr.contentWindow.document;
400        else
401            ifr=ifr.contentDocument;
402
403
404   
405
406
407    var evento = this.onclick.toString();
408    alert("Replace");
409
410   
411
412
413   
414
415
416
417
418
419    evento = evento.replace("function onclick(event) {", "");
420    evento = evento.replace("}", "");
421    var array_func = evento.split(";");
422    eval(array_func[0]);
423    return false;
424}
425
426
427
428/*************************************************************
429 * spellCheck_cb
430 *
431 * This is the callback function that the spellCheck php function
432 * returns the spell checked data to.  It sets the results div
433 * to contain the markedup misspelled data and changes the status
434 * message.  It also sets the width and height of the results
435 * div to match the element that's being checked.
436 * If there are no misspellings then new_data is the empty
437 * string and the status is set to "No Misspellings Found".
438 *
439 * @param new_data The marked up misspelled data returned from php.
440 *************************************************************/
441function spellCheck_cb(new_data)
442{
443         //adicionado nathalie
444        var ifr= currObj.objToCheck;
445        if(ifr.contentWindow)
446            ifr=ifr.contentWindow.document;
447        else
448            ifr=ifr.contentDocument;
449
450
451        with(currObj);
452
453        new_data = new_data.toString();
454        var isThereAMisspelling = new_data.charAt(0);
455        new_data = new_data.substring(1);
456
457        if(currObj.spellingResultsDiv)
458        {
459           
460                ifr.removeChild(currObj.spellingResultsDiv.id);
461               
462        }
463
464       
465        /*currObj.spellingResultsDiv =  document.createElement('DIV');
466        currObj.spellingResultsDiv.className = 'edit_box';
467        currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
468        currObj.spellingResultsDiv.style.width =  "99%";//the width of the textarea
469        currObj.spellingResultsDiv.style.height = 300;  //   = height; //currObj.objToCheck.style.height;
470        currObj.spellingResultsDiv.innerHTML = new_data;       
471        currObj.objToCheck.style.display = "none";
472        currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck);
473        currObj.statusSpan.innerHTML = ""; */
474
475
476
477
478        // Teste de iFrame - Nathalie
479         var ifr= currObj.objToCheck;
480         if(ifr.contentWindow)
481            ifr=ifr.contentWindow.document;
482         else
483            ifr=ifr.contentDocument;
484         ifr.body.innerHTML =  "";
485         var cssLink = ifr.createElement("link");
486         cssLink.href = "spell_checker/css/spell_checker.css";
487         cssLink .rel = "stylesheet";
488         cssLink .type = "text/css";           
489              //Testes nathalie - substituido
490        currObj.spellingResultsDiv =  ifr.createElement('span');
491        currObj.spellingResultsDiv.className = 'edit_box';
492        currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
493        currObj.spellingResultsDiv.style.width =  "99%";//the width of the textarea
494        currObj.spellingResultsDiv.style.height = 300;  //   = height; //currObj.objToCheck.style.height;
495        currObj.spellingResultsDiv.innerHTML = new_data;
496        currObj.spellingResultsDiv.border = 0;
497        //currObj.spellingResultsDiv.style.display = "none";
498        //currObj.objToCheck.style.display = "none";
499        currObj.statusSpan.innerHTML = ""; 
500       
501
502
503       
504         //ifr.body.appendChild(currObj.spellingResultsDiv);
505         ifr.body.innerHTML = new_data;
506         ifr.body.appendChild(cssLink);
507
508
509        // Obtain all the span tags which have highlight className
510        //    and add the eventListener for the click - This event shows the suggestions menu
511        var nodeArray = ifr.getElementsByTagName("span");
512        var totArray = nodeArray.length;
513        for (var i = 0 ; i < totArray ; i++) {
514            var node = nodeArray[i];
515            if (node.className == "highlight") {
516                if (document.addEventListener)
517                    ifr.getElementsByTagName("span")[i].addEventListener("click", showMenu , true);
518                else
519                    ifr.getElementsByTagName("span")[i].attachEvent("click", showMenu );
520
521            }
522        }
523
524
525//adicionado Paula
526//    currObj.objToCheck.style.display = "none"; //Paula
527        //currObj.objToCheck.parentNode.
528        //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck);
529//      currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); //Paula
530        currObj.statusSpan.innerHTML = "";   
531
532       
533        if(currObj.config['useIcons'])
534        {
535                currObj.actionSpan.innerHTML = "<a class=\"resume_editing\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".resumeEditing();\"><img src=\"images/page_white_edit.png\" width=\"16\" height=\"16\" title=\"Continuar Editando\" alt=\"Continuar Editando\" border=\"0\" /></a>";
536        }
537        else
538        {
539                currObj.actionSpan.innerHTML = "<a class=\"resume_editing\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".resumeEditing();\">Continuar Editando </a>";
540        }
541               
542        if(isThereAMisspelling != "1")
543        {
544                if(currObj.config['useIcons'])
545                {
546                        currObj.statusSpan.innerHTML = "<img src=\"images/accept.png\" width=\"16\" height=\"16\" title=\"Nenhum Erro Encontrado\" alt=\"Nenhum Erro Encontrado\" border=\"0\" />";
547                }
548                else
549                {
550                        currObj.statusSpan.innerHTML = "Nenhum Erro Encontrado";
551                }
552                currObj.objToCheck.disabled = false;
553        }
554
555       currObj.controlPanelDiv.style.display = "block";
556
557}; // end spellCheck_cb
558
559
560/*************************************************************
561 * spellCheck()
562 *
563 * The spellCheck javascript function sends the text entered by
564 * the user in the text box to php to be spell checked.  It also
565 * sets the status message to "Checking..." because it's currently
566 * checking the spelling.
567 *************************************************************/
568function spellCheck() {
569// adicionado nathalie
570/*        with(currObj);
571        var query;
572
573        if(currObj.spellingResultsDiv)
574        {
575                currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
576                currObj.spellingResultsDiv = null;
577        }
578       
579        if(currObj.config['useIcons'])
580        {
581                currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
582        }
583        else
584        {
585                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
586        }
587       
588        if(currObj.config['useIcons'])
589        {
590                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
591        }
592        else
593        {
594                currObj.statusSpan.innerHTML = "Verificando Ortografia...";
595        }       
596       
597        // Obtain the HTML content from iframe (edit area)
598         var ifr= currObj.objToCheck;
599         if(ifr.contentWindow)
600            ifr=ifr.contentWindow.document;
601         else
602            ifr=ifr.contentDocument;
603         var texto = ifr.body.innerHTML;
604       
605       
606        query = texto;
607        //query = currObj.objToCheck.value;       
608       
609        //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
610        query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
611       
612       
613        cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']);
614*/
615//adicionado Paula
616        if(!blockSpellCheck) {
617            blockSpellCheck = true;
618
619         languageId =  document.getElementById("selectLanguage");
620            languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
621
622            with(currObj);
623            var query;
624
625            currObj.controlPanelDiv.style.display = "block";
626
627            if(currObj.spellingResultsDiv)
628            {
629                    currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
630                    currObj.spellingResultsDiv = null;
631            }
632
633            /*if(currObj.config['useIcons'])
634            {
635                    currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
636            }
637            else
638            {
639                    currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
640            }*/
641
642            /*if(currObj.config['useIcons'])
643            {
644                    currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
645            }
646            else
647            {
648                    currObj.statusSpan.innerHTML = "Verificando Ortografia...";
649            }*/
650
651            // Obtain the HTML content from iframe (edit area)
652             var ifr= currObj.objToCheck;
653             if(ifr.contentWindow)
654                ifr=ifr.contentWindow.document;
655             else
656                ifr=ifr.contentDocument;
657             var texto = ifr.body.innerHTML;
658
659            query = texto;
660            //query = currObj.objToCheck.value;
661
662            //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
663            query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
664
665            cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], languageId);
666        }
667}; // end spellcheck
668
669
670
671/*************************************************************
672 * addWord
673 *
674 * The addWord function adds a word to the custom dictionary
675 * file.
676 *
677 * @param id The id of the span that contains the word to be added
678 *************************************************************/
679function addWord(id)
680{
681        var wordToAdd = document.getElementById(id).innerHTML;
682       
683        with(currObj);
684       
685        if(spellingSuggestionsDiv)
686        {
687                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
688                spellingSuggestionsDiv = null;
689        }
690
691        currObj.controlPanelDiv.style.display = "block";
692
693        if(currObj.config['useIcons'])
694        {
695                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Adding Word...\" alt=\"Adding Word...\" border=\"0\" />";
696        }
697        else
698        {
699                currObj.statusSpan.innerHTML = "Adding Word...";
700        }
701       
702        cp.call(currObj.config['spellUrl'], 'addWord', addWord_cb, wordToAdd);
703
704}; // end addWord
705
706/*************************************************************
707 * addWord_cb
708 *
709 * The addWord_cb function is a callback function that
710 * PHP's addWord function returns to.  It recieves the
711 * return status of the add to word to personal dictionary call.
712 * It hides the status item.
713 *
714 * @param returnedData The return code from PHP.
715 *************************************************************/
716function addWord_cb(returnedData)
717{
718        with(currObj);
719        currObj.statusSpan.innerHTML = "";
720        resumeEditing();
721        spellCheck();
722}; // end addWord_cb
723
724
725
726/*************************************************************
727 * checkClickLocation(e)
728 *
729 * This function is called by the event listener when the user
730 * clicks on anything.  It is used to close the suggestion div
731 * if the user clicks anywhere that's not inside the suggestion
732 * div.  It just checks to see if the name of what the user clicks
733 * on is not "suggestions" then hides the div if it's not.
734 *
735 * @param e The event, in this case the user clicking somewhere on
736 *          the page.
737 *************************************************************/
738function checkClickLocation(e)
739{
740   
741    if(spellingSuggestionsDiv)
742        {
743                // Bah.  There's got to be a better way to deal with this, but the click
744                // on a word to get suggestions starts up a race condition between
745                // showing and hiding the suggestion box, so we'll ignore the first
746                // click.
747                if(spellingSuggestionsDiv.ignoreNextClick){
748                        spellingSuggestionsDiv.ignoreNextClick = false;
749                }
750                else
751                {
752                        var theTarget = getTarget(e);
753                       
754                        if(theTarget != spellingSuggestionsDiv)
755                        {
756                                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
757                                spellingSuggestionsDiv = null;
758                        }
759                }
760        }
761       
762        return true; // Allow other handlers to continue.
763}; //end checkClickLocation
764
765
766/*************************************************************
767 * getTarget
768 *
769 * The get target function gets the correct target of the event.
770 * This function is required because IE handles the events in
771 * a different (wrong) manner than the rest of the browsers.
772 *
773 * @param e The target, in this case the user clicking somewhere on
774 *     the page.
775 *
776 *************************************************************/
777function getTarget(e)
778{
779       
780        var value;
781        if(checkBrowser() == "ie")
782        {
783                value = window.event.srcElement;
784        }
785        else
786        {
787                value = e.target;
788        }
789        return value;
790}; //end getTarget
791
792
793/*************************************************************
794 * checkBrowser()
795 *
796 * The checkBrowser function simply checks to see what browser
797 * the user is using and returns a string containing the browser
798 * type.
799 *
800 * @return string The browser type
801 *************************************************************/
802function checkBrowser()
803{
804        var theAgent = navigator.userAgent.toLowerCase();
805        if(theAgent.indexOf("msie") != -1)
806        {
807                if(theAgent.indexOf("opera") != -1)
808                {
809                        return "opera";
810                }
811                else
812                {
813                        return "ie";
814                }
815        }
816        else if(theAgent.indexOf("netscape") != -1)
817        {
818                return "netscape";
819        }
820        else if(theAgent.indexOf("firefox") != -1)
821        {
822                return "firefox";
823        }
824        else if(theAgent.indexOf("mozilla/5.0") != -1)
825        {
826                return "mozilla";
827        }
828        else if(theAgent.indexOf("\/") != -1)
829        {
830                if(theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla')
831                {
832                        return navigator.userAgent.substr(0,theAgent.indexOf('\/'));
833                }
834                else
835                {
836                        return "netscape";
837                }
838        }
839        else if(theAgent.indexOf(' ') != -1)
840        {
841                return navigator.userAgent.substr(0,theAgent.indexOf(' '));
842        }
843        else
844        {
845                return navigator.userAgent;
846        }
847}; // end checkBrowser
848
849
850/*************************************************************
851 * showSuggestions_cb
852 *
853 * The showSuggestions_cb function is a callback function that
854 * php's showSuggestions function returns to.  It sets the
855 * suggestions table to contain the new data and then displays
856 * the suggestions div.  It also clears the status message.
857 *
858 * @param new_data The suggestions table returned from php.
859 *************************************************************/
860function showSuggestions_cb(new_data)
861{
862       
863        with(currObj);
864        spellingSuggestionsDiv.innerHTML = new_data;
865        spellingSuggestionsDiv.style.display = 'block';
866        currObj.statusSpan.innerHTML = "";
867
868        //adicionado os listener - nathalie
869         var ifr= currObj.objToCheck;
870         if(ifr.contentWindow)
871            ifr=ifr.contentWindow.document;
872         else
873            ifr=ifr.contentDocument;
874
875        var nodeArray = ifr.getElementsByTagName("span");
876        var totArray = nodeArray.length;
877        for (var i = 0 ; i < totArray ; i++) {
878            var node = nodeArray[i];
879            if (node.className == "suggestion" || node.className == "ignore" ) {
880                 if (document.addEventListener)
881                    ifr.getElementsByTagName("span")[i].addEventListener("click", replaceMenu , true);
882                else
883                    ifr.getElementsByTagName("span")[i].attachEvent("click", replaceMenu);
884                   
885
886
887
888               
889
890            }
891        }
892
893
894}; //end showSuggestions_cb
895
896
897/*************************************************************
898 * showSuggestions
899 *
900 * The showSuggestions function calls the showSuggestions php
901 * function to get suggestions for the misspelled word that the
902 * user has clicked on.  It sets the status to "Searching...",
903 * hides the suggestions div, finds the x and y position of the
904 * span containing the misspelled word that user clicked on so
905 * the div can be displayed in the correct location, and then
906 * calls the showSuggestions php function with the misspelled word
907 * and the id of the span containing it.
908 *
909 * @param word The misspelled word that the user clicked on
910 * @param id The id of the span that contains the misspelled word
911 *************************************************************/
912function showSuggestions(word, id)
913{
914       
915        //adicionado nathalie
916         var ifr= currObj.objToCheck;
917         if(ifr.contentWindow)
918            ifr=ifr.contentWindow.document;
919         else
920            ifr=ifr.contentDocument;
921
922//alterado - colocar ifr
923        languageId =  document.getElementById("selectLanguage");
924        languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
925       
926     
927        with(currObj);
928        if(currObj.config['useIcons'])
929        {
930                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Procurando...\" alt=\"Procurando...\" border=\"0\" />";
931        }
932        else
933        {
934                currObj.statusSpan.innerHTML = "Procurando...";
935        }
936       
937        var x = findPosXById(id);
938        var y = findPosYById(id);     
939       
940        var scrollPos = 0;
941        if(checkBrowser() != "ie")
942        {
943               
944               
945                //scrollPos = ifr.getElementById(currObj.spellingResultsDiv.id).scrollTop;
946                scrollPos = ifr.getElementsByTagName("body")[0].scrollTop;
947               
948        }
949
950        if(spellingSuggestionsDiv)
951        {
952                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
953        }
954        spellingSuggestionsDiv = document.createElement('span');
955        spellingSuggestionsDiv.style.display = "none";
956        spellingSuggestionsDiv.className = 'suggestion_box';
957        spellingSuggestionsDiv.style.position = 'absolute';
958        spellingSuggestionsDiv.style.left = x + 'px';
959        spellingSuggestionsDiv.style.top = (y+16-scrollPos) + 'px';
960        spellingSuggestionsDiv.id = 'suggestion_box'; //Adicionado Nathalie
961       
962       
963        spellingSuggestionsDiv.addEventListener("active", focusDiv , true); //Adicionado Nathalie
964
965       
966       
967               
968       
969        // Bah. There's got to be a better way to deal with this, but the click
970        // on a word to get suggestions starts up a race condition between
971        // showing and hiding the suggestion box, so we'll ignore the first
972        // click.
973        //spellingSuggestionsDiv.ignoreNextClick = true; // comentado Nathalie
974
975       
976        //document.body.appendChild(spellingSuggestionsDiv);
977        ifr.body.appendChild(spellingSuggestionsDiv); //alterado nathalie
978       
979
980
981
982       
983        cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, languageId);
984}; // end showSuggestions
985
986
987
988/*************************************************************
989 * replaceWord
990 *
991 * The replaceWord function replaces the innerHTML of all the span tags
992 * that contains the old word with the new word that the user selects
993 * from the suggestion div.  It hides the suggestions div and changes the color of
994 * the previously misspelled word to green to let the user know
995 * it has been changed.  It then calls the switchText php function
996 * with the innerHTML of the div to update the text of the text box.
997 *
998 * @param id The id of the element to be checked
999 * @param newword The word the user selected from the suggestions div
1000 *                to replace the misspelled word.
1001 *************************************************************/
1002function replaceWord(id, newWord)
1003{
1004
1005   
1006    var ifr= currObj.objToCheck;
1007    if(ifr.contentWindow)
1008        ifr=ifr.contentWindow.document;
1009    else
1010        ifr=ifr.contentDocument;
1011
1012    var valorNo = trim(ifr.getElementById(id).innerHTML);
1013
1014    //ifr.location.reload(true);
1015
1016    //alert(ifr.getElementById(currObj.spellingResultsDiv.id).getElementsByTagName("div").length);
1017    //ifr.getElementById(currObj.spellingResultsDiv.id).style.display = 'none';
1018 
1019
1020    //ifr.getElementById(currObj.spellingResultsDiv.id).
1021   
1022
1023
1024    // Obtain all span tags which have highlight className and contais the old word
1025    var nodeArray = ifr.getElementsByTagName("span");
1026    var totArray = nodeArray.length;
1027    var nodeRemove = new Array(totArray);
1028    var j = -1;
1029    for (var i = 0 ; i < totArray ; i++) {
1030        var node = nodeArray[i];
1031        if (node.className == "highlight" && trim(node.innerHTML) == valorNo ) {
1032            j++;
1033            nodeRemove[j] = node.id;
1034        }
1035    }
1036
1037    //Replace the class of the span tags with highlight and the innerHTML with the new_word
1038    for (var i = 0 ; i <= j ; i++) {
1039        ifr.getElementById(nodeRemove[i]).innerHTML = newWord;
1040        ifr.getElementById(nodeRemove[i]).className = "corrected_word";
1041    }
1042
1043
1044    if(spellingSuggestionsDiv)
1045    {
1046        spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
1047        spellingSuggestionsDiv = null;
1048    }
1049
1050    /*var nodeArray = ifr.getElementsByTagName("img");
1051
1052        var totArray = nodeArray.length;
1053        for (var i = 0 ; i < totArray ; i++) {
1054            alert("Tem Imagem");
1055            var node = nodeArray[i];
1056                ifr.getElementsByTagName("img")[i].style = 'none';
1057       }*/
1058
1059
1060    return false;
1061
1062
1063// FIMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
1064
1065         //Função antiga - substitui apenas uma palavra
1066   /*       var ifr= currObj.objToCheck;
1067         if(ifr.contentWindow)
1068            ifr=ifr.contentWindow.document;
1069         else
1070            ifr=ifr.contentDocument;
1071
1072        var valorNo = trim(newWord);       
1073        if(spellingSuggestionsDiv)
1074        {
1075
1076                spellingSuggestionsDiv.style.display = 'none';
1077                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
1078                spellingSuggestionsDiv = null;
1079        }
1080       
1081        var fake = document.createTextNode(valorNo);
1082       
1083       var parent =  ifr.getElementById(id).parentNode;
1084
1085           
1086       parent.replaceChild(fake, ifr.getElementById(id));
1087
1088        return false;*/
1089
1090           
1091
1092
1093}; // end replaceWord
1094
1095
1096/*************************************************************
1097 * switchText
1098 *
1099 * The switchText function is a funtion is called when the user
1100 * clicks on resume editing (or submits the form).  It calls the
1101 * php function to switchText and uncomments the html and replaces
1102 * breaks and everything.  Here all the breaks that the user has
1103 * typed are replaced with %u2026.  Firefox does this goofy thing
1104 * where it cleans up the display of your html, which adds in \n's
1105 * where you don't want them.  So I replace the user-entered returns
1106 * with something unique so that I can rip out all the breaks that
1107 * the browser might add and we don't want.
1108 *************************************************************/
1109function switchText()
1110{
1111       
1112        with(currObj);
1113        //By Nathalie - The Element means that this div belongs to the current tab
1114        //var parentElement = Element(currObj.spellingResultsDiv.id); //alterado nathalie
1115        var ifr= currObj.objToCheck;
1116        if(ifr.contentWindow)
1117            ifr=ifr.contentWindow.document;
1118        else
1119            ifr=ifr.contentDocument;
1120        var parentElement =ifr.getElementById(currObj.spellingResultsDiv.id); //alterado nathalie
1121        // Obtain all span tags which have highlight className or corrected_word className
1122        var nodeArray = ifr.getElementsByTagName("span");
1123        var totArray = nodeArray.length;
1124        var nodeRemove = new Array(totArray);
1125        var j = -1;
1126
1127        for (var i = 0 ; i < totArray ; i++) {
1128            var node = nodeArray[i];
1129            if (node.className == "highlight" || node.className == "corrected_word") {
1130                j++;
1131                nodeRemove[j] = node.id;
1132               
1133               
1134            }
1135        }
1136
1137        //Remove span tags which have highlight className or corrected_word className
1138        for (var i = 0 ; i <= j ; i++) {
1139            var valorNo = ifr.getElementById(nodeRemove[i]).innerHTML;
1140            var fake = document.createTextNode(valorNo);
1141            var parent =  ifr.getElementById(nodeRemove[i]).parentNode;
1142            parent.replaceChild(fake, ifr.getElementById(nodeRemove[i]));
1143        }
1144
1145        var text = ifr.getElementById(currObj.spellingResultsDiv.id).innerHTML;
1146
1147        text = text.replace(/&nbsp;/gi, " %u2026 "); // Replace &nbsp; with the code %u2026
1148        text = '*' + text;
1149
1150        cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text);
1151       
1152}; // end switchText
1153
1154
1155/*************************************************************
1156 * switchText_cb
1157 *
1158 * The switchText_cb function is a call back funtion that the
1159 * switchText php function returns to.  I replace all the %u2026's
1160 * with returns.  It then replaces the text in the text box with
1161 * the corrected text fromt he div.
1162 *
1163 * @param new_string The corrected text from the div.
1164 *
1165 *************************************************************/
1166function switchText_cb(new_string)
1167{
1168
1169
1170//adicionado Paula
1171    with(currObj);
1172
1173        new_string = new_string.replace(/ %u2026/gi, "&nbsp;"); // Replace the code %u2026 with &nbsp;
1174             
1175        new_string = new_string.replace(/~~~/gi, "\n");
1176       
1177        // Remove the prefixed asterisk that was added in switchText().
1178        new_string = new_string.substr(1);
1179
1180
1181         currObj.objToCheck.style.display = "none";
1182         var ifr= currObj.objToCheck;
1183         if(ifr.contentWindow)
1184            ifr=ifr.contentWindow.document;
1185         else
1186            ifr=ifr.contentDocument;
1187         var texto = ifr.body.innerHTML;
1188
1189         ifr.body.innerHTM = ""; //adicionado nathalie
1190         ifr.body.innerHTML = new_string;
1191         currObj.spellingResultsDiv = null; //adicionado nathalie
1192
1193         
1194
1195        currObj.objToCheck.disabled = false;
1196       
1197        //Removido Nathalie
1198        /*if(currObj.spellingResultsDiv)
1199        {
1200                ifr.removeChild(currObj.spellingResultsDiv); //Alterado nathalie
1201                currObj.spellingResultsDiv = null;
1202        }*/
1203        currObj.objToCheck.style.display = "block";
1204        currObj.resetAction();
1205}; // end switchText_cb
1206
1207
1208/*************************************************************
1209 * resumeEditing
1210 *
1211 * The resumeEditing function is called when the user is in the
1212 * correction mode and wants to return to the editing mode.  It
1213 * hides the results div and the suggestions div, then enables
1214 * the text box and unhides the text box.  It also calls
1215 * resetAction() to reset the status message.
1216 *************************************************************/
1217function resumeEditing()
1218{
1219       
1220        with(currObj);
1221
1222        currObj.controlPanelDiv.style.display = "block";
1223        if(currObj.config['useIcons'])
1224        {
1225                currObj.actionSpan.innerHTML = "<a class=\"resume_editing\"><img src=\"images/page_white_edit.png\" width=\"16\" height=\"16\" title=\"Continuar Editando\" alt=\"Continuar Editando\" border=\"0\" /></a>";
1226        }
1227        else
1228        {
1229                currObj.actionSpan.innerHTML = "<a class=\"resume_editing\">Continuar Editando</a>";
1230        }
1231        if(currObj.config['useIcons'])
1232        {
1233                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Carregando...\" alt=\"Carregando...\" border=\"0\" />";
1234        }
1235        else
1236        {
1237                currObj.statusSpan.innerHTML = "Carregando...";
1238        }
1239       
1240       
1241        if(spellingSuggestionsDiv)
1242        {
1243               
1244                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
1245                spellingSuggestionsDiv = null;
1246        }
1247       
1248        currObj.switchText();
1249}; // end resumeEditing
1250
1251
1252/*************************************************************
1253 * resetAction
1254 *
1255 * The resetAction function just resets the status message to
1256 * the default action of "Check Spelling".
1257 *************************************************************/
1258function resetAction()
1259{
1260
1261//adicionado Paula
1262        with(currObj);
1263        /*if(currObj.config['useIcons'])
1264        {
1265                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>";
1266        }
1267        else
1268        {
1269                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
1270        }*/
1271
1272        currObj.actionSpan.innerHTML = "";
1273        currObj.statusSpan.innerHTML = "";
1274        currObj.controlPanelDiv.style.display = "none";
1275        blockSpellCheck = false;
1276}; // end resetAction
1277
1278
1279/*************************************************************
1280 * resetSpellChecker
1281 *
1282 * The resetSpellChecker function resets the entire spell checker
1283 * to the defaults.
1284 *************************************************************/
1285function resetSpellChecker()
1286{
1287       
1288        //adicionado nathalie
1289        var ifr= currObj.objToCheck;
1290         if(ifr.contentWindow)
1291            ifr=ifr.contentWindow.document;
1292         else
1293            ifr=ifr.contentDocument;
1294
1295
1296        with(currObj);
1297        currObj.resetAction();
1298       
1299        currObj.objToCheck.value = "";
1300        currObj.objToCheck.style.display = "block";
1301        currObj.objToCheck.disabled = false;
1302       
1303        if(currObj.spellingResultsDiv)
1304        {
1305                ifr.removeChild(currObj.spellingResultsDiv); //alterado nathalie
1306                currObj.spellingResultsDiv = null;
1307        }
1308        if(spellingSuggestionsDiv)
1309        {
1310                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
1311                spellingSuggestionsDiv = null;
1312        }
1313        currObj.statusSpan.style.display = "none";
1314       
1315}; // end resetSpellChecker
1316
1317
1318/*************************************************************
1319 * findPosX
1320 *
1321 * The findPosX function just finds the X offset of the top left
1322 * corner of the object id it's given.
1323 *
1324 * @param object The id of the object that you want to find the
1325 *               upper left X coordinate of.
1326 * @return int The X coordinate of the object
1327 *************************************************************/
1328    function findPosXById(object)
1329{
1330       
1331        //adicionado Nathalie
1332        var ifr= currObj.objToCheck;
1333         if(ifr.contentWindow)
1334            ifr=ifr.contentWindow.document;
1335         else
1336            ifr=ifr.contentDocument;
1337        var obj = ifr.getElementById(object);
1338
1339
1340        var curleft = 0;
1341        //var obj = document.getElementById(object); //removido nathalie
1342
1343
1344        if(obj.offsetParent)
1345        {
1346                while(obj.offsetParent)
1347                {
1348                        curleft += obj.offsetLeft - obj.scrollLeft;
1349                        obj = obj.offsetParent;
1350                }
1351        }
1352        else if(obj.x)
1353        {
1354                curleft += obj.x;
1355        }
1356        return curleft;
1357}; // end findPosX
1358
1359
1360/*************************************************************
1361 * findPosY
1362 *
1363 * The findPosY function just finds the Y offset of the top left
1364 * corner of the object id it's given.
1365 *
1366 * @param object The id of the object that you want to find the
1367 *               upper left Y coordinate of.
1368 * @return int The Y coordinate of the object
1369 *************************************************************/
1370function findPosYById(object)
1371{
1372       
1373        //adicionado Nathalie
1374        var ifr= currObj.objToCheck;
1375         if(ifr.contentWindow)
1376            ifr=ifr.contentWindow.document;
1377         else
1378            ifr=ifr.contentDocument;
1379        var obj = ifr.getElementById(object); //removido Nathalie
1380
1381   
1382        var curtop = 0;var curtop = 0;
1383        //var obj = document.getElementById(object); //removido Nathalie
1384        if(obj.offsetParent)
1385        {
1386                while(obj.offsetParent)
1387                {
1388                        curtop += obj.offsetTop - obj.scrollTop;
1389                        obj = obj.offsetParent;
1390                }
1391        }
1392        else if(obj.y)
1393        {
1394                curtop += obj.y;
1395        }
1396        return curtop;
1397}; // end findPosY
1398
1399
1400/*************************************************************
1401 * trim
1402 *
1403 * Trims white space from a string.
1404 *
1405 * @param s The string you want to trim.
1406 * @return string The trimmed string.
1407 *************************************************************/
1408function trim(s)
1409{
1410       
1411        while(s.substring(0,1) == ' ')
1412        {
1413        s = s.substring(1,s.length);
1414        }
1415        while(s.substring(s.length-1,s.length) == ' ')
1416        {
1417        s = s.substring(0,s.length-1);
1418        }
1419        return s;
1420}; // end trim
Note: See TracBrowser for help on using the repository browser.