mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
size -> dimensions
D3 3.2 adds selection.size, where size means "number of selected elements".
This commit is contained in:
2
Makefile
2
Makefile
@@ -22,7 +22,7 @@ dist/iD.js: \
|
||||
js/lib/d3.jsonp.js \
|
||||
js/lib/d3.keybinding.js \
|
||||
js/lib/d3.one.js \
|
||||
js/lib/d3.size.js \
|
||||
js/lib/d3.dimensions.js \
|
||||
js/lib/d3.trigger.js \
|
||||
js/lib/d3.typeahead.js \
|
||||
js/lib/d3.curtain.js \
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script src='js/lib/d3.typeahead.js'></script>
|
||||
<script src='js/lib/d3.combobox.js'></script>
|
||||
<script src='js/lib/d3.geo.tile.js'></script>
|
||||
<script src='js/lib/d3.size.js'></script>
|
||||
<script src='js/lib/d3.dimensions.js'></script>
|
||||
<script src='js/lib/d3.trigger.js'></script>
|
||||
<script src='js/lib/d3.jsonp.js'></script>
|
||||
<script src='js/lib/d3.keybinding.js'></script>
|
||||
|
||||
@@ -10,11 +10,11 @@ iD.behavior.Tail = function() {
|
||||
if (!text) return;
|
||||
|
||||
d3.select(window)
|
||||
.on('resize.tail', function() { selection_size = selection.size(); });
|
||||
.on('resize.tail', function() { selection_size = selection.dimensions(); });
|
||||
|
||||
function show() {
|
||||
container.style('display', 'block');
|
||||
tooltip_size = container.size();
|
||||
tooltip_size = container.dimensions();
|
||||
}
|
||||
|
||||
function mousemove() {
|
||||
@@ -55,8 +55,8 @@ iD.behavior.Tail = function() {
|
||||
container
|
||||
.on('mousemove.tail', mousemove);
|
||||
|
||||
tooltip_size = container.size();
|
||||
selection_size = selection.size();
|
||||
tooltip_size = container.dimensions();
|
||||
selection_size = selection.dimensions();
|
||||
}
|
||||
|
||||
tail.off = function(selection) {
|
||||
|
||||
@@ -93,7 +93,7 @@ iD.modes.DragNode = function(context) {
|
||||
|
||||
var nudge = childOf(context.container().node(),
|
||||
d3.event.sourceEvent.toElement) &&
|
||||
edge(d3.event.point, context.map().size());
|
||||
edge(d3.event.point, context.map().dimensions());
|
||||
|
||||
if (nudge) startNudge(nudge);
|
||||
else stopNudge();
|
||||
|
||||
@@ -54,7 +54,7 @@ iD.modes.Move = function(context, entityIDs) {
|
||||
p[1] - context.projection(origin)[1]] :
|
||||
[0, 0];
|
||||
|
||||
var nudge = edge(p, context.map().size());
|
||||
var nudge = edge(p, context.map().dimensions());
|
||||
if (nudge) startNudge(nudge);
|
||||
else stopNudge();
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ iD.Background = function(backgroundType) {
|
||||
return background;
|
||||
};
|
||||
|
||||
background.size = function(_) {
|
||||
background.dimensions = function(_) {
|
||||
if (!arguments.length) return tile.size();
|
||||
tile.size(_);
|
||||
return background;
|
||||
|
||||
@@ -2,7 +2,6 @@ iD.LocalGpx = function(context) {
|
||||
var projection,
|
||||
gj = {},
|
||||
enable = true,
|
||||
size = [0, 0],
|
||||
svg;
|
||||
|
||||
function render(selection) {
|
||||
@@ -50,9 +49,9 @@ iD.LocalGpx = function(context) {
|
||||
return render;
|
||||
};
|
||||
|
||||
render.size = function(_) {
|
||||
if (!arguments.length) return svg.size();
|
||||
svg.size(_);
|
||||
render.dimensions = function(_) {
|
||||
if (!arguments.length) return svg.dimensions();
|
||||
svg.dimensions(_);
|
||||
return render;
|
||||
};
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ iD.Map = function(context) {
|
||||
}
|
||||
});
|
||||
|
||||
map.size(selection.size());
|
||||
map.dimensions(selection.dimensions());
|
||||
|
||||
labels.supersurface(supersurface);
|
||||
mouse = iD.util.fastMouse(supersurface.node());
|
||||
@@ -315,13 +315,13 @@ iD.Map = function(context) {
|
||||
return redraw();
|
||||
};
|
||||
|
||||
map.size = function(_) {
|
||||
map.dimensions = function(_) {
|
||||
if (!arguments.length) return dimensions;
|
||||
var center = map.center();
|
||||
dimensions = _;
|
||||
surface.size(dimensions);
|
||||
surface.dimensions(dimensions);
|
||||
layers.forEach(function(layer) {
|
||||
layer.size(dimensions);
|
||||
layer.dimensions(dimensions);
|
||||
});
|
||||
projection.clipExtent([[0, 0], dimensions]);
|
||||
setCenter(center);
|
||||
|
||||
@@ -131,7 +131,7 @@ iD.ui = function(context) {
|
||||
};
|
||||
|
||||
d3.select(window).on('resize.editor', function() {
|
||||
map.size(m.size());
|
||||
map.dimensions(m.dimensions());
|
||||
});
|
||||
|
||||
function pan(d) {
|
||||
|
||||
@@ -26,8 +26,8 @@ iD.ui.intro.navigation = function(context, reveal) {
|
||||
var map = {
|
||||
left: 30,
|
||||
top: 60,
|
||||
width: context.map().size()[0] - 60,
|
||||
height: context.map().size()[1] - 200
|
||||
width: context.map().dimensions()[0] - 60,
|
||||
height: context.map().dimensions()[1] - 200
|
||||
};
|
||||
|
||||
context.map().centerZoom([-85.63591, 41.94285], 19);
|
||||
|
||||
@@ -57,10 +57,10 @@ d3.curtain = function() {
|
||||
var html = parts[0] ? '<span>' + parts[0] + '</span>' : '';
|
||||
if (parts[1]) html += '<span class="bold">' + parts[1] + '</span>';
|
||||
|
||||
var size = tooltip.classed('in', true)
|
||||
var dimensions = tooltip.classed('in', true)
|
||||
.select('.tooltip-inner')
|
||||
.html(html)
|
||||
.size();
|
||||
.dimensions();
|
||||
|
||||
var pos;
|
||||
|
||||
@@ -69,23 +69,23 @@ d3.curtain = function() {
|
||||
|
||||
if (box.top + box.height < Math.min(100, box.width + box.left)) {
|
||||
side = 'bottom';
|
||||
pos = [box.left + box.width / 2 - size[0]/ 2, box.top + box.height];
|
||||
pos = [box.left + box.width / 2 - dimensions[0]/ 2, box.top + box.height];
|
||||
|
||||
} else if (box.left + box.width + 300 < window.innerWidth) {
|
||||
side = 'right';
|
||||
pos = [box.left + box.width, box.top + box.height / 2 - size[1] / 2];
|
||||
pos = [box.left + box.width, box.top + box.height / 2 - dimensions[1] / 2];
|
||||
|
||||
} else if (box.left > 300) {
|
||||
side = 'left';
|
||||
pos = [box.left - 200, box.top + box.height / 2 - size[1] / 2];
|
||||
pos = [box.left - 200, box.top + box.height / 2 - dimensions[1] / 2];
|
||||
} else {
|
||||
side = 'bottom';
|
||||
pos = [box.left, box.top + box.height];
|
||||
}
|
||||
|
||||
pos = [
|
||||
Math.min(Math.max(10, pos[0]), w - size[0] - 10),
|
||||
Math.min(Math.max(10, pos[1]), h - size[1] - 10)
|
||||
Math.min(Math.max(10, pos[0]), w - dimensions[0] - 10),
|
||||
Math.min(Math.max(10, pos[1]), h - dimensions[1] - 10)
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
d3.selection.prototype.size = function (size) {
|
||||
d3.selection.prototype.dimensions = function (dimensions) {
|
||||
if (!arguments.length) {
|
||||
var node = this.node();
|
||||
return [node.offsetWidth,
|
||||
node.offsetHeight];
|
||||
}
|
||||
return this.attr({width: size[0], height: size[1]});
|
||||
return this.attr({width: dimensions[0], height: dimensions[1]});
|
||||
};
|
||||
@@ -23,7 +23,7 @@
|
||||
<script src='../js/lib/d3.typeahead.js'></script>
|
||||
<script src='../js/lib/d3.combobox.js'></script>
|
||||
<script src='../js/lib/d3.geo.tile.js'></script>
|
||||
<script src='../js/lib/d3.size.js'></script>
|
||||
<script src='../js/lib/d3.dimensions.js'></script>
|
||||
<script src='../js/lib/d3.trigger.js'></script>
|
||||
<script src='../js/lib/d3.jsonp.js'></script>
|
||||
<script src='../js/lib/d3.keybinding.js'></script>
|
||||
|
||||
@@ -16,9 +16,9 @@ describe('iD.Background', function() {
|
||||
expect(c).to.be.ok;
|
||||
});
|
||||
|
||||
it('#size', function() {
|
||||
expect(c.size([100, 100])).to.equal(c);
|
||||
expect(c.size()).to.eql([100,100]);
|
||||
it('#dimensions', function() {
|
||||
expect(c.dimensions([100, 100])).to.equal(c);
|
||||
expect(c.dimensions()).to.eql([100,100]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('iD.Map', function() {
|
||||
|
||||
describe('#extent', function() {
|
||||
it('gets and sets extent', function() {
|
||||
map.size([100, 100])
|
||||
map.dimensions([100, 100])
|
||||
.center([0, 0]);
|
||||
|
||||
expect(map.extent()[0][0]).to.be.closeTo(-17.5, 0.5);
|
||||
|
||||
Reference in New Issue
Block a user