// Notes and Relations exist within a div in a Page that's known as the
// Workspace.  The Workspace is a client-side concept that is related to the
// server-side concept of the Page.
MN.Workspace = Class.create();

MN.Workspace.current = null;

MN.Workspace.moveNote = function(note, workspace) {
  var x = note.offsetLeft;
  var y = note.offsetTop;
  var id = MN.id(note);
  var url = '/note/move/' + id;
  new Ajax.Request (
    url,
    {
      postBody  : 'x=' + x + '&y=' + y,
      onSuccess : function() {
        var note = MN.Note.instances[id];
        note.organizeRelations();
        note.drawRelations();
      }
    }
  );
};

MN.Workspace.prototype = {

  // attributes

  element : null,
  pageId  : null,
  width   : null,
  height  : null,

  // methods

  initialize: function(element) {
    this.element = element;
    this.width   = element.width;
    this.height  = element.height;
    this.pageId  = MN.id(element);
    Droppables.add (
      element,
      {
        accept : [ 'note' ],
        onDrop : MN.Workspace.moveNote
      }
    );
    MN.Workspace.current = this;
  }

};

// vim:sw=2 sts=2 expandtab
