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