mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
Namespace UI components
This commit is contained in:
1
Makefile
1
Makefile
@@ -41,6 +41,7 @@ all: \
|
||||
js/id/renderer/*.js \
|
||||
js/id/svg.js \
|
||||
js/id/svg/*.js \
|
||||
js/id/ui.js \
|
||||
js/id/ui/*.js \
|
||||
js/id/end.js
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<script src="js/id/svg/tag_classes.js"></script>
|
||||
<script src="js/id/svg/vertices.js"></script>
|
||||
|
||||
<script src="js/id/ui.js"></script>
|
||||
<script src='js/id/ui/inspector.js'></script>
|
||||
<script src='js/id/ui/modal.js'></script>
|
||||
<script src='js/id/ui/confirm.js'></script>
|
||||
|
||||
14
js/id/id.js
14
js/id/id.js
@@ -46,13 +46,13 @@ window.iD = function(container) {
|
||||
}
|
||||
}
|
||||
|
||||
notice = iD.notice(bar
|
||||
notice = iD.ui.notice(bar
|
||||
.append('div')
|
||||
.attr('class', 'notice'));
|
||||
|
||||
map.on('move.disable-buttons', disableTooHigh)
|
||||
.on('move.contributors', _.debounce(function() {
|
||||
contributors.call(iD.contributors(map));
|
||||
contributors.call(iD.ui.contributors(map));
|
||||
}, 1000));
|
||||
|
||||
buttons.append('span')
|
||||
@@ -96,7 +96,7 @@ window.iD = function(container) {
|
||||
|
||||
var save_button = bar.append('button')
|
||||
.attr('class', 'save action wide')
|
||||
.call(iD.save().map(map));
|
||||
.call(iD.ui.save().map(map));
|
||||
|
||||
history.on('change.warn-unload', function() {
|
||||
var changes = history.changes(),
|
||||
@@ -129,14 +129,14 @@ window.iD = function(container) {
|
||||
|
||||
if (navigator.geolocation) {
|
||||
container.append('div')
|
||||
.call(iD.geolocate(map));
|
||||
.call(iD.ui.geolocate(map));
|
||||
}
|
||||
|
||||
var gc = container.append('div').attr('class', 'geocode-control map-control')
|
||||
.call(iD.geocoder().map(map));
|
||||
.call(iD.ui.geocoder().map(map));
|
||||
|
||||
container.append('div').attr('class', 'map-control layerswitcher-control')
|
||||
.call(iD.layerswitcher(map));
|
||||
.call(iD.ui.layerswitcher(map));
|
||||
|
||||
container.append('div')
|
||||
.attr('class', 'inspector-wrap fillL')
|
||||
@@ -209,7 +209,7 @@ window.iD = function(container) {
|
||||
.center([-77.02271,38.90085]);
|
||||
}
|
||||
|
||||
d3.select('.user-container').call(iD.userpanel(connection)
|
||||
d3.select('.user-container').call(iD.ui.userpanel(connection)
|
||||
.on('logout', connection.logout)
|
||||
.on('login', connection.authenticate));
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ iD.modes.Select = function (entity) {
|
||||
entity: entity
|
||||
};
|
||||
|
||||
var inspector = iD.Inspector(),
|
||||
var inspector = iD.ui.inspector(),
|
||||
behaviors;
|
||||
|
||||
function remove() {
|
||||
|
||||
@@ -67,7 +67,7 @@ iD.OAuth = function() {
|
||||
o.oauth_signature = ohauth.signature(oauth_secret, '',
|
||||
ohauth.baseString('POST', url, o));
|
||||
|
||||
var l = iD.loading('contacting openstreetmap...');
|
||||
var l = iD.ui.loading('contacting openstreetmap...');
|
||||
|
||||
// it would make more sense to have this code within the callback
|
||||
// to oauth.xhr below. however, it needs to be directly within a
|
||||
@@ -116,7 +116,7 @@ iD.OAuth = function() {
|
||||
var request_token_secret = token('oauth_request_token_secret');
|
||||
o.oauth_signature = ohauth.signature(oauth_secret, request_token_secret,
|
||||
ohauth.baseString('POST', url, o));
|
||||
var l = iD.loading('contacting openstreetmap...');
|
||||
var l = iD.ui.loading('contacting openstreetmap...');
|
||||
|
||||
function accessTokenDone(err, xhr) {
|
||||
if (err) callback(err);
|
||||
|
||||
1
js/id/ui.js
Normal file
1
js/id/ui.js
Normal file
@@ -0,0 +1 @@
|
||||
iD.ui = {};
|
||||
@@ -1,6 +1,6 @@
|
||||
iD.commit = function() {
|
||||
iD.ui.commit = function() {
|
||||
var event = d3.dispatch('cancel', 'save');
|
||||
|
||||
|
||||
function zipSame(d) {
|
||||
var c = [], n = -1;
|
||||
for (var i = 0; i < d.length; i++) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
iD.confirm = function() {
|
||||
var modal = iD.modal();
|
||||
iD.ui.confirm = function() {
|
||||
var modal = iD.ui.modal();
|
||||
modal.select('.modal').classed('modal-alert', true);
|
||||
modal.select('.content')
|
||||
.classed('modal-section', true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.contributors = function(map) {
|
||||
iD.ui.contributors = function(map) {
|
||||
|
||||
function contributors(selection) {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
iD.flash = function() {
|
||||
var modal = iD.modal();
|
||||
iD.ui.flash = function() {
|
||||
var modal = iD.ui.modal();
|
||||
|
||||
modal.select('.modal').classed('modal-alert', true);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.geocoder = function() {
|
||||
iD.ui.geocoder = function() {
|
||||
|
||||
var map;
|
||||
|
||||
@@ -11,7 +11,7 @@ iD.geocoder = function() {
|
||||
if (err) return hide();
|
||||
hide();
|
||||
if (!resp.results.length) {
|
||||
return iD.flash()
|
||||
return iD.ui.flash()
|
||||
.select('.content')
|
||||
.text('No location found for "' + resp.query[0] + '"');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.geolocate = function(map) {
|
||||
iD.ui.geolocate = function(map) {
|
||||
|
||||
function success(position) {
|
||||
map.center([position.coords.longitude, position.coords.latitude]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.Inspector = function() {
|
||||
iD.ui.inspector = function() {
|
||||
var event = d3.dispatch('changeTags', 'changeWayDirection',
|
||||
'update', 'remove', 'close', 'splitWay'),
|
||||
taginfo = iD.taginfo(),
|
||||
@@ -155,12 +155,12 @@ iD.Inspector = function() {
|
||||
if (en.on_way) types.push('line');
|
||||
en.types = types;
|
||||
console.log(en);
|
||||
iD.modal()
|
||||
iD.ui.modal()
|
||||
.select('.content')
|
||||
.datum(en)
|
||||
.call(iD.tagReference);
|
||||
.call(iD.ui.tagReference);
|
||||
} else {
|
||||
iD.flash()
|
||||
iD.ui.flash()
|
||||
.select('.content')
|
||||
.text('This is no documentation available for this tag combination');
|
||||
}
|
||||
@@ -168,7 +168,7 @@ iD.Inspector = function() {
|
||||
} else if (d.key) {
|
||||
taginfo.values(params, function(err, values) {
|
||||
if (values.data.length) {
|
||||
iD.modal()
|
||||
iD.ui.modal()
|
||||
.select('.content')
|
||||
.datum({
|
||||
data: values.data,
|
||||
@@ -177,7 +177,7 @@ iD.Inspector = function() {
|
||||
})
|
||||
.call(iD.keyReference);
|
||||
} else {
|
||||
iD.flash()
|
||||
iD.ui.flash()
|
||||
.select('.content')
|
||||
.text('This is no documentation available for this key');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.keyReference = function(selection) {
|
||||
iD.ui.keyReference = function(selection) {
|
||||
selection.each(function() {
|
||||
|
||||
var selection = d3.select(this),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.layerswitcher = function(map) {
|
||||
iD.ui.layerswitcher = function(map) {
|
||||
var event = d3.dispatch('cancel', 'save'),
|
||||
sources = [{
|
||||
name: 'Bing',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
iD.loading = function(message) {
|
||||
var modal = iD.modal();
|
||||
iD.ui.loading = function(message) {
|
||||
var modal = iD.ui.modal();
|
||||
|
||||
var loadertext = modal.select('.content')
|
||||
.classed('loading-modal', true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.modal = function() {
|
||||
iD.ui.modal = function() {
|
||||
var animate = d3.select('div.modal').empty();
|
||||
|
||||
d3.select('div.modal').transition()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.notice = function(selection) {
|
||||
iD.ui.notice = function(selection) {
|
||||
var message = '',
|
||||
notice = {};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.save = function() {
|
||||
iD.ui.save = function() {
|
||||
|
||||
var map;
|
||||
|
||||
@@ -16,7 +16,7 @@ iD.save = function() {
|
||||
|
||||
function commit(e) {
|
||||
d3.select('.shaded').remove();
|
||||
var l = iD.loading('Uploading changes to OpenStreetMap.');
|
||||
var l = iD.ui.loading('Uploading changes to OpenStreetMap.');
|
||||
connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) {
|
||||
l.remove();
|
||||
history.reset();
|
||||
@@ -28,14 +28,14 @@ iD.save = function() {
|
||||
.text('An error occurred while trying to save');
|
||||
desc.append('p').text(err.responseText);
|
||||
} else {
|
||||
var modal = iD.modal();
|
||||
var modal = iD.ui.modal();
|
||||
modal.select('.content')
|
||||
.classed('success-modal', true)
|
||||
.datum({
|
||||
id: changeset_id,
|
||||
comment: e.comment
|
||||
})
|
||||
.call(iD.success()
|
||||
.call(iD.ui.success()
|
||||
.on('cancel', function() {
|
||||
modal.remove();
|
||||
}));
|
||||
@@ -49,13 +49,13 @@ iD.save = function() {
|
||||
|
||||
if (has_changes) {
|
||||
connection.authenticate(function(err) {
|
||||
var modal = iD.modal();
|
||||
var modal = iD.ui.modal();
|
||||
var changes = history.changes();
|
||||
changes.connection = connection;
|
||||
modal.select('.content')
|
||||
.classed('commit-modal', true)
|
||||
.datum(changes)
|
||||
.call(iD.commit()
|
||||
.call(iD.ui.commit()
|
||||
.on('cancel', function() {
|
||||
modal.remove();
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.success = function() {
|
||||
iD.ui.success = function() {
|
||||
var event = d3.dispatch('cancel', 'save');
|
||||
|
||||
function success(selection) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.tagReference = function(selection) {
|
||||
iD.ui.tagReference = function(selection) {
|
||||
selection.each(function() {
|
||||
function g(x) { return function(d) { return d[x]; }; }
|
||||
var selection = d3.select(this);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.userpanel = function(connection) {
|
||||
iD.ui.userpanel = function(connection) {
|
||||
var event = d3.dispatch('logout', 'login');
|
||||
|
||||
function user(selection) {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<script src="../js/id/svg/tag_classes.js"></script>
|
||||
<script src="../js/id/svg/vertices.js"></script>
|
||||
|
||||
<script src='../js/id/ui.js'></script>
|
||||
<script src='../js/id/ui/inspector.js'></script>
|
||||
<script src='../js/id/ui/commit.js'></script>
|
||||
<script src='../js/id/ui/loading.js'></script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe("Geocoder", function () {
|
||||
describe("iD.ui.geocoder", function () {
|
||||
it('can be instantiated', function () {
|
||||
var geocoder = iD.geocoder();
|
||||
var geocoder = iD.ui.geocoder();
|
||||
expect(geocoder).to.be.ok;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
describe("iD.Inspector", function () {
|
||||
describe("iD.ui.inspector", function () {
|
||||
var inspector, element,
|
||||
tags = {highway: 'residential'},
|
||||
entity;
|
||||
|
||||
function render() {
|
||||
inspector = iD.Inspector();
|
||||
inspector = iD.ui.inspector();
|
||||
element = d3.select('body')
|
||||
.append('div')
|
||||
.attr('id', 'inspector-wrap')
|
||||
|
||||
Reference in New Issue
Block a user