Files
iD/modules/ui/view_on_keepRight.js
Quincy Morgan 5435082d9c Revert t function to returning the plain string by default
Add `t.html` function for getting the string with the `lang` attribute
2020-09-22 12:03:29 -04:00

44 lines
1.0 KiB
JavaScript

import { t } from '../core/localizer';
import { services } from '../services';
import { svgIcon } from '../svg/icon';
import { QAItem } from '../osm';
export function uiViewOnKeepRight() {
let _qaItem;
function viewOnKeepRight(selection) {
let url;
if (services.keepRight && (_qaItem instanceof QAItem)) {
url = services.keepRight.issueURL(_qaItem);
}
const link = selection.selectAll('.view-on-keepRight')
.data(url ? [url] : []);
// exit
link.exit()
.remove();
// enter
const linkEnter = link.enter()
.append('a')
.attr('class', 'view-on-keepRight')
.attr('target', '_blank')
.attr('rel', 'noopener') // security measure
.attr('href', d => d)
.call(svgIcon('#iD-icon-out-link', 'inline'));
linkEnter
.append('span')
.html(t.html('inspector.view_on_keepRight'));
}
viewOnKeepRight.what = function(val) {
if (!arguments.length) return _qaItem;
_qaItem = val;
return viewOnKeepRight;
};
return viewOnKeepRight;
}