From a823278279e157aabfccd519113a45e2068cece4 Mon Sep 17 00:00:00 2001 From: dsc Date: Sun, 21 Nov 2010 15:36:07 -0800 Subject: [PATCH] Fixes grid overlapping content; fixes text-selection annoyance with grid. --- css/lttl.css | 3 ++- src/tanks/config.js | 2 +- src/tanks/thing/player.js | 12 ++++++++++++ src/tanks/ui/grid.js | 19 ++++++------------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/css/lttl.css b/css/lttl.css index 08cc5b0..9717a2b 100644 --- a/css/lttl.css +++ b/css/lttl.css @@ -10,7 +10,8 @@ td { text-align:center; vertical-align:middle; } table.grid { position:absolute; top:0; left:0; z-index:10; } table.grid, -table.grid td { outline:1px solid rgba(255,255,255,0.1); color:transparent; font: 18pt monospace; +table.grid td { /* outline:1px solid rgba(255,255,255,0.1); */ + color:transparent; font: 18pt monospace; margin:0; padding:0; white-space:nowrap; overflow:hidden; } .gridShowCoords table.grid td:hover { color:rgba(255,255,255,0.1); } diff --git a/src/tanks/config.js b/src/tanks/config.js index 948c6d0..d6e2652 100644 --- a/src/tanks/config.js +++ b/src/tanks/config.js @@ -6,7 +6,7 @@ tanks.config = { traceTrajectories : false }, debug : { - gridShowCoords : true + gridShowCoords : false } }; \ No newline at end of file diff --git a/src/tanks/thing/player.js b/src/tanks/thing/player.js index b4a2af0..efad127 100644 --- a/src/tanks/thing/player.js +++ b/src/tanks/thing/player.js @@ -133,6 +133,12 @@ PlayerTank = Tank.subclass('PlayerTank', { case 3: evt.middleMouse = true; break; } this.updateMeta(evt); + + if (window.getSelection) { + window.getSelection().removeAllRanges(); + } + + return false; }, mouseup : function mouseup(evt){ @@ -144,6 +150,12 @@ PlayerTank = Tank.subclass('PlayerTank', { case 3: evt.middleMouse = false; break; } this.updateMeta(evt); + + if (window.getSelection) { + window.getSelection().removeAllRanges(); + } + + return false; }, mousemove : function mousemove(evt){ diff --git a/src/tanks/ui/grid.js b/src/tanks/ui/grid.js index 4eefd43..ca98808 100644 --- a/src/tanks/ui/grid.js +++ b/src/tanks/ui/grid.js @@ -4,6 +4,7 @@ Grid = new Y.Class('Grid', Rect, { lineWidth : 0.5, strokeStyle : '#6E6E6E', + init : function init(cols,rows, size){ this.cols = cols; this.rows = rows; @@ -13,7 +14,10 @@ Grid = new Y.Class('Grid', Rect, { drawShape : function drawShape(ctx){ var tbody = $('') - , cols = this.cols, rows = this.rows, size = this.size + , cols = this.cols, rows = this.rows + , size = this.size + , w = this.canvasWidth + , h = this.canvasHeight ; Y(0, rows).forEach(function(y){ @@ -33,18 +37,7 @@ Grid = new Y.Class('Grid', Rect, { .append(tbody) .prependTo( this.layer ); - this.canvas.remove(); - - return this; - }, - - _drawShape : function drawShape(ctx){ - var size = this.size - , rows = this.rows - , cols = this.cols - , w = this.canvasWidth - , h = this.canvasHeight - ; + // this.canvas.remove(); ctx.lineWidth = this.lineWidth; ctx.strokeStyle = this.strokeStyle; -- 1.7.0.4