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

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

Ticket #891 - Remocao do div dentro do iframe - 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 * showMenu
353 *
354 * This function is associated with the click event
355 *  of all the tags span with correctd_word class.
356 *
357 *************************************************************/
358function showMenu(){
359    alert("showMenu");
360    var browser = checkBrowser();
361    if (browser == "ie"){
362         var ifr= currObj.objToCheck;
363         if(!e){var e = ifr.contentWindow.event;}
364            if(!e.target){e.target = e.srcElement;}
365
366            if(ifr.contentWindow)
367            ifr=ifr.contentWindow.document;
368        else
369            ifr=ifr.contentDocument;
370        var evento = ifr.getElementById(e.target.id).onclick.toString();
371    }
372    else {
373        var evento = this.onclick.toString();
374    }
375
376    evento = evento.replace("function onclick(event) {", "");
377    evento = evento.replace("}", "");
378    var array_func = evento.split(";");
379    eval(array_func[0]);
380   eval(array_func[1]);
381    return false;   
382   
383
384   
385 
386//
387}
388
389/*************************************************************
390 * showMenu
391 *
392 * This function is associated with the click event
393 *  of all the tags div with suggestion class.
394 *
395 *************************************************************/
396function replaceMenu(){
397     //adicionado nathalie
398        var ifr= currObj.objToCheck;
399        if(ifr.contentWindow)
400            ifr=ifr.contentWindow.document;
401        else
402            ifr=ifr.contentDocument;
403
404
405   
406
407
408    var evento = this.onclick.toString();
409    alert("Replace");
410
411   
412
413
414   
415
416
417
418
419
420    evento = evento.replace("function onclick(event) {", "");
421    evento = evento.replace("}", "");
422    var array_func = evento.split(";");
423    eval(array_func[0]);
424    return false;
425}
426
427
428
429/*************************************************************
430 * spellCheck_cb
431 *
432 * This is the callback function that the spellCheck php function
433 * returns the spell checked data to.  It sets the results div
434 * to contain the markedup misspelled data and changes the status
435 * message.  It also sets the width and height of the results
436 * div to match the element that's being checked.
437 * If there are no misspellings then new_data is the empty
438 * string and the status is set to "No Misspellings Found".
439 *
440 * @param new_data The marked up misspelled data returned from php.
441 *************************************************************/
442function spellCheck_cb(new_data)
443{
444         //adicionado nathalie
445        var ifr= currObj.objToCheck;
446        if(ifr.contentWindow)
447            ifr=ifr.contentWindow.document;
448        else
449            ifr=ifr.contentDocument;
450
451
452        with(currObj);
453
454        new_data = new_data.toString();
455        var isThereAMisspelling = new_data.charAt(0);
456        new_data = new_data.substring(1);
457
458        if(currObj.spellingResultsDiv)
459        {
460           
461                ifr.removeChild(currObj.spellingResultsDiv.id);
462               
463        }
464
465       
466        /*currObj.spellingResultsDiv =  document.createElement('DIV');
467        currObj.spellingResultsDiv.className = 'edit_box';
468        currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
469        currObj.spellingResultsDiv.style.width =  "99%";//the width of the textarea
470        currObj.spellingResultsDiv.style.height = 300;  //   = height; //currObj.objToCheck.style.height;
471        currObj.spellingResultsDiv.innerHTML = new_data;       
472        currObj.objToCheck.style.display = "none";
473        currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv,currObj.objToCheck);
474        currObj.statusSpan.innerHTML = ""; */
475
476
477
478
479        // Teste de iFrame - Nathalie
480         var ifr= currObj.objToCheck;
481         if(ifr.contentWindow)
482            ifr=ifr.contentWindow.document;
483         else
484            ifr=ifr.contentDocument;
485         ifr.body.innerHTML =  "";
486         var cssLink = ifr.createElement("link");
487         cssLink.href = "spell_checker/css/spell_checker.css";
488         cssLink .rel = "stylesheet";
489         cssLink .type = "text/css";           
490              //Testes nathalie - substituido
491        currObj.spellingResultsDiv =  ifr.createElement('span');
492        currObj.spellingResultsDiv.className = 'edit_box';
493        currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
494        currObj.spellingResultsDiv.style.width =  "99%";//the width of the textarea
495        currObj.spellingResultsDiv.style.height = 300;  //   = height; //currObj.objToCheck.style.height;
496        currObj.spellingResultsDiv.innerHTML = new_data;
497        currObj.spellingResultsDiv.border = 0;
498        //currObj.spellingResultsDiv.style.display = "none";
499        //currObj.objToCheck.style.display = "none";
500        currObj.statusSpan.innerHTML = ""; 
501       
502
503
504       
505         //ifr.body.appendChild(currObj.spellingResultsDiv);
506         ifr.body.innerHTML = new_data;
507         ifr.body.appendChild(cssLink);
508
509
510        // Obtain all the span tags which have highlight className
511        //    and add the eventListener for the click - This event shows the suggestions menu
512        var nodeArray = ifr.getElementsByTagName("span");
513        var totArray = nodeArray.length;
514        for (var i = 0 ; i < totArray ; i++) {
515            var node = nodeArray[i];
516            if (node.className == "highlight") {
517                if (document.addEventListener)
518                    ifr.getElementsByTagName("span")[i].addEventListener("click", showMenu , true);
519                else
520                    ifr.getElementsByTagName("span")[i].attachEvent("onclick", showMenu );
521
522            }
523        }
524
525
526//adicionado Paula
527//    currObj.objToCheck.style.display = "none"; //Paula
528        //currObj.objToCheck.parentNode.
529        //currObj.objToCheck.parentNode.appendChild(currObj.spellingResultsDiv,currObj.objToCheck);
530//      currObj.objToCheck.parentNode.insertBefore(currObj.spellingResultsDiv, document.getElementById("viewsource_rt_checkbox_" + currentTab)); //Paula
531        currObj.statusSpan.innerHTML = "";   
532
533       
534        if(currObj.config['useIcons'])
535        {
536                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>";
537        }
538        else
539        {
540                currObj.actionSpan.innerHTML = "<a class=\"resume_editing\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".resumeEditing();\">Continuar Editando </a>";
541        }
542               
543        if(isThereAMisspelling != "1")
544        {
545                if(currObj.config['useIcons'])
546                {
547                        currObj.statusSpan.innerHTML = "<img src=\"images/accept.png\" width=\"16\" height=\"16\" title=\"Nenhum Erro Encontrado\" alt=\"Nenhum Erro Encontrado\" border=\"0\" />";
548                }
549                else
550                {
551                        currObj.statusSpan.innerHTML = "Nenhum Erro Encontrado";
552                }
553                currObj.objToCheck.disabled = false;
554        }
555
556       currObj.controlPanelDiv.style.display = "block";
557
558}; // end spellCheck_cb
559
560
561/*************************************************************
562 * spellCheck()
563 *
564 * The spellCheck javascript function sends the text entered by
565 * the user in the text box to php to be spell checked.  It also
566 * sets the status message to "Checking..." because it's currently
567 * checking the spelling.
568 *************************************************************/
569function spellCheck() {
570// adicionado nathalie
571/*        with(currObj);
572        var query;
573
574        if(currObj.spellingResultsDiv)
575        {
576                currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
577                currObj.spellingResultsDiv = null;
578        }
579       
580        if(currObj.config['useIcons'])
581        {
582                currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
583        }
584        else
585        {
586                currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
587        }
588       
589        if(currObj.config['useIcons'])
590        {
591                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
592        }
593        else
594        {
595                currObj.statusSpan.innerHTML = "Verificando Ortografia...";
596        }       
597       
598        // Obtain the HTML content from iframe (edit area)
599         var ifr= currObj.objToCheck;
600         if(ifr.contentWindow)
601            ifr=ifr.contentWindow.document;
602         else
603            ifr=ifr.contentDocument;
604         var texto = ifr.body.innerHTML;
605       
606       
607        query = texto;
608        //query = currObj.objToCheck.value;       
609       
610        //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
611        query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
612       
613       
614        cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']);
615*/
616//adicionado Paula
617        if(!blockSpellCheck) {
618            blockSpellCheck = true;
619
620         languageId =  document.getElementById("selectLanguage");
621            languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
622
623            with(currObj);
624            var query;
625
626            currObj.controlPanelDiv.style.display = "block";
627
628            if(currObj.spellingResultsDiv)
629            {
630                    currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
631                    currObj.spellingResultsDiv = null;
632            }
633
634            /*if(currObj.config['useIcons'])
635            {
636                    currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
637            }
638            else
639            {
640                    currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
641            }*/
642
643            /*if(currObj.config['useIcons'])
644            {
645                    currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
646            }
647            else
648            {
649                    currObj.statusSpan.innerHTML = "Verificando Ortografia...";
650            }*/
651
652            // Obtain the HTML content from iframe (edit area)
653             var ifr= currObj.objToCheck;
654             if(ifr.contentWindow)
655                ifr=ifr.contentWindow.document;
656             else
657                ifr=ifr.contentDocument;
658             var texto = ifr.body.innerHTML;
659
660            query = texto;
661            //query = currObj.objToCheck.value;
662
663            //query = query.replace(/\r?\n/gi, "<br />"); //  Commented from the original by Nathalie
664            query = query.replace(/\r?\n/gi, " ");  // replace \n with " " - By Nathalie
665
666            cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], languageId);
667        }
668}; // end spellcheck
669
670
671
672/*************************************************************
673 * addWord
674 *
675 * The addWord function adds a word to the custom dictionary
676 * file.
677 *
678 * @param id The id of the span that contains the word to be added
679 *************************************************************/
680function addWord(id)
681{
682        var wordToAdd = document.getElementById(id).innerHTML;
683       
684        with(currObj);
685       
686        if(spellingSuggestionsDiv)
687        {
688                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
689                spellingSuggestionsDiv = null;
690        }
691
692        currObj.controlPanelDiv.style.display = "block";
693
694        if(currObj.config['useIcons'])
695        {
696                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Adding Word...\" alt=\"Adding Word...\" border=\"0\" />";
697        }
698        else
699        {
700                currObj.statusSpan.innerHTML = "Adding Word...";
701        }
702       
703        cp.call(currObj.config['spellUrl'], 'addWord', addWord_cb, wordToAdd);
704
705}; // end addWord
706
707/*************************************************************
708 * addWord_cb
709 *
710 * The addWord_cb function is a callback function that
711 * PHP's addWord function returns to.  It recieves the
712 * return status of the add to word to personal dictionary call.
713 * It hides the status item.
714 *
715 * @param returnedData The return code from PHP.
716 *************************************************************/
717function addWord_cb(returnedData)
718{
719        with(currObj);
720        currObj.statusSpan.innerHTML = "";
721        resumeEditing();
722        spellCheck();
723}; // end addWord_cb
724
725
726
727/*************************************************************
728 * checkClickLocation(e)
729 *
730 * This function is called by the event listener when the user
731 * clicks on anything.  It is used to close the suggestion div
732 * if the user clicks anywhere that's not inside the suggestion
733 * div.  It just checks to see if the name of what the user clicks
734 * on is not "suggestions" then hides the div if it's not.
735 *
736 * @param e The event, in this case the user clicking somewhere on
737 *          the page.
738 *************************************************************/
739function checkClickLocation(e)
740{
741   
742    if(spellingSuggestionsDiv)
743        {
744                // Bah.  There's got to be a better way to deal with this, but the click
745                // on a word to get suggestions starts up a race condition between
746                // showing and hiding the suggestion box, so we'll ignore the first
747                // click.
748                if(spellingSuggestionsDiv.ignoreNextClick){
749                        spellingSuggestionsDiv.ignoreNextClick = false;
750                }
751                else
752                {
753                        var theTarget = getTarget(e);
754                       
755                        if(theTarget != spellingSuggestionsDiv)
756                        {
757                                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
758                                spellingSuggestionsDiv = null;
759                        }
760                }
761        }
762       
763        return true; // Allow other handlers to continue.
764}; //end checkClickLocation
765
766
767/*************************************************************
768 * getTarget
769 *
770 * The get target function gets the correct target of the event.
771 * This function is required because IE handles the events in
772 * a different (wrong) manner than the rest of the browsers.
773 *
774 * @param e The target, in this case the user clicking somewhere on
775 *     the page.
776 *
777 *************************************************************/
778function getTarget(e)
779{
780       
781        var value;
782        if(checkBrowser() == "ie")
783        {
784                value = window.event.srcElement;
785        }
786        else
787        {
788                value = e.target;
789        }
790        return value;
791}; //end getTarget
792
793
794/*************************************************************
795 * checkBrowser()
796 *
797 * The checkBrowser function simply checks to see what browser
798 * the user is using and returns a string containing the browser
799 * type.
800 *
801 * @return string The browser type
802 *************************************************************/
803function checkBrowser()
804{
805        var theAgent = navigator.userAgent.toLowerCase();
806        if(theAgent.indexOf("msie") != -1)
807        {
808                if(theAgent.indexOf("opera") != -1)
809                {
810                        return "opera";
811                }
812                else
813                {
814                        return "ie";
815                }
816        }
817        else if(theAgent.indexOf("netscape") != -1)
818        {
819                return "netscape";
820        }
821        else if(theAgent.indexOf("firefox") != -1)
822        {
823                return "firefox";
824        }
825        else if(theAgent.indexOf("mozilla/5.0") != -1)
826        {
827                return "mozilla";
828        }
829        else if(theAgent.indexOf("\/") != -1)
830        {
831                if(theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla')
832                {
833                        return navigator.userAgent.substr(0,theAgent.indexOf('\/'));
834                }
835                else
836                {
837                        return "netscape";
838                }
839        }
840        else if(theAgent.indexOf(' ') != -1)
841        {
842                return navigator.userAgent.substr(0,theAgent.indexOf(' '));
843        }
844        else
845        {
846                return navigator.userAgent;
847        }
848}; // end checkBrowser
849
850
851/*************************************************************
852 * showSuggestions_cb
853 *
854 * The showSuggestions_cb function is a callback function that
855 * php's showSuggestions function returns to.  It sets the
856 * suggestions table to contain the new data and then displays
857 * the suggestions div.  It also clears the status message.
858 *
859 * @param new_data The suggestions table returned from php.
860 *************************************************************/
861function showSuggestions_cb(new_data)
862{
863       
864        with(currObj);
865        spellingSuggestionsDiv.innerHTML = new_data;
866        spellingSuggestionsDiv.style.display = 'block';
867        currObj.statusSpan.innerHTML = "";
868
869        //adicionado os listener - nathalie
870         var ifr= currObj.objToCheck;
871         if(ifr.contentWindow)
872            ifr=ifr.contentWindow.document;
873         else
874            ifr=ifr.contentDocument;
875
876        var nodeArray = ifr.getElementsByTagName("span");
877        var totArray = nodeArray.length;
878        for (var i = 0 ; i < totArray ; i++) {
879            var node = nodeArray[i];
880            if (node.className == "suggestion" || node.className == "ignore" ) {
881                 if (document.addEventListener)
882                    ifr.getElementsByTagName("span")[i].addEventListener("click", replaceMenu , true);
883                else
884                    ifr.getElementsByTagName("span")[i].attachEvent("onclick", replaceMenu);
885                   
886
887
888
889               
890
891            }
892        }
893
894
895}; //end showSuggestions_cb
896
897
898/*************************************************************
899 * showSuggestions
900 *
901 * The showSuggestions function calls the showSuggestions php
902 * function to get suggestions for the misspelled word that the
903 * user has clicked on.  It sets the status to "Searching...",
904 * hides the suggestions div, finds the x and y position of the
905 * span containing the misspelled word that user clicked on so
906 * the div can be displayed in the correct location, and then
907 * calls the showSuggestions php function with the misspelled word
908 * and the id of the span containing it.
909 *
910 * @param word The misspelled word that the user clicked on
911 * @param id The id of the span that contains the misspelled word
912 *************************************************************/
913function showSuggestions(word, id)
914{
915        alert("showSuggestions");
916        //adicionado nathalie
917         var ifr= currObj.objToCheck;
918         if(ifr.contentWindow)
919            ifr=ifr.contentWindow.document;
920         else
921            ifr=ifr.contentDocument;
922
923//alterado - colocar ifr
924        languageId =  document.getElementById("selectLanguage");
925        languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
926       
927     
928        with(currObj);
929        if(currObj.config['useIcons'])
930        {
931                currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Procurando...\" alt=\"Procurando...\" border=\"0\" />";
932        }
933        else
934        {
935                currObj.statusSpan.innerHTML = "Procurando...";
936        }
937       
938        var x = findPosXById(id);
939        var y = findPosYById(id);     
940       
941        var scrollPos = 0;
942        if(checkBrowser() != "ie")
943        {
944               
945               
946                //scrollPos = ifr.getElementById(currObj.spellingResultsDiv.id).scrollTop;
947                scrollPos = ifr.getElementsByTagName("body")[0].scrollTop;
948               
949        }
950
951        if(spellingSuggestionsDiv)
952        {
953                spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
954        }
955        spellingSuggestionsDiv = document.createElement('span');
956        spellingSuggestionsDiv.style.display = "none";
957        spellingSuggestionsDiv.className = 'suggestion_box';
958        spellingSuggestionsDiv.style.position = 'absolute';
959        spellingSuggestionsDiv.style.left = x + 'px';
960        spellingSuggestionsDiv.style.top = (y+16-scrollPos) + 'px';
961        spellingSuggestionsDiv.id = 'suggestion_box'; //Adicionado Nathalie
962       
963       
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.body.innerHTML; //alterado result div
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.