controlWindow.js
上传用户:ah_jiwei
上传日期:2022-07-24
资源大小:54044k
文件大小:2k
源码类别:

数据库编程

开发平台:

Visual C++

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