var CommentEdit = klass.create();
Object.extend(CommentEdit.prototype, {
  initialize: function(instance) {
    this.id = instance;

    this.bindControls();
    this.text = null;

    //
    // If owned by the user then no
    // controls now
    //
    this.span.style.cursor = 'default';
    Event.observe(this.span, 'click',
                  this.startEdit.bindAsEventListener(this));
    Event.observe(this.descriptionClose, 'click',
                  this.closeEdit.bindAsEventListener(this));
    this.span.style.cursor = 'pointer';
  },

  bindControls: function() {
    this.span = $('comment-' + this.id + '-start');
    this.description = $('comment-' + this.id + '-comment');
    this.descriptionEdit = $('comment-' + this.id + '-edit');
    this.descriptionClose = $('comment-' + this.id + '-close');
  },

  startEdit: function(e) {
    this.description.style.display = 'none';
    this.description.style.visibility = 'hidden';
    this.descriptionEdit.style.display = '';
    this.descriptionEdit.style.visibility = 'visible';
  },

  closeEdit: function(e) {
    this.description.style.display = '';
    this.description.style.visibility = 'visible';
    this.descriptionEdit.style.display = 'none';
    this.descriptionEdit.style.visibility = 'hidden';
  }
});

var g_commentEditComponents = [];

function g_commentEditInit() {
  g_commentEditComponents.each(function(inst, i) {
    new CommentEdit(inst);
  });
}

g_components.push(g_commentEditInit);

// vim: set sts=2 sw=2 expandtab:
