1 Ajax.InPlaceEditorWithLocalAutocomplete = Class.create(); //<label id="code.create" />
    2 Object.extend(Object.extend(Ajax.InPlaceEditorWithLocalAutocomplete.prototype,
    3                             Ajax.InPlaceEditor.prototype), {
    4   createEditField: function() {
    5     var text;
    6     if(this.options.loadTextURL) {
    7       text = this.options.loadingText;
    8     } else {
    9       text = this.getText();
   10     }
   11 
   12     var obj = this;
   13 
   14     this.options.textarea = false;
   15     var textField = document.createElement("input");
   16     textField.obj = this;
   17     // Give the textfield an id so that we can autocomplete it
   18     textField.id = this.form.id + "_value"
   19     textField.type = "text";
   20     textField.name = "value";
   21     textField.value = text;
   22     textField.style.backgroundColor = this.options.highlightcolor;
   23     textField.className = 'editor_field';
   24     var size = this.options.size || this.options.cols || 0;
   25     if (size != 0) textField.size = size;
   26     if (this.options.submitOnBlur)
   27       textField.onblur = this.onSubmit.bind(this);
   28     this.editField = textField;
   29 
   30     if(this.options.loadTextURL) {
   31       this.loadExternalText();
   32     }
   33     this.form.appendChild(this.editField);
   34   },
   35   enterEditMode: function(evt) {
   36     if (this.saving) return;
   37     if (this.editing) return;
   38     this.editing = true;
   39     this.onEnterEditMode();
   40     if (this.options.externalControl) {
   41       Element.hide(this.options.externalControl);
   42     }
   43     Element.hide(this.element);
   44     this.createForm();
   45     this.element.parentNode.insertBefore(this.form, this.element);
   46     
   47     // Make the div we'll put the autocomplete info in
   48     var autocompleteDiv = document.createElement("div");
   49     autocompleteDiv.id = this.editField.id + "_auto_complete";
   50     autocompleteDiv.className = "auto_complete";
   51     this.form.appendChild(autocompleteDiv);
   52     
   53     // Can't add the autocompleter until the field and dive have been added to the DOM
   54     new Autocompleter.Local(this.editField.id, autocompleteDiv.id, this.options.catalog, this.options.autocomplete_options);
   55 
   56     Field.scrollFreeActivate(this.editField);
   57     // stop the event to avoid a page refresh in Safari
   58     if (evt) {
   59       Event.stop(evt);
   60     }
   61     return false;
   62   },
   63   
   64 });