mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Convert lodah-es and d3 to named imports for lib
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
import * as d3 from 'd3';
|
||||
import { utilRebind } from '../../modules/util/rebind';
|
||||
import { utilTriggerEvent } from '../../modules/util/trigger_event';
|
||||
import {
|
||||
dispatch as d3_dispatch
|
||||
} from 'd3-dispatch';
|
||||
|
||||
import {
|
||||
event as d3_event,
|
||||
select as d3_select
|
||||
} from 'd3-selection';
|
||||
|
||||
import {
|
||||
utilRebind,
|
||||
utilTriggerEvent
|
||||
} from '../../modules/util';
|
||||
|
||||
|
||||
export function d3combobox() {
|
||||
var dispatch = d3.dispatch('accept'),
|
||||
container = d3.select(document.body),
|
||||
var dispatch = d3_dispatch('accept'),
|
||||
container = d3_select(document.body),
|
||||
data = [],
|
||||
suggestions = [],
|
||||
minItems = 2,
|
||||
@@ -38,7 +48,7 @@ export function d3combobox() {
|
||||
var parent = this.parentNode,
|
||||
sibling = this.nextSibling;
|
||||
|
||||
var caret = d3.select(parent).selectAll('.combobox-caret')
|
||||
var caret = d3_select(parent).selectAll('.combobox-caret')
|
||||
.filter(function(d) { return d === input.node(); })
|
||||
.data([input.node()]);
|
||||
|
||||
@@ -51,8 +61,8 @@ export function d3combobox() {
|
||||
.on('mousedown', function () {
|
||||
// prevent the form element from blurring. it blurs
|
||||
// on mousedown
|
||||
d3.event.stopPropagation();
|
||||
d3.event.preventDefault();
|
||||
d3_event.stopPropagation();
|
||||
d3_event.preventDefault();
|
||||
if (!shown) {
|
||||
input.node().focus();
|
||||
fetch('', render);
|
||||
@@ -81,10 +91,10 @@ export function d3combobox() {
|
||||
.style('left', '0px')
|
||||
.on('mousedown', function () {
|
||||
// prevent moving focus out of the text field
|
||||
d3.event.preventDefault();
|
||||
d3_event.preventDefault();
|
||||
});
|
||||
|
||||
d3.select('body')
|
||||
d3_select('body')
|
||||
.on('scroll.combobox', render, true);
|
||||
|
||||
shown = true;
|
||||
@@ -96,7 +106,7 @@ export function d3combobox() {
|
||||
idx = -1;
|
||||
wrapper.remove();
|
||||
|
||||
d3.select('body')
|
||||
d3_select('body')
|
||||
.on('scroll.combobox', null);
|
||||
|
||||
shown = false;
|
||||
@@ -104,7 +114,7 @@ export function d3combobox() {
|
||||
}
|
||||
|
||||
function keydown() {
|
||||
switch (d3.event.keyCode) {
|
||||
switch (d3_event.keyCode) {
|
||||
// backspace, delete
|
||||
case 8:
|
||||
case 46:
|
||||
@@ -125,24 +135,24 @@ export function d3combobox() {
|
||||
break;
|
||||
// return
|
||||
case 13:
|
||||
d3.event.preventDefault();
|
||||
d3_event.preventDefault();
|
||||
break;
|
||||
// up arrow
|
||||
case 38:
|
||||
nav(-1);
|
||||
d3.event.preventDefault();
|
||||
d3_event.preventDefault();
|
||||
break;
|
||||
// down arrow
|
||||
case 40:
|
||||
nav(+1);
|
||||
d3.event.preventDefault();
|
||||
d3_event.preventDefault();
|
||||
break;
|
||||
}
|
||||
d3.event.stopPropagation();
|
||||
d3_event.stopPropagation();
|
||||
}
|
||||
|
||||
function keyup() {
|
||||
switch (d3.event.keyCode) {
|
||||
switch (d3_event.keyCode) {
|
||||
// escape
|
||||
case 27:
|
||||
hide();
|
||||
@@ -308,11 +318,11 @@ d3combobox.off = function(input) {
|
||||
.on('keyup.typeahead', null)
|
||||
.on('input.typeahead', null)
|
||||
.each(function() {
|
||||
d3.select(this.parentNode).selectAll('.combobox-caret')
|
||||
d3_select(this.parentNode).selectAll('.combobox-caret')
|
||||
.filter(function(d) { return d === input.node(); })
|
||||
.on('mousedown', null);
|
||||
});
|
||||
|
||||
d3.select('body')
|
||||
d3_select('body')
|
||||
.on('scroll.combobox', null);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as d3 from 'd3';
|
||||
import { range as d3_range } from 'd3-array';
|
||||
|
||||
|
||||
export function d3geoTile() {
|
||||
var size = [960, 500],
|
||||
@@ -17,8 +18,8 @@ export function d3geoTile() {
|
||||
k = Math.pow(2, z - z0 + 8),
|
||||
origin = [(translate[0] - scale / 2) / k, (translate[1] - scale / 2) / k],
|
||||
tiles = [],
|
||||
cols = d3.range(Math.max(0, Math.floor(-origin[0])), Math.max(0, Math.ceil(size[0] / k - origin[0]))),
|
||||
rows = d3.range(Math.max(0, Math.floor(-origin[1])), Math.max(0, Math.ceil(size[1] / k - origin[1])));
|
||||
cols = d3_range(Math.max(0, Math.floor(-origin[0])), Math.max(0, Math.ceil(size[0] / k - origin[0]))),
|
||||
rows = d3_range(Math.max(0, Math.floor(-origin[1])), Math.max(0, Math.ceil(size[1] / k - origin[1])));
|
||||
|
||||
rows.forEach(function(y) {
|
||||
cols.forEach(function(x) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
event as d3_event,
|
||||
select as d3_select
|
||||
} from 'd3-selection';
|
||||
|
||||
|
||||
/*
|
||||
@@ -48,11 +50,11 @@ export function d3keybinding(namespace) {
|
||||
|
||||
|
||||
function matches(binding, testShift) {
|
||||
var event = d3.event;
|
||||
var event = d3_event;
|
||||
if (event.key !== undefined) {
|
||||
if (binding.event.key === undefined) {
|
||||
return false;
|
||||
} else if (_.isArray(binding.event.key)) {
|
||||
} else if (Array.isArray(binding.event.key)) {
|
||||
if (binding.event.key.map(function(s) { return s.toLowerCase(); }).indexOf(event.key.toLowerCase()) === -1)
|
||||
return false;
|
||||
} else {
|
||||
@@ -84,7 +86,7 @@ export function d3keybinding(namespace) {
|
||||
|
||||
|
||||
function bubble() {
|
||||
var tagName = d3.select(d3.event.target).node().tagName;
|
||||
var tagName = d3_select(d3_event.target).node().tagName;
|
||||
if (tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +95,7 @@ export function d3keybinding(namespace) {
|
||||
|
||||
|
||||
function keybinding(selection) {
|
||||
selection = selection || d3.select(document);
|
||||
selection = selection || d3_select(document);
|
||||
selection.on('keydown.capture' + namespace, capture, true);
|
||||
selection.on('keydown.bubble' + namespace, bubble, false);
|
||||
return keybinding;
|
||||
@@ -102,7 +104,7 @@ export function d3keybinding(namespace) {
|
||||
|
||||
keybinding.off = function(selection) {
|
||||
bindings = [];
|
||||
selection = selection || d3.select(document);
|
||||
selection = selection || d3_select(document);
|
||||
selection.on('keydown.capture' + namespace, null);
|
||||
selection.on('keydown.bubble' + namespace, null);
|
||||
return keybinding;
|
||||
|
||||
Reference in New Issue
Block a user