1 /**
  2  * @fileoverview A class which represents the model of 
  3  * the model-view-controller.
  4  */
  5 
  6 goog.provide('xrx.model');
  7 
  8 
  9 
 10 goog.require('xrx.component');
 11 
 12 
 13 
 14 /**
 15  * @constructor
 16  */
 17 xrx.model = function(element) {
 18 
 19 
 20 
 21   goog.base(this, element);
 22 
 23 
 24 
 25   this.element_ = element;
 26   
 27 
 28 
 29   this.recalculate();
 30 };
 31 goog.inherits(xrx.model, xrx.component);
 32 
 33 
 34 
 35 xrx.model.prototype.recalculate = goog.abstractMethod;
 36 
 37 
 38 
 39 xrx.model.classes = [
 40   'xrx-instance',
 41   'xrx-bind'
 42 ];
 43 
 44 
 45 
 46 xrx.model.components_ = {};
 47 
 48 
 49 
 50 xrx.model.addComponent = function(id, component) {
 51   xrx.model.components_[id] = component;
 52 };
 53 
 54 
 55 
 56 xrx.model.getComponent = function(id) {
 57   return xrx.model.components_[id];
 58 };
 59 
 60 
 61 
 62 xrx.model.getComponents = function() {
 63   return xrx.model.components_;
 64 };
 65 
 66 
 67 
 68 xrx.model.cursor = {};
 69 
 70 
 71 
 72 xrx.model.cursor.node_ = [];
 73 
 74 
 75 
 76 xrx.model.cursor.setNodes = function(nodes) {
 77   var n = xrx.model.cursor.node_;
 78   n.splice(0, n.length);
 79 
 80   for (var i = 0, len = nodes.length; i < len; i++) {
 81     n[i] = nodes[i];
 82   }
 83 };
 84 
 85 
 86 
 87 xrx.model.cursor.getNode = function(pos) {
 88   return xrx.model.cursor.node_[pos];
 89 };
 90 
 91