From c2ddf67cc0639661d2534ab9c9c90c2b0374a03b Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 4 Feb 2013 11:20:23 -0800 Subject: [PATCH] Show appropriate tooltips for disabled undo/redo buttons Implementing this cross-browser requires using a `.disabled` class rather than the `disabled` property. No browsers except Opera dispatch mouse events on disabled buttons. Fixes #620. --- css/app.css | 11 ++++++++--- js/id/ui.js | 12 ++++++------ locale/en.js | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/css/app.css b/css/app.css index e660d5989..a43133f3d 100644 --- a/css/app.css +++ b/css/app.css @@ -273,7 +273,12 @@ button.active { cursor:url(../img/cursor-pointing.png) 6 1, auto; } -button.active:not([disabled]) { +button.disabled { + background: #6c6c6c; + cursor: auto; +} + +button.active:not([disabled]):not(.disabled) { background: #6bc641; } @@ -450,8 +455,8 @@ button[disabled] .icon.browse { background-position: 0px -40px;} button[disabled] .icon.add-point { background-position: -20px -40px;} button[disabled] .icon.add-line { background-position: -40px -40px;} button[disabled] .icon.add-area { background-position: -60px -40px;} -button[disabled] .icon.undo { background-position: -80px -40px;} -button[disabled] .icon.redo { background-position: -100px -40px;} +button.disabled .icon.undo { background-position: -80px -40px;} +button.disabled .icon.redo { background-position: -100px -40px;} button[disabled] .apply.icon { background-position: -120px -40px;} button[disabled] .save.icon { background-position: -140px -40px;} button[disabled] .close.icon { background-position: -160px -40px;} diff --git a/js/id/ui.js b/js/id/ui.js index 69f20c2fd..f8c58903f 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -91,14 +91,14 @@ iD.ui = function (context) { undo_buttons.append('button') .attr({ id: 'undo', 'class': 'col6' }) - .property('disabled', true) + .classed('disabled', true) .html("") .on('click.editor', history.undo) .call(undo_tooltip); undo_buttons.append('button') .attr({ id: 'redo', 'class': 'col6' }) - .property('disabled', true) + .classed('disabled', true) .html("") .on('click.editor', history.redo) .call(undo_tooltip); @@ -209,13 +209,13 @@ iD.ui = function (context) { } limiter.select('#undo') - .property('disabled', !undo) - .attr('data-original-title', hintprefix('⌘ + Z', undo)) + .classed('disabled', !undo) + .attr('data-original-title', hintprefix('⌘ + Z', undo || t('nothing_to_undo'))) .call(refreshTooltip); limiter.select('#redo') - .property('disabled', !redo) - .attr('data-original-title', hintprefix('⌘ + ⇧ + Z', redo)) + .classed('disabled', !redo) + .attr('data-original-title', hintprefix('⌘ + ⇧ + Z', redo || t('nothing_to_redo'))) .call(refreshTooltip); }); diff --git a/locale/en.js b/locale/en.js index 31d6a13de..b446c4ae4 100644 --- a/locale/en.js +++ b/locale/en.js @@ -141,6 +141,9 @@ locale.en = { "zoom-in": "Zoom In", "zoom-out": "Zoom Out", + nothing_to_undo: "Nothing to undo.", + nothing_to_redo: "Nothing to redo.", + "browser_notice": "This editor is supported in Firefox, Chrome, Safari, Opera, and Internet Explorer 9 and above. Please upgrade your browser or use Potlatch 2 to edit the map.", "layer_settings": "Layer Settings",