Commit 780960c7 authored by Kushan Joshi's avatar Kushan Joshi

interim

parent 7188065a
......@@ -10,6 +10,6 @@
"no-invalid-this": 0
},
globals: {
"iD": false,
# "iD": false,
}
}
import { cmd } from '../ui/core/index';
import { cmd } from '../ui/index';
export function Copy(context) {
var keybinding = d3.keybinding('copy');
......
import { Select } from '../modes/index';
import { Extent, pointInPolygon } from '../geo/index';
import { Lasso as uiLasso } from '../ui/core/index';
import { Lasso as uiLasso } from '../ui/index';
export function Lasso(context) {
......
import { Move as MoveMode } from '../modes/index';
import { Extent, pointInPolygon } from '../geo/index';
import { CopyEntities, ChangeTags, Move as MoveAction} from '../actions/index';
import { cmd } from '../ui/core/index';
import { cmd } from '../ui/index';
export function Paste(context) {
var keybinding = d3.keybinding('paste');
......
......@@ -3,7 +3,7 @@ import { Graph } from './graph';
import { Difference } from './difference';
import { Tree } from './tree';
import { SessionMutex } from '../util/index';
import { Loading } from '../ui/core/index';
import { Loading } from '../ui/index';
export function History(context) {
var stack, index, tree,
......
......@@ -6,6 +6,7 @@ import * as util from './util/index';
import * as operations from './operations/index';
import * as presets from './presets/index';
import * as validations from './validations/index';
import * as ui from './ui/index';
// core
export { Connection } from './core/connection';
......@@ -25,7 +26,6 @@ export { Background } from './renderer/background';
export { Features } from './renderer/features';
export { Map } from './renderer/map';
export { TileLayer } from './renderer/tile_layer';
export { ui } from './ui/index';
export {
actions,
......@@ -35,5 +35,6 @@ export {
operations,
presets,
util,
ui,
validations
};
......@@ -2,7 +2,7 @@ import { Graph } from '../core/index';
import { displayName, displayType } from '../util/index';
import { Browse } from './index';
import { DiscardTags, Noop, MergeRemoteChanges, Revert } from '../actions/index';
import { Commit, Loading, Success, Conflicts } from '../ui/core/index';
import { Commit, Loading, Success, Conflicts } from '../ui/index';
export function Save(context) {
var ui = Commit(context)
......
......@@ -5,7 +5,7 @@ import { DragNode, Browse } from './index';
import { Extent, pointInPolygon, chooseEdge } from '../geo/index';
import { AddMidpoint } from '../actions/index';
import * as Operations from '../operations/index';
import { RadialMenu, SelectionList } from '../ui/core/index';
import { RadialMenu, SelectionList } from '../ui/index';
export function Select(context, selectedIDs) {
var mode = {
......
import { Select, Browse } from '../modes/index';
import { sphericalDistance } from '../geo/index';
import { DeleteMultiple } from '../actions/index';
import { cmd } from '../ui/core/cmd';
import { cmd } from '../ui/index';
export function Delete(selectedIDs, context) {
var action = DeleteMultiple(selectedIDs);
......
import { setTransform, fastMouse } from '../util/index';
import { interp, Extent } from '../geo/index';
import { Layers, Areas, Midpoints, Points, Vertices, Lines, Labels } from '../svg/index';
import { flash } from '../ui/core/index';
import { flash } from '../ui/index';
export function Map(context) {
var dimensions = [1, 1],
......
import { modal as modalModule } from './modal';
import { modal } from './modal';
export function confirm(selection) {
var modal = modalModule(selection);
var modalSelection = modal(selection);
modal.select('.modal')
modalSelection.select('.modal')
.classed('modal-alert', true);
var section = modal.select('.content');
var section = modalSelection.select('.content');
section.append('div')
.attr('class', 'modal-section header');
......@@ -17,17 +17,17 @@ export function confirm(selection) {
var buttons = section.append('div')
.attr('class', 'modal-section buttons cf');
modal.okButton = function() {
modalSelection.okButton = function() {
buttons
.append('button')
.attr('class', 'action col4')
.on('click.confirm', function() {
modal.remove();
modalSelection.remove();
})
.text(t('confirm.okay'));
return modal;
return modalSelection;
};
return modal;
return modalSelection;
}
export { Account } from './account';
export { Attribution } from './attribution';
export { Background } from './background';
export { cmd } from './cmd';
export { Commit } from './commit';
export { confirm } from './confirm';
export { Conflicts } from './conflicts';
export { Contributors } from './contributors';
export { Disclosure } from './disclosure';
export { EntityEditor } from './entity_editor';
export { FeatureInfo } from './feature_info';
export { FeatureList } from './feature_list';
export { flash } from './flash';
export { FullScreen } from './full_screen';
export { Geolocate } from './geolocate';
export { Help } from './help';
export { Info } from './info';
export { Inspector } from './inspector';
export { intro } from './intro';
export { Lasso } from './lasso';
export { Loading } from './loading';
export { MapData } from './map_data';
export { MapInMap } from './map_in_map';
export { modal } from './modal';
export { Modes } from './modes';
export { Notice } from './notice';
export { preset } from './preset';
export { PresetIcon } from './preset_icon';
export { PresetList } from './preset_list';
export { RadialMenu } from './radial_menu';
export { RawMemberEditor } from './raw_member_editor';
export { RawMembershipEditor } from './raw_membership_editor';
export { RawTagEditor } from './raw_tag_editor';
export { Restore } from './restore';
export { Save } from './save';
export { Scale } from './scale';
export { SelectionList } from './selection_list';
export { Sidebar } from './sidebar';
export { SourceSwitch } from './source_switch';
export { Spinner } from './spinner';
export { Splash } from './splash';
export { Status } from './status';
export { Success } from './success';
export { TagReference } from './tag_reference';
export { Toggle } from './toggle';
export { tooltipHtml } from './tooltipHtml';
export { UndoRedo } from './undo_redo';
export { ViewOnOSM } from './view_on_osm';
export { Zoom } from './zoom';
import { Icon } from '../svg/index';
import { Browse } from '../modes/index';
import { ChangeTags } from '../actions/index';
import { preset as presetModule } from './preset';
import { preset } from './preset';
import { PresetIcon } from './preset_icon';
import { RawTagEditor } from './raw_tag_editor';
import { RawMemberEditor } from './raw_member_editor';
......@@ -15,10 +15,10 @@ export function EntityEditor(context) {
modified = false,
base,
id,
preset,
activePreset,
reference;
var presetEditor = presetModule(context)
var presetEditor = preset(context)
.on('change', changeTags);
var rawTagEditor = RawTagEditor(context)
.on('change', changeTags);
......@@ -93,28 +93,28 @@ export function EntityEditor(context) {
selection.selectAll('.preset-reset')
.on('click', function() {
dispatch.choose(preset);
dispatch.choose(activePreset);
});
// Update
$body.select('.preset-list-item button')
.call(PresetIcon()
.geometry(context.geometry(id))
.preset(preset));
.preset(activePreset));
$body.select('.preset-list-item .label')
.text(preset.name());
.text(activePreset.name());
$body.select('.inspector-preset')
.call(presetEditor
.preset(preset)
.preset(activePreset)
.entityID(id)
.tags(tags)
.state(state));
$body.select('.raw-tag-editor')
.call(rawTagEditor
.preset(preset)
.preset(activePreset)
.entityID(id)
.tags(tags)
.state(state));
......@@ -233,10 +233,10 @@ export function EntityEditor(context) {
};
entityEditor.preset = function(_) {
if (!arguments.length) return preset;
if (_ !== preset) {
preset = _;
reference = TagReference(preset.reference(context.geometry(id)), context)
if (!arguments.length) return activePreset;
if (_ !== activePreset) {
activePreset = _;
reference = TagReference(activePreset.reference(context.geometry(id)), context)
.showing(false);
}
return entityEditor;
......
export { check as defaultcheck };
import { oneWayTags } from '../../core/index';
export function check(field) {
var dispatch = d3.dispatch('change'),
options = field.strings && field.strings.options,
......@@ -25,7 +26,7 @@ export function check(field) {
// where implied oneway tag exists (e.g. `junction=roundabout`) #2220, #1841
if (field.id === 'oneway') {
for (var key in entity.tags) {
if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) {
if (key in oneWayTags && (entity.tags[key] in oneWayTags[key])) {
texts[0] = t('presets.fields.oneway_yes.options.undefined');
break;
}
......
import { modal as modalModule } from './modal';
import { modal } from './modal';
export function flash(selection) {
var modal = modalModule(selection);
var modalSelection = modal(selection);
modal.select('.modal').classed('modal-flash', true);
modalSelection.select('.modal').classed('modal-flash', true);
modal.select('.content')
modalSelection.select('.content')
.classed('modal-section', true)
.append('div')
.attr('class', 'description');
modal.on('click.flash', function() { modal.remove(); });
modalSelection.on('click.flash', function() { modalSelection.remove(); });
setTimeout(function() {
modal.remove();
modalSelection.remove();
return true;
}, 1500);
return modal;
return modalSelection;
}
import { ui } from './ui';
import { presetObj } from './preset/index';
import { Account } from './account';
import { Attribution } from './attribution';
import { Background } from './background';
import { cmd } from './cmd';
import { Commit } from './commit';
import { confirm } from './confirm';
import { Conflicts } from './conflicts';
import { Contributors } from './contributors';
import { Disclosure } from './disclosure';
import { EntityEditor } from './entity_editor';
import { FeatureInfo } from './feature_info';
import { FeatureList } from './feature_list';
import { flash } from './flash';
import { FullScreen } from './full_screen';
import { Geolocate } from './geolocate';
import { Help } from './help';
import { Info } from './info';
import { Inspector } from './inspector';
import { intro } from './intro';
import { Lasso } from './lasso';
import { Loading } from './loading';
import { MapData } from './map_data';
import { MapInMap } from './map_in_map';
import { modal } from './modal';
import { Modes } from './modes';
import { Notice } from './notice';
import { preset } from './preset';
import { PresetIcon } from './preset_icon';
import { PresetList } from './preset_list';
import { RadialMenu } from './radial_menu';
import { RawMemberEditor } from './raw_member_editor';
import { RawMembershipEditor } from './raw_membership_editor';
import { RawTagEditor } from './raw_tag_editor';
import { Restore } from './restore';
import { Save } from './save';
import { Scale } from './scale';
import { SelectionList } from './selection_list';
import { Sidebar } from './sidebar';
import { SourceSwitch } from './source_switch';
import { Spinner } from './spinner';
import { Splash } from './splash';
import { Status } from './status';
import { Success } from './success';
import { TagReference } from './tag_reference';
import { Toggle } from './toggle';
import { tooltipHtml } from './tooltipHtml';
import { UndoRedo } from './undo_redo';
import { ViewOnOSM } from './view_on_osm';
import { Zoom } from './zoom';
export {ui};
ui.preset = preset;
Object.keys(presetObj).map(function(p) {
ui.preset[p] = presetObj[p];
});
// Need to do for test cases
ui.intro = intro;
ui.Account = Account;
ui.Attribution = Attribution;
ui.Background = Background;
ui.cmd = cmd;
ui.Commit = Commit;
ui.confirm = confirm;
ui.Conflicts = Conflicts;
ui.Contributors = Contributors;
ui.Disclosure = Disclosure;
ui.EntityEditor = EntityEditor;
ui.FeatureInfo = FeatureInfo;
ui.FeatureList = FeatureList;
ui.flash = flash;
ui.FullScreen = FullScreen;
ui.Geolocate = Geolocate;
ui.Help = Help;
ui.Info = Info;
ui.Inspector = Inspector;
ui.intro = intro;
ui.Lasso = Lasso;
ui.Loading = Loading;
ui.MapData = MapData;
ui.MapInMap = MapInMap;
ui.modal = modal;
ui.Modes = Modes;
ui.Notice = Notice;
ui.preset = preset;
ui.PresetIcon = PresetIcon;
ui.PresetList = PresetList;
ui.RadialMenu = RadialMenu;
ui.RawMemberEditor = RawMemberEditor;
ui.RawMembershipEditor = RawMembershipEditor;
ui.RawTagEditor = RawTagEditor;
ui.Restore = Restore;
ui.Save = Save;
ui.Scale = Scale;
ui.SelectionList = SelectionList;
ui.Sidebar = Sidebar;
ui.SourceSwitch = SourceSwitch;
ui.Spinner = Spinner;
ui.Splash = Splash;
ui.Status = Status;
ui.Success = Success;
ui.TagReference = TagReference;
ui.Toggle = Toggle;
ui.tooltipHtml = tooltipHtml;
ui.UndoRedo = UndoRedo;
ui.ViewOnOSM = ViewOnOSM;
ui.Zoom = Zoom;
export { init } from './init';
export { fields } from './fields/index';
export { Account } from './account';
export { Attribution } from './attribution';
export { Background } from './background';
export { cmd } from './cmd';
export { Commit } from './commit';
export { confirm } from './confirm';
export { Conflicts } from './conflicts';
export { Contributors } from './contributors';
export { Disclosure } from './disclosure';
export { EntityEditor } from './entity_editor';
export { FeatureInfo } from './feature_info';
export { FeatureList } from './feature_list';
export { flash } from './flash';
export { FullScreen } from './full_screen';
export { Geolocate } from './geolocate';
export { Help } from './help';
export { Info } from './info';
export { Inspector } from './inspector';
export { intro } from './intro';
export { Lasso } from './lasso';
export { Loading } from './loading';
export { MapData } from './map_data';
export { MapInMap } from './map_in_map';
export { modal } from './modal';
export { Modes } from './modes';
export { Notice } from './notice';
export { preset } from './preset';
export { PresetIcon } from './preset_icon';
export { PresetList } from './preset_list';
export { RadialMenu } from './radial_menu';
export { RawMemberEditor } from './raw_member_editor';
export { RawMembershipEditor } from './raw_membership_editor';
export { RawTagEditor } from './raw_tag_editor';
export { Restore } from './restore';
export { Save } from './save';
export { Scale } from './scale';
export { SelectionList } from './selection_list';
export { Sidebar } from './sidebar';
export { SourceSwitch } from './source_switch';
export { Spinner } from './spinner';
export { Splash } from './splash';
export { Status } from './status';
export { Success } from './success';
export { TagReference } from './tag_reference';
export { Toggle } from './toggle';
export { tooltipHtml } from './tooltipHtml';
export { UndoRedo } from './undo_redo';
export { ViewOnOSM } from './view_on_osm';
export { Zoom } from './zoom';
import {
Account,
Attribution,
Background,
cmd,
Contributors,
FeatureInfo,
FullScreen,
Geolocate,
Help,
Info,
Loading,
MapData,
MapInMap,
Modes,
Restore,
Save,
Scale,
Sidebar,
Spinner,
Splash,
Status,
UndoRedo,
Zoom
} from './core/index';
import { fields } from './fields/index';
import { Account } from './account';
import { Attribution } from './attribution';
import { Background } from './background';
import { cmd } from './cmd';
import { Commit } from './commit';
import { confirm } from './confirm';
import { Conflicts } from './conflicts';
import { Contributors } from './contributors';
import { Disclosure } from './disclosure';
import { EntityEditor } from './entity_editor';
import { FeatureInfo } from './feature_info';
import { FeatureList } from './feature_list';
import { flash } from './flash';
import { FullScreen } from './full_screen';
import { Geolocate } from './geolocate';
import { Help } from './help';
import { Info } from './info';
import { Inspector } from './inspector';
import { intro } from './intro/index';
import { Lasso } from './lasso';
import { Loading } from './loading';
import { MapData } from './map_data';
import { MapInMap } from './map_in_map';
import { modal } from './modal';
import { Modes } from './modes';
import { Notice } from './notice';
import { preset } from './preset';
import { PresetIcon } from './preset_icon';
import { PresetList } from './preset_list';
import { RadialMenu } from './radial_menu';
import { RawMemberEditor } from './raw_member_editor';
import { RawMembershipEditor } from './raw_membership_editor';
import { RawTagEditor } from './raw_tag_editor';
import { Restore } from './restore';
import { Save } from './save';
import { Scale } from './scale';
import { SelectionList } from './selection_list';
import { Sidebar } from './sidebar';
import { SourceSwitch } from './source_switch';
import { Spinner } from './spinner';
import { Splash } from './splash';
import { Status } from './status';
import { Success } from './success';
import { TagReference } from './tag_reference';
import { Toggle } from './toggle';
import { tooltipHtml } from './tooltipHtml';
import { UndoRedo } from './undo_redo';
import { ViewOnOSM } from './view_on_osm';
import { Zoom } from './zoom';
import { Defs, Icon } from '../svg/index';
import { Hash } from '../behavior/index';
import { Browse } from '../modes/index';
export function ui(context) {
export function init(context) {
function render(container) {
var map = context.map();
......@@ -254,7 +279,66 @@ export function ui(context) {
});
}
//TODO: figure this sidebar
ui.sidebar = Sidebar(context);
return ui;
}
//
// ui.preset = preset;
// Object.keys(fields).map(function(p) {
// ui.preset[p] = fields[p];
// });
//
// ui.intro = intro;
// ui.Account = Account;
// ui.Attribution = Attribution;
// ui.Background = Background;
// ui.cmd = cmd;
// ui.Commit = Commit;
// ui.confirm = confirm;
// ui.Conflicts = Conflicts;
// ui.Contributors = Contributors;
// ui.Disclosure = Disclosure;
// ui.EntityEditor = EntityEditor;
// ui.FeatureInfo = FeatureInfo;
// ui.FeatureList = FeatureList;
// ui.flash = flash;
// ui.FullScreen = FullScreen;
// ui.Geolocate = Geolocate;
// ui.Help = Help;
// ui.Info = Info;
// ui.Inspector = Inspector;
// ui.intro = intro;
// ui.Lasso = Lasso;
// ui.Loading = Loading;
// ui.MapData = MapData;
// ui.MapInMap = MapInMap;
// ui.modal = modal;
// ui.Modes = Modes;
// ui.Notice = Notice;
// ui.preset = preset;
// ui.PresetIcon = PresetIcon;
// ui.PresetList = PresetList;
// ui.RadialMenu = RadialMenu;
// ui.RawMemberEditor = RawMemberEditor;
// ui.RawMembershipEditor = RawMembershipEditor;
// ui.RawTagEditor = RawTagEditor;
// ui.Restore = Restore;
// ui.Save = Save;
// ui.Scale = Scale;
// ui.SelectionList = SelectionList;
// ui.Sidebar = Sidebar;
// ui.SourceSwitch = SourceSwitch;
// ui.Spinner = Spinner;
// ui.Splash = Splash;
// ui.Status = Status;
// ui.Success = Success;
// ui.TagReference = TagReference;
// ui.Toggle = Toggle;
// ui.tooltipHtml = tooltipHtml;
// ui.UndoRedo = UndoRedo;
// ui.ViewOnOSM = ViewOnOSM;
// ui.Zoom = Zoom;
import { intro } from '../core/index';
import { icon, pad } from './helper';
export function area(context, reveal) {
var event = d3.dispatch('done'),
......@@ -13,7 +13,7 @@ export function area(context, reveal) {
corner = [-85.63565411045074, 41.9417715536927];
context.map().centerZoom(playground, 19);
reveal('button.add-area',
t('intro.areas.add', { button: intro.icon('#icon-area', 'pre-text') }),
t('intro.areas.add', { button: icon('#icon-area', 'pre-text') }),
{ tooltipClass: 'intro-areas-add' });
context.on('enter.intro', addArea);
......@@ -23,12 +23,12 @@ export function area(context, reveal) {
context.on('enter.intro', drawArea);
var padding = 120 * Math.pow(2, context.map().zoom() - 19);
var pointBox = intro.pad(corner, padding, context);
var pointBox = pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'));
context.map().on('move.intro', function() {
padding = 120 * Math.pow(2, context.map().zoom() - 19);
pointBox = intro.pad(corner, padding, context);
pointBox = pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'), {duration: 0});
});
}
......@@ -38,12 +38,12 @@ export function area(context, reveal) {
context.on('enter.intro', enterSelect);
var padding = 150 * Math.pow(2, context.map().zoom() - 19);
var pointBox = intro.pad(playground, padding, context);
var pointBox = pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 19);
pointBox = intro.pad(playground, padding, context);
pointBox = pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'), {duration: 0});
});
}
......@@ -72,7 +72,7 @@ export function area(context, reveal) {
function selectedPreset() {
reveal('.pane',
t('intro.areas.describe', { button: intro.icon('#icon-apply', 'pre-text') }));
t('intro.areas.describe', { button: icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
};
......
export function pointBox (point, context) {
var rect = context.surfaceRect();
point = context.projection(point);
return {
left: point[0] + rect.left - 30,
top: point[1] + rect.top - 50,
width: 60,
height: 70
};
}
export function pad (box, padding, context) {
if (box instanceof Array) {
var rect = context.surfaceRect();
box = context.projection(box);
box = {
left: box[0] + rect.left,
top: box[1] + rect.top
};
}
return {
left: box.left - padding,
top: box.top - padding,
width: (box.width || 0) + 2 * padding,
height: (box.width || 0) + 2 * padding