mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 09:19:25 +02:00
Reorganize the code for setting the mode class on the container
This commit is contained in:
@@ -364,6 +364,16 @@ export function uiInit(context) {
|
||||
context.map().toggleHighlightEdited();
|
||||
});
|
||||
|
||||
context
|
||||
.on('enter.editor', function(entered) {
|
||||
container
|
||||
.classed('mode-' + entered.id, true);
|
||||
})
|
||||
.on('exit.editor', function(exited) {
|
||||
container
|
||||
.classed('mode-' + exited.id, false);
|
||||
});
|
||||
|
||||
context.enter(modeBrowse(context));
|
||||
|
||||
if (!_initCounter++) {
|
||||
|
||||
@@ -73,21 +73,6 @@ export function uiToolOldDrawModes(context) {
|
||||
.attr('class', 'joined')
|
||||
.style('display', 'flex');
|
||||
|
||||
context
|
||||
.on('enter.editor', function(entered) {
|
||||
selection.selectAll('button.add-button')
|
||||
.classed('active', function(mode) { return entered.button === mode.button; });
|
||||
context.container()
|
||||
.classed('mode-' + entered.id, true);
|
||||
});
|
||||
|
||||
context
|
||||
.on('exit.editor', function(exited) {
|
||||
context.container()
|
||||
.classed('mode-' + exited.id, false);
|
||||
});
|
||||
|
||||
|
||||
var debouncedUpdate = _debounce(update, 500, { leading: true, trailing: true });
|
||||
|
||||
context.map()
|
||||
@@ -152,7 +137,8 @@ export function uiToolOldDrawModes(context) {
|
||||
// update
|
||||
buttons = buttons
|
||||
.merge(buttonsEnter)
|
||||
.classed('disabled', function(d) { return !enabled(d); });
|
||||
.classed('disabled', function(d) { return !enabled(d); })
|
||||
.classed('active', function(d) { return context.mode() && context.mode().button === d.button; });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,20 +46,6 @@ export function uiToolNotes(context) {
|
||||
|
||||
tool.render = function(selection) {
|
||||
|
||||
context
|
||||
.on('enter.editor.notes', function(entered) {
|
||||
selection.selectAll('button.add-button')
|
||||
.classed('active', function(mode) { return entered.button === mode.button; });
|
||||
context.container()
|
||||
.classed('mode-' + entered.id, true);
|
||||
});
|
||||
|
||||
context
|
||||
.on('exit.editor.notes', function(exited) {
|
||||
context.container()
|
||||
.classed('mode-' + exited.id, false);
|
||||
});
|
||||
|
||||
|
||||
var debouncedUpdate = _debounce(update, 500, { leading: true, trailing: true });
|
||||
|
||||
@@ -123,7 +109,8 @@ export function uiToolNotes(context) {
|
||||
// update
|
||||
buttons = buttons
|
||||
.merge(buttonsEnter)
|
||||
.classed('disabled', function(d) { return !enabled(d); });
|
||||
.classed('disabled', function(d) { return !enabled(d); })
|
||||
.classed('active', function(d) { return context.mode() && context.mode().button === d.button; });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user