From fc6cb352d855be62958a661b57974b83adfd9f4f Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 11 Feb 2013 12:12:18 -0500 Subject: [PATCH 1/3] use compatible mouse position properties --- js/id/behavior/lasso.js | 4 ++-- js/id/behavior/select.js | 6 +++--- js/id/modes/select.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/id/behavior/lasso.js b/js/id/behavior/lasso.js index e99b1bf14..0a26f311d 100644 --- a/js/id/behavior/lasso.js +++ b/js/id/behavior/lasso.js @@ -10,7 +10,7 @@ iD.behavior.Lasso = function(context) { function mousedown() { if (d3.event.shiftKey === true) { - pos = [d3.event.x, d3.event.y]; + pos = [d3.event.clientX, d3.event.clientY]; lasso = iD.ui.lasso().a(d3.mouse(context.surface().node())); @@ -48,7 +48,7 @@ iD.behavior.Lasso = function(context) { .on('mousemove.lasso', null) .on('mouseup.lasso', null); - if (d3.event.x !== pos[0] || d3.event.y !== pos[1]) { + if (d3.event.clientX !== pos[0] || d3.event.clientY !== pos[1]) { var selected = context.graph().intersects(extent); if (selected.length) { diff --git a/js/id/behavior/select.js b/js/id/behavior/select.js index 4d0bef2de..7369af97c 100644 --- a/js/id/behavior/select.js +++ b/js/id/behavior/select.js @@ -22,7 +22,7 @@ iD.behavior.Select = function(context) { function mousedown() { var datum = d3.event.target.__data__; - pos = [d3.event.x, d3.event.y]; + pos = [d3.event.clientX, d3.event.clientY]; if (datum instanceof iD.Entity || (datum && datum.type === 'midpoint')) { selection .on('mousemove.select', mousemove) @@ -51,7 +51,7 @@ iD.behavior.Select = function(context) { // allow mousemoves to cancel the click function mousemove() { - if (iD.geo.dist([d3.event.x, d3.event.y], pos) > 4) { + if (iD.geo.dist([d3.event.clientX, d3.event.clientY], pos) > 4) { window.clearTimeout(timeout); timeout = null; } @@ -59,7 +59,7 @@ iD.behavior.Select = function(context) { function mouseup() { selection.on('mousemove.select', null); - if (pos && d3.event.x === pos[0] && d3.event.y === pos[1] && + if (pos && d3.event.clientX === pos[0] && d3.event.clientY === pos[1] && !(d3.event.target.__data__ instanceof iD.Entity)) { context.enter(iD.modes.Browse(context)); } diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 5732b58df..9b12c8134 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -76,10 +76,10 @@ iD.modes.Select = function(context, selection, initial) { var inspector_size = context.container().select('.inspector-wrap').size(), map_size = context.map().size(), offset = 50, - shift_left = d3.event.x - map_size[0] + inspector_size[0] + offset, + shift_left = d3.event.clientX - map_size[0] + inspector_size[0] + offset, center = (map_size[0] / 2) + shift_left + offset; - if (shift_left > 0 && inspector_size[1] > d3.event.y) { + if (shift_left > 0 && inspector_size[1] > d3.event.clientY) { context.map().centerEase(context.projection.invert([center, map_size[1]/2])); } } From fe32ca9d03ca27ed0b7d5d22400a3b374470f700 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 11 Feb 2013 12:36:21 -0500 Subject: [PATCH 2/3] Yep, detecting opera. Goal can be achieved with two different svg styles, but Opera only implements one, Firefox the other. Can't apply both because Chrome implements both. --- css/map.css | 6 ++++++ js/id/id.js | 2 ++ js/id/ui.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/css/map.css b/css/map.css index 885c8195c..bea6edde3 100644 --- a/css/map.css +++ b/css/map.css @@ -648,7 +648,13 @@ text.pointlabel { } .pathlabel .textpath { + dominant-baseline: middle; +} + +/* Opera doesn't support dominant-baseline */ +.opera .pathlabel .textpath { baseline-shift: -33%; + dominant-baseline: auto; } .pointlabel-halo, diff --git a/js/id/id.js b/js/id/id.js index 665e0b0a1..df986bc5f 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -127,6 +127,8 @@ iD.detect = function() { browser.support = true; } + browser.opera = ua.indexOf('Opera') >= 0; + browser.locale = navigator.language; function nav(x) { diff --git a/js/id/ui.js b/js/id/ui.js index 529d8bca5..ecab88470 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -12,6 +12,8 @@ iD.ui = function(context) { return; } + if (iD.detect().opera) container.classed('opera', true); + function hintprefix(x, y) { return '' + y + '' + '
' + x + '
'; } From d458a3707f2271bbc8ee69e37ac9233f2e052c86 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 11 Feb 2013 12:42:02 -0500 Subject: [PATCH 3/3] Add comments about opera detection --- css/map.css | 2 +- js/id/id.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/css/map.css b/css/map.css index bea6edde3..d8f8ab220 100644 --- a/css/map.css +++ b/css/map.css @@ -651,7 +651,7 @@ text.pointlabel { dominant-baseline: middle; } -/* Opera doesn't support dominant-baseline */ +/* Opera doesn't support dominant-baseline. See #715 */ .opera .pathlabel .textpath { baseline-shift: -33%; dominant-baseline: auto; diff --git a/js/id/id.js b/js/id/id.js index df986bc5f..a7d7a44ac 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -127,6 +127,7 @@ iD.detect = function() { browser.support = true; } + // Added due to incomplete svg style support. See #715 browser.opera = ua.indexOf('Opera') >= 0; browser.locale = navigator.language;