import torrus 1.0.9
[freeside.git] / httemplate / elements / fckeditor / editor / dialog / fck_spellerpages / spellerpages / controlWindow.js
1 ////////////////////////////////////////////////////\r
2 // controlWindow object\r
3 ////////////////////////////////////////////////////\r
4 function controlWindow( controlForm ) {\r
5         // private properties\r
6         this._form = controlForm;\r
7 \r
8         // public properties\r
9         this.windowType = "controlWindow";\r
10 //      this.noSuggestionSelection = "- No suggestions -";      // by FredCK\r
11         this.noSuggestionSelection = FCKLang.DlgSpellNoSuggestions ;\r
12         // set up the properties for elements of the given control form\r
13         this.suggestionList  = this._form.sugg;\r
14         this.evaluatedText   = this._form.misword;\r
15         this.replacementText = this._form.txtsugg;\r
16         this.undoButton      = this._form.btnUndo;\r
17 \r
18         // public methods\r
19         this.addSuggestion = addSuggestion;\r
20         this.clearSuggestions = clearSuggestions;\r
21         this.selectDefaultSuggestion = selectDefaultSuggestion;\r
22         this.resetForm = resetForm;\r
23         this.setSuggestedText = setSuggestedText;\r
24         this.enableUndo = enableUndo;\r
25         this.disableUndo = disableUndo;\r
26 }\r
27 \r
28 function resetForm() {\r
29         if( this._form ) {\r
30                 this._form.reset();\r
31         }\r
32 }\r
33 \r
34 function setSuggestedText() {\r
35         var slct = this.suggestionList;\r
36         var txt = this.replacementText;\r
37         var str = "";\r
38         if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) {\r
39                 str = slct.options[slct.selectedIndex].text;\r
40         }\r
41         txt.value = str;\r
42 }\r
43 \r
44 function selectDefaultSuggestion() {\r
45         var slct = this.suggestionList;\r
46         var txt = this.replacementText;\r
47         if( slct.options.length == 0 ) {\r
48                 this.addSuggestion( this.noSuggestionSelection );\r
49         } else {\r
50                 slct.options[0].selected = true;\r
51         }\r
52         this.setSuggestedText();\r
53 }\r
54 \r
55 function addSuggestion( sugg_text ) {\r
56         var slct = this.suggestionList;\r
57         if( sugg_text ) {\r
58                 var i = slct.options.length;\r
59                 var newOption = new Option( sugg_text, 'sugg_text'+i );\r
60                 slct.options[i] = newOption;\r
61          }\r
62 }\r
63 \r
64 function clearSuggestions() {\r
65         var slct = this.suggestionList;\r
66         for( var j = slct.length - 1; j > -1; j-- ) {\r
67                 if( slct.options[j] ) {\r
68                         slct.options[j] = null;\r
69                 }\r
70         }\r
71 }\r
72 \r
73 function enableUndo() {\r
74         if( this.undoButton ) {\r
75                 if( this.undoButton.disabled == true ) {\r
76                         this.undoButton.disabled = false;\r
77                 }\r
78         }\r
79 }\r
80 \r
81 function disableUndo() {\r
82         if( this.undoButton ) {\r
83                 if( this.undoButton.disabled == false ) {\r
84                         this.undoButton.disabled = true;\r
85                 }\r
86         }\r
87 }\r