From 02dd0344889f45701021e86efef8d04b56175047 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Sun, 27 Apr 2014 02:12:28 -0400 Subject: group coincident walls --- assets/javascripts/rectangles/models/wall.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'assets/javascripts/rectangles/models/wall.js') diff --git a/assets/javascripts/rectangles/models/wall.js b/assets/javascripts/rectangles/models/wall.js index b9705a2..50ae0e8 100644 --- a/assets/javascripts/rectangles/models/wall.js +++ b/assets/javascripts/rectangles/models/wall.js @@ -3,9 +3,14 @@ window.Wall = (function(){ var Wall = function(opt){ this.id = opt.id this.room = opt.room - this.rect = opt.rect + 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(){ @@ -14,15 +19,24 @@ window.Wall = (function(){ 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(){ - this.$walls.bind({ + var base = this + base.$walls = $( this.mx.map(function(mx){ return mx.el }) ) + base.$walls.bind({ mouseover: function(){ }, mousemove: function(e){ }, mousedown: function(){ - $(this).css("background-color", choice(window.palettes.colors)) + base.$walls.css("background-color", choice(window.palettes.colors)) + console.log("zz") } }) } -- cgit v1.2.3-70-g09d2