Add icons to operation flash messages

This commit is contained in:
Bryan Housel
2017-02-16 10:20:37 -05:00
parent 3fc36b66a9
commit 1db4ea86f7
2 changed files with 59 additions and 5 deletions

View File

@@ -575,9 +575,22 @@ button.save.has-count .count::before {
#flash .content {
margin: 0 auto;
padding: 10px;
padding: 6px;
max-width: 50%;
border-radius: 3px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
#flash svg.operation-icon {
width: 36px;
height: 36px;
}
#flash div.operation-tip {
margin: 0 10px;
}
/* Header for modals / panes
@@ -3734,6 +3747,11 @@ img.tile-removing {
-ms-filter: "FlipH";
}
[dir='rtl'] #flash .content {
display: flex;
flex-direction: row-reverse;
}
/* footer */
[dir='rtl'] #scale-block {
float: right;

View File

@@ -1,6 +1,6 @@
import * as d3 from 'd3';
import { d3keybinding } from '../lib/d3.keybinding.js';
import { uiFlash } from '../ui/index';
import { uiFlash } from '../ui';
/* Creates a keybinding behavior for an operation */
@@ -8,17 +8,53 @@ export function behaviorOperation(context) {
var which, keybinding;
function drawIcon(selection) {
var button = selection
.append('svg')
.attr('class', 'operation-icon')
.append('g')
.attr('class', 'radial-menu-item radial-menu-item-' + which.id)
.attr('transform', 'translate(18,18)')
.classed('disabled', which.disabled());
button
.append('circle')
.attr('r', 15);
button
.append('use')
.attr('transform', 'translate(-10,-10)')
.attr('width', '20')
.attr('height', '20')
.attr('xlink:href', '#operation-' + which.id);
return selection;
}
var behavior = function () {
if (which && which.available() && !context.inIntro()) {
keybinding = d3keybinding('behavior.key.' + which.id);
keybinding.on(which.keys, function() {
d3.event.preventDefault();
var disabled = which.disabled();
if (disabled) {
uiFlash(2500, 500).text(which.tooltip);
uiFlash(2500, 500)
.html('')
.call(drawIcon)
.append('div')
.attr('class', 'operation-tip')
.text(which.tooltip);
} else {
var annotation = which.annotation() || which.title;
uiFlash(1500, 250).text(annotation);
uiFlash(1500, 250)
.html('')
.call(drawIcon)
.append('div')
.attr('class', 'operation-tip')
.text(which.annotation() || which.title);
which();
}
});