+
+var Model = Class.extend({
+ observers: {},
+
+ init: function() {},
+
+ signal: function(event, data) {
+ console.log('signal', this, event, data);
+ if (this.observers[event]) {
+ for (var i=0; i < this.observers[event].length; i++) {
+ this.observers[event][i].handle(event, data);
+ };
+ };
+ return this;
+ },
+
+ addObserver: function(observer, event) {
+ if (!this.observers[event]) {
+ this.observers[event] = [];
+ }
+ this.observers[event].push(observer);
+ return this;
+ },
+
+ removeObserver: function(observer, event) {
+ if (!event) {
+ for (e in this.observers) {
+ this.removeObserver(observer, e);
+ }
+ } else {
+ for (var i=0; i < this.observers[event].length; i++) {
+ if (this.observers[event][i] === observer) {
+ this.observers[event].splice(i, 1);
+ }
+ }
+ }
+ return this;
+ }
+})
+
+var DocumentModel = Model.extend({