Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A MooTools plugin that adds spellcheck support to inputs using the Google spell checker API.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 Source
Octocat-spinner-32 Test
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 package.yml
Octocat-spinner-32 screenshot.png
README.md

SpellChecker

This class allows you to provide spell checking for text. It uses Google to check if the text is correct and to get some suggestions. This is done by a PHP script that uses cURL to get some xml and translates it to JSON, so we can use Request.JSON for our client-side. That is where Request.SpellCheck is build on. Request.SpellCheck will give you an array in the onSuccess event that you can use. (for mark-up things)

Screenshot

How to use

var spell = new Request.SpellCheck([options]);

Class: Request.SpellCheck

This class extends Request.JSON, so you can use all Request.JSON stuff you already know.

Syntax

#JS
var spell = new Request.SpellCheck([options]);

Options

All the options of Request.JSON

  • lang: (string: default en) The language Code
  • ignoredigits: (boolean: default false) true to ignore digits, false to check them
  • ignoreallcaps: (boolean: default false) true to ignore words with all caps, false to check them

Events

All the events you know from Request.JSON

success

Fired when the request completes. This overrides the signature of the Request.JSON success event.

Signature:

#JS
onSuccess(suggestions, responseJSON, responseText, text)

Arguments:

  • suggestions: (array) An array with the data
    • text: (string) The text
    • valid: (boolean) Is this little text valid or not
    • suggestions: (array) An array with suggestions
  • responseJSON: (object) The JSON response object from the remote request.
  • responseText: (string) The JSON response as string.
  • text: (string) The original input text

Method: spellcheck

This is the method you use this method to check a text.

Syntax

#JS
spell.checkspell('Testng ths spelcheckr out.');

Method: setLang

You can use this method to set the language to another language.

Syntax

#JS
spell.setLang('nl');

Example

#JS
window.addEvent('domready', function() {

    var result = document.id('result');

    var spell = new Request.SpellCheck({
        url: '../Source/spellcheck.php',
        onSuccess: function(suggestions,data,response,text){

            result.empty();
            $each(suggestions,function(sug){

                new Element('span',{
                    'class': sug.valid ? '' : 'error',
                    text: sug.text
                }).inject(result);

                if(!sug.valid){
                    new Element('span',{
                        'class': 'suggestions',
                        text: '('+sug.suggestions.join(', ')+')'
                    }).inject(result);
                }

            });
        }
    });

    spell.checkspell('Testng ths spelcheckr out.');

});
Something went wrong with that request. Please try again.