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