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