- // the spell button
- qt.SpellButton = function() {
- qt.Button.call(this, 'spell', quicktagsL10n.lookup, '', quicktagsL10n.dictionaryLookup);
- };
- qt.SpellButton.prototype = new qt.Button();
- qt.SpellButton.prototype.callback = function(element, canvas, ed) {
- var word = '', sel, startPos, endPos;
-
- if ( document.selection ) {
- canvas.focus();
- sel = document.selection.createRange();
- if ( sel.text.length > 0 ) {
- word = sel.text;
- }
- } else if ( canvas.selectionStart || canvas.selectionStart == '0' ) {
- startPos = canvas.selectionStart;
- endPos = canvas.selectionEnd;
- if ( startPos != endPos ) {
- word = canvas.value.substring(startPos, endPos);
- }
- }
-
- if ( word === '' ) {
- word = prompt(quicktagsL10n.wordLookup, '');
- }
-
- if ( word !== null && /^\w[\w ]*$/.test(word)) {
- window.open('http://www.answers.com/' + encodeURIComponent(word));
- }
- };