Commit 9f2a251d authored by Kushan Joshi's avatar Kushan Joshi

Fixing Interdependecy between ui.preset and ui.core

parent 94c5f432
......@@ -45,11 +45,7 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
MODULE_TARGETS = \
js/lib/id/index.js \
js/lib/id/services.js \
js/lib/id/ui/index.js \
js/lib/id/svg.js \
js/lib/id/ui/core.js \
js/lib/id/ui/intro.js \
js/lib/id/ui/preset.js
js/lib/id/svg.js
js/lib/id/index.js: $(shell find modules/index.js -type f)
@rm -f $@
......@@ -63,22 +59,6 @@ js/lib/id/svg.js: $(shell find modules/svg -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.svg modules/svg/index.js --no-strict -o $@
js/lib/id/ui/index.js: $(shell find modules/ui -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD modules/ui/ui.js --no-strict -o $@
js/lib/id/ui/core.js: $(shell find modules/ui/core -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui modules/ui/core/index.js --no-strict -o $@
js/lib/id/ui/intro.js: $(shell find modules/ui/intro -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui.intro modules/ui/intro/index.js --no-strict -o $@
js/lib/id/ui/preset.js: $(shell find modules/ui/preset -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui.preset modules/ui/preset/index.js --no-strict -o $@
dist/iD.js: \
js/lib/bootstrap-tooltip.js \
js/lib/d3.v3.js \
......
......@@ -38,11 +38,6 @@
<script src='js/lib/id/svg.js'></script>
<script src='js/lib/id/services.js'></script>
<script src='js/lib/id/ui/index.js'></script>
<script src='js/lib/id/ui/core.js'></script>
<script src='js/lib/id/ui/intro.js'></script>
<script src='js/lib/id/ui/preset.js'></script>
<script src='data/data_dev.js'></script>
<script src='js/lib/locale.js'></script>
......
This diff is collapsed.
This diff is collapsed.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.iD = global.iD || {})));
}(this, function (exports) { 'use strict';
function ui(context) {
function render(container) {
var map = context.map();
if (iD.detect().opera) container.classed('opera', true);
var hash = iD.behavior.Hash(context);
hash();
if (!hash.hadHash) {
map.centerZoom([0, 0], 2);
}
container.append('svg')
.attr('id', 'defs')
.call(iD.svg.Defs(context));
container.append('div')
.attr('id', 'sidebar')
.attr('class', 'col4')
.call(ui.sidebar);
var content = container.append('div')
.attr('id', 'content');
var bar = content.append('div')
.attr('id', 'bar')
.attr('class', 'fillD');
content.append('div')
.attr('id', 'map')
.call(map);
content
.call(iD.ui.MapInMap(context));
content.append('div')
.call(iD.ui.Info(context));
bar.append('div')
.attr('class', 'spacer col4');
var limiter = bar.append('div')
.attr('class', 'limiter');
limiter.append('div')
.attr('class', 'button-wrap joined col3')
.call(iD.ui.Modes(context), limiter);
limiter.append('div')
.attr('class', 'button-wrap joined col1')
.call(iD.ui.UndoRedo(context));
limiter.append('div')
.attr('class', 'button-wrap col1')
.call(iD.ui.Save(context));
bar.append('div')
.attr('class', 'full-screen')
.call(iD.ui.FullScreen(context));
bar.append('div')
.attr('class', 'spinner')
.call(iD.ui.Spinner(context));
var controls = bar.append('div')
.attr('class', 'map-controls');
controls.append('div')
.attr('class', 'map-control zoombuttons')
.call(iD.ui.Zoom(context));
controls.append('div')
.attr('class', 'map-control geolocate-control')
.call(iD.ui.Geolocate(context));
controls.append('div')
.attr('class', 'map-control background-control')
.call(iD.ui.Background(context));
controls.append('div')
.attr('class', 'map-control map-data-control')
.call(iD.ui.MapData(context));
controls.append('div')
.attr('class', 'map-control help-control')
.call(iD.ui.Help(context));
var about = content.append('div')
.attr('id', 'about');
about.append('div')
.attr('id', 'attrib')
.call(iD.ui.Attribution(context));
var footer = about.append('div')
.attr('id', 'footer')
.attr('class', 'fillD');
footer.append('div')
.attr('class', 'api-status')
.call(iD.ui.Status(context));
footer.append('div')
.attr('id', 'scale-block')
.call(iD.ui.Scale(context));
var aboutList = footer.append('div')
.attr('id', 'info-block')
.append('ul')
.attr('id', 'about-list');
if (!context.embed()) {
aboutList.call(iD.ui.Account(context));
}
aboutList.append('li')
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD')
.text(iD.version);
var issueLinks = aboutList.append('li');
issueLinks.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/issues')
.call(iD.svg.Icon('#icon-bug', 'light'))
.call(bootstrap.tooltip()
.title(t('report_a_bug'))
.placement('top')
);
issueLinks.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/blob/master/CONTRIBUTING.md#translating')
.call(iD.svg.Icon('#icon-translate', 'light'))
.call(bootstrap.tooltip()
.title(t('help_translate'))
.placement('top')
);
aboutList.append('li')
.attr('class', 'feature-warning')
.attr('tabindex', -1)
.call(iD.ui.FeatureInfo(context));
aboutList.append('li')
.attr('class', 'user-list')
.attr('tabindex', -1)
.call(iD.ui.Contributors(context));
window.onbeforeunload = function() {
return context.save();
};
window.onunload = function() {
context.history().unlock();
};
var mapDimensions = map.dimensions();
d3.select(window).on('resize.editor', function() {
mapDimensions = content.dimensions(null);
map.dimensions(mapDimensions);
});
function pan(d) {
return function() {
d3.event.preventDefault();
if (!context.inIntro()) context.pan(d);
};
}
// pan amount
var pa = 10;
var keybinding = d3.keybinding('main')
.on('⌫', function() { d3.event.preventDefault(); })
.on('←', pan([pa, 0]))
.on('↑', pan([0, pa]))
.on('→', pan([-pa, 0]))
.on('↓', pan([0, -pa]))
.on('⇧←', pan([mapDimensions[0], 0]))
.on('⇧↑', pan([0, mapDimensions[1]]))
.on('⇧→', pan([-mapDimensions[0], 0]))
.on('⇧↓', pan([0, -mapDimensions[1]]))
.on(iD.ui.cmd('⌘←'), pan([mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↑'), pan([0, mapDimensions[1]]))
.on(iD.ui.cmd('⌘→'), pan([-mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↓'), pan([0, -mapDimensions[1]]));
d3.select(document)
.call(keybinding);
context.enter(iD.modes.Browse(context));
context.container()
.call(iD.ui.Splash(context))
.call(iD.ui.Restore(context));
var authenticating = iD.ui.Loading(context)
.message(t('loading_auth'));
context.connection()
.on('authenticating.ui', function() {
context.container()
.call(authenticating);
})
.on('authenticated.ui', function() {
authenticating.close();
});
}
function ui(container) {
context.container(container);
context.loadLocale(function() {
render(container);
});
}
ui.sidebar = iD.ui.Sidebar(context);
return ui;
}
ui.tooltipHtml = function(text, key) {
var s = '<span>' + text + '</span>';
if (key) {
s += '<div class="keyhint-wrap">' +
'<span> ' + (t('tooltip_keyhint')) + ' </span>' +
'<span class="keyhint"> ' + key + '</span></div>';
}
return s;
};
exports.ui = ui;
Object.defineProperty(exports, '__esModule', { value: true });
}));
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -25,6 +25,7 @@ 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,
......
import { Select, Browse } from '../modes/index';
import { sphericalDistance } from '../geo/index';
import { DeleteMultiple } from '../actions/index';
import { cmd } from '../ui/core/cmd';
export function Delete(selectedIDs, context) {
var action = DeleteMultiple(selectedIDs);
......@@ -70,7 +71,7 @@ export function Delete(selectedIDs, context) {
};
operation.id = 'delete';
operation.keys = [iD.ui.cmd('⌘⌫'), iD.ui.cmd('⌘⌦')];
operation.keys = [cmd('⌘⌫'), cmd('⌘⌦')];
operation.title = t('operations.delete.title');
return operation;
......
import { Icon } from '../../svg/index';
import { setTransform } from '../../util/index';
import { BackgroundSource } from '../../renderer';
import { BackgroundSource } from '../../renderer/index';
import { offsetToMeters, metersToOffset } from '../../geo/index';
import { cmd } from './cmd';
import { MapInMap } from './map_in_map';
......
import { Icon } from '../../svg/index';
import { Entity, Graph } from '../../core/index';
import { Browse } from '../../modes/index';
import { Intro } from '../intro/index';
export function intro(context) {
var step;
......@@ -96,7 +98,7 @@ export function intro(context) {
}
var steps = ['navigation', 'point', 'area', 'line', 'startEditing'].map(function(step, i) {
var s = intro[step](context, reveal)
var s = Intro[step](context, reveal)
.on('done', function() {
entered.filter(function(d) {
return d.title === s.title;
......@@ -157,3 +159,36 @@ export function intro(context) {
}
return intro;
}
intro.pointBox = function(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
};
};
intro.pad = function(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
};
};
intro.icon = function(name, svgklass) {
return '<svg class="icon ' + (svgklass || '') + '">' +
'<use xlink:href="' + name + '"></use></svg>';
};
import { Icon } from '../../svg/index';
import { Browse } from '../../modes/index';
import { ChangePreset } from '../../actions/index';
import { Delete } from '../../operations';
import { Delete } from '../../operations/index';
import { PresetIcon } from './preset_icon';
import { TagReference } from './tag_reference';
......
import { ui } from './ui';
import { presetObj } from './preset/index';
import {
Account,
Attribution,
Background,
cmd,
Commit,
confirm,
Conflicts,
Contributors,
Disclosure,
EntityEditor,
FeatureInfo,
FeatureList,
flash,
FullScreen,
Geolocate,
Help,
Info,
Inspector,
intro,
Lasso,
Loading,
MapData,
MapInMap,
modal,
Modes,
Notice,
preset,
PresetIcon,
PresetList,
RadialMenu,
RawMemberEditor,
RawMembershipEditor,
RawTagEditor,
Restore,
Save,
Scale,
SelectionList,
Sidebar,
SourceSwitch,
Spinner,
Splash,
Status,
Success,
TagReference,
Toggle,
tooltipHtml,
UndoRedo,
ViewOnOSM,
Zoom
} from './core/index';
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;
import { intro } from '../core/index';
export function area(context, reveal) {
var event = d3.dispatch('done'),
timeout;
......@@ -11,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: iD.ui.intro.icon('#icon-area', 'pre-text') }),
t('intro.areas.add', { button: intro.icon('#icon-area', 'pre-text') }),
{ tooltipClass: 'intro-areas-add' });
context.on('enter.intro', addArea);
......@@ -21,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 = iD.ui.intro.pad(corner, padding, context);
var pointBox = intro.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 = iD.ui.intro.pad(corner, padding, context);
pointBox = intro.pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'), {duration: 0});
});
}
......@@ -36,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 = iD.ui.intro.pad(playground, padding, context);
var pointBox = intro.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 = iD.ui.intro.pad(playground, padding, context);
pointBox = intro.pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'), {duration: 0});
});
}
......@@ -70,7 +72,7 @@ export function area(context, reveal) {
function selectedPreset() {
reveal('.pane',
t('intro.areas.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.areas.describe', { button: intro.icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
};
......
export { area } from './area';
export { line } from './line';
export { navigation } from './navigation';
export { point } from './point';
export { startEditing } from './start_editing';
import { area } from './area';
import { line } from './line';
import { navigation } from './navigation';
import { point } from './point';
import { startEditing } from './start_editing';
export var Intro = {
area: area,
line: line,
navigation: navigation,
point: point,
startEditing: startEditing
};
import { intro } from '../core/index';
import { DeleteMultiple } from '../../actions/index';
export function line(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
......@@ -23,7 +26,7 @@ export function line(context, reveal) {
context.map().centerZoom(start, 18);
reveal('button.add-line',
t('intro.lines.add', { button: iD.ui.intro.icon('#icon-line', 'pre-text') }),
t('intro.lines.add', { button: intro.icon('#icon-line', 'pre-text') }),
{ tooltipClass: 'intro-lines-add' });
context.on('enter.intro', addLine);
......@@ -33,12 +36,12 @@ export function line(context, reveal) {
context.on('enter.intro', drawLine);
var padding = 150 * Math.pow(2, context.map().zoom() - 18);
var pointBox = iD.ui.intro.pad(start, padding, context);
var pointBox = intro.pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 18);
pointBox = iD.ui.intro.pad(start, padding, context);
pointBox = intro.pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'), {duration: 0});
});
}
......@@ -49,12 +52,12 @@ export function line(context, reveal) {
context.on('enter.intro', retry);
var padding = 300 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(midpoint, padding, context);
var pointBox = intro.pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}));
context.map().on('move.intro', function() {
padding = 300 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(midpoint, padding, context);
pointBox = intro.pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}), {duration: 0});
});
}
......@@ -62,13 +65,13 @@ export function line(context, reveal) {
// ended line before creating intersection
function retry(mode) {
if (mode.id !== 'select') return;
var pointBox = iD.ui.intro.pad(intersection, 30, context),
var pointBox = intro.pad(intersection, 30, context),
ids = mode.selectedIDs();
reveal(pointBox, t('intro.lines.restart', {name: t('intro.graph.flower_st')}));
d3.select(window).on('mousedown.intro', eventCancel, true);
timeout(function() {
context.replace(iD.actions.DeleteMultiple(ids));
context.replace(DeleteMultiple(ids));
step.exit();
step.enter();
}, 3000);
......@@ -82,12 +85,12 @@ export function line(context, reveal) {
context.on('enter.intro', enterSelect);
var padding = 900 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(centroid, padding, context);
var pointBox = intro.pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'));
context.map().on('move.intro', function() {
padding = 900 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(centroid, padding, context);
pointBox = intro.pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'), {duration: 0});
});
}
......@@ -133,7 +136,7 @@ export function line(context, reveal) {
function roadDetails() {
reveal('.pane',
t('intro.lines.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.lines.describe', { button: intro.icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
......
import { intro } from '../core/index';
export function navigation(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
......@@ -43,11 +45,11 @@ export function navigation(context, reveal) {
context.map().center(hall);
}
var box = iD.ui.intro.pointBox(hall, context);
var box = intro.pointBox(hall, context);
reveal(box, t('intro.navigation.select'));
context.map().on('move.intro', function() {
var box = iD.ui.intro.pointBox(hall, context);
var box = intro.pointBox(hall, context);
reveal(box, t('intro.navigation.select'), {duration: 0});
});
}
......@@ -58,7 +60,7 @@ export function navigation(context, reveal) {
context.map().on('move.intro', null);
set(function() {
reveal('.entity-editor-pane',
t('intro.navigation.pane', { button: iD.ui.intro.icon('#icon-close', 'pre-text') }));
t('intro.navigation.pane', { button: intro.icon('#icon-close', 'pre-text') }));
context.on('exit.intro', streetSearch);
}, 700);
}
......@@ -92,7 +94,7 @@ export function navigation(context, reveal) {
reveal('.entity-editor-pane',
t('intro.navigation.chosen', {
name: t('intro.graph.spring_st'),
button: iD.ui.intro.icon('#icon-close', 'pre-text')
button: intro.icon('#icon-close', 'pre-text')
}));
}, 400);
}
......
import { intro } from '../core/index';