diff options
Diffstat (limited to 'lib/scripts/spellcheck.js')
-rw-r--r-- | lib/scripts/spellcheck.js | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/scripts/spellcheck.js b/lib/scripts/spellcheck.js index 308b3dd1f..ceb1cd074 100644 --- a/lib/scripts/spellcheck.js +++ b/lib/scripts/spellcheck.js @@ -47,6 +47,9 @@ * * findPosX() * findPosY() + * + * Defined in events.js: + * * addEvent() * * Defined in edit.js: @@ -103,12 +106,12 @@ function ajax_spell_class(){ */ this.init = function(txtStart,txtStop,txtRun,txtNoErr,txtNoSug,txtChange){ // don't run twice - if (this.inited) return; + if (this.inited){ return; } this.inited = true; // check for AJAX availability var ajax = new sack(this.handler); - if(ajax.failed) return; + if(ajax.failed){ return; } // get Elements this.textboxObj = document.getElementById('wikitext'); @@ -138,7 +141,7 @@ function ajax_spell_class(){ ajax.runAJAX('call=utf8test&data='+encodeURIComponent('ü')); // second part of initialisation is in initReady() function - } + }; /** * Eventhandler for click objects anywhere on the document @@ -159,7 +162,7 @@ function ajax_spell_class(){ if (target.id != ajax_spell.suggestObj.id){ ajax_spell.suggestObj.style.display = "none"; } - } + }; /** * Changes the Spellchecker link according to the given mode @@ -193,7 +196,7 @@ function ajax_spell_class(){ ajax_spell.imageObj.src = DOKU_BASE+'lib/images/toolbar/spellcheck.png'; break; } - } + }; /** * Replaces a word identified by id with its correction given in word @@ -205,7 +208,7 @@ function ajax_spell_class(){ obj.innerHTML = decodeURIComponent(word); obj.style.color = "#005500"; this.suggestObj.style.display = "none"; - } + }; /** * Opens a prompt to let the user change the word her self @@ -218,7 +221,7 @@ function ajax_spell_class(){ if(word){ this.correct(id,encodeURIComponent(word)); } - } + }; /** * Displays the suggestions for a misspelled word @@ -228,7 +231,7 @@ function ajax_spell_class(){ */ this.suggest = function(){ var args = this.suggest.arguments; - if(!args[0]) return; + if(!args[0]){ return; } var id = args[0]; // set position of the popup @@ -237,10 +240,11 @@ function ajax_spell_class(){ var y = findPosY('spell_error'+id); // handle scrolling + var scrollPos; if(is_opera){ - var scrollPos = 0; //FIXME how to do this without browser sniffing? + scrollPos = 0; //FIXME how to do this without browser sniffing? }else{ - var scrollPos = this.showboxObj.scrollTop; + scrollPos = this.showboxObj.scrollTop; } this.suggestObj.style.left = x+'px'; @@ -265,7 +269,7 @@ function ajax_spell_class(){ this.suggestObj.innerHTML = text; this.suggestObj.style.display = "block"; - } + }; // --- Callbacks --- @@ -284,14 +288,14 @@ function ajax_spell_class(){ } // register click event - addEvent(document,'onclick',ajax_spell.docClick); + addEvent(document,'click',ajax_spell.docClick); // register focus event - addEvent(ajax_spell.textboxObj,'onfocus',ajax_spell.setState); + addEvent(ajax_spell.textboxObj,'focus',ajax_spell.setState); // get started ajax_spell.setState('start'); - } + }; /** * Callback. Called after finishing spellcheck. @@ -329,7 +333,7 @@ function ajax_spell_class(){ ajax_spell.editbarObj.style.visibility = 'visible'; ajax_spell.setState('noerr'); } - } + }; /** * Callback. Gets called by resume() - switches back to edit mode @@ -358,7 +362,7 @@ function ajax_spell_class(){ ajax_spell.editbarObj.style.visibility = 'visible'; ajax_spell.showboxObj.innerHTML = ''; ajax_spell.setState('start'); - } + }; // --- Callers --- @@ -376,7 +380,7 @@ function ajax_spell_class(){ ajax.onCompletion = this.start; ajax.runAJAX('call=check&utf8='+ajax_spell.utf8ok+ '&data='+encodeURIComponent(ajax_spell.textboxObj.value)); - } + }; /** * Rewrites the HTML back to text again using an AJAX request @@ -386,7 +390,7 @@ function ajax_spell_class(){ this.resume = function(){ ajax_spell.setState('run'); var text = ajax_spell.showboxObj.innerHTML; - if(text != ''){ + if(text !== ''){ var ajax = new sack(ajax_spell.handler); ajax.AjaxFailedAlert = ''; ajax.encodeURIString = false; @@ -394,7 +398,7 @@ function ajax_spell_class(){ ajax.runAJAX('call=resume&utf8='+ajax_spell.utf8ok+ '&data='+encodeURIComponent(text)); } - } + }; } |