All pastes #596328 Raw Edit

Stuff

public text v1 · immutable
#596328 ·published 2007-06-29 21:32 UTC
rendered paste body
Ajax.InPlaceCheckboxEditor = Class.create();
Object.extend(Ajax.InPlaceCheckboxEditor.prototype, Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceCheckboxEditor.prototype, {
  createEditField: function() {
    if (!this.cached_collectionTag) {
      var collection = this.options.collection || [];
      var collectionTag = document.createElement("div");
      var checkboxTag;
      collection.each(function(e,i) {
        checkboxTag = document.createElement("input");
        checkboxTag.type = "checkbox";
        checkboxTag.value = (e instanceof Array) ? e[0] : e;
        for(var index=0; index<this.options.values.length; ++index) {
          if (this.options.values[index] == checkboxTag.value) checkboxTag.checked = "checked";
        }
        collectionTag.appendChild(checkboxTag);
        collectionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
      }.bind(this));
      this.cached_collectionTag = collectionTag;
    }

    this.editField = this.cached_collectionTag;
    if(this.options.loadTextURL) this.loadExternalText();
    this.form.appendChild(this.editField);
    this.options.callback = function(form, value) {
      return "value=" + encodeURIComponent(value);
    }
  }
});