From 6e5fbc0e4a1e55cfaa602ddf917222bc8f9cdf72 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 8 Jan 2013 11:59:13 -0500 Subject: [PATCH] Hide and refresh undo tooltips as needed --- js/id/id.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index cdd8260d6..ac48d7878 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -84,23 +84,22 @@ window.iD = function(container) { }); var undo_buttons = bar.append('div') - .attr('class', 'buttons-joined'); + .attr('class', 'buttons-joined'), + undo_tooltip = bootstrap.tooltip().placement('bottom'); undo_buttons.append('button') .attr({ id: 'undo', 'class': 'narrow' }) .property('disabled', true) .html("") .on('click', history.undo) - .call(bootstrap.tooltip() - .placement('bottom')); + .call(undo_tooltip); undo_buttons.append('button') .attr({ id: 'redo', 'class': 'narrow' }) .property('disabled', true) .html("") .on('click', history.redo) - .call(bootstrap.tooltip() - .placement('bottom')); + .call(undo_tooltip); container.append('div') .attr('class', 'user-container pad1 fillD about-block') @@ -246,13 +245,21 @@ window.iD = function(container) { var undo = history.undoAnnotation(), redo = history.redoAnnotation(); + function refreshTooltip(selection) { + if (selection.property('tooltipVisible')) { + selection.call(undo_tooltip.show); + } + } + bar.select('#undo') .property('disabled', !undo) - .attr('data-original-title', undo); + .attr('data-original-title', undo) + .call(undo ? refreshTooltip : undo_tooltip.hide); bar.select('#redo') .property('disabled', !redo) - .attr('data-original-title', redo); + .attr('data-original-title', redo) + .call(redo ? refreshTooltip : undo_tooltip.hide); }); window.onresize = function() {