[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 | var iframe= currObj.objToCheck;
|
---|
| 335 | if(iframe.contentWindow)
|
---|
| 336 | iframe=iframe.contentWindow.document;
|
---|
| 337 | else
|
---|
| 338 | iframe=iframe.contentDocument;
|
---|
| 339 |
|
---|
[2512] | 340 | var browser = checkBrowser();
|
---|
[2554] | 341 | if (browser == "ie"){
|
---|
[2540] | 342 | iframe.body.contentEditable="true" ;
|
---|
[2546] | 343 | var ifr= currObj.objToCheck;
|
---|
| 344 | if(!e){var e = ifr.contentWindow.event;}
|
---|
| 345 | if(!e.target){e.target = e.srcElement;}
|
---|
| 346 | var evento = e.target.onclick.toString();
|
---|
[2536] | 347 | }
|
---|
| 348 | else {
|
---|
| 349 | iframe.designMode = "off";
|
---|
| 350 | iframe.designMode = "on";
|
---|
[2512] | 351 | var evento = this.onclick.toString();
|
---|
[2546] | 352 | }
|
---|
[2486] | 353 | evento = evento.replace("function onclick(event) {", "");
|
---|
| 354 | evento = evento.replace("}", "");
|
---|
| 355 | var array_func = evento.split(";");
|
---|
| 356 | eval(array_func[0]);
|
---|
[2546] | 357 | eval(array_func[1]);
|
---|
[2486] | 358 | return false;
|
---|
[2546] | 359 |
|
---|
[2512] | 360 |
|
---|
| 361 | //
|
---|
[2486] | 362 | }
|
---|
| 363 |
|
---|
| 364 | /*************************************************************
|
---|
[2546] | 365 | * replaceMenu
|
---|
[2486] | 366 | *
|
---|
| 367 | * This function is associated with the click event
|
---|
[2546] | 368 | * of all the div tags with suggestion class.
|
---|
[2486] | 369 | *
|
---|
| 370 | *************************************************************/
|
---|
[2546] | 371 | function replaceMenu(){
|
---|
[2536] | 372 | var iframe= currObj.objToCheck;
|
---|
| 373 | if(iframe.contentWindow)
|
---|
| 374 | iframe=iframe.contentWindow.document;
|
---|
| 375 | else
|
---|
| 376 | iframe=iframe.contentDocument;
|
---|
[2516] | 377 | var browser = checkBrowser();
|
---|
| 378 | if (browser == "ie"){
|
---|
[2540] | 379 | iframe.body.contentEditable="false" ;
|
---|
[2546] | 380 | var ifr= currObj.objToCheck;
|
---|
| 381 | if(!e){var e = ifr.contentWindow.event;}
|
---|
| 382 | if(!e.target){e.target = e.srcElement;}
|
---|
| 383 | var evento = e.target.onclick.toString();
|
---|
[2536] | 384 | }
|
---|
| 385 | else {
|
---|
| 386 | iframe.designMode = "off";
|
---|
| 387 | iframe.designMode = "on";
|
---|
[2516] | 388 | var evento = this.onclick.toString();
|
---|
| 389 | }
|
---|
[2486] | 390 | evento = evento.replace("function onclick(event) {", "");
|
---|
| 391 | evento = evento.replace("}", "");
|
---|
| 392 | var array_func = evento.split(";");
|
---|
| 393 | eval(array_func[0]);
|
---|
| 394 | return false;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 |
|
---|
| 398 |
|
---|
| 399 | /*************************************************************
|
---|
[2375] | 400 | * spellCheck_cb
|
---|
| 401 | *
|
---|
| 402 | * This is the callback function that the spellCheck php function
|
---|
| 403 | * returns the spell checked data to. It sets the results div
|
---|
| 404 | * to contain the markedup misspelled data and changes the status
|
---|
| 405 | * message. It also sets the width and height of the results
|
---|
| 406 | * div to match the element that's being checked.
|
---|
| 407 | * If there are no misspellings then new_data is the empty
|
---|
| 408 | * string and the status is set to "No Misspellings Found".
|
---|
| 409 | *
|
---|
| 410 | * @param new_data The marked up misspelled data returned from php.
|
---|
| 411 | *************************************************************/
|
---|
| 412 | function spellCheck_cb(new_data)
|
---|
| 413 | {
|
---|
[2557] | 414 | var ifr= currObj.objToCheck;
|
---|
[2486] | 415 | if(ifr.contentWindow)
|
---|
| 416 | ifr=ifr.contentWindow.document;
|
---|
| 417 | else
|
---|
| 418 | ifr=ifr.contentDocument;
|
---|
[2477] | 419 |
|
---|
| 420 | with(currObj);
|
---|
[2486] | 421 |
|
---|
[2554] | 422 | new_data = new_data.toString();
|
---|
[2375] | 423 | var isThereAMisspelling = new_data.charAt(0);
|
---|
| 424 | new_data = new_data.substring(1);
|
---|
[2430] | 425 |
|
---|
[2557] | 426 | if(currObj.spellingResultsDiv)
|
---|
[2375] | 427 | {
|
---|
[2557] | 428 | ifr.removeChild(currObj.spellingResultsDiv.id);
|
---|
[2375] | 429 | }
|
---|
[2430] | 430 |
|
---|
[2557] | 431 | var ifr= currObj.objToCheck;
|
---|
| 432 | if(ifr.contentWindow)
|
---|
| 433 | ifr=ifr.contentWindow.document;
|
---|
| 434 | else
|
---|
| 435 | ifr=ifr.contentDocument;
|
---|
| 436 | ifr.body.innerHTML = "";
|
---|
| 437 | var cssLink = ifr.createElement("link");
|
---|
| 438 | cssLink.href = "spell_checker/css/spell_checker.css";
|
---|
| 439 | cssLink .rel = "stylesheet";
|
---|
| 440 | cssLink .type = "text/css";
|
---|
| 441 |
|
---|
| 442 | // this is not being used
|
---|
[2510] | 443 | currObj.spellingResultsDiv = ifr.createElement('span');
|
---|
[2508] | 444 | currObj.spellingResultsDiv.className = 'edit_box';
|
---|
| 445 | currObj.spellingResultsDiv.id = 'edit_box'; //Added the id property - By Nathalie
|
---|
| 446 | currObj.spellingResultsDiv.style.width = "99%";//the width of the textarea
|
---|
| 447 | currObj.spellingResultsDiv.style.height = 300; // = height; //currObj.objToCheck.style.height;
|
---|
| 448 | currObj.spellingResultsDiv.innerHTML = new_data;
|
---|
| 449 | currObj.spellingResultsDiv.border = 0;
|
---|
| 450 | //currObj.spellingResultsDiv.style.display = "none";
|
---|
| 451 | //currObj.objToCheck.style.display = "none";
|
---|
| 452 | currObj.statusSpan.innerHTML = "";
|
---|
[2430] | 453 |
|
---|
[2557] | 454 | //add the new_data to iframe and the css style
|
---|
| 455 | ifr.body.innerHTML = "";
|
---|
| 456 | ifr.body.innerHTML = new_data;
|
---|
| 457 | ifr.body.appendChild(cssLink);
|
---|
[2486] | 458 |
|
---|
[2557] | 459 |
|
---|
[2486] | 460 | // Obtain all the span tags which have highlight className
|
---|
| 461 | // and add the eventListener for the click - This event shows the suggestions menu
|
---|
[2554] | 462 | var nodeArray = ifr.getElementsByTagName("span");
|
---|
[2486] | 463 | var totArray = nodeArray.length;
|
---|
| 464 | for (var i = 0 ; i < totArray ; i++) {
|
---|
| 465 | var node = nodeArray[i];
|
---|
| 466 | if (node.className == "highlight") {
|
---|
[2536] | 467 | if (document.addEventListener) {
|
---|
[2554] | 468 | ifr.getElementsByTagName("span")[i].addEventListener("click", showMenu , true);
|
---|
| 469 | ifr.getElementsByTagName("span")[i].contentEditable="false" ;
|
---|
[2536] | 470 | }
|
---|
| 471 | else {
|
---|
[2554] | 472 | ifr.getElementsByTagName("span")[i].attachEvent("onclick", showMenu );
|
---|
| 473 | ifr.getElementsByTagName("span")[i].contentEditable="false" ;
|
---|
[2536] | 474 | }
|
---|
[2486] | 475 |
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 |
|
---|
[2546] | 480 | currObj.statusSpan.innerHTML = "";
|
---|
[2486] | 481 |
|
---|
[2430] | 482 |
|
---|
[2375] | 483 | if(currObj.config['useIcons'])
|
---|
| 484 | {
|
---|
[2407] | 485 | 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] | 486 | }
|
---|
| 487 | else
|
---|
| 488 | {
|
---|
[2407] | 489 | currObj.actionSpan.innerHTML = "<a class=\"resume_editing\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".resumeEditing();\">Continuar Editando </a>";
|
---|
[2375] | 490 | }
|
---|
| 491 |
|
---|
| 492 | if(isThereAMisspelling != "1")
|
---|
| 493 | {
|
---|
| 494 | if(currObj.config['useIcons'])
|
---|
| 495 | {
|
---|
[2407] | 496 | currObj.statusSpan.innerHTML = "<img src=\"images/accept.png\" width=\"16\" height=\"16\" title=\"Nenhum Erro Encontrado\" alt=\"Nenhum Erro Encontrado\" border=\"0\" />";
|
---|
[2375] | 497 | }
|
---|
| 498 | else
|
---|
| 499 | {
|
---|
[2407] | 500 | currObj.statusSpan.innerHTML = "Nenhum Erro Encontrado";
|
---|
[2375] | 501 | }
|
---|
| 502 | currObj.objToCheck.disabled = false;
|
---|
| 503 | }
|
---|
[2477] | 504 |
|
---|
| 505 | currObj.controlPanelDiv.style.display = "block";
|
---|
| 506 |
|
---|
[2375] | 507 | }; // end spellCheck_cb
|
---|
| 508 |
|
---|
| 509 |
|
---|
| 510 | /*************************************************************
|
---|
| 511 | * spellCheck()
|
---|
| 512 | *
|
---|
| 513 | * The spellCheck javascript function sends the text entered by
|
---|
| 514 | * the user in the text box to php to be spell checked. It also
|
---|
| 515 | * sets the status message to "Checking..." because it's currently
|
---|
| 516 | * checking the spelling.
|
---|
| 517 | *************************************************************/
|
---|
| 518 | function spellCheck() {
|
---|
[2486] | 519 | // adicionado nathalie
|
---|
| 520 | /* with(currObj);
|
---|
| 521 | var query;
|
---|
[2430] | 522 |
|
---|
[2486] | 523 | if(currObj.spellingResultsDiv)
|
---|
| 524 | {
|
---|
| 525 | currObj.spellingResultsDiv.parentNode.removeChild(currObj.spellingResultsDiv);
|
---|
| 526 | currObj.spellingResultsDiv = null;
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | if(currObj.config['useIcons'])
|
---|
| 530 | {
|
---|
| 531 | currObj.actionSpan.innerHTML = "<img src=\"images/spellcheck.png\" width=\"16\" height=\"16\" title=\"Verificar Ortografia\" alt=\"Verificar Ortografia\" border=\"0\" />";
|
---|
| 532 | }
|
---|
| 533 | else
|
---|
| 534 | {
|
---|
| 535 | currObj.actionSpan.innerHTML = "<a class=\"check_spelling\">Verificar Ortografia</a>";
|
---|
| 536 | }
|
---|
| 537 |
|
---|
| 538 | if(currObj.config['useIcons'])
|
---|
| 539 | {
|
---|
| 540 | currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Verificando Ortografia...\" alt=\"Verificando Ortografia...\" border=\"0\" />";
|
---|
| 541 | }
|
---|
| 542 | else
|
---|
| 543 | {
|
---|
| 544 | currObj.statusSpan.innerHTML = "Verificando Ortografia...";
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | // Obtain the HTML content from iframe (edit area)
|
---|
| 548 | var ifr= currObj.objToCheck;
|
---|
| 549 | if(ifr.contentWindow)
|
---|
| 550 | ifr=ifr.contentWindow.document;
|
---|
| 551 | else
|
---|
| 552 | ifr=ifr.contentDocument;
|
---|
| 553 | var texto = ifr.body.innerHTML;
|
---|
| 554 |
|
---|
| 555 |
|
---|
| 556 | query = texto;
|
---|
| 557 | //query = currObj.objToCheck.value;
|
---|
| 558 |
|
---|
| 559 | //query = query.replace(/\r?\n/gi, "<br />"); // Commented from the original by Nathalie
|
---|
| 560 | query = query.replace(/\r?\n/gi, " "); // replace \n with " " - By Nathalie
|
---|
| 561 |
|
---|
| 562 |
|
---|
| 563 | cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName']);
|
---|
| 564 | */
|
---|
| 565 | //adicionado Paula
|
---|
[2554] | 566 | languageId = document.getElementById("selectLanguage");
|
---|
[2508] | 567 | languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
|
---|
[2477] | 568 |
|
---|
| 569 | with(currObj);
|
---|
| 570 | var query;
|
---|
| 571 |
|
---|
| 572 | currObj.controlPanelDiv.style.display = "block";
|
---|
| 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 |
|
---|
[2546] | 598 |
|
---|
[2477] | 599 | // Obtain the HTML content from iframe (edit area)
|
---|
| 600 | var ifr= currObj.objToCheck;
|
---|
| 601 | if(ifr.contentWindow)
|
---|
| 602 | ifr=ifr.contentWindow.document;
|
---|
| 603 | else
|
---|
| 604 | ifr=ifr.contentDocument;
|
---|
| 605 | var texto = ifr.body.innerHTML;
|
---|
| 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 |
|
---|
[2557] | 613 | var browser = trim(checkBrowser());
|
---|
| 614 |
|
---|
| 615 | cp.call(currObj.config['spellUrl'], 'spellCheck', spellCheck_cb, query, currObj.config['varName'], languageId, browser);
|
---|
[2550] | 616 |
|
---|
[2375] | 617 | }; // end spellcheck
|
---|
| 618 |
|
---|
| 619 |
|
---|
| 620 |
|
---|
| 621 | /*************************************************************
|
---|
| 622 | * addWord
|
---|
| 623 | *
|
---|
| 624 | * The addWord function adds a word to the custom dictionary
|
---|
| 625 | * file.
|
---|
| 626 | *
|
---|
| 627 | * @param id The id of the span that contains the word to be added
|
---|
| 628 | *************************************************************/
|
---|
| 629 | function addWord(id)
|
---|
| 630 | {
|
---|
[2486] | 631 | var wordToAdd = document.getElementById(id).innerHTML;
|
---|
[2375] | 632 |
|
---|
| 633 | with(currObj);
|
---|
| 634 |
|
---|
| 635 | if(spellingSuggestionsDiv)
|
---|
| 636 | {
|
---|
| 637 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 638 | spellingSuggestionsDiv = null;
|
---|
| 639 | }
|
---|
[2477] | 640 |
|
---|
| 641 | currObj.controlPanelDiv.style.display = "block";
|
---|
| 642 |
|
---|
[2375] | 643 | if(currObj.config['useIcons'])
|
---|
| 644 | {
|
---|
| 645 | currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Adding Word...\" alt=\"Adding Word...\" border=\"0\" />";
|
---|
| 646 | }
|
---|
| 647 | else
|
---|
| 648 | {
|
---|
| 649 | currObj.statusSpan.innerHTML = "Adding Word...";
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | cp.call(currObj.config['spellUrl'], 'addWord', addWord_cb, wordToAdd);
|
---|
| 653 |
|
---|
| 654 | }; // end addWord
|
---|
| 655 |
|
---|
| 656 | /*************************************************************
|
---|
| 657 | * addWord_cb
|
---|
| 658 | *
|
---|
| 659 | * The addWord_cb function is a callback function that
|
---|
| 660 | * PHP's addWord function returns to. It recieves the
|
---|
| 661 | * return status of the add to word to personal dictionary call.
|
---|
| 662 | * It hides the status item.
|
---|
| 663 | *
|
---|
| 664 | * @param returnedData The return code from PHP.
|
---|
| 665 | *************************************************************/
|
---|
| 666 | function addWord_cb(returnedData)
|
---|
| 667 | {
|
---|
[2510] | 668 | with(currObj);
|
---|
[2375] | 669 | currObj.statusSpan.innerHTML = "";
|
---|
| 670 | resumeEditing();
|
---|
| 671 | spellCheck();
|
---|
| 672 | }; // end addWord_cb
|
---|
| 673 |
|
---|
| 674 |
|
---|
| 675 |
|
---|
| 676 | /*************************************************************
|
---|
| 677 | * checkClickLocation(e)
|
---|
| 678 | *
|
---|
| 679 | * This function is called by the event listener when the user
|
---|
| 680 | * clicks on anything. It is used to close the suggestion div
|
---|
| 681 | * if the user clicks anywhere that's not inside the suggestion
|
---|
| 682 | * div. It just checks to see if the name of what the user clicks
|
---|
| 683 | * on is not "suggestions" then hides the div if it's not.
|
---|
| 684 | *
|
---|
| 685 | * @param e The event, in this case the user clicking somewhere on
|
---|
| 686 | * the page.
|
---|
| 687 | *************************************************************/
|
---|
| 688 | function checkClickLocation(e)
|
---|
| 689 | {
|
---|
[2554] | 690 |
|
---|
[2546] | 691 | var browser = checkBrowser();
|
---|
[2375] | 692 | if(spellingSuggestionsDiv)
|
---|
| 693 | {
|
---|
| 694 | // Bah. There's got to be a better way to deal with this, but the click
|
---|
| 695 | // on a word to get suggestions starts up a race condition between
|
---|
| 696 | // showing and hiding the suggestion box, so we'll ignore the first
|
---|
[2546] | 697 | // click. Problem with IE browser
|
---|
| 698 | if(spellingSuggestionsDiv.ignoreNextClick && browser == "ie"){
|
---|
[2375] | 699 | spellingSuggestionsDiv.ignoreNextClick = false;
|
---|
| 700 | }
|
---|
| 701 | else
|
---|
| 702 | {
|
---|
| 703 | var theTarget = getTarget(e);
|
---|
| 704 |
|
---|
| 705 | if(theTarget != spellingSuggestionsDiv)
|
---|
| 706 | {
|
---|
| 707 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 708 | spellingSuggestionsDiv = null;
|
---|
[2546] | 709 |
|
---|
| 710 | if (browser == "ie"){
|
---|
| 711 | var iframe= currObj.objToCheck;
|
---|
| 712 | if(iframe.contentWindow)
|
---|
| 713 | iframe=iframe.contentWindow.document;
|
---|
| 714 | else
|
---|
| 715 | iframe=iframe.contentDocument;
|
---|
| 716 | iframe.body.contentEditable="false" ;
|
---|
| 717 | }
|
---|
| 718 | }
|
---|
| 719 | }
|
---|
[2375] | 720 | }
|
---|
| 721 |
|
---|
| 722 | return true; // Allow other handlers to continue.
|
---|
| 723 | }; //end checkClickLocation
|
---|
| 724 |
|
---|
| 725 |
|
---|
| 726 | /*************************************************************
|
---|
| 727 | * getTarget
|
---|
| 728 | *
|
---|
| 729 | * The get target function gets the correct target of the event.
|
---|
| 730 | * This function is required because IE handles the events in
|
---|
| 731 | * a different (wrong) manner than the rest of the browsers.
|
---|
| 732 | *
|
---|
| 733 | * @param e The target, in this case the user clicking somewhere on
|
---|
| 734 | * the page.
|
---|
| 735 | *
|
---|
| 736 | *************************************************************/
|
---|
| 737 | function getTarget(e)
|
---|
| 738 | {
|
---|
[2486] | 739 |
|
---|
[2375] | 740 | var value;
|
---|
| 741 | if(checkBrowser() == "ie")
|
---|
| 742 | {
|
---|
[2546] | 743 | if(!e){var e = ifr.contentWindow.event;}
|
---|
| 744 | if(!e.target){value = e.srcElement;}
|
---|
| 745 |
|
---|
[2375] | 746 | }
|
---|
| 747 | else
|
---|
| 748 | {
|
---|
[2546] | 749 | value = e.target;
|
---|
[2375] | 750 | }
|
---|
| 751 | return value;
|
---|
| 752 | }; //end getTarget
|
---|
| 753 |
|
---|
| 754 |
|
---|
| 755 | /*************************************************************
|
---|
| 756 | * checkBrowser()
|
---|
| 757 | *
|
---|
| 758 | * The checkBrowser function simply checks to see what browser
|
---|
| 759 | * the user is using and returns a string containing the browser
|
---|
| 760 | * type.
|
---|
| 761 | *
|
---|
| 762 | * @return string The browser type
|
---|
| 763 | *************************************************************/
|
---|
| 764 | function checkBrowser()
|
---|
| 765 | {
|
---|
[2486] | 766 | var theAgent = navigator.userAgent.toLowerCase();
|
---|
[2375] | 767 | if(theAgent.indexOf("msie") != -1)
|
---|
| 768 | {
|
---|
| 769 | if(theAgent.indexOf("opera") != -1)
|
---|
| 770 | {
|
---|
| 771 | return "opera";
|
---|
| 772 | }
|
---|
| 773 | else
|
---|
| 774 | {
|
---|
| 775 | return "ie";
|
---|
| 776 | }
|
---|
| 777 | }
|
---|
| 778 | else if(theAgent.indexOf("netscape") != -1)
|
---|
| 779 | {
|
---|
| 780 | return "netscape";
|
---|
| 781 | }
|
---|
| 782 | else if(theAgent.indexOf("firefox") != -1)
|
---|
| 783 | {
|
---|
| 784 | return "firefox";
|
---|
| 785 | }
|
---|
| 786 | else if(theAgent.indexOf("mozilla/5.0") != -1)
|
---|
| 787 | {
|
---|
| 788 | return "mozilla";
|
---|
| 789 | }
|
---|
| 790 | else if(theAgent.indexOf("\/") != -1)
|
---|
| 791 | {
|
---|
| 792 | if(theAgent.substr(0,theAgent.indexOf('\/')) != 'mozilla')
|
---|
| 793 | {
|
---|
| 794 | return navigator.userAgent.substr(0,theAgent.indexOf('\/'));
|
---|
| 795 | }
|
---|
| 796 | else
|
---|
| 797 | {
|
---|
| 798 | return "netscape";
|
---|
| 799 | }
|
---|
| 800 | }
|
---|
| 801 | else if(theAgent.indexOf(' ') != -1)
|
---|
| 802 | {
|
---|
| 803 | return navigator.userAgent.substr(0,theAgent.indexOf(' '));
|
---|
| 804 | }
|
---|
| 805 | else
|
---|
| 806 | {
|
---|
| 807 | return navigator.userAgent;
|
---|
| 808 | }
|
---|
| 809 | }; // end checkBrowser
|
---|
| 810 |
|
---|
| 811 |
|
---|
| 812 | /*************************************************************
|
---|
| 813 | * showSuggestions_cb
|
---|
| 814 | *
|
---|
| 815 | * The showSuggestions_cb function is a callback function that
|
---|
| 816 | * php's showSuggestions function returns to. It sets the
|
---|
| 817 | * suggestions table to contain the new data and then displays
|
---|
[2546] | 818 | * the suggestions div. It also adds the event listener - click -
|
---|
| 819 | * for all the suggestions tags and sets te property to be not editable.
|
---|
[2375] | 820 | *
|
---|
| 821 | * @param new_data The suggestions table returned from php.
|
---|
| 822 | *************************************************************/
|
---|
| 823 | function showSuggestions_cb(new_data)
|
---|
| 824 | {
|
---|
[2430] | 825 |
|
---|
| 826 | with(currObj);
|
---|
[2375] | 827 | spellingSuggestionsDiv.innerHTML = new_data;
|
---|
| 828 | spellingSuggestionsDiv.style.display = 'block';
|
---|
| 829 | currObj.statusSpan.innerHTML = "";
|
---|
[2486] | 830 |
|
---|
[2546] | 831 | var ifr= currObj.objToCheck;
|
---|
| 832 | if(ifr.contentWindow)
|
---|
| 833 | ifr=ifr.contentWindow.document;
|
---|
| 834 | else
|
---|
| 835 | ifr=ifr.contentDocument;
|
---|
[2486] | 836 |
|
---|
[2536] | 837 | var nodeArray = ifr.getElementsByTagName("div");
|
---|
[2486] | 838 | var totArray = nodeArray.length;
|
---|
| 839 | for (var i = 0 ; i < totArray ; i++) {
|
---|
| 840 | var node = nodeArray[i];
|
---|
| 841 | if (node.className == "suggestion" || node.className == "ignore" ) {
|
---|
[2536] | 842 | if (document.addEventListener){
|
---|
| 843 | ifr.getElementsByTagName("div")[i].addEventListener("click", replaceMenu , true);
|
---|
[2540] | 844 | ifr.getElementsByTagName("div")[i].contentEditable="false" ;
|
---|
[2536] | 845 | }
|
---|
[2546] | 846 | else {
|
---|
[2536] | 847 | ifr.getElementsByTagName("div")[i].attachEvent("onclick", replaceMenu);
|
---|
[2540] | 848 | ifr.getElementsByTagName("div")[i].contentEditable="false" ;
|
---|
[2546] | 849 | }
|
---|
| 850 |
|
---|
[2486] | 851 |
|
---|
| 852 | }
|
---|
| 853 | }
|
---|
| 854 |
|
---|
| 855 |
|
---|
[2375] | 856 | }; //end showSuggestions_cb
|
---|
| 857 |
|
---|
| 858 |
|
---|
| 859 | /*************************************************************
|
---|
| 860 | * showSuggestions
|
---|
| 861 | *
|
---|
| 862 | * The showSuggestions function calls the showSuggestions php
|
---|
| 863 | * function to get suggestions for the misspelled word that the
|
---|
| 864 | * user has clicked on. It sets the status to "Searching...",
|
---|
| 865 | * hides the suggestions div, finds the x and y position of the
|
---|
| 866 | * span containing the misspelled word that user clicked on so
|
---|
| 867 | * the div can be displayed in the correct location, and then
|
---|
| 868 | * calls the showSuggestions php function with the misspelled word
|
---|
| 869 | * and the id of the span containing it.
|
---|
[2546] | 870 | * This function is only executed when the word is in red (the word id misspelled).
|
---|
[2375] | 871 | *
|
---|
| 872 | * @param word The misspelled word that the user clicked on
|
---|
| 873 | * @param id The id of the span that contains the misspelled word
|
---|
| 874 | *************************************************************/
|
---|
| 875 | function showSuggestions(word, id)
|
---|
| 876 | {
|
---|
[2546] | 877 |
|
---|
[2486] | 878 | var ifr= currObj.objToCheck;
|
---|
| 879 | if(ifr.contentWindow)
|
---|
| 880 | ifr=ifr.contentWindow.document;
|
---|
| 881 | else
|
---|
| 882 | ifr=ifr.contentDocument;
|
---|
| 883 |
|
---|
[2546] | 884 | if (ifr.getElementById(id).className == "highlight"){ //show the suggestion box only if the words are in red
|
---|
[2375] | 885 |
|
---|
[2546] | 886 |
|
---|
[2543] | 887 | languageId = document.getElementById("selectLanguage");
|
---|
| 888 | languageId = languageId[document.getElementById("selectLanguage").selectedIndex].value;
|
---|
[2486] | 889 |
|
---|
| 890 |
|
---|
[2543] | 891 | with(currObj);
|
---|
| 892 | if(currObj.config['useIcons'])
|
---|
| 893 | {
|
---|
| 894 | currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Procurando...\" alt=\"Procurando...\" border=\"0\" />";
|
---|
| 895 | }
|
---|
| 896 | else
|
---|
| 897 | {
|
---|
| 898 | currObj.statusSpan.innerHTML = "Procurando...";
|
---|
| 899 | }
|
---|
[2486] | 900 |
|
---|
[2543] | 901 | var x = findPosXById(id);
|
---|
| 902 | var y = findPosYById(id);
|
---|
[2486] | 903 |
|
---|
[2543] | 904 | var scrollPos = 0;
|
---|
| 905 | if(checkBrowser() != "ie")
|
---|
| 906 | {
|
---|
| 907 |
|
---|
| 908 |
|
---|
| 909 | //scrollPos = ifr.getElementById(currObj.spellingResultsDiv.id).scrollTop;
|
---|
| 910 | scrollPos = ifr.getElementsByTagName("body")[0].scrollTop;
|
---|
| 911 |
|
---|
| 912 | }
|
---|
| 913 |
|
---|
| 914 | if(spellingSuggestionsDiv)
|
---|
| 915 | {
|
---|
| 916 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 917 | }
|
---|
| 918 | spellingSuggestionsDiv = ifr.createElement('div');
|
---|
| 919 | spellingSuggestionsDiv.style.display = "none";
|
---|
| 920 | spellingSuggestionsDiv.className = 'suggestion_box';
|
---|
| 921 | spellingSuggestionsDiv.style.position = 'absolute';
|
---|
| 922 | spellingSuggestionsDiv.style.left = x + 'px';
|
---|
| 923 | spellingSuggestionsDiv.style.top = (y+16-scrollPos) + 'px';
|
---|
[2546] | 924 | spellingSuggestionsDiv.id = 'suggestion_box';
|
---|
[2543] | 925 | spellingSuggestionsDiv.contentEditable="false" ;
|
---|
| 926 |
|
---|
| 927 |
|
---|
| 928 | // Bah. There's got to be a better way to deal with this, but the click
|
---|
| 929 | // on a word to get suggestions starts up a race condition between
|
---|
| 930 | // showing and hiding the suggestion box, so we'll ignore the first
|
---|
| 931 | // click.
|
---|
[2546] | 932 | spellingSuggestionsDiv.ignoreNextClick = true;
|
---|
[2543] | 933 |
|
---|
| 934 |
|
---|
| 935 | //document.body.appendChild(spellingSuggestionsDiv);
|
---|
[2546] | 936 | ifr.body.appendChild(spellingSuggestionsDiv);
|
---|
[2543] | 937 |
|
---|
| 938 |
|
---|
| 939 | cp.call(currObj.config['spellUrl'], 'showSuggestions', showSuggestions_cb, word, id, languageId);
|
---|
[2546] | 940 | } // end if - show the suggestion box only if the words are in red
|
---|
[2543] | 941 |
|
---|
[2375] | 942 | }; // end showSuggestions
|
---|
| 943 |
|
---|
| 944 |
|
---|
[2486] | 945 |
|
---|
[2375] | 946 | /*************************************************************
|
---|
| 947 | * replaceWord
|
---|
| 948 | *
|
---|
[2486] | 949 | * The replaceWord function replaces the innerHTML of all the span tags
|
---|
| 950 | * that contains the old word with the new word that the user selects
|
---|
| 951 | * from the suggestion div. It hides the suggestions div and changes the color of
|
---|
[2375] | 952 | * the previously misspelled word to green to let the user know
|
---|
| 953 | * it has been changed. It then calls the switchText php function
|
---|
| 954 | * with the innerHTML of the div to update the text of the text box.
|
---|
| 955 | *
|
---|
[2486] | 956 | * @param id The id of the element to be checked
|
---|
| 957 | * @param newword The word the user selected from the suggestions div
|
---|
[2375] | 958 | * to replace the misspelled word.
|
---|
| 959 | *************************************************************/
|
---|
| 960 | function replaceWord(id, newWord)
|
---|
| 961 | {
|
---|
[2486] | 962 |
|
---|
[2536] | 963 |
|
---|
[2486] | 964 | var ifr= currObj.objToCheck;
|
---|
| 965 | if(ifr.contentWindow)
|
---|
| 966 | ifr=ifr.contentWindow.document;
|
---|
| 967 | else
|
---|
| 968 | ifr=ifr.contentDocument;
|
---|
| 969 |
|
---|
| 970 | var valorNo = trim(ifr.getElementById(id).innerHTML);
|
---|
| 971 |
|
---|
[2543] | 972 |
|
---|
[2486] | 973 | // Obtain all span tags which have highlight className and contais the old word
|
---|
[2554] | 974 | var nodeArray = ifr.getElementsByTagName("span");
|
---|
[2486] | 975 | var totArray = nodeArray.length;
|
---|
| 976 | var nodeRemove = new Array(totArray);
|
---|
| 977 | var j = -1;
|
---|
| 978 | for (var i = 0 ; i < totArray ; i++) {
|
---|
| 979 | var node = nodeArray[i];
|
---|
| 980 | if (node.className == "highlight" && trim(node.innerHTML) == valorNo ) {
|
---|
| 981 | j++;
|
---|
| 982 | nodeRemove[j] = node.id;
|
---|
| 983 | }
|
---|
| 984 | }
|
---|
| 985 |
|
---|
| 986 | //Replace the class of the span tags with highlight and the innerHTML with the new_word
|
---|
| 987 | for (var i = 0 ; i <= j ; i++) {
|
---|
| 988 | ifr.getElementById(nodeRemove[i]).innerHTML = newWord;
|
---|
| 989 | ifr.getElementById(nodeRemove[i]).className = "corrected_word";
|
---|
[2543] | 990 | }
|
---|
[2486] | 991 |
|
---|
| 992 |
|
---|
[2510] | 993 | if(spellingSuggestionsDiv)
|
---|
| 994 | {
|
---|
| 995 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 996 | spellingSuggestionsDiv = null;
|
---|
[2543] | 997 | }
|
---|
[2510] | 998 |
|
---|
[2543] | 999 | return false;
|
---|
[2510] | 1000 |
|
---|
| 1001 |
|
---|
[2543] | 1002 | }; // end replaceWord
|
---|
[2510] | 1003 |
|
---|
[2486] | 1004 |
|
---|
[2543] | 1005 | /*************************************************************
|
---|
| 1006 | * ignore
|
---|
| 1007 | *
|
---|
| 1008 | * The ignore function removes the span tags and mantain
|
---|
| 1009 | * the original word. So, the word comes back to the original, without
|
---|
| 1010 | * css.
|
---|
| 1011 | *
|
---|
| 1012 | * @param id The id of the element to be checked
|
---|
| 1013 | * @param word The original word.
|
---|
| 1014 | *************************************************************/
|
---|
[2486] | 1015 |
|
---|
[2543] | 1016 | function ignore(id, word){
|
---|
[2486] | 1017 |
|
---|
[2543] | 1018 |
|
---|
| 1019 | var ifr= currObj.objToCheck;
|
---|
| 1020 | if(ifr.contentWindow)
|
---|
| 1021 | ifr=ifr.contentWindow.document;
|
---|
| 1022 | else
|
---|
| 1023 | ifr=ifr.contentDocument;
|
---|
[2486] | 1024 |
|
---|
[2543] | 1025 | var valorNo = trim(word);
|
---|
| 1026 | if(spellingSuggestionsDiv)
|
---|
| 1027 | {
|
---|
[2486] | 1028 |
|
---|
[2543] | 1029 | spellingSuggestionsDiv.style.display = 'none';
|
---|
| 1030 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 1031 | spellingSuggestionsDiv = null;
|
---|
| 1032 | }
|
---|
[2486] | 1033 |
|
---|
[2543] | 1034 | var fake = ifr.createTextNode(valorNo);
|
---|
[2486] | 1035 |
|
---|
[2543] | 1036 | var parent = ifr.getElementById(id).parentNode;
|
---|
[2486] | 1037 |
|
---|
| 1038 |
|
---|
[2543] | 1039 | parent.replaceChild(fake, ifr.getElementById(id));
|
---|
[2486] | 1040 |
|
---|
[2543] | 1041 | return false;
|
---|
[2375] | 1042 |
|
---|
| 1043 |
|
---|
[2543] | 1044 |
|
---|
| 1045 | };
|
---|
| 1046 |
|
---|
| 1047 |
|
---|
| 1048 |
|
---|
| 1049 |
|
---|
[2375] | 1050 | /*************************************************************
|
---|
| 1051 | * switchText
|
---|
| 1052 | *
|
---|
| 1053 | * The switchText function is a funtion is called when the user
|
---|
| 1054 | * clicks on resume editing (or submits the form). It calls the
|
---|
| 1055 | * php function to switchText and uncomments the html and replaces
|
---|
| 1056 | * breaks and everything. Here all the breaks that the user has
|
---|
| 1057 | * typed are replaced with %u2026. Firefox does this goofy thing
|
---|
| 1058 | * where it cleans up the display of your html, which adds in \n's
|
---|
| 1059 | * where you don't want them. So I replace the user-entered returns
|
---|
| 1060 | * with something unique so that I can rip out all the breaks that
|
---|
| 1061 | * the browser might add and we don't want.
|
---|
| 1062 | *************************************************************/
|
---|
| 1063 | function switchText()
|
---|
| 1064 | {
|
---|
[2536] | 1065 |
|
---|
[2430] | 1066 | with(currObj);
|
---|
[2486] | 1067 | var ifr= currObj.objToCheck;
|
---|
| 1068 | if(ifr.contentWindow)
|
---|
| 1069 | ifr=ifr.contentWindow.document;
|
---|
| 1070 | else
|
---|
| 1071 | ifr=ifr.contentDocument;
|
---|
[2546] | 1072 |
|
---|
[2404] | 1073 | // Obtain all span tags which have highlight className or corrected_word className
|
---|
[2554] | 1074 | var nodeArray = ifr.getElementsByTagName("span");
|
---|
[2404] | 1075 | var totArray = nodeArray.length;
|
---|
| 1076 | var nodeRemove = new Array(totArray);
|
---|
| 1077 | var j = -1;
|
---|
[2477] | 1078 |
|
---|
[2404] | 1079 | for (var i = 0 ; i < totArray ; i++) {
|
---|
| 1080 | var node = nodeArray[i];
|
---|
| 1081 | if (node.className == "highlight" || node.className == "corrected_word") {
|
---|
| 1082 | j++;
|
---|
| 1083 | nodeRemove[j] = node.id;
|
---|
| 1084 |
|
---|
| 1085 |
|
---|
| 1086 | }
|
---|
| 1087 | }
|
---|
| 1088 |
|
---|
| 1089 | //Remove span tags which have highlight className or corrected_word className
|
---|
| 1090 | for (var i = 0 ; i <= j ; i++) {
|
---|
[2486] | 1091 | var valorNo = ifr.getElementById(nodeRemove[i]).innerHTML;
|
---|
[2516] | 1092 | var fake = ifr.createTextNode(valorNo);
|
---|
[2486] | 1093 | var parent = ifr.getElementById(nodeRemove[i]).parentNode;
|
---|
| 1094 | parent.replaceChild(fake, ifr.getElementById(nodeRemove[i]));
|
---|
[2404] | 1095 | }
|
---|
| 1096 |
|
---|
[2546] | 1097 | var text = ifr.body.innerHTML;
|
---|
[2477] | 1098 |
|
---|
[2404] | 1099 | text = text.replace(/ /gi, " %u2026 "); // Replace with the code %u2026
|
---|
| 1100 | text = '*' + text;
|
---|
[2477] | 1101 |
|
---|
[2404] | 1102 | cp.call(currObj.config['spellUrl'], 'switchText', switchText_cb, text);
|
---|
| 1103 |
|
---|
[2375] | 1104 | }; // end switchText
|
---|
| 1105 |
|
---|
| 1106 |
|
---|
| 1107 | /*************************************************************
|
---|
| 1108 | * switchText_cb
|
---|
| 1109 | *
|
---|
| 1110 | * The switchText_cb function is a call back funtion that the
|
---|
| 1111 | * switchText php function returns to. I replace all the %u2026's
|
---|
| 1112 | * with returns. It then replaces the text in the text box with
|
---|
| 1113 | * the corrected text fromt he div.
|
---|
| 1114 | *
|
---|
| 1115 | * @param new_string The corrected text from the div.
|
---|
| 1116 | *
|
---|
| 1117 | *************************************************************/
|
---|
| 1118 | function switchText_cb(new_string)
|
---|
| 1119 | {
|
---|
[2430] | 1120 |
|
---|
[2536] | 1121 |
|
---|
[2486] | 1122 | with(currObj);
|
---|
| 1123 |
|
---|
[2546] | 1124 | new_string = new_string.replace(/ %u2026/gi, " "); // Replace the code %u2026 with
|
---|
[2404] | 1125 |
|
---|
[2546] | 1126 | new_string = new_string.replace(/~~~/gi, "\n");
|
---|
[2404] | 1127 |
|
---|
[2546] | 1128 | // Remove the prefixed asterisk that was added in switchText().
|
---|
| 1129 | new_string = new_string.substr(1);
|
---|
[2486] | 1130 |
|
---|
| 1131 |
|
---|
[2546] | 1132 | currObj.objToCheck.style.display = "none";
|
---|
| 1133 | var ifr= currObj.objToCheck;
|
---|
| 1134 | if(ifr.contentWindow)
|
---|
| 1135 | ifr=ifr.contentWindow.document;
|
---|
| 1136 | else
|
---|
| 1137 | ifr=ifr.contentDocument;
|
---|
| 1138 | var texto = ifr.body.innerHTML;
|
---|
[2486] | 1139 |
|
---|
[2546] | 1140 | ifr.body.innerHTM = "";
|
---|
| 1141 | ifr.body.innerHTML = new_string;
|
---|
| 1142 | currObj.spellingResultsDiv = null;
|
---|
| 1143 |
|
---|
| 1144 | currObj.objToCheck.disabled = false;
|
---|
| 1145 |
|
---|
| 1146 |
|
---|
| 1147 | currObj.objToCheck.style.display = "block";
|
---|
| 1148 | currObj.resetAction();
|
---|
[2375] | 1149 | }; // end switchText_cb
|
---|
| 1150 |
|
---|
| 1151 |
|
---|
| 1152 | /*************************************************************
|
---|
| 1153 | * resumeEditing
|
---|
| 1154 | *
|
---|
| 1155 | * The resumeEditing function is called when the user is in the
|
---|
| 1156 | * correction mode and wants to return to the editing mode. It
|
---|
| 1157 | * hides the results div and the suggestions div, then enables
|
---|
| 1158 | * the text box and unhides the text box. It also calls
|
---|
| 1159 | * resetAction() to reset the status message.
|
---|
| 1160 | *************************************************************/
|
---|
| 1161 | function resumeEditing()
|
---|
| 1162 | {
|
---|
[2536] | 1163 |
|
---|
[2430] | 1164 | with(currObj);
|
---|
[2477] | 1165 |
|
---|
| 1166 | currObj.controlPanelDiv.style.display = "block";
|
---|
[2375] | 1167 | if(currObj.config['useIcons'])
|
---|
| 1168 | {
|
---|
[2407] | 1169 | 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] | 1170 | }
|
---|
| 1171 | else
|
---|
| 1172 | {
|
---|
[2407] | 1173 | currObj.actionSpan.innerHTML = "<a class=\"resume_editing\">Continuar Editando</a>";
|
---|
[2375] | 1174 | }
|
---|
| 1175 | if(currObj.config['useIcons'])
|
---|
| 1176 | {
|
---|
[2407] | 1177 | currObj.statusSpan.innerHTML = "<img src=\"images/working.gif\" width=\"16\" height=\"16\" title=\"Carregando...\" alt=\"Carregando...\" border=\"0\" />";
|
---|
[2375] | 1178 | }
|
---|
| 1179 | else
|
---|
| 1180 | {
|
---|
[2407] | 1181 | currObj.statusSpan.innerHTML = "Carregando...";
|
---|
[2375] | 1182 | }
|
---|
[2404] | 1183 |
|
---|
[2375] | 1184 |
|
---|
| 1185 | if(spellingSuggestionsDiv)
|
---|
| 1186 | {
|
---|
[2404] | 1187 |
|
---|
[2486] | 1188 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
[2375] | 1189 | spellingSuggestionsDiv = null;
|
---|
| 1190 | }
|
---|
[2540] | 1191 |
|
---|
[2543] | 1192 | //set the contentEditable to true for IE browsers to continue editing
|
---|
[2540] | 1193 | var iframe= currObj.objToCheck;
|
---|
| 1194 | if(iframe.contentWindow)
|
---|
| 1195 | iframe=iframe.contentWindow.document;
|
---|
| 1196 | else
|
---|
| 1197 | iframe=iframe.contentDocument;
|
---|
| 1198 |
|
---|
| 1199 | var browser = checkBrowser();
|
---|
| 1200 | if (browser == "ie"){
|
---|
| 1201 | iframe.body.contentEditable="true" ;
|
---|
[2543] | 1202 |
|
---|
[2540] | 1203 | }
|
---|
[2375] | 1204 |
|
---|
| 1205 | currObj.switchText();
|
---|
| 1206 | }; // end resumeEditing
|
---|
| 1207 |
|
---|
| 1208 |
|
---|
| 1209 | /*************************************************************
|
---|
| 1210 | * resetAction
|
---|
| 1211 | *
|
---|
| 1212 | * The resetAction function just resets the status message to
|
---|
| 1213 | * the default action of "Check Spelling".
|
---|
| 1214 | *************************************************************/
|
---|
| 1215 | function resetAction()
|
---|
| 1216 | {
|
---|
[2486] | 1217 |
|
---|
[2546] | 1218 |
|
---|
[2375] | 1219 | with(currObj);
|
---|
[2477] | 1220 | /*if(currObj.config['useIcons'])
|
---|
[2375] | 1221 | {
|
---|
[2407] | 1222 | 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] | 1223 | }
|
---|
| 1224 | else
|
---|
| 1225 | {
|
---|
[2407] | 1226 | currObj.actionSpan.innerHTML = "<a class=\"check_spelling\" onclick=\"setCurrentObject(" + currObj.config['varName'] + "); " + currObj.config['varName'] + ".spellCheck();\">Verificar Ortografia</a>";
|
---|
[2477] | 1227 | }*/
|
---|
[2375] | 1228 |
|
---|
[2477] | 1229 | currObj.actionSpan.innerHTML = "";
|
---|
[2375] | 1230 | currObj.statusSpan.innerHTML = "";
|
---|
[2477] | 1231 | currObj.controlPanelDiv.style.display = "none";
|
---|
[2550] | 1232 |
|
---|
[2375] | 1233 | }; // end resetAction
|
---|
| 1234 |
|
---|
| 1235 |
|
---|
| 1236 | /*************************************************************
|
---|
| 1237 | * resetSpellChecker
|
---|
| 1238 | *
|
---|
| 1239 | * The resetSpellChecker function resets the entire spell checker
|
---|
| 1240 | * to the defaults.
|
---|
| 1241 | *************************************************************/
|
---|
| 1242 | function resetSpellChecker()
|
---|
| 1243 | {
|
---|
[2486] | 1244 |
|
---|
[2546] | 1245 |
|
---|
[2486] | 1246 | var ifr= currObj.objToCheck;
|
---|
[2546] | 1247 | if(ifr.contentWindow)
|
---|
[2486] | 1248 | ifr=ifr.contentWindow.document;
|
---|
[2546] | 1249 | else
|
---|
[2486] | 1250 | ifr=ifr.contentDocument;
|
---|
| 1251 |
|
---|
| 1252 |
|
---|
| 1253 | with(currObj);
|
---|
[2375] | 1254 | currObj.resetAction();
|
---|
| 1255 |
|
---|
| 1256 | currObj.objToCheck.value = "";
|
---|
| 1257 | currObj.objToCheck.style.display = "block";
|
---|
| 1258 | currObj.objToCheck.disabled = false;
|
---|
| 1259 |
|
---|
| 1260 | if(currObj.spellingResultsDiv)
|
---|
| 1261 | {
|
---|
[2546] | 1262 | ifr.removeChild(currObj.spellingResultsDiv);
|
---|
[2375] | 1263 | currObj.spellingResultsDiv = null;
|
---|
| 1264 | }
|
---|
| 1265 | if(spellingSuggestionsDiv)
|
---|
| 1266 | {
|
---|
| 1267 | spellingSuggestionsDiv.parentNode.removeChild(spellingSuggestionsDiv);
|
---|
| 1268 | spellingSuggestionsDiv = null;
|
---|
| 1269 | }
|
---|
| 1270 | currObj.statusSpan.style.display = "none";
|
---|
| 1271 |
|
---|
| 1272 | }; // end resetSpellChecker
|
---|
| 1273 |
|
---|
| 1274 |
|
---|
| 1275 | /*************************************************************
|
---|
| 1276 | * findPosX
|
---|
| 1277 | *
|
---|
| 1278 | * The findPosX function just finds the X offset of the top left
|
---|
| 1279 | * corner of the object id it's given.
|
---|
| 1280 | *
|
---|
| 1281 | * @param object The id of the object that you want to find the
|
---|
| 1282 | * upper left X coordinate of.
|
---|
| 1283 | * @return int The X coordinate of the object
|
---|
| 1284 | *************************************************************/
|
---|
[2486] | 1285 | function findPosXById(object)
|
---|
[2375] | 1286 | {
|
---|
[2546] | 1287 |
|
---|
[2486] | 1288 | var ifr= currObj.objToCheck;
|
---|
[2546] | 1289 | if(ifr.contentWindow)
|
---|
[2486] | 1290 | ifr=ifr.contentWindow.document;
|
---|
[2546] | 1291 | else
|
---|
[2486] | 1292 | ifr=ifr.contentDocument;
|
---|
| 1293 | var obj = ifr.getElementById(object);
|
---|
| 1294 |
|
---|
| 1295 |
|
---|
[2430] | 1296 | var curleft = 0;
|
---|
[2546] | 1297 |
|
---|
[2375] | 1298 | if(obj.offsetParent)
|
---|
| 1299 | {
|
---|
| 1300 | while(obj.offsetParent)
|
---|
| 1301 | {
|
---|
| 1302 | curleft += obj.offsetLeft - obj.scrollLeft;
|
---|
| 1303 | obj = obj.offsetParent;
|
---|
| 1304 | }
|
---|
| 1305 | }
|
---|
| 1306 | else if(obj.x)
|
---|
| 1307 | {
|
---|
| 1308 | curleft += obj.x;
|
---|
| 1309 | }
|
---|
| 1310 | return curleft;
|
---|
| 1311 | }; // end findPosX
|
---|
| 1312 |
|
---|
| 1313 |
|
---|
| 1314 | /*************************************************************
|
---|
| 1315 | * findPosY
|
---|
| 1316 | *
|
---|
| 1317 | * The findPosY function just finds the Y offset of the top left
|
---|
| 1318 | * corner of the object id it's given.
|
---|
| 1319 | *
|
---|
| 1320 | * @param object The id of the object that you want to find the
|
---|
| 1321 | * upper left Y coordinate of.
|
---|
| 1322 | * @return int The Y coordinate of the object
|
---|
| 1323 | *************************************************************/
|
---|
| 1324 | function findPosYById(object)
|
---|
[2546] | 1325 | {
|
---|
[2486] | 1326 | var ifr= currObj.objToCheck;
|
---|
[2546] | 1327 | if(ifr.contentWindow)
|
---|
[2486] | 1328 | ifr=ifr.contentWindow.document;
|
---|
[2546] | 1329 | else
|
---|
[2486] | 1330 | ifr=ifr.contentDocument;
|
---|
[2546] | 1331 | var obj = ifr.getElementById(object);
|
---|
[2430] | 1332 |
|
---|
[2375] | 1333 | var curtop = 0;var curtop = 0;
|
---|
| 1334 | if(obj.offsetParent)
|
---|
| 1335 | {
|
---|
| 1336 | while(obj.offsetParent)
|
---|
| 1337 | {
|
---|
| 1338 | curtop += obj.offsetTop - obj.scrollTop;
|
---|
| 1339 | obj = obj.offsetParent;
|
---|
| 1340 | }
|
---|
| 1341 | }
|
---|
| 1342 | else if(obj.y)
|
---|
| 1343 | {
|
---|
| 1344 | curtop += obj.y;
|
---|
| 1345 | }
|
---|
| 1346 | return curtop;
|
---|
| 1347 | }; // end findPosY
|
---|
| 1348 |
|
---|
| 1349 |
|
---|
| 1350 | /*************************************************************
|
---|
| 1351 | * trim
|
---|
| 1352 | *
|
---|
| 1353 | * Trims white space from a string.
|
---|
| 1354 | *
|
---|
| 1355 | * @param s The string you want to trim.
|
---|
| 1356 | * @return string The trimmed string.
|
---|
| 1357 | *************************************************************/
|
---|
| 1358 | function trim(s)
|
---|
| 1359 | {
|
---|
[2430] | 1360 |
|
---|
[2375] | 1361 | while(s.substring(0,1) == ' ')
|
---|
| 1362 | {
|
---|
| 1363 | s = s.substring(1,s.length);
|
---|
| 1364 | }
|
---|
| 1365 | while(s.substring(s.length-1,s.length) == ' ')
|
---|
| 1366 | {
|
---|
| 1367 | s = s.substring(0,s.length-1);
|
---|
| 1368 | }
|
---|
| 1369 | return s;
|
---|
| 1370 | }; // end trim |
---|