window.Wall = (function(){ var Wall = function(opt){ this.id = opt.id this.room = opt.room this.rect = opt.rect || new Rect (0,0,0,0) this.rect.sides = opt.side this.side = opt.side this.mx = [] this.els = [] if (opt.el) { this.mx.push(opt.el) } } Wall.prototype.toString = function(){ return this.rect.toString() } Wall.prototype.reset = function(){ } Wall.prototype.destroy = function(){ this.mx.forEach(function(mx){ mx.destroy && mx.destroy() }) this.room = this.rect = this.mx = this.els = null } Wall.prototype.bind = function(){ var base = this base.$walls = $( this.mx.map(function(mx){ return mx.el }) ) base.$walls.bind({ mouseover: function(){ }, mousemove: function(e){ }, mousedown: function(){ base.$walls.css("background-color", choice(window.palettes.colors)) console.log("zz") } }) } return Wall })()