Namespace events

Fixes an issue where cursor sometimes stopped working.
This commit is contained in:
John Firebaugh
2013-01-23 18:18:48 -05:00
parent 9041e6470f
commit 5eabb931ff
2 changed files with 22 additions and 22 deletions

View File

@@ -37,7 +37,7 @@ window.iD = function(container) {
.attr('class', function (mode) { return mode.title + ' add-button col3'; })
.attr('data-original-title', function (mode) { return mode.description; })
.call(bootstrap.tooltip().placement('bottom'))
.on('click', function (mode) { controller.enter(mode); });
.on('click.editor', function (mode) { controller.enter(mode); });
function disableTooHigh() {
if (map.zoom() < 16) {
@@ -52,10 +52,10 @@ window.iD = function(container) {
var notice = iD.ui.notice(limiter).message(null);
map.on('move.disable-buttons', disableTooHigh)
.on('move.contributors', _.debounce(function() {
contributors.call(iD.ui.contributors(map));
}, 1000));
map.on('move.editor', _.debounce(function() {
disableTooHigh();
contributors.call(iD.ui.contributors(map));
}, 500));
buttons.append('span')
.attr('class', function(d) {
@@ -64,12 +64,12 @@ window.iD = function(container) {
buttons.append('span').attr('class', 'label').text(function (mode) { return mode.title; });
controller.on('enter', function (entered) {
controller.on('enter.editor', function (entered) {
buttons.classed('active', function (mode) { return entered.button === mode.button; });
container.classed("mode-" + entered.id, true);
});
controller.on('exit', function (exited) {
controller.on('exit.editor', function (exited) {
container.classed("mode-" + exited.id, false);
});
@@ -81,21 +81,21 @@ window.iD = function(container) {
.attr({ id: 'undo', 'class': 'col6' })
.property('disabled', true)
.html("<span class='undo icon'></span><small></small>")
.on('click', history.undo)
.on('click.editor', history.undo)
.call(undo_tooltip);
undo_buttons.append('button')
.attr({ id: 'redo', 'class': 'col6' })
.property('disabled', true)
.html("<span class='redo icon'><small></small>")
.on('click', history.redo)
.on('click.editor', history.redo)
.call(undo_tooltip);
var save_button = limiter.append('div').attr('class','button-wrap col1').append('button')
.attr('class', 'save col12')
.call(iD.ui.save().map(map).controller(controller));
history.on('change.warn-unload', function() {
history.on('change.editor', function() {
window.onbeforeunload = history.hasChanges() ? function() {
return 'You have unsaved changes.';
} : null;
@@ -109,7 +109,7 @@ window.iD = function(container) {
.append('button')
.attr('class', function(d) { return d[0]; })
.attr('title', function(d) { return d[3]; })
.on('click', function(d) { return d[2](); })
.on('click.editor', function(d) { return d[2](); })
.append('span')
.attr('class', function(d) {
return d[0] + ' icon';
@@ -157,7 +157,7 @@ window.iD = function(container) {
aboutList.append('li').attr('class', 'source-switch').append('a').attr('href', '#')
.text('dev')
.on('click', function() {
.on('click.editor', function() {
d3.event.preventDefault();
if (d3.select(this).classed('live')) {
map.flush().connection()
@@ -183,7 +183,7 @@ window.iD = function(container) {
contributors.append('span')
.attr('class', 'contributor-count');
history.on('change.buttons', function() {
history.on('change.editor', function() {
var undo = history.undoAnnotation(),
redo = history.redoAnnotation();
@@ -204,7 +204,7 @@ window.iD = function(container) {
.call(redo ? refreshTooltip : undo_tooltip.hide);
});
d3.select(window).on('resize.map-size', function() {
d3.select(window).on('resize.editor', function() {
map.size(m.size());
});
@@ -228,8 +228,8 @@ window.iD = function(container) {
}
d3.select('.user-container').call(iD.ui.userpanel(connection)
.on('logout', connection.logout)
.on('login', connection.authenticate));
.on('logout.editor', connection.logout)
.on('login.editor', connection.authenticate));
controller.enter(iD.modes.Browse());
}

View File

@@ -45,20 +45,20 @@ iD.Hash = function() {
// do so before any features are loaded. thus wait for the feature to
// be loaded and then select
function willselect(id) {
map.on('drawn.after-draw-select', function() {
map.on('drawn.hash', function() {
var entity = map.history().graph().entity(id);
if (entity === undefined) return;
else selectoff();
controller.enter(iD.modes.Select(entity));
map.on('drawn.after-draw-select', null);
map.on('drawn.hash', null);
});
controller.on('enter', function() {
controller.on('enter.hash', function() {
if (controller.mode.id !== 'browse') selectoff();
});
}
function selectoff() {
map.on('drawn.after-draw-select', null);
map.on('drawn.hash', null);
}
hash.controller = function(_) {
@@ -70,12 +70,12 @@ iD.Hash = function() {
hash.map = function(x) {
if (!arguments.length) return map;
if (map) {
map.off("move", move);
map.on("move.hash", null);
window.removeEventListener("hashchange", hashchange, false);
}
map = x;
if (x) {
map.on("move", move);
map.on("move.hash", move);
window.addEventListener("hashchange", hashchange, false);
if (location.hash) {
var q = iD.util.stringQs(location.hash.substring(1));