JAVASCRIPT 6
ControlWindow.js Guest on 21st November 2020 12:33:26 AM
  1. ////////////////////////////////////////////////////
  2.  
  3. // controlWindow object
  4.  
  5. ////////////////////////////////////////////////////
  6.  
  7. function controlWindow( controlForm ) {
  8.  
  9.         // private properties
  10.  
  11.         this._form = controlForm;
  12.  
  13.  
  14.  
  15.         // public properties
  16.  
  17.         this.windowType = "controlWindow";
  18.  
  19. //      this.noSuggestionSelection = "- No suggestions -";      // by FredCK
  20.  
  21.         this.noSuggestionSelection = FCKLang.DlgSpellNoSuggestions ;
  22.  
  23.         // set up the properties for elements of the given control form
  24.  
  25.         this.suggestionList  = this._form.sugg;
  26.  
  27.         this.evaluatedText   = this._form.misword;
  28.  
  29.         this.replacementText = this._form.txtsugg;
  30.  
  31.         this.undoButton      = this._form.btnUndo;
  32.  
  33.  
  34.  
  35.         // public methods
  36.  
  37.         this.addSuggestion = addSuggestion;
  38.  
  39.         this.clearSuggestions = clearSuggestions;
  40.  
  41.         this.selectDefaultSuggestion = selectDefaultSuggestion;
  42.  
  43.         this.resetForm = resetForm;
  44.  
  45.         this.setSuggestedText = setSuggestedText;
  46.  
  47.         this.enableUndo = enableUndo;
  48.  
  49.         this.disableUndo = disableUndo;
  50.  
  51. }
  52.  
  53.  
  54.  
  55. function resetForm() {
  56.  
  57.         if( this._form ) {
  58.  
  59.                 this._form.reset();
  60.  
  61.         }
  62.  
  63. }
  64.  
  65.  
  66.  
  67. function setSuggestedText() {
  68.  
  69.         var slct = this.suggestionList;
  70.  
  71.         var txt = this.replacementText;
  72.  
  73.         var str = "";
  74.  
  75.         if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) {
  76.  
  77.                 str = slct.options[slct.selectedIndex].text;
  78.  
  79.         }
  80.  
  81.         txt.value = str;
  82.  
  83. }
  84.  
  85.  
  86.  
  87. function selectDefaultSuggestion() {
  88.  
  89.         var slct = this.suggestionList;
  90.  
  91.         var txt = this.replacementText;
  92.  
  93.         if( slct.options.length == 0 ) {
  94.  
  95.                 this.addSuggestion( this.noSuggestionSelection );
  96.  
  97.         } else {
  98.  
  99.                 slct.options[0].selected = true;
  100.  
  101.         }
  102.  
  103.         this.setSuggestedText();
  104.  
  105. }
  106.  
  107.  
  108.  
  109. function addSuggestion( sugg_text ) {
  110.  
  111.         var slct = this.suggestionList;
  112.  
  113.         if( sugg_text ) {
  114.  
  115.                 var i = slct.options.length;
  116.  
  117.                 var newOption = new Option( sugg_text, 'sugg_text'+i );
  118.  
  119.                 slct.options[i] = newOption;
  120.  
  121.          }
  122.  
  123. }
  124.  
  125.  
  126.  
  127. function clearSuggestions() {
  128.  
  129.         var slct = this.suggestionList;
  130.  
  131.         for( var j = slct.length - 1; j > -1; j-- ) {
  132.  
  133.                 if( slct.options[j] ) {
  134.  
  135.                         slct.options[j] = null;
  136.  
  137.                 }
  138.  
  139.         }
  140.  
  141. }
  142.  
  143.  
  144.  
  145. function enableUndo() {
  146.  
  147.         if( this.undoButton ) {
  148.  
  149.                 if( this.undoButton.disabled == true ) {
  150.  
  151.                         this.undoButton.disabled = false;
  152.  
  153.                 }
  154.  
  155.         }
  156.  
  157. }
  158.  
  159.  
  160.  
  161. function disableUndo() {
  162.  
  163.         if( this.undoButton ) {
  164.  
  165.                 if( this.undoButton.disabled == false ) {
  166.  
  167.                         this.undoButton.disabled = true;
  168.  
  169.                 }
  170.  
  171.         }
  172.  
  173. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.