Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / editor / htmlarea / plugins / SpellChecker / spell-checker.js
blob48a8fa6d6b40fc619064264c068863791d4bdd43
1 // Spell Checker Plugin for HTMLArea-3.0
2 // Implementation by Mihai Bazon.  Sponsored by www.americanbible.org
3 //
4 // htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
5 // This notice MUST stay intact for use (see license.txt).
6 //
7 // A free WYSIWYG editor replacement for <textarea> fields.
8 // For full source code and docs, visit http://www.interactivetools.com/
9 //
10 // Version 3.0 developed by Mihai Bazon for InteractiveTools.
11 //           http://students.infoiasi.ro/~mishoo
13 // $Id$
15 function SpellChecker(editor) {
16         this.editor = editor;
18         var cfg = editor.config;
19         var tt = SpellChecker.I18N;
20         var bl = SpellChecker.btnList;
21         var self = this;
23         // register the toolbar buttons provided by this plugin
24         var toolbar = [];
25         for (var i in bl) {
26                 var btn = bl[i];
27                 if (!btn) {
28                         toolbar.push("separator");
29                 } else {
30                         var id = "SC-" + btn[0];
31                         cfg.registerButton(id, tt[id], "plugins/SpellChecker/img/" + btn[0] + ".gif", false,
32                                            function(editor, id) {
33                                                    // dispatch button press event
34                                                    self.buttonPress(editor, id);
35                                            }, btn[1]);
36                         toolbar.push(id);
37                 }
38         }
40         for (var i in toolbar) {
41                 cfg.toolbar[0].push(toolbar[i]);
42         }
45 SpellChecker.btnList = [
46         null, // separator
47         ["spell-check"]
48         ];
50 SpellChecker.prototype.buttonPress = function(editor, id) {
51         switch (id) {
52             case "SC-spell-check":
53                 SpellChecker.editor = editor;
54                 SpellChecker.init = true;
55                 var uiurl = editor.config.editorURL + "plugins/SpellChecker/spell-check-ui.html";
56                 var win;
57                 if (HTMLArea.is_ie) {
58                         win = window.open(uiurl, "SC_spell_checker",
59                                           "toolbar=no,location=no,directories=no,status=no,menubar=no," +
60                                           "scrollbars=no,resizable=yes,width=600,height=400");
61                 } else {
62                         win = window.open(uiurl, "SC_spell_checker",
63                                           "toolbar=no,menubar=no,personalbar=no,width=600,height=400," +
64                                           "scrollbars=no,resizable=yes");
65                 }
66                 win.focus();
67                 break;
68         }
71 // this needs to be global, it's accessed from spell-check-ui.html
72 SpellChecker.editor = null;