From 1431f71f7bb89dacf9b812ea1ab589448c22c6b0 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 15 Mar 2013 15:49:58 -0400 Subject: [PATCH] Transition between preset grid and tag editor panes. Fixes #1056 --- css/app.css | 8 ++++++-- js/id/ui/background.js | 3 ++- js/id/ui/inspector.js | 29 +++++++++++++++++++++++++---- js/id/ui/preset_grid.js | 11 ++++++++--- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/css/app.css b/css/app.css index d6d38e6bd..a596cd1de 100644 --- a/css/app.css +++ b/css/app.css @@ -305,6 +305,12 @@ form.hide { background-size:5px 5px; } +.pane { + position:absolute; + width:100%; + height:100%; +} + /* Buttons */ button { @@ -757,7 +763,6 @@ a.selected:hover .toggle.icon { background-position: -40px -180px;} left: 10px; top: 20px; pointer-events: none; - z-index: 2; } .preset-grid-search-wrap input { @@ -770,7 +775,6 @@ a.selected:hover .toggle.icon { background-position: -40px -180px;} text-indent: 30px; height: 100%; position: absolute; - z-index: 1; } .preset-search-result { diff --git a/js/id/ui/background.js b/js/id/ui/background.js index 21e710dc2..5ea9d963b 100644 --- a/js/id/ui/background.js +++ b/js/id/ui/background.js @@ -200,7 +200,8 @@ iD.ui.Background = function(context) { .on('click', function() { var exp = d3.select(this).classed('expanded'); nudge_container.style('display', exp ? 'none' : 'block'); - d3.select(this).classed('expanded', !exp); + d3.select(this) + .classed('expanded', !exp); d3.event.preventDefault(); }); diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 4ad63ef50..c80bef04c 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -6,13 +6,28 @@ iD.ui.Inspector = function(context) { function inspector(selection) { var entity = selection.datum(); + var presetLayer = selection + .append('div') + .style('right', '0px') + .classed('pane', true); + + var tagLayer = selection + .append('div') + .style('right', '0px') + .classed('pane', true); + var presetGrid = iD.ui.PresetGrid(context) .entity(entity) .on('close', function() { event.close(); }) .on('choose', function(preset) { - selection.call(tagEditor, preset); + tagLayer + .style('right', '-500px') + .style('display', 'block') + .call(tagEditor, preset) + .transition() + .style('right', '0px'); }); tagEditor = iD.ui.TagEditor(context) @@ -24,12 +39,18 @@ iD.ui.Inspector = function(context) { event.close(entity); }) .on('choose', function() { - selection.call(presetGrid, true); + tagLayer + .transition() + .style('right', '-500px') + .each('end', function() { + d3.select(this).style('display', 'none'); + }); + presetLayer.call(presetGrid, true); }); - selection.call(initial ? presetGrid : tagEditor); + if (initial) presetLayer.call(presetGrid); + else tagLayer.call(tagEditor); - selection.call(iD.ui.Toggle(true)); } inspector.tags = function() { diff --git a/js/id/ui/preset_grid.js b/js/id/ui/preset_grid.js index 85136fbfd..482364e8c 100644 --- a/js/id/ui/preset_grid.js +++ b/js/id/ui/preset_grid.js @@ -23,8 +23,6 @@ iD.ui.PresetGrid = function(context) { .attr('class', 'preset-grid inspector-body fillL inspector-body-' + entity.geometry(context.graph())) .call(drawGrid, context.presets().defaults(entity, 12)); - searchwrap.append('span').attr('class', 'icon search'); - function keydown() { // hack to let delete shortcut work when search is autofocused if (search.property('value').length === 0 && @@ -53,7 +51,10 @@ iD.ui.PresetGrid = function(context) { grid.classed('filtered', value.length); if (value.length) { var results = presets.search(value); - message.text(t('inspector.results', {n: results.collection.length, search: value})); + message.text(t('inspector.results', { + n: results.collection.length, + search: value + })); grid.call(drawGrid, results); } else { grid.call(drawGrid, context.presets().defaults(entity, 12)); @@ -67,6 +68,10 @@ iD.ui.PresetGrid = function(context) { .attr('type', 'search') .on('keydown', keydown) .on('keyup', keyup); + + searchwrap.append('span') + .attr('class', 'icon search'); + search.node().focus(); if (preset) {