mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
ecfe8ce943
If localStorage writes were free, we'd want to just save on every history change. Second best is to debounce the write. Writing on mode change is problematic; it sometimes happens when not desired and sometimes doesn't happen when desired. Fixes #1857.
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
iD.modes.Browse = function(context) {
|
|
var mode = {
|
|
button: 'browse',
|
|
id: 'browse',
|
|
title: t('modes.browse.title'),
|
|
description: t('modes.browse.description'),
|
|
key: '1'
|
|
}, sidebar;
|
|
|
|
var behaviors = [
|
|
iD.behavior.Hover(context)
|
|
.on('hover', context.ui().sidebar.hover),
|
|
iD.behavior.Select(context),
|
|
iD.behavior.Lasso(context),
|
|
iD.modes.DragNode(context).behavior];
|
|
|
|
mode.enter = function() {
|
|
behaviors.forEach(function(behavior) {
|
|
context.install(behavior);
|
|
});
|
|
|
|
// Get focus on the body.
|
|
if (document.activeElement) {
|
|
document.activeElement.blur();
|
|
}
|
|
|
|
if (sidebar) {
|
|
context.ui().sidebar.show(sidebar);
|
|
} else {
|
|
context.ui().sidebar.select(null);
|
|
}
|
|
};
|
|
|
|
mode.exit = function() {
|
|
behaviors.forEach(function(behavior) {
|
|
context.uninstall(behavior);
|
|
});
|
|
|
|
if (sidebar) {
|
|
context.ui().sidebar.hide(sidebar);
|
|
}
|
|
};
|
|
|
|
mode.sidebar = function(_) {
|
|
if (!arguments.length) return sidebar;
|
|
sidebar = _;
|
|
return mode;
|
|
};
|
|
|
|
return mode;
|
|
};
|